浏览代码

WIP - Migrating the duktape debugger example from the duktape repo to be embeded into the editor.

Shaddock Heath 8 年之前
父节点
当前提交
8aaf04d124
共有 45 个文件被更改,包括 11879 次插入7 次删除
  1. 1 0
      .gitignore
  2. 585 0
      Data/AtomicEditor/CodeEditor/css/duk_debug.css
  3. 48 0
      Data/AtomicEditor/CodeEditor/css/reset.css
  4. 214 0
      Data/AtomicEditor/CodeEditor/duk_debug.html
  5. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_diagonals-thick_18_b81900_40x40.png
  6. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_diagonals-thick_20_666666_40x40.png
  7. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_flat_10_000000_40x100.png
  8. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_glass_100_f6f6f6_1x400.png
  9. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_glass_100_fdf5ce_1x400.png
  10. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_glass_65_ffffff_1x400.png
  11. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_gloss-wave_35_f6a828_500x100.png
  12. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
  13. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
  14. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_222222_256x240.png
  15. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_228ef1_256x240.png
  16. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_ef8c08_256x240.png
  17. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_ffd27a_256x240.png
  18. 二进制
      Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_ffffff_256x240.png
  19. 1 0
      Data/AtomicEditor/CodeEditor/source/thirdparty/jquery-1.11.1.min.js
  20. 6 0
      Data/AtomicEditor/CodeEditor/source/thirdparty/jquery-ui.min.css
  21. 5 0
      Data/AtomicEditor/CodeEditor/source/thirdparty/jquery-ui.min.js
  22. 48 0
      Data/AtomicEditor/CodeEditor/source/thirdparty/reset.css
  23. 0 0
      Data/AtomicEditor/CodeEditor/source/thirdparty/socket.io-1.2.0.js
  24. 567 0
      Data/AtomicEditor/CodeEditor/source/thirdparty/style.css
  25. 5 1
      Script/AtomicEditor/main.ts
  26. 5 1
      Script/AtomicEditor/ui/ResourceEditorProvider.ts
  27. 7 3
      Script/AtomicEditor/ui/Shortcuts.ts
  28. 1 1
      Script/AtomicEditor/ui/resourceEditors/AbstractTextResourceEditorBuilder.ts
  29. 64 0
      Script/AtomicEditor/ui/resourceEditors/DukDebuggerResourceEditorBuilder.ts
  30. 920 0
      Script/AtomicWebViewEditor/debugger/DuktapeDebugger.ts
  31. 9 1
      Script/AtomicWebViewEditor/editor/editorCommands.ts
  32. 9 0
      Script/AtomicWebViewEditor/interop.ts
  33. 4 0
      Script/AtomicWebViewEditor/tsconfig.json
  34. 3779 0
      Script/AtomicWebViewEditor/typings/jquery.d.ts
  35. 1913 0
      Script/AtomicWebViewEditor/typings/jqueryui.d.ts
  36. 45 0
      Script/AtomicWebViewEditor/typings/socketio.d.ts
  37. 384 0
      Script/DuktapeDebugProxy/README.rst
  38. 32 0
      Script/DuktapeDebugProxy/duk_classnames.yaml
  39. 2473 0
      Script/DuktapeDebugProxy/duk_debug.js
  40. 52 0
      Script/DuktapeDebugProxy/duk_debugcommands.yaml
  41. 6 0
      Script/DuktapeDebugProxy/duk_debugerrors.yaml
  42. 658 0
      Script/DuktapeDebugProxy/duk_opcodes.yaml
  43. 28 0
      Script/DuktapeDebugProxy/package.json
  44. 1 0
      Script/tsconfig.json
  45. 9 0
      Source/AtomicApp/Player/IPCPlayerApp.cpp

+ 1 - 0
.gitignore

@@ -22,3 +22,4 @@ Script/TypeScript/**/*.d.ts
 !Script/TypeScript/**/*Work.d.ts
 !Script/TypeScript/**/*Work.d.ts
 Script/Haxe/*
 Script/Haxe/*
 **/.vscode
 **/.vscode
+Script/DuktapeDebugProxy/node_modules

+ 585 - 0
Data/AtomicEditor/CodeEditor/css/duk_debug.css

@@ -0,0 +1,585 @@
+// http://stackoverflow.com/questions/71074/how-to-remove-firefoxs-dotted-outline-on-buttons-as-well-as-links/3844452#3844452
+:focus {
+	outline: none;
+}
+::-moz-focus-inner {
+	border: 0;
+}
+
+@keyframes pulsate {
+	from { opacity: 1; }
+	to { opacity: 0.25; }
+}
+
+#part-header {
+	background: #444444;
+	color: #ffffff;
+	font: 24pt monospace;
+	border-bottom: 2px solid #cccccc;
+	padding: 20px 0px 20px 10px;
+}
+
+/* http://css-tricks.com/snippets/css/a-guide-to-flexbox/ */
+#part-middle {
+	display: flex;
+	flex-flow: row;
+	flex-wrap: nowrap;
+	justify-content: space-between;
+	align-items: space-around;
+	align-content: space-between;
+
+	/*min-height: 800px;*/
+
+	border-top: 1px solid #ffffff;
+	padding: 8px;
+	margin-top: 2px;
+	margin-left: 10px;
+	margin-right: 10px;
+}
+
+#center-area {
+	flex: 1 1 auto;
+	/*flex: 1 90%;*/
+	margin-bottom: 10px;
+	min-width: 60%;
+	order: 1;
+}
+#right-area {
+	/*flex: 0 0 40em;*/
+	/*flex: 1 10%;*/
+	flex: 0 1 auto;
+	margin-left: 10px;
+	margin-right: 10px;
+	margin-bottom: 10px;
+	order: 2;
+	width: 450px;
+}
+
+#part-footer {
+	clear: both;
+	border-top: 2px solid #bbbbbb;
+	background: #eeeeee;
+	color: #555555;
+	text-align: center;
+	padding-top: 12px;
+	padding-bottom: 12px;
+	line-height: 1.5;
+}
+
+#exec-status {
+	margin-top: 25px;
+	margin-bottom: 25px;
+}
+#exec-state {
+	/*display: inline-block;*/
+	float: right;
+	vertical-align: middle;
+}
+#exec-other {
+	display: inline-block;
+	vertical-align: middle;
+	font-size: 125%;
+}
+#current-state {
+	background: #228822;
+	color: #ffffff;
+	/*
+	font: 16pt;
+	*/
+	padding: 3pt;
+	border: 5px solid #228822;
+	border-radius: 10px;
+	/*
+	font-size: 200%;
+	*/
+	font-weight: bold;
+	margin-right: 10px;
+}
+#current-state.notrunning {
+	background: #882222;
+	border: 5px solid #882222;
+	border-radius: 10px;
+	animation: pulsate 0.7s cubic-bezier(0.75, 0, 0.75, 1) infinite alternate;
+}
+#exec-other:hover {
+	text-decoration: underline;
+	color: #9999ff;
+}
+
+#left-area button {
+	display: inline-block;
+	width: 100%;
+	min-width: 8em;
+	background: #226622;
+	color: #ffffff;
+	font: 8pt sans-serif;
+	font-weight: bold;
+	text-decoration: none;
+	margin: 2px 0 0 0;
+	padding: 0.4em;
+	border: 2px solid #000000;
+	border-radius: 4px;
+}
+#left-area button a {
+	color: #ffffff;
+	text-decoration: none;
+}
+#left-area button:hover {
+	background: #55aa55;
+}
+#left-area button:disabled {
+	background: #555555;
+	color: #888888;
+}
+#left-area button:disabled a {
+	background: #555555;
+	color: #888888;
+}
+#action-area {
+	margin-top: 10px;
+	margin-left: 10px;
+}
+
+#action-area button {
+	/*display: inline-block;
+	width: 100%;
+	min-width: 8em;*/
+	background: #226622;
+	color: #ffffff;
+	/*
+	font: 8pt sans-serif;
+	font-weight: bold;
+	text-decoration: none;
+	margin: 2px 0 0 0;
+	padding: 0.4em;
+	*/
+	border: 2px solid #000000;
+	border-radius: 4px;
+}
+#action-area button a {
+	color: #ffffff;
+	text-decoration: none;
+}
+#action-area button:hover {
+	background: #55aa55;
+}
+#action-area button:disabled {
+	background: #555555;
+	color: #888888;
+}
+#action-area button:disabled a {
+	background: #555555;
+	color: #888888;
+}
+
+#pause-button.pending {
+	background: #5555ff;
+	animation: pulsate 0.2s cubic-bezier(0.75, 0, 0.75, 1) infinite alternate;
+}
+
+#attach-button {
+}
+#attach-button.enabled {
+	animation: pulsate 0.7s cubic-bezier(0.75, 0, 0.75, 1) infinite alternate;
+}
+
+.duktape-exec-line {
+	outline: 2px solid red;
+	background: #550000;
+}
+.duktape-break-line {
+	outline: 2px solid white;
+}
+
+#output {
+	font: 9pt monospace;
+	color: #000000;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 3px;
+	height: 30ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#output .alert {
+	color: #ff0000;
+}
+/* Default color (should be overridden by level) */
+#output .log {
+	color: #00ff00;
+}
+/* Trace */
+#output .loglevel0 {
+	color: #cccccc;
+}
+/* Debug */
+#output .loglevel1 {
+	color: #cccccc;
+}
+/* Info */
+#output .loglevel2 {
+	color: #888888;
+	font-weight: bold;
+}
+/* Warn */
+#output .loglevel3 {
+	color: #ff4444;
+	font-weight: bold;
+}
+/* Error */
+#output .loglevel4 {
+	color: #ff0000;
+	font-weight: bold;
+}
+/* Fatal */
+#output .loglevel5 {
+	background: #000000;
+	color: #ff0000;
+	font-weight: bold;
+}
+#output .debugger-info {
+	color: #880000;
+	font-weight: bold;
+	font-style: italic;
+}
+#output .debugger-debug {
+	color: #888888;
+	font-weight: bold;
+	font-style: italic;
+}
+
+#callstack {
+	font: 9pt monospace;
+	color: #000000;
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 3px;
+	height: 14ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#callstack div:nth-child(2n) {
+	background: #eeeeee;
+}
+#callstack .func {
+}
+#callstack .rest {
+	float: right;
+	color: #6666ff;
+}
+#callstack .rest:hover {
+	text-decoration: underline;
+	color: #9999ff;
+}
+
+#locals {
+	font: 9pt monospace;
+	color: #000000;
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 10px;
+	height: 30ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#locals div:nth-child(2n) {
+	background: #eeeeee;
+}
+#locals .key {
+}
+#locals .value {
+	float: right;
+	color: #888888;
+}
+
+#breakpoints {
+	color: #000000;
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 3px;
+	height: 15ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#breakpoints div {
+	margin: 2px 0 2px 0;
+}
+#breakpoints div:nth-child(2n) {
+	background: #eeeeee;
+}
+#breakpoints a {
+	font: 9pt monospace;
+	color: #6666ff;
+}
+#breakpoints a:hover {
+	text-decoration: underline;
+	color: #9999ff;
+}
+.breakpoint-line {
+	clear: both;
+	padding-top: 2px;
+	padding-bottom: 2px;
+}
+#add-breakpoint-file {
+	font: 10pt monospace;
+	width: 10em;
+	padding: 5px;
+}
+#add-breakpoint-line {
+	font: 10pt monospace;
+	width: 3em;
+	margin-left: 3px;
+	padding: 5px;
+}
+#delete-all-breakpoints-button {
+	float: left;
+	font: 10pt sans-serif;
+	padding: 5px;
+	border: 1px solid #888888;
+	background: #ddffdd;
+	color: #000000;
+}
+#delete-all-breakpoints-button:hover {
+	background: #f8fff8;
+}
+#delete-all-breakpoints-button:disabled {
+	background: #dddddd;
+	color: #444444;
+}
+#add-breakpoint-button {
+	font: 10pt sans-serif;
+	margin-left: 10px;
+	padding: 5px;
+	border: 1px solid #888888;
+	background: #ddffdd;
+	color: #000000;
+}
+#add-breakpoint-button:hover {
+	background: #f8fff8;
+}
+#add-breakpoint-button:disabled {
+	background: #dddddd;
+	color: #444444;
+}
+#breakpoint-hint {
+	color: #aaaaaa;
+	font-style: italic;
+	margin-left: 10px;
+}
+.delete-breakpoint-button {
+	float: right;
+	display: inline;
+	font: 9pt sans-serif;
+	padding: 3px;
+	border: none;
+	background: none;
+	color: #6666ff;
+}
+.delete-breakpoint-button {
+	font: 9pt sans-serif;
+}
+.delete-breakpoint-button:hover {
+	text-decoration: underline;
+	color: #9999ff;
+}
+.delete-breakpoint-button:disabled {
+	color: #888888;
+}
+
+#about-dialog p {
+	margin: 10px 0 10px 0;
+}
+
+#bytecode-dialog p {
+	margin: 10px 0 10px 0;
+}
+#bytecode-dialog pre {
+	font: 10pt monospace;
+	color: #000000;
+}
+#bytecode-dialog div.highlight {
+	background: #888888;
+	color: #ffffff;
+}
+
+#eval {
+	color: #000000;
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 3px;
+	height: 30ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#eval-input {
+	display: inline;
+	font: 10pt monospace;
+	width: 20em;
+	padding: 5px;
+}
+#eval-button {
+	display: inline;
+	margin-left: 10px;
+	padding: 5px;
+	border: 1px solid #888888;
+	font: 10pt sans-serif;
+	background: #ddffdd;
+	color: #000000;
+}
+#eval-button {
+}
+#eval-button:hover {
+	background: #f8fff8;
+}
+#eval-button:disabled {
+	background: #dddddd;
+	color: #444444;
+}
+#eval-button.pending {
+	background: #5555ff;
+	animation: pulsate 0.2s cubic-bezier(0.75, 0, 0.75, 1) infinite alternate;
+}
+#eval-watch {
+	margin-left: 20px;
+	vertical-align: middle;
+}
+#eval-output {
+	font: 10pt monospace;
+	white-space: pre;
+	padding: 5px;
+	border: 1px solid #888888;
+	min-height: 4ex;
+	margin-top: 5px;
+}
+
+#varname-input {
+	font: 10pt monospace;
+	width: 10em;
+	padding: 5px;
+}
+#varvalue-input {
+	margin-left: 10px;
+	font: 10pt monospace;
+	width: 20em;
+	padding: 5px;
+}
+#getvar-button,
+#putvar-button {
+	display: inline;
+	float: right;
+	margin-left: 10px;
+	padding: 5px;
+	border: 1px solid #888888;
+	font: 10pt sans-serif;
+	background: #ddffdd;
+	color: #000000;
+}
+#getvar-button:hover,
+#putvar-button:hover {
+	background: #f8fff8;
+}
+#getvar-button:disabled,
+#putvar-button:disabled {
+	background: #dddddd;
+	color: #444444;
+}
+#var-output {
+	font: 10pt monospace;
+	white-space: pre;
+	padding: 5px;
+	border: 1px solid #888888;
+	min-height: 4ex;
+	margin-top: 5px;
+}
+
+#source-pre {
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	height: 400px;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+}
+#source-pre.running {
+	background: #eeeeee;
+	color: #888888;
+}
+#source-pre.running #source-code {
+	background: #eeeeee;
+	color: #888888;
+}
+#source-filename {
+	font-size: 125%;
+	color: #888888;
+}
+code.sourcecode {
+	counter-reset: source-line;
+}
+code.sourcecode div {
+	font: 10pt monospace;
+	padding: 2px 5px 2px 5px;
+	white-space: pre;
+	border-bottom: 1px solid #eeeeee;
+}
+code.sourcecode div:before {
+	display: inline-block;
+	content: counter(source-line);
+	counter-increment: source-line;
+	width: 4em;
+	color: #888888;
+	text-align: right;
+	margin-right: 20px;
+}
+code.sourcecode div.breakpoint:before {
+	margin-right: 0px;
+	border-right: 20px solid #ff0000;
+}
+code.sourcecode div.highlight {
+	background: #aaaaaa;
+	color: #000000;
+}
+code.sourcecode div.execution {
+	background: #000000;
+	color: #ffffff;
+}
+
+.code-breakpoint {
+	background: red;
+	border-radius: 50%;
+	margin-left: 5px;
+}
+.code-breakpoint-pending {
+	background: goldenrod;
+	border-radius: 50%;
+	margin-left: 5px;
+}
+.code-breakpoint-margin-hover {
+	background: pink;
+	border-radius: 50%;
+	margin-left: 5px;
+}
+
+#source-select {
+	margin-top: 5px;
+}
+
+#container {
+	width: 100%;
+	height: 60%;
+	border: 1px solid gray;
+}

+ 48 - 0
Data/AtomicEditor/CodeEditor/css/reset.css

@@ -0,0 +1,48 @@
+/* http://meyerweb.com/eric/tools/css/reset/ 
+   v2.0 | 20110126
+   License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed, 
+figure, figcaption, footer, header, hgroup, 
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+	margin: 0;
+	padding: 0;
+	border: 0;
+	font-size: 100%;
+	font: inherit;
+	vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure, 
+footer, header, hgroup, menu, nav, section {
+	display: block;
+}
+body {
+	line-height: 1;
+}
+ol, ul {
+	list-style: none;
+}
+blockquote, q {
+	quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+	content: '';
+	content: none;
+}
+table {
+	border-collapse: collapse;
+	border-spacing: 0;
+}

+ 214 - 0
Data/AtomicEditor/CodeEditor/duk_debug.html

@@ -0,0 +1,214 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+    <meta charset="utf-8" />
+    <link rel="stylesheet" href="./css/reset.css" type="text/css" />
+    <link rel="stylesheet" href="./source/thirdparty/jquery-ui.min.css" type="text/css" />
+    <link rel="stylesheet" href="./css/duk_debug.css" type="text/css" />
+    <title>Duktape debugger</title>
+</head>
+
+<body>
+
+    <div id="action-area">
+        <button id="stepinto-button">Step&#x00a0;into</button>
+        <button id="stepover-button">Step&#x00a0;over</button>
+        <button id="stepout-button">Step&#x00a0;out</button>
+        <button id="resume-button">Resume</button>
+        <button id="pause-button">Pause</button>
+        <button id="attach-button">Attach</button>
+        <button id="detach-button">Detach</button>
+        <button id="about-button">About</button>
+        <button id="heap-dump-download-button"><a id="heap-dump-download" href="/heapDump.json" target="_blank">Dump&#x00a0;heap</a></button>
+        <button id="show-bytecode-button">Show bytecode</button>
+        <div id="exec-state"><span id="current-state">?</span></div>
+    </div>
+
+    <div id="part-middle">
+
+        <!--
+<div id="left-area">
+
+</div> -->
+        <!-- #left-area -->
+
+        <div id="center-area">
+            <div id="container"></div>
+
+            <div id="exec-status">
+                <div id="exec-other"><span id="current-fileline">?</span></div>
+            </div>
+            <!-- #exec-status -->
+            <div id="output">
+                <div style="color: #dddddd">(output from script, print() and alert() calls)</div>
+            </div>
+        </div>
+        <!-- #center-area -->
+
+        <div id="right-area">
+            <div id="callstack">
+                <div style="color: #dddddd">(callstack)</div>
+            </div>
+            <div id="locals">
+                <div style="color: #dddddd">(locals)</div>
+            </div>
+            <div id="breakpoints">
+                <div style="color: #dddddd">(breakpoints)</div>
+            </div>
+            <div id="eval">
+                <input id="eval-input" value="print('hello world'); 1+2" /><button id="eval-button">Eval</button><input id="eval-watch" type="checkbox" />&#xa0;watch (eval on pause)
+                <div id="eval-output"></div>
+                <button id="putvar-button">PutVar</button><button id="getvar-button">GetVar</button><input id="varname-input" value="varname" /><input id="varvalue-input" value="varvalue" />
+                <div id="var-output"></div>
+            </div>
+        </div>
+        <!-- #right-area -->
+
+    </div>
+    <!-- #part-middle -->
+
+    <div id="part-footer">
+        <div>DUK_VERSION: <span id="duk-version">?</span>, DUK_GIT_DESCRIBE: <span id="duk-git-describe">?</span>, Target info: <span id="target-info">?</span>, Endianness: <span id="endianness">?</span><br /> Debug protocol stats: recv <span id="debug-rx-bytes">?</span>            (<span id="debug-rx-kbrate">?</span> kB/s), <span id="debug-rx-dvalues">?</span> dvalues, <span id="debug-rx-messages">?</span> messages; send <span id="debug-tx-bytes">?</span> (<span id="debug-tx-kbrate">?</span> kB/s), <span id="debug-tx-dvalues">?</span>            dvalues, <span id="debug-tx-messages">?</span> messages
+        </div>
+    </div>
+    <!-- #part-footer -->
+
+    <div id="about-dialog" title="About Duktape debugger">
+        <p>Duktape debugger is a web UI for debugging Ecmascript on a target device.</p>
+        <p>This web UI talks to a NodeJS debug server using <a href="http://socket.io/" target="_blank">socket.io</a>. The debug server talks to the target device using the Duktape debug protocol (see
+            <a href="https://github.com/svaarala/duktape/blob/master/doc/debugger.rst" target="_blank">debugger.rst</a>).</p>
+    </div>
+    <!-- #about-dialog -->
+
+    <div id="bytecode-dialog" title="Bytecode for current function">
+        <pre id="bytecode-preformatted"></pre>
+
+    </div>
+
+    <script src="./source/thirdparty/jquery-1.11.1.min.js" type="text/javascript"></script>
+    <script src="./source/thirdparty/jquery-ui.min.js" type="text/javascript"></script>
+    <script src="./source/thirdparty/socket.io-1.2.0.js" type="text/javascript"></script>
+
+    <script src="./source/systemjs/system.js" type="text/javascript" charset="utf-8"></script>
+    <script src="./source/monaco/vs/loader.js"></script>
+    <script>
+        System.config({
+            "baseURL": "./",
+            "defaultJSExtensions": true
+        });
+
+        // Load up the monaco editor and set it up to be able to be configured
+        require.config({
+            paths: {
+                'vs': 'source/monaco/vs'
+            }
+        });
+
+        // Need to override how Monaco web workers are getting resolved since for some reason they can't get located properly
+        // inside the Monaco editor code
+        window.MonacoEnvironment = {
+            getWorkerUrl: function(workerId, label) {
+                return 'source/monaco/vs/base/worker/' + workerId;
+            }
+        };
+
+        var setupEditor = new Promise((resolve, reject) => {
+            require(['vs/editor/editor.main'], function() {
+                //editor = monaco.editor.create(document.getElementById('editor'));
+                editor = monaco.editor.create(document.getElementById('container'), {
+                    value: [
+                        '//No source loaded'
+                    ].join('\n'),
+                    language: 'javascript',
+                    glyphMargin: true
+                });
+
+                // Make sure the editor resizes when the window resizes
+                window.onresize = () => {
+                    editor.layout();
+                }
+
+                /*
+                                    System.import('./source/editorCore/debugger/webui').then(module => {
+                                        console.log("Importing webui");
+                                        module.default.initialize(editor);
+                                    });
+                                    */
+                System.import('./source/editorCore/interop').then((module) => {
+                    module.default.getInstance().setDebuggerEditor(editor);
+                    //module.default.getInstance().editorLoaded();
+                    resolve(module.default);
+                });
+            });
+        });
+
+        // Functions exposed to the host editor.  These
+        // are hooked in here so that they are available immediately from the host
+        // and when called will bring in the interop as a promise and call it once
+        // it has been loaded
+        function HOST_loadCode(url) {
+            setupEditor.then((interop) => {
+                //interop.getInstance().loadCode(url);
+            });
+        }
+
+        function HOST_saveCode() {
+            setupEditor.then((interop) => {
+                //interop.getInstance().saveCode();
+            });
+        }
+
+        function HOST_resourceRenamed(path, newPath) {
+            setupEditor.then((interop) => {
+                //interop.getInstance().resourceRenamed(path, newPath);
+            });
+        }
+
+        function HOST_resourceDeleted(path) {
+            setupEditor.then((interop) => {
+                //interop.getInstance().resourceDeleted(path);
+            });
+        }
+
+        function HOST_preferencesChanged(jsonProjectPrefs, jsonApplicationPrefs) {
+            setupEditor.then((interop) => {
+
+                let prefs = {
+                    projectPreferences: JSON.parse(jsonProjectPrefs),
+                    applicationPreferences: JSON.parse(jsonApplicationPrefs)
+                };
+
+                //interop.getInstance().preferencesChanged(prefs);
+            });
+        }
+
+        function HOST_invokeShortcut(shortcut) {
+            setupEditor.then((interop) => {
+                //interop.getInstance().invokeShortcut(shortcut);
+            });
+        }
+
+        function HOST_formatCode() {
+            setupEditor.then((interop) => {
+                //interop.getInstance().formatCode();
+            });
+        }
+
+        function HOST_gotoLineNumber(lineNumber) {
+            setupEditor.then((interop) => {
+                //interop.getInstance().gotoLineNumber(lineNumber);
+            });
+        }
+
+        function HOST_gotoTokenPos(tokenPosition) {
+            setupEditor.then((interop) => {
+                //interop.getInstance().gotoPos(tokenPosition);
+            });
+        }
+    </script>
+</body>
+
+</html>

二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_diagonals-thick_18_b81900_40x40.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_diagonals-thick_20_666666_40x40.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_flat_10_000000_40x100.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_glass_100_f6f6f6_1x400.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_glass_100_fdf5ce_1x400.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_glass_65_ffffff_1x400.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_gloss-wave_35_f6a828_500x100.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_highlight-soft_100_eeeeee_1x100.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-bg_highlight-soft_75_ffe45c_1x100.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_222222_256x240.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_228ef1_256x240.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_ef8c08_256x240.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_ffd27a_256x240.png


二进制
Data/AtomicEditor/CodeEditor/source/thirdparty/images/ui-icons_ffffff_256x240.png


文件差异内容过多而无法显示
+ 1 - 0
Data/AtomicEditor/CodeEditor/source/thirdparty/jquery-1.11.1.min.js


文件差异内容过多而无法显示
+ 6 - 0
Data/AtomicEditor/CodeEditor/source/thirdparty/jquery-ui.min.css


文件差异内容过多而无法显示
+ 5 - 0
Data/AtomicEditor/CodeEditor/source/thirdparty/jquery-ui.min.js


+ 48 - 0
Data/AtomicEditor/CodeEditor/source/thirdparty/reset.css

@@ -0,0 +1,48 @@
+/* http://meyerweb.com/eric/tools/css/reset/ 
+   v2.0 | 20110126
+   License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed, 
+figure, figcaption, footer, header, hgroup, 
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+	margin: 0;
+	padding: 0;
+	border: 0;
+	font-size: 100%;
+	font: inherit;
+	vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure, 
+footer, header, hgroup, menu, nav, section {
+	display: block;
+}
+body {
+	line-height: 1;
+}
+ol, ul {
+	list-style: none;
+}
+blockquote, q {
+	quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+	content: '';
+	content: none;
+}
+table {
+	border-collapse: collapse;
+	border-spacing: 0;
+}

文件差异内容过多而无法显示
+ 0 - 0
Data/AtomicEditor/CodeEditor/source/thirdparty/socket.io-1.2.0.js


+ 567 - 0
Data/AtomicEditor/CodeEditor/source/thirdparty/style.css

@@ -0,0 +1,567 @@
+// http://stackoverflow.com/questions/71074/how-to-remove-firefoxs-dotted-outline-on-buttons-as-well-as-links/3844452#3844452
+:focus {
+	outline: none;
+}
+::-moz-focus-inner {
+	border: 0;
+}
+
+@keyframes pulsate {
+	from { opacity: 1; }
+	to { opacity: 0.25; }
+}
+
+#part-header {
+	background: #444444;
+	color: #ffffff;
+	font: 24pt monospace;
+	border-bottom: 2px solid #cccccc;
+	padding: 20px 0px 20px 10px;
+}
+
+/* http://css-tricks.com/snippets/css/a-guide-to-flexbox/ */
+#part-middle {
+	display: flex;
+	flex-direction: row;
+	flex-wrap: nowrap;
+	justify-content: space-between;
+	align-items: stretch;
+	align-content: stretch;
+
+	min-height: 800px;
+
+	border-top: 1px solid #ffffff;
+	padding: 8px;
+	margin-top: 2px;
+}
+#left-area {
+	flex: 0 0 11em;
+	margin-right: 20px;
+	margin-bottom: 10px;
+}
+#center-area {
+	flex: 1 1 0;
+	margin-bottom: 10px;
+}
+#right-area {
+	flex: 0 0 40em;
+	margin-left: 20px;
+	margin-bottom: 10px;
+}
+
+#part-footer {
+	clear: both;
+	border-top: 2px solid #bbbbbb;
+	background: #eeeeee;
+	color: #555555;
+	text-align: center;
+	padding-top: 12px;
+	padding-bottom: 12px;
+	line-height: 1.5;
+}
+
+#exec-status {
+	margin-top: 25px;
+	margin-bottom: 25px;
+}
+#exec-state {
+	/*display: inline-block;*/
+	float: right;
+	vertical-align: middle;
+}
+#exec-other {
+	display: inline-block;
+	vertical-align: middle;
+	font-size: 125%;
+}
+#current-state {
+	background: #228822;
+	color: #ffffff;
+	/*
+	font: 16pt;
+	*/
+	padding: 3pt;
+	border: 5px solid #228822;
+	border-radius: 10px;
+	/*
+	font-size: 200%;
+	*/
+	font-weight: bold;
+	margin-right: 10px;
+}
+#current-state.notrunning {
+	background: #882222;
+	border: 5px solid #882222;
+	border-radius: 10px;
+	animation: pulsate 0.7s cubic-bezier(0.75, 0, 0.75, 1) infinite alternate;
+}
+#exec-other:hover {
+	text-decoration: underline;
+	color: #9999ff;
+}
+
+#left-area button {
+	display: inline-block;
+	width: 100%;
+	min-width: 8em;
+	background: #226622;
+	color: #ffffff;
+	font: 8pt sans-serif;
+	font-weight: bold;
+	text-decoration: none;
+	margin: 2px 0 0 0;
+	padding: 0.4em;
+	border: 2px solid #000000;
+	border-radius: 4px;
+}
+#left-area button a {
+	color: #ffffff;
+	text-decoration: none;
+}
+#left-area button:hover {
+	background: #55aa55;
+}
+#left-area button:disabled {
+	background: #555555;
+	color: #888888;
+}
+#left-area button:disabled a {
+	background: #555555;
+	color: #888888;
+}
+#action-area {
+	margin-left: 10px;
+}
+
+#action-area button {
+	/*display: inline-block;
+	width: 100%;
+	min-width: 8em;*/
+	background: #226622;
+	color: #ffffff;
+	/*
+	font: 8pt sans-serif;
+	font-weight: bold;
+	text-decoration: none;
+	margin: 2px 0 0 0;
+	padding: 0.4em;
+	*/
+	border: 2px solid #000000;
+	border-radius: 4px;
+}
+#action-area button a {
+	color: #ffffff;
+	text-decoration: none;
+}
+#action-area button:hover {
+	background: #55aa55;
+}
+#action-area button:disabled {
+	background: #555555;
+	color: #888888;
+}
+#action-area button:disabled a {
+	background: #555555;
+	color: #888888;
+}
+
+#pause-button.pending {
+	background: #5555ff;
+	animation: pulsate 0.2s cubic-bezier(0.75, 0, 0.75, 1) infinite alternate;
+}
+
+#attach-button {
+}
+#attach-button.enabled {
+	animation: pulsate 0.7s cubic-bezier(0.75, 0, 0.75, 1) infinite alternate;
+}
+
+.duktape-exec-line {
+	outline: 2px solid red;
+	background: #550000;
+}
+.duktape-break-line {
+	outline: 2px solid white;
+}
+
+#output {
+	font: 9pt monospace;
+	color: #000000;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 3px;
+	height: 30ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#output .alert {
+	color: #ff0000;
+}
+/* Default color (should be overridden by level) */
+#output .log {
+	color: #00ff00;
+}
+/* Trace */
+#output .loglevel0 {
+	color: #cccccc;
+}
+/* Debug */
+#output .loglevel1 {
+	color: #cccccc;
+}
+/* Info */
+#output .loglevel2 {
+	color: #888888;
+	font-weight: bold;
+}
+/* Warn */
+#output .loglevel3 {
+	color: #ff4444;
+	font-weight: bold;
+}
+/* Error */
+#output .loglevel4 {
+	color: #ff0000;
+	font-weight: bold;
+}
+/* Fatal */
+#output .loglevel5 {
+	background: #000000;
+	color: #ff0000;
+	font-weight: bold;
+}
+#output .debugger-info {
+	color: #880000;
+	font-weight: bold;
+	font-style: italic;
+}
+#output .debugger-debug {
+	color: #888888;
+	font-weight: bold;
+	font-style: italic;
+}
+
+#callstack {
+	font: 9pt monospace;
+	color: #000000;
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 3px;
+	height: 14ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#callstack div:nth-child(2n) {
+	background: #eeeeee;
+}
+#callstack .func {
+}
+#callstack .rest {
+	float: right;
+	color: #6666ff;
+}
+#callstack .rest:hover {
+	text-decoration: underline;
+	color: #9999ff;
+}
+
+#locals {
+	font: 9pt monospace;
+	color: #000000;
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 10px;
+	height: 30ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#locals div:nth-child(2n) {
+	background: #eeeeee;
+}
+#locals .key {
+}
+#locals .value {
+	float: right;
+	color: #888888;
+}
+
+#breakpoints {
+	color: #000000;
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 3px;
+	height: 15ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#breakpoints div {
+	margin: 2px 0 2px 0;
+}
+#breakpoints div:nth-child(2n) {
+	background: #eeeeee;
+}
+#breakpoints a {
+	font: 9pt monospace;
+	color: #6666ff;
+}
+#breakpoints a:hover {
+	text-decoration: underline;
+	color: #9999ff;
+}
+.breakpoint-line {
+	clear: both;
+	padding-top: 2px;
+	padding-bottom: 2px;
+}
+#add-breakpoint-file {
+	font: 10pt monospace;
+	width: 10em;
+	padding: 5px;
+}
+#add-breakpoint-line {
+	font: 10pt monospace;
+	width: 3em;
+	margin-left: 3px;
+	padding: 5px;
+}
+#delete-all-breakpoints-button {
+	float: right;
+	font: 10pt sans-serif;
+	padding: 5px;
+	border: 1px solid #888888;
+	background: #ddffdd;
+	color: #000000;
+}
+#delete-all-breakpoints-button:hover {
+	background: #f8fff8;
+}
+#delete-all-breakpoints-button:disabled {
+	background: #dddddd;
+	color: #444444;
+}
+#add-breakpoint-button {
+	font: 10pt sans-serif;
+	margin-left: 10px;
+	padding: 5px;
+	border: 1px solid #888888;
+	background: #ddffdd;
+	color: #000000;
+}
+#add-breakpoint-button:hover {
+	background: #f8fff8;
+}
+#add-breakpoint-button:disabled {
+	background: #dddddd;
+	color: #444444;
+}
+#breakpoint-hint {
+	color: #aaaaaa;
+	font-style: italic;
+	margin-left: 10px;
+}
+.delete-breakpoint-button {
+	float: right;
+	display: inline;
+	font: 9pt sans-serif;
+	padding: 3px;
+	border: none;
+	background: none;
+	color: #6666ff;
+}
+.delete-breakpoint-button {
+	font: 9pt sans-serif;
+}
+.delete-breakpoint-button:hover {
+	text-decoration: underline;
+	color: #9999ff;
+}
+.delete-breakpoint-button:disabled {
+	color: #888888;
+}
+
+#about-dialog p {
+	margin: 10px 0 10px 0;
+}
+
+#bytecode-dialog p {
+	margin: 10px 0 10px 0;
+}
+#bytecode-dialog pre {
+	font: 10pt monospace;
+	color: #000000;
+}
+#bytecode-dialog div.highlight {
+	background: #888888;
+	color: #ffffff;
+}
+
+#eval {
+	color: #000000;
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	padding: 3px;
+	height: 30ex;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+	white-space: pre;
+}
+#eval-input {
+	display: inline;
+	font: 10pt monospace;
+	width: 20em;
+	padding: 5px;
+}
+#eval-button {
+	display: inline;
+	margin-left: 10px;
+	padding: 5px;
+	border: 1px solid #888888;
+	font: 10pt sans-serif;
+	background: #ddffdd;
+	color: #000000;
+}
+#eval-button {
+}
+#eval-button:hover {
+	background: #f8fff8;
+}
+#eval-button:disabled {
+	background: #dddddd;
+	color: #444444;
+}
+#eval-button.pending {
+	background: #5555ff;
+	animation: pulsate 0.2s cubic-bezier(0.75, 0, 0.75, 1) infinite alternate;
+}
+#eval-watch {
+	margin-left: 20px;
+	vertical-align: middle;
+}
+#eval-output {
+	font: 10pt monospace;
+	white-space: pre;
+	padding: 5px;
+	border: 1px solid #888888;
+	min-height: 4ex;
+	margin-top: 5px;
+}
+
+#varname-input {
+	font: 10pt monospace;
+	width: 10em;
+	padding: 5px;
+}
+#varvalue-input {
+	margin-left: 10px;
+	font: 10pt monospace;
+	width: 20em;
+	padding: 5px;
+}
+#getvar-button,
+#putvar-button {
+	display: inline;
+	float: right;
+	margin-left: 10px;
+	padding: 5px;
+	border: 1px solid #888888;
+	font: 10pt sans-serif;
+	background: #ddffdd;
+	color: #000000;
+}
+#getvar-button:hover,
+#putvar-button:hover {
+	background: #f8fff8;
+}
+#getvar-button:disabled,
+#putvar-button:disabled {
+	background: #dddddd;
+	color: #444444;
+}
+#var-output {
+	font: 10pt monospace;
+	white-space: pre;
+	padding: 5px;
+	border: 1px solid #888888;
+	min-height: 4ex;
+	margin-top: 5px;
+}
+
+#source-pre {
+	margin-top: 10px;
+	border: 2px solid #cccccc;
+	border-radius: 5px;
+	height: 400px;
+	overflow: scroll;
+	overflow-x: auto;
+	overflow-y: scroll;
+}
+#source-pre.running {
+	background: #eeeeee;
+	color: #888888;
+}
+#source-pre.running #source-code {
+	background: #eeeeee;
+	color: #888888;
+}
+#source-filename {
+	font-size: 125%;
+	color: #888888;
+}
+code.sourcecode {
+	counter-reset: source-line;
+}
+code.sourcecode div {
+	font: 10pt monospace;
+	padding: 2px 5px 2px 5px;
+	white-space: pre;
+	border-bottom: 1px solid #eeeeee;
+}
+code.sourcecode div:before {
+	display: inline-block;
+	content: counter(source-line);
+	counter-increment: source-line;
+	width: 4em;
+	color: #888888;
+	text-align: right;
+	margin-right: 20px;
+}
+code.sourcecode div.breakpoint:before {
+	margin-right: 0px;
+	border-right: 20px solid #ff0000;
+}
+code.sourcecode div.highlight {
+	background: #aaaaaa;
+	color: #000000;
+}
+code.sourcecode div.execution {
+	background: #000000;
+	color: #ffffff;
+}
+
+.code-breakpoint {
+	background: red;
+	border-radius: 50%;
+	margin-left: 5px;
+}
+.code-breakpoint:hover {
+	background: pink;
+	border-radius: 50%;
+	margin-left: 5px;
+}
+
+#source-select {
+	margin-top: 5px;
+}

+ 5 - 1
Script/AtomicEditor/main.ts

@@ -39,4 +39,8 @@ class Main {
     }
     }
 }
 }
 
 
-Main.main();
+try {
+    Main.main();
+} catch (e) {
+    console.log(`ERROR: ${e}\n\n${e.stack}`);
+}

+ 5 - 1
Script/AtomicEditor/ui/ResourceEditorProvider.ts

@@ -30,6 +30,7 @@ import CSharpResourceEditorBuilder from "./resourceEditors/CSharpResourceEditorB
 import XMLResourceEditorBuilder from "./resourceEditors/XMLResourceEditorBuilder";
 import XMLResourceEditorBuilder from "./resourceEditors/XMLResourceEditorBuilder";
 import ShaderResourceEditorBuilder from "./resourceEditors/ShaderResourceEditorBuilder";
 import ShaderResourceEditorBuilder from "./resourceEditors/ShaderResourceEditorBuilder";
 import VisualStudioResourceEditorBuilder from "./resourceEditors/VisualStudioResourceEditorBuilder";
 import VisualStudioResourceEditorBuilder from "./resourceEditors/VisualStudioResourceEditorBuilder";
+import DukDebugResourceEditorBuilder from "./resourceEditors/DukDebuggerResourceEditorBuilder";
 
 
 export default class ResourceEditorProvider {
 export default class ResourceEditorProvider {
     private standardEditorRegistry: Editor.Extensions.ResourceEditorBuilder[] = [];
     private standardEditorRegistry: Editor.Extensions.ResourceEditorBuilder[] = [];
@@ -107,7 +108,10 @@ export default class ResourceEditorProvider {
         this.registerStandardEditor(new XMLResourceEditorBuilder());
         this.registerStandardEditor(new XMLResourceEditorBuilder());
         this.registerStandardEditor(new ShaderResourceEditorBuilder());
         this.registerStandardEditor(new ShaderResourceEditorBuilder());
 
 
-        // this overrides the test resource editor so need to put it in the custom bucket
+        // This will hook in and possibly override all editors, so put it in the custom bucket
+        this.registerCustomEditor(new DukDebugResourceEditorBuilder());
+
+        // this overrides the TextFileResourceEditorBuilder so need to put it in the custom bucket
         this.registerCustomEditor(new TurboBadgerResourceEditorBuilder());
         this.registerCustomEditor(new TurboBadgerResourceEditorBuilder());
 
 
         this.registerCustomEditor(new VisualStudioResourceEditorBuilder());
         this.registerCustomEditor(new VisualStudioResourceEditorBuilder());

+ 7 - 3
Script/AtomicEditor/ui/Shortcuts.ts

@@ -104,6 +104,10 @@ class Shortcuts extends Atomic.ScriptObject {
 
 
     invokePlayerJSDebug() {
     invokePlayerJSDebug() {
         Atomic.editorMode.playerJSDebug();
         Atomic.editorMode.playerJSDebug();
+        this.sendEvent(Editor.EditorEditResourceEventData({
+            path: "Duktape Debugger",
+            lineNumber: -1
+        }));
     }
     }
 
 
     invokeFormatCode() {
     invokeFormatCode() {
@@ -246,8 +250,8 @@ class Shortcuts extends Atomic.ScriptObject {
 
 
         var cmdKey = this.cmdKeyDown();
         var cmdKey = this.cmdKeyDown();
 
 
-        if ( !cmdKey && ev.qualifiers > 0 ) { // check the event, the qualifier may have been programmitically set
-            cmdKey = ( ev.qualifiers == Atomic.QUAL_CTRL );
+        if (!cmdKey && ev.qualifiers > 0) { // check the event, the qualifier may have been programmitically set
+            cmdKey = (ev.qualifiers == Atomic.QUAL_CTRL);
         }
         }
 
 
         if (cmdKey) {
         if (cmdKey) {
@@ -264,7 +268,7 @@ class Shortcuts extends Atomic.ScriptObject {
             else if (ev.key == Atomic.KEY_P) {
             else if (ev.key == Atomic.KEY_P) {
                 this.invokePlayOrStopPlayer();
                 this.invokePlayOrStopPlayer();
             } else if (ev.key == Atomic.KEY_J) {
             } else if (ev.key == Atomic.KEY_J) {
-                this.invokePlayerJSDebug ();
+                this.invokePlayerJSDebug();
             } else if (ev.key == Atomic.KEY_B) {
             } else if (ev.key == Atomic.KEY_B) {
                 if (ev.qualifiers & Atomic.QUAL_SHIFT) {
                 if (ev.qualifiers & Atomic.QUAL_SHIFT) {
                     EditorUI.getModelOps().showBuildSettings();
                     EditorUI.getModelOps().showBuildSettings();

+ 1 - 1
Script/AtomicEditor/ui/resourceEditors/AbstractTextResourceEditorBuilder.ts

@@ -20,7 +20,7 @@
 // THE SOFTWARE.
 // THE SOFTWARE.
 //
 //
 
 
-export abstract class AbstractTextResourceEditorBuilder implements Editor.Extensions.ResourceEditorBuilder {
+export abstract class AbstractTextResourceEditorBuilder extends Atomic.ScriptObject implements Editor.Extensions.ResourceEditorBuilder {
 
 
     abstract canHandleResource(resourcePath: string): boolean;
     abstract canHandleResource(resourcePath: string): boolean;
 
 

+ 64 - 0
Script/AtomicEditor/ui/resourceEditors/DukDebuggerResourceEditorBuilder.ts

@@ -0,0 +1,64 @@
+//
+// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+import {AbstractTextResourceEditorBuilder} from "./AbstractTextResourceEditorBuilder";
+import * as EditorEvents from "../../editor/EditorEvents";
+
+export default class DukDebuggerResourceEditorBuilder extends AbstractTextResourceEditorBuilder {
+
+    private debuggerRunning = false;
+
+    constructor() {
+        super();
+        this.subscribeToEvent(Atomic.GoJSDebuggerEvent(() => {
+            console.log("======== got a debugger event");
+            this.debuggerRunning = true;
+        }));
+
+        this.subscribeToEvent(Atomic.ScriptEvent(EditorEvents.IPCPlayerExitRequestEventType, () => {
+            this.debuggerRunning = false;
+        }));
+    }
+
+    canHandleResource(resourcePath: string): boolean {
+        if (resourcePath == "Duktape Debugger") {
+            this.debuggerRunning = true;
+            return true;
+        }
+
+/*
+        if (this.debuggerRunning) {
+            const ext = Atomic.getExtension(resourcePath).toLowerCase();
+            return ext == ".js" || ext == ".ts";
+        }
+*/
+        return false;
+    }
+
+    /**
+     * Returns the URL to load into the web view.  Override this to return a custom url
+     * @return {string}
+     */
+    getEditorUrl(): string {
+        return `atomic://${ToolCore.toolEnvironment.toolDataDir}CodeEditor/duk_debug.html`;
+    }
+}

+ 920 - 0
Script/AtomicWebViewEditor/debugger/DuktapeDebugger.ts

@@ -0,0 +1,920 @@
+import HostInteropType from "../interop";
+
+
+interface Breakpoint {
+    fileName: string;
+    lineNumber: number;
+}
+
+class BreakpointDecoratorManager {
+    currEditorDecorations: monaco.editor.IModelDeltaDecoration[] = [];
+    currEditorDecorationIds: string[] = [];
+    currFileName: string;
+
+    constructor(private editor: monaco.editor.IStandaloneCodeEditor) { }
+
+    setCurrentFileName(fileName: string) {
+        if (this.currFileName != fileName) {
+            this.clearBreakpointDecorations();
+        }
+        this.currFileName = fileName;
+    }
+
+    clearBreakpointDecorations() {
+        this.currEditorDecorations.length = 0;
+        this.currEditorDecorationIds = this.editor.deltaDecorations(this.currEditorDecorationIds, this.currEditorDecorations);
+    }
+
+    removeBreakpointDecoration(fileName: string, lineNumber: number) {
+        if (fileName != this.currFileName) {
+            return;
+        }
+
+        const idx = this.currEditorDecorations.findIndex(d => d.range.startLineNumber == lineNumber);
+        if (idx != -1) {
+            this.currEditorDecorations.splice(idx);
+            this.currEditorDecorationIds = this.editor.deltaDecorations(this.currEditorDecorationIds, this.currEditorDecorations);
+        }
+    }
+
+    addBreakpointDecoration(fileName: string, lineNumber: number, pendingBreakpoint?: boolean) {
+        if (fileName != this.currFileName) {
+            return;
+        }
+
+        const requestedBreakpointClass = pendingBreakpoint ? "code-breakpoint-pending" : "code-breakpoint";
+        let idx = this.currEditorDecorations.findIndex(d => d.range.startLineNumber == lineNumber);
+        if (idx != -1 && this.currEditorDecorations[idx].options.glyphMarginClassName != requestedBreakpointClass) {
+            this.removeBreakpointDecoration(fileName, lineNumber);
+            idx = -1;
+        }
+
+        if (idx == -1) {
+            this.currEditorDecorations.push({
+                range: new monaco.Range(lineNumber, 1, lineNumber, 1),
+                options: {
+                    glyphMarginClassName: pendingBreakpoint ? "code-breakpoint-pending" : "code-breakpoint"
+                }
+            });
+
+            this.currEditorDecorationIds = this.editor.deltaDecorations(this.currEditorDecorationIds, this.currEditorDecorations);
+        }
+    }
+
+    getBreakpointDecorator(fileName: string, lineNumber: number) {
+        return this.currEditorDecorations.find(d => d.range.startLineNumber == lineNumber && d.options.glyphMarginClassName != "code-breakpoint-margin-hover");
+    }
+
+    toggleBreakpoint(fileName: string, lineNumber: number) {
+        if (fileName != this.currFileName) {
+            return;
+        }
+
+        let decoration = this.getBreakpointDecorator(fileName, lineNumber);
+        if (decoration) {
+            this.removeBreakpointDecoration(fileName, lineNumber);
+        } else {
+            this.addBreakpointDecoration(fileName, lineNumber, true);
+        }
+    }
+
+    updateMarginHover(lineNumber: number) {
+        let idx = this.currEditorDecorations.findIndex(d => d.options.glyphMarginClassName == "code-breakpoint-margin-hover");
+
+        if (idx != -1 && this.currEditorDecorations[idx].range.startLineNumber == lineNumber) {
+            return; // nothing to do
+        }
+
+        const hover = {
+            range: new monaco.Range(lineNumber, 1, lineNumber, 1),
+            options: {
+                glyphMarginClassName: "code-breakpoint-margin-hover"
+            }
+        };
+
+        if (idx == -1) {
+            this.currEditorDecorations.push(hover);
+        } else {
+            this.currEditorDecorations[idx] = hover;
+        }
+
+        this.currEditorDecorationIds = this.editor.deltaDecorations(this.currEditorDecorationIds, this.currEditorDecorations);
+    }
+
+    removeMarginHover() {
+        let idx = this.currEditorDecorations.findIndex(d => d.options.glyphMarginClassName == "code-breakpoint-margin-hover");
+        if (idx != -1) {
+            this.currEditorDecorations.splice(idx);
+            this.currEditorDecorationIds = this.editor.deltaDecorations(this.currEditorDecorationIds, this.currEditorDecorations);
+        }
+    }
+}
+/*
+ *  Duktape debugger web client
+ *
+ *  Talks to the NodeJS server using socket.io.
+ *
+ *  http://unixpapa.com/js/key.html
+ */
+export default class DuktapeDebugger {
+    // Monaco editor
+    editor: monaco.editor.IStandaloneCodeEditor;
+    socket: SocketIOClient.Socket;
+    breakpointDecorator: BreakpointDecoratorManager;
+
+    // Update interval for custom source highlighting.
+    SOURCE_UPDATE_INTERVAL = 350;
+
+    // Source view
+    activeFileName = null;          // file that we want to be loaded in source view
+    activeLine = null;              // scroll to line once file has been loaded
+    activeHighlight = null;         // line that we want to highlight (if any)
+    loadedFileName = null;          // currently loaded (shown) file
+    loadedLineCount = 0;            // currently loaded file line count
+    loadedFileExecuting = false;    // true if currFileName (loosely) matches loadedFileName
+    loadedLinePending = null;       // if set, scroll loaded file to requested line
+    highlightLine = null;           // highlight line
+    sourceEditedLines = [];         // line numbers which have been modified
+    // (added classes etc, tracked for removing)
+    sourceUpdateInterval = null;    // timer for updating source view
+    sourceFetchXhr = null;          // current AJAX request for fetching a source file (if any)
+    forceButtonUpdate = false;      // hack to reset button states
+    bytecodeDialogOpen = false;     // bytecode dialog active
+    bytecodeIdxHighlight = null;    // index of currently highlighted line (or null)
+    bytecodeIdxInstr = 0;           // index to first line of bytecode instructions
+
+    // Execution state
+    prevState = null;               // previous execution state ("paused", "running", etc)
+    prevAttached = null;            // previous debugger attached state (true, false, null)
+    currFileName = null;            // current filename being executed
+    currFuncName = null;            // current function name being executed
+    currLine = 0;                   // current line being executed
+    currPc = 0;                     // current bytecode PC being executed
+    // current execution state ("paused", "running", "detached", etc)
+    currState: "connected" | "disconnected" | "running" | "paused" | "reconnecting";
+    currAttached = false;           // current debugger attached state (true or false)
+    currLocals = [];                // current local variables
+    currCallstack = [];             // current callstack (from top to bottom)
+    currBreakpoints: Breakpoint[] = [];           // current breakpoints
+    startedRunning = 0;             // timestamp when last started running (if running)
+    // (used to grey out the source file if running for long enough)
+
+    /*
+     *  Helpers
+     */
+
+    formatBytes(x) {
+        if (x < 1024) {
+            return String(x) + " bytes";
+        } else if (x < 1024 * 1024) {
+            return (x / 1024).toPrecision(3) + " kB";
+        } else {
+            return (x / (1024 * 1024)).toPrecision(3) + " MB";
+        }
+    }
+
+    /*
+     *  Source view periodic update handling
+     */
+
+    doSourceUpdate() {
+        var elem;
+
+        // Remove previously added custom classes
+        this.sourceEditedLines.forEach((linenum) => {
+            elem = $("#source-code div")[linenum - 1];
+            if (elem) {
+                elem.classList.remove("breakpoint");
+                elem.classList.remove("execution");
+                elem.classList.remove("highlight");
+            }
+        });
+        this.sourceEditedLines.length = 0;
+
+        // If we"re executing the file shown, highlight current line
+        if (this.loadedFileExecuting) {
+            this.editor.revealLineInCenterIfOutsideViewport(this.currLine);
+            this.editor.setPosition(new monaco.Position(this.currLine, 0));
+            this.sourceEditedLines.push(this.currLine);
+
+            elem = $("#source-code div")[this.currLine - 1];
+            if (elem) {
+                //sourceEditedLines.push(currLine);
+                elem.classList.add("execution");
+            }
+        }
+
+        // Add breakpoints
+        this.breakpointDecorator.setCurrentFileName(this.loadedFileName);
+        this.currBreakpoints.forEach((bp) => {
+            if (bp.fileName === this.loadedFileName) {
+                this.breakpointDecorator.addBreakpointDecoration(bp.fileName, bp.lineNumber);
+                this.sourceEditedLines.push(bp.lineNumber);
+            }
+        });
+
+        if (this.highlightLine !== null) {
+            elem = $("#source-code div")[this.highlightLine - 1];
+            if (elem) {
+                this.sourceEditedLines.push(this.highlightLine);
+                elem.classList.add("highlight");
+            }
+        }
+
+        // Bytecode dialog highlight
+        if (this.loadedFileExecuting && this.bytecodeDialogOpen && this.bytecodeIdxHighlight !== this.bytecodeIdxInstr + this.currPc) {
+            if (typeof this.bytecodeIdxHighlight === "number") {
+                $("#bytecode-preformatted div")[this.bytecodeIdxHighlight].classList.remove("highlight");
+            }
+            this.bytecodeIdxHighlight = this.bytecodeIdxInstr + this.currPc;
+            $("#bytecode-preformatted div")[this.bytecodeIdxHighlight].classList.add("highlight");
+        }
+
+        // If no-one requested us to scroll to a specific line, finish.
+        if (this.loadedLinePending == null) {
+            return;
+        }
+
+        // Scroll to the requested line
+        var reqLine = this.loadedLinePending;
+        this.loadedLinePending = null;
+
+        this.editor.revealLineInCenterIfOutsideViewport(reqLine);
+        this.editor.setPosition(new monaco.Position(reqLine, 0));
+    }
+
+    /*
+     *  UI update handling when exec-status update arrives
+     */
+
+    doUiUpdate() {
+        var now = Date.now();
+
+        // Note: loadedFileName can be either from target or from server, but they
+        // must match exactly.  We could do a loose match here, but exact matches
+        // are needed for proper breakpoint handling anyway.
+        this.loadedFileExecuting = (this.loadedFileName === this.currFileName);
+
+        // If we just started running, store a timestamp so we can grey out the
+        // source view only if we execute long enough (i.e. we"re not just
+        // stepping).
+        if (this.currState !== this.prevState && this.currState === "running") {
+            this.startedRunning = now;
+        }
+
+        // If we just became paused, check for eval watch
+        if (this.currState !== this.prevState && this.currState === "paused") {
+            if ($("#eval-watch").is(":checked")) {
+                this.submitEval();  // don"t clear eval input
+            }
+        }
+
+        // Update current execution state
+        if (this.currFileName === "" && this.currLine === 0) {
+            $("#current-fileline").text("");
+        } else {
+            $("#current-fileline").text(String(this.currFileName) + ":" + String(this.currLine));
+        }
+        if (this.currFuncName === "" && this.currPc === 0) {
+            $("#current-funcpc").text("");
+        } else {
+            $("#current-funcpc").text(String(this.currFuncName) + "() pc " + String(this.currPc));
+        }
+        $("#current-state").text(String(this.currState));
+
+        // Update buttons
+        if (this.currState !== this.prevState || this.currAttached !== this.prevAttached || this.forceButtonUpdate) {
+            $("#stepinto-button").prop("disabled", !this.currAttached || this.currState !== "paused");
+            $("#stepover-button").prop("disabled", !this.currAttached || this.currState !== "paused");
+            $("#stepout-button").prop("disabled", !this.currAttached || this.currState !== "paused");
+            $("#resume-button").prop("disabled", !this.currAttached || this.currState !== "paused");
+            $("#pause-button").prop("disabled", !this.currAttached || this.currState !== "running");
+            $("#attach-button").prop("disabled", this.currAttached);
+            if (this.currAttached) {
+                $("#attach-button").removeClass("enabled");
+            } else {
+                $("#attach-button").addClass("enabled");
+            }
+            $("#detach-button").prop("disabled", !this.currAttached);
+            $("#eval-button").prop("disabled", !this.currAttached);
+            $("#add-breakpoint-button").prop("disabled", !this.currAttached);
+            $("#delete-all-breakpoints-button").prop("disabled", !this.currAttached);
+            $(".delete-breakpoint-button").prop("disabled", !this.currAttached);
+            $("#putvar-button").prop("disabled", !this.currAttached);
+            $("#getvar-button").prop("disabled", !this.currAttached);
+            $("#heap-dump-download-button").prop("disabled", !this.currAttached);
+        }
+        if (this.currState !== "running" || this.forceButtonUpdate) {
+            // Remove pending highlight once we"re no longer running.
+            $("#pause-button").removeClass("pending");
+            $("#eval-button").removeClass("pending");
+        }
+        this.forceButtonUpdate = false;
+
+        // Make source window grey when running for a longer time, use a small
+        // delay to avoid flashing grey when stepping.
+        if (this.currState === "running" && now - this.startedRunning >= 500) {
+            $("#source-pre").removeClass("notrunning");
+            $("#current-state").removeClass("notrunning");
+        } else {
+            $("#source-pre").addClass("notrunning");
+            $("#current-state").addClass("notrunning");
+        }
+
+        // Force source view to match currFileName only when running or when
+        // just became paused (from running or detached).
+        var fetchSource = false;
+        if (typeof this.currFileName === "string") {
+            if (this.currState === "running" ||
+                (this.prevState !== "paused" && this.currState === "paused") ||
+                (this.currAttached !== this.prevAttached)) {
+                if (this.activeFileName !== this.currFileName) {
+                    fetchSource = true;
+                    this.activeFileName = this.currFileName;
+                    this.activeLine = this.currLine;
+                    this.activeHighlight = null;
+                    this.requestSourceRefetch();
+                }
+            }
+        }
+
+        // Force line update (scrollTop) only when running or just became paused.
+        // Otherwise let user browse and scroll source files freely.
+        if (!fetchSource) {
+            if ((this.prevState !== "paused" && this.currState === "paused") ||
+                this.currState === "running") {
+                this.loadedLinePending = this.currLine || 0;
+            }
+        }
+    }
+
+    deleteAllBreakpoints() {
+        this.socket.emit("delete-all-breakpoints");
+        this.breakpointDecorator.clearBreakpointDecorations();
+    }
+
+    addBreakpoint(fileName: string, lineNumber: number) {
+        this.breakpointDecorator.addBreakpointDecoration(fileName, lineNumber);
+        this.socket.emit("add-breakpoint", {
+            fileName,
+            lineNumber
+        });
+    }
+
+    toggleBreakpoint(fileName: string, lineNumber: number) {
+        this.breakpointDecorator.toggleBreakpoint(fileName, lineNumber);
+        this.socket.emit("toggle-breakpoint", {
+            fileName,
+            lineNumber
+        });
+    }
+
+    deleteBreakpoint(fileName: string, lineNumber: number) {
+        this.breakpointDecorator.removeBreakpointDecoration(fileName, lineNumber);
+        this.socket.emit("delete-breakpoint", {
+            fileName,
+            lineNumber
+        });
+    }
+
+    initSocket() {
+        /*
+         *  Init socket.io and add handlers
+         */
+
+        this.socket = io.connect("http://localhost:9092");  // returns a Manager
+
+        setInterval(() => {
+            this.socket.emit("keepalive", {
+                userAgent: (navigator || {} as Navigator).userAgent
+            });
+        }, 30000);
+
+        this.socket.on("connect", () => {
+            $("#socketio-info").text("connected");
+            this.currState = "connected";
+
+            this.fetchSourceList();
+        });
+        this.socket.on("disconnect", () => {
+            $("#socketio-info").text("not connected");
+            this.currState = "disconnected";
+        });
+        this.socket.on("reconnecting", () => {
+            $("#socketio-info").text("reconnecting");
+            this.currState = "reconnecting";
+        });
+        this.socket.on("error", (err) => {
+            $("#socketio-info").text(err);
+        });
+
+        this.socket.on("replaced", () => {
+            // XXX: how to minimize the chance we"ll further communciate with the
+            // server or reconnect to it?  socket.reconnection()?
+
+            // We"d like to window.close() here but can"t (not allowed from scripts).
+            // Alert is the next best thing.
+            alert("Debugger connection replaced by a new one, do you have multiple tabs open? If so, please close this tab.");
+        });
+
+        this.socket.on("keepalive", (msg) => {
+            // Not really interesting in the UI
+            // $("#server-info").text(new Date() + ": " + JSON.stringify(msg));
+        });
+
+        this.socket.on("basic-info", (msg) => {
+            $("#duk-version").text(String(msg.duk_version));
+            $("#duk-git-describe").text(String(msg.duk_git_describe));
+            $("#target-info").text(String(msg.target_info));
+            $("#endianness").text(String(msg.endianness));
+        });
+
+        this.socket.on("exec-status", (msg) => {
+            // Not 100% reliable if callstack has several functions of the same name
+            if (this.bytecodeDialogOpen && (this.currFileName != msg.fileName || this.currFuncName != msg.funcName)) {
+                this.socket.emit("get-bytecode", {});
+            }
+
+            this.currFileName = msg.fileName;
+            this.currFuncName = msg.funcName;
+            this.currLine = msg.line;
+            this.currPc = msg.pc;
+            this.currState = msg.state;
+            this.currAttached = msg.attached;
+
+            // Duktape now restricts execution status updates quite effectively so
+            // there"s no need to rate limit UI updates now.
+
+            this.doUiUpdate();
+
+            this.prevState = this.currState;
+            this.prevAttached = this.currAttached;
+        });
+
+        // Update the "console" output based on lines sent by the server.  The server
+        // rate limits these updates to keep the browser load under control.  Even
+        // better would be for the client to pull this (and other stuff) on its own.
+        this.socket.on("output-lines", (msg) => {
+            var elem = $("#output");
+            var i, n, ent;
+
+            elem.empty();
+            for (i = 0, n = msg.length; i < n; i++) {
+                ent = msg[i];
+                if (ent.type === "print") {
+                    elem.append($("<div></div>").text(ent.message));
+                } else if (ent.type === "alert") {
+                    elem.append($("<div class='alert'></div>").text(ent.message));
+                } else if (ent.type === "log") {
+                    elem.append($("<div class='log loglevel' + ent.level + ''></div>").text(ent.message));
+                } else if (ent.type === "debugger-info") {
+                    elem.append($("<div class='debugger-info'><div>").text(ent.message));
+                } else if (ent.type === "debugger-debug") {
+                    elem.append($("<div class='debugger-debug'><div>").text(ent.message));
+                } else {
+                    elem.append($("<div></div>").text(ent.message));
+                }
+            }
+
+            // http://stackoverflow.com/questions/14918787/jquery-scroll-to-bottom-of-div-even-after-it-updates
+            // Stop queued animations so that we always scroll quickly to bottom
+            $("#output").stop(true);
+            $("#output").animate({ scrollTop: $("#output")[0].scrollHeight }, 1000);
+        });
+
+        this.socket.on("callstack", (msg) => {
+            var elem = $("#callstack");
+            var s1, s2, div;
+
+            this.currCallstack = msg.callstack;
+
+            elem.empty();
+            msg.callstack.forEach((e) => {
+                s1 = $("<a class='rest'></a>").text(e.fileName + ":" + e.lineNumber + " (pc " + e.pc + ")");  // float
+                s1.on("click", () => {
+                    this.activeFileName = e.fileName;
+                    this.activeLine = e.lineNumber || 1;
+                    this.activeHighlight = this.activeLine;
+                    this.requestSourceRefetch();
+                });
+                s2 = $("<span class='func'></span>").text(e.funcName + "()");
+                div = $("<div></div>");
+                div.append(s1);
+                div.append(s2);
+                elem.append(div);
+            });
+        });
+
+        this.socket.on("locals", (msg) => {
+            var elem = $("#locals");
+            var s1, s2, div;
+            var i, n, e;
+
+            this.currLocals = msg.locals;
+
+            elem.empty();
+            for (i = 0, n = msg.locals.length; i < n; i++) {
+                e = msg.locals[i];
+                s1 = $("<span class='value'></span>").text(e.value);  // float
+                s2 = $("<span class='key'></span>").text(e.key);
+                div = $("<div></div>");
+                div.append(s1);
+                div.append(s2);
+                elem.append(div);
+            }
+        });
+
+        this.socket.on("debug-stats", (msg) => {
+            $("#debug-rx-bytes").text(this.formatBytes(msg.rxBytes));
+            $("#debug-rx-dvalues").text(msg.rxDvalues);
+            $("#debug-rx-messages").text(msg.rxMessages);
+            $("#debug-rx-kbrate").text((msg.rxBytesPerSec / 1024).toFixed(2));
+            $("#debug-tx-bytes").text(this.formatBytes(msg.txBytes));
+            $("#debug-tx-dvalues").text(msg.txDvalues);
+            $("#debug-tx-messages").text(msg.txMessages);
+            $("#debug-tx-kbrate").text((msg.txBytesPerSec / 1024).toFixed(2));
+        });
+
+
+        this.socket.on("breakpoints", (msg) => {
+            var elem = $("#breakpoints");
+            var div;
+            var sub;
+
+            this.currBreakpoints = msg.breakpoints;
+
+            elem.empty();
+
+            // First line is special
+            div = $("<div></div>");
+            sub = $("<button id='delete-all-breakpoints-button'></button>").text("Delete all breakpoints");
+            sub.on("click", () => {
+                this.deleteAllBreakpoints();
+            });
+            div.append(sub);
+            //sub = $("<input id='add-breakpoint-file'></input>").val("file.js");
+            //div.append(sub);
+            //sub = $("<span></span>").text(":");
+            //div.append(sub);
+            //sub = $("<input id='add-breakpoint-line'></input>").val("123");
+            //div.append(sub);
+            //sub = $("<button id='add-breakpoint-button'></button>").text("Add breakpoint");
+            //sub.on("click", () => {
+                //this.addBreakpoint($("#add-breakpoint-file").val(), Number($("#add-breakpoint-line").val()));
+            //});
+            //div.append(sub);
+            //sub = $("<span id='breakpoint-hint'></span>").text("or dblclick source");
+            //div.append(sub);
+            elem.append(div);
+
+            // Active breakpoints follow
+            msg.breakpoints.forEach((bp) => {
+                var div;
+                var sub;
+
+                div = $("<div class='breakpoint-line'></div>");
+                sub = $("<button class='delete-breakpoint-button'></button>").text("Delete");
+                sub.on("click", () => {
+                    this.deleteBreakpoint(bp.fileName, bp.lineNumber);
+                });
+                div.append(sub);
+                sub = $("<a></a>").text((bp.fileName || "?") + ":" + (bp.lineNumber || 0));
+                sub.on("click", () => {
+                    this.activeFileName = bp.fileName || "";
+                    this.activeLine = bp.lineNumber || 1;
+                    this.activeHighlight = this.activeLine;
+                    this.requestSourceRefetch();
+                });
+                div.append(sub);
+                elem.append(div);
+            });
+
+            this.forceButtonUpdate = true;
+            this.doUiUpdate();
+        });
+
+        this.socket.on("eval-result", (msg) => {
+            $("#eval-output").text((msg.error ? "ERROR: " : "") + msg.result);
+
+            // Remove eval button "pulsating" glow when we get a result
+            $("#eval-button").removeClass("pending");
+        });
+
+        this.socket.on("getvar-result", (msg) => {
+            $("#var-output").text(msg.found ? msg.result : "NOTFOUND");
+        });
+
+        this.socket.on("bytecode", (msg) => {
+            var elem, div;
+
+            elem = $("#bytecode-preformatted");
+            elem.empty();
+
+            msg.preformatted.split("\n").forEach((line, idx) => {
+                div = $("<div></div>");
+                div.text(line);
+                elem.append(div);
+            });
+
+            this.bytecodeIdxHighlight = null;
+            this.bytecodeIdxInstr = msg.idxPreformattedInstructions;
+        });
+
+        $("#stepinto-button").click(() => {
+            this.socket.emit("stepinto", {});
+        });
+
+        $("#stepover-button").click(() => {
+            this.socket.emit("stepover", {});
+        });
+
+        $("#stepout-button").click(() => {
+            this.socket.emit("stepout", {});
+        });
+
+        $("#pause-button").click(() => {
+            this.socket.emit("pause", {});
+
+            // Pause may take seconds to complete so indicate it is pending.
+            $("#pause-button").addClass("pending");
+        });
+
+        $("#resume-button").click(() => {
+            this.socket.emit("resume", {});
+        });
+
+        $("#attach-button").click(() => {
+            this.socket.emit("attach", {});
+        });
+
+        $("#detach-button").click(() => {
+            this.socket.emit("detach", {});
+        });
+
+        $("#about-button").click(() => {
+            $("#about-dialog").dialog("open");
+        });
+
+        $("#show-bytecode-button").click(() => {
+            this.bytecodeDialogOpen = true;
+            $("#bytecode-dialog").dialog("open");
+
+            let elem = $("#bytecode-preformatted");
+            elem.empty().text("Loading bytecode...");
+
+            this.socket.emit("get-bytecode", {});
+        });
+        $("#eval-button").click(() => {
+            this.submitEval();
+            $("#eval-input").val("");
+        });
+
+        $("#getvar-button").click(() => {
+            this.socket.emit("getvar", { varname: $("#varname-input").val() });
+        });
+
+        $("#putvar-button").click(() => {
+            // The variable value is parsed as JSON right now, but it"d be better to
+            // also be able to parse buffer values etc.
+            var val = JSON.parse($("#varvalue-input").val());
+            this.socket.emit("putvar", { varname: $("#varname-input").val(), varvalue: val });
+        });
+
+        $("#source-code").dblclick((event) => {
+            var target = event.target;
+            var elems = $("#source-code div");
+            var i, n;
+            var line = 0;
+
+            // XXX: any faster way; elems doesn"t have e.g. indexOf()
+            for (i = 0, n = elems.length; i < n; i++) {
+                if (target === elems[i]) {
+                    line = i + 1;
+                }
+            }
+
+            this.toggleBreakpoint(this.loadedFileName, line);
+        });
+    }
+
+    submitEval() {
+        this.socket.emit("eval", { input: $("#eval-input").val() });
+
+        // Eval may take seconds to complete so indicate it is pending.
+        $("#eval-button").addClass("pending");
+    }
+
+
+    setSourceText(data) {
+        /* TSH
+        var elem, div;
+
+        elem = $("#source-code");
+        elem.empty();
+        data.split("\n").forEach(function (line) {
+            div = $("<div></div>");
+            div.text(line);
+            elem.append(div);
+        });
+        */
+
+        this.editor.deltaDecorations([], []);
+        this.editor.getModel().setValue(data);
+        this.sourceEditedLines = [];
+    }
+
+    /*
+     *  AJAX request handling to fetch source files
+     */
+    requestSourceFile(fileName: string, lineNumber: number) {
+        // If previous update is pending, abort and start a new one.
+        if (this.sourceFetchXhr) {
+            this.sourceFetchXhr.abort();
+            this.sourceFetchXhr = null;
+        }
+
+        console.log(`Retrieving File: ${fileName}`);
+        // get the code
+        return HostInteropType.getInstance().getFileResource("Resources/" + fileName).then((data: string) => {
+            this.loadedFileName = fileName;
+            this.loadedLineCount = data.split("\n").length;  // XXX: ignore issue with last empty line for now
+            this.loadedFileExecuting = (this.loadedFileName === this.currFileName);
+            this.setSourceText(data);
+            this.loadedLinePending = this.activeLine || 1;
+            this.highlightLine = this.activeHighlight;  // may be null
+            this.activeLine = null;
+            this.activeHighlight = null;
+            this.doSourceUpdate();
+
+        }).catch((e: Editor.ClientExtensions.AtomicErrorMessage) => {
+            console.log("Error loading code: " + e.error_message);
+            // Not worth alerting about because source fetch errors happen
+            // all the time, e.g. for dynamically evaluated code.
+
+            this.sourceFetchXhr = null;
+
+            // XXX: prevent retry of no-such-file by negative caching?
+            this.loadedFileName = fileName;
+            this.loadedLineCount = 1;
+            this.loadedFileExecuting = false;
+            this.setSourceText("// Cannot load source file: " + fileName);
+            this.loadedLinePending = 1;
+            this.activeLine = null;
+            this.activeHighlight = null;
+            this.doSourceUpdate();
+        });
+    }
+
+    requestSourceRefetch() {
+        if (!this.activeFileName) {
+            return;
+        }
+
+        this.requestSourceFile(this.activeFileName, this.activeLine).then(() => {
+            // XXX: hacky transition, make source change visible
+            $("#source-pre").fadeTo("fast", 0.25, () => {
+                $("#source-pre").fadeTo("fast", 1.0);
+            });
+        }).catch((e: Editor.ClientExtensions.AtomicErrorMessage) => {
+            // XXX: error transition here
+            console.log("Error loading code: " + e.error_message);
+            $("#source-pre").fadeTo("fast", 0.25, function() {
+                $("#source-pre").fadeTo("fast", 1.0);
+            });
+        });
+    }
+
+    /*
+     *  AJAX request for fetching the source list
+     */
+
+    fetchSourceList() {
+        /* TODO: Fix Ajax
+        $.ajax({
+            type: "POST",
+            url: "/sourceList",
+            data: JSON.stringify({}),
+            contentType: "application/json",
+            success: function(data, status, jqxhr) {
+                var elem = $("#source-select");
+
+                data = JSON.parse(data);
+
+                elem.empty();
+                var opt = $("<option></option>").attr({ "value": "__none__" }).text("No source file selected");
+                elem.append(opt);
+                data.forEach(function(ent) {
+                    var opt = $("<option></option>").attr({ "value": ent }).text(ent);
+                    elem.append(opt);
+                });
+                elem.change(function() {
+                    activeFileName = elem.val();
+                    activeLine = 1;
+                    requestSourceRefetch();
+                });
+            },
+            error: function(jqxhr, status, err) {
+                // This is worth alerting about as the UI is somewhat unusable
+                // if we don"t get a source list.
+
+                alert("Failed to load source list: " + err);
+            },
+            dataType: "text"
+        });
+        */
+    }
+
+    /*
+     *  Initialization
+     */
+    initialize(editorProvided) {
+        this.editor = editorProvided;
+        this.breakpointDecorator = new BreakpointDecoratorManager(editorProvided);
+        var showAbout = true;
+
+        this.initSocket();
+
+        // Source is updated periodically.  Other code can also call doSourceUpdate()
+        // directly if an immediate update is needed.
+        this.sourceUpdateInterval = setInterval(this.doSourceUpdate.bind(this), this.SOURCE_UPDATE_INTERVAL);
+        this.editor.onMouseMove((e) => {
+            var targetZone = e.target.toString();
+            if (targetZone.indexOf("GUTTER_GLYPH_MARGIN") != -1) {
+                var line = e.target.position.lineNumber;
+                this.breakpointDecorator.updateMarginHover(line);
+            } else {
+                this.breakpointDecorator.removeMarginHover();
+            }
+        });
+
+        this.editor.onMouseDown((e) => {
+            var targetZone = e.target.toString();
+            if (targetZone.indexOf("GUTTER_GLYPH_MARGIN") != -1) {
+                var line = e.target.position.lineNumber;
+                this.toggleBreakpoint(this.loadedFileName, line);
+            }
+
+        });
+
+        // About dialog, shown automatically on first startup.
+        $("#about-dialog").dialog({
+            autoOpen: false,
+            hide: "fade",  // puff
+            show: "fade",  // slide, puff
+            width: 500,
+            height: 300
+        });
+
+        // Bytecode dialog
+        $("#bytecode-dialog").dialog({
+            autoOpen: false,
+            hide: "fade",  // puff
+            show: "fade",  // slide, puff
+            width: 700,
+            height: 600,
+            close: () => {
+                this.bytecodeDialogOpen = false;
+                this.bytecodeIdxHighlight = null;
+                this.bytecodeIdxInstr = 0;
+            }
+        });
+
+        // http://diveintohtml5.info/storage.html
+        if (typeof localStorage !== "undefined") {
+            if (localStorage.getItem("about-shown")) {
+                showAbout = false;
+            } else {
+                localStorage.setItem("about-shown", "yes");
+            }
+        }
+        if (showAbout) {
+            $("#about-dialog").dialog("open");
+        }
+
+        // onclick handler for exec status text
+        function loadCurrFunc() {
+            this.activeFileName = this.currFileName;
+            this.activeLine = this.currLine;
+            this.requestSourceRefetch();
+        }
+        $("#exec-other").on("click", loadCurrFunc);
+
+        // Enter handling for eval input
+        // https://forum.jquery.com/topic/bind-html-input-to-enter-key-keypress
+        $("#eval-input").keypress((event) => {
+            if (event.keyCode == 13) {
+                this.submitEval();
+                $("#eval-input").val("");
+            }
+        });
+
+        // Eval watch handling
+        $("#eval-watch").change(() => {
+            // nop
+        });
+
+        this.forceButtonUpdate = true;
+        this.doUiUpdate();
+    };
+
+}

+ 9 - 1
Script/AtomicWebViewEditor/editor/editorCommands.ts

@@ -24,6 +24,7 @@ import * as internalEditor from "./editor";
 import serviceLocator from "../clientExtensions/ServiceLocator";
 import serviceLocator from "../clientExtensions/ServiceLocator";
 import HostInterop from "../interop";
 import HostInterop from "../interop";
 import ClientExtensionEventNames from "../clientExtensions/ClientExtensionEventNames";
 import ClientExtensionEventNames from "../clientExtensions/ClientExtensionEventNames";
+import DuktapeDebugger from "../debugger/DuktapeDebugger";
 
 
 
 
 /**
 /**
@@ -172,6 +173,13 @@ export function setEditor(editor: any) {
     internalEditor.setInternalEditor(editor);
     internalEditor.setInternalEditor(editor);
 }
 }
 
 
+export function setDebuggerEditor(editor: any) {
+    internalEditor.setInternalEditor(editor);
+
+    const dbg = new DuktapeDebugger();
+    dbg.initialize(editor);
+}
+
 /**
 /**
  * Called when a resource is getting deleted
  * Called when a resource is getting deleted
  * @param  {string} path
  * @param  {string} path
@@ -218,4 +226,4 @@ export function gotoTokenPos(tokenPos:number) {
     const pos = ed.getModel().getPositionAt(tokenPos);
     const pos = ed.getModel().getPositionAt(tokenPos);
     ed.revealPositionInCenterIfOutsideViewport(pos);
     ed.revealPositionInCenterIfOutsideViewport(pos);
     ed.setPosition(pos);
     ed.setPosition(pos);
-}
+}

+ 9 - 0
Script/AtomicWebViewEditor/interop.ts

@@ -234,6 +234,15 @@ export default class HostInteropType {
         editorCommands.setEditor(editor);
         editorCommands.setEditor(editor);
     }
     }
 
 
+    /**
+     * Sets the editor used for debugging
+     * @param  {any} editor
+     * @return {[type]}
+     */
+    setDebuggerEditor(editor: any) {
+        editorCommands.setDebuggerEditor(editor);
+    }
+
     /**
     /**
      * Called when a shortcut should be invoked, coming from the host editor
      * Called when a shortcut should be invoked, coming from the host editor
      * @param {Editor.EditorShortcutType} shortcut shortcut to be executed
      * @param {Editor.EditorShortcutType} shortcut shortcut to be executed

+ 4 - 0
Script/AtomicWebViewEditor/tsconfig.json

@@ -31,11 +31,15 @@
         "./clientExtensions/languageExtensions/typescript/workerprocess/workerLoader.ts",
         "./clientExtensions/languageExtensions/typescript/workerprocess/workerLoader.ts",
         "./clientExtensions/languageExtensions/typescript/workerprocess/workerProcessTypes.ts",
         "./clientExtensions/languageExtensions/typescript/workerprocess/workerProcessTypes.ts",
         "./clientExtensions/ServiceLocator.ts",
         "./clientExtensions/ServiceLocator.ts",
+        "./debugger/DuktapeDebugger.ts",
         "./editor/editor.ts",
         "./editor/editor.ts",
         "./editor/editorCommands.ts",
         "./editor/editorCommands.ts",
         "./interop.ts",
         "./interop.ts",
         "./modules/typescript.d.ts",
         "./modules/typescript.d.ts",
+        "./typings/jquery.d.ts",
+        "./typings/jqueryui.d.ts",
         "./typings/monaco.d.ts",
         "./typings/monaco.d.ts",
+        "./typings/socketio.d.ts",
         "./typings/systemjs.d.ts",
         "./typings/systemjs.d.ts",
         "./typings/webworkers.d.ts",
         "./typings/webworkers.d.ts",
         "./typings/WindowExt.d.ts",
         "./typings/WindowExt.d.ts",

+ 3779 - 0
Script/AtomicWebViewEditor/typings/jquery.d.ts

@@ -0,0 +1,3779 @@
+// Type definitions for jQuery 1.10.x / 2.0.x
+// Project: http://jquery.com/
+// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Christian Hoffmeister <https://github.com/choffmeister>, Steve Fenton <https://github.com/Steve-Fenton>, Diullei Gomes <https://github.com/Diullei>, Tass Iliopoulos <https://github.com/tasoili>, Jason Swearingen <https://github.com/jasons-novaleaf>, Sean Hill <https://github.com/seanski>, Guus Goossens <https://github.com/Guuz>, Kelly Summerlin <https://github.com/ksummerlin>, Basarat Ali Syed <https://github.com/basarat>, Nicholas Wolverson <https://github.com/nwolverson>, Derek Cicerone <https://github.com/derekcicerone>, Andrew Gaspar <https://github.com/AndrewGaspar>, James Harrison Fisher <https://github.com/jameshfisher>, Seikichi Kondo <https://github.com/seikichi>, Benjamin Jackman <https://github.com/benjaminjackman>, Poul Sorensen <https://github.com/s093294>, Josh Strobl <https://github.com/JoshStrobl>, John Reilly <https://github.com/johnnyreilly/>, Dick van den Brink <https://github.com/DickvdBrink>, Thomas Schulz <https://github.com/King2500>
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+/* *****************************************************************************
+Copyright (c) Microsoft Corporation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0
+
+THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+
+
+/**
+ * Interface for the AJAX setting that will configure the AJAX request
+ * @see {@link https://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings}
+ */
+interface JQueryAjaxSettings {
+    /**
+     * The content type sent in the request header that tells the server what kind of response it will accept in return. If the accepts setting needs modification, it is recommended to do so once in the $.ajaxSetup() method.
+     */
+    accepts?: any;
+    /**
+     * By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success().
+     */
+    async?: boolean;
+    /**
+     * A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request.
+     */
+    beforeSend? (jqXHR: JQueryXHR, settings: JQueryAjaxSettings): any;
+    /**
+     * If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
+     */
+    cache?: boolean;
+    /**
+     * A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request ("success", "notmodified", "error", "timeout", "abort", or "parsererror"). As of jQuery 1.5, the complete setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event.
+     */
+    complete? (jqXHR: JQueryXHR, textStatus: string): any;
+    /**
+     * An object of string/regular-expression pairs that determine how jQuery will parse the response, given its content type. (version added: 1.5)
+     */
+    contents?: { [key: string]: any; };
+    //According to jQuery.ajax source code, ajax's option actually allows contentType to set to "false"
+    // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/742
+    /**
+     * When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding.
+     */
+    contentType?: any;
+    /**
+     * This object will be made the context of all Ajax-related callbacks. By default, the context is an object that represents the ajax settings used in the call ($.ajaxSettings merged with the settings passed to $.ajax).
+     */
+    context?: any;
+    /**
+     * An object containing dataType-to-dataType converters. Each converter's value is a function that returns the transformed value of the response. (version added: 1.5)
+     */
+    converters?: { [key: string]: any; };
+    /**
+     * If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. (version added: 1.5)
+     */
+    crossDomain?: boolean;
+    /**
+     * Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be key-value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below).
+     */
+    data?: any;
+    /**
+     * A function to be used to handle the raw response data of XMLHttpRequest.This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter.
+     */
+    dataFilter? (data: any, ty: any): any;
+    /**
+     * The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string).
+     */
+    dataType?: string;
+    /**
+     * A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event.
+     */
+    error? (jqXHR: JQueryXHR, textStatus: string, errorThrown: string): any;
+    /**
+     * Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events.
+     */
+    global?: boolean;
+    /**
+     * An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added, but its default XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from within the beforeSend function. (version added: 1.5)
+     */
+    headers?: { [key: string]: any; };
+    /**
+     * Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header. In jQuery 1.4 this technique also checks the 'etag' specified by the server to catch unmodified data.
+     */
+    ifModified?: boolean;
+    /**
+     * Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: file, *-extension, and widget. If the isLocal setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. (version added: 1.5.1)
+     */
+    isLocal?: boolean;
+    /**
+     * Override the callback function name in a jsonp request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" }
+     */
+    jsonp?: any;
+    /**
+     * Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function.
+     */
+    jsonpCallback?: any;
+    /**
+     * The HTTP method to use for the request (e.g. "POST", "GET", "PUT"). (version added: 1.9.0)
+     */
+    method?: string;
+    /**
+     * A MIME type to override the XHR MIME type. (version added: 1.5.1)
+     */
+    mimeType?: string;
+    /**
+     * A password to be used with XMLHttpRequest in response to an HTTP access authentication request.
+     */
+    password?: string;
+    /**
+     * By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false.
+     */
+    processData?: boolean;
+    /**
+     * Only applies when the "script" transport is used (e.g., cross-domain requests with "jsonp" or "script" dataType and "GET" type). Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script.
+     */
+    scriptCharset?: string;
+    /**
+     * An object of numeric HTTP codes and functions to be called when the response has the corresponding code. f the request is successful, the status code functions take the same parameters as the success callback; if it results in an error (including 3xx redirect), they take the same parameters as the error callback. (version added: 1.5)
+     */
+    statusCode?: { [key: string]: any; };
+    /**
+     * A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event.
+     */
+    success? (data: any, textStatus: string, jqXHR: JQueryXHR): any;
+    /**
+     * Set a timeout (in milliseconds) for the request. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period.
+     */
+    timeout?: number;
+    /**
+     * Set this to true if you wish to use the traditional style of parameter serialization.
+     */
+    traditional?: boolean;
+    /**
+     * The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.
+     */
+    type?: string;
+    /**
+     * A string containing the URL to which the request is sent.
+     */
+    url?: string;
+    /**
+     * A username to be used with XMLHttpRequest in response to an HTTP access authentication request.
+     */
+    username?: string;
+    /**
+     * Callback for creating the XMLHttpRequest object. Defaults to the ActiveXObject when available (IE), the XMLHttpRequest otherwise. Override to provide your own implementation for XMLHttpRequest or enhancements to the factory.
+     */
+    xhr?: any;
+    /**
+     * An object of fieldName-fieldValue pairs to set on the native XHR object. For example, you can use it to set withCredentials to true for cross-domain requests if needed. In jQuery 1.5, the withCredentials property was not propagated to the native XHR and thus CORS requests requiring it would ignore this flag. For this reason, we recommend using jQuery 1.5.1+ should you require the use of it. (version added: 1.5.1)
+     */
+    xhrFields?: { [key: string]: any; };
+}
+
+/**
+ * Interface for the jqXHR object
+ * @see {@link https://api.jquery.com/jQuery.ajax/#jqXHR}
+ */
+interface JQueryXHR extends XMLHttpRequest, JQueryPromise<any> {
+    /**
+     * The .overrideMimeType() method may be used in the beforeSend() callback function, for example, to modify the response content-type header. As of jQuery 1.5.1, the jqXHR object also contains the overrideMimeType() method (it was available in jQuery 1.4.x, as well, but was temporarily removed in jQuery 1.5).
+     */
+    overrideMimeType(mimeType: string): any;
+    /**
+     * Cancel the request.
+     *
+     * @param statusText A string passed as the textStatus parameter for the done callback. Default value: "canceled"
+     */
+    abort(statusText?: string): void;
+    /**
+     * Incorporates the functionality of the .done() and .fail() methods, allowing (as of jQuery 1.8) the underlying Promise to be manipulated. Refer to deferred.then() for implementation details.
+     */
+    then<R>(doneCallback: (data: any, textStatus: string, jqXHR: JQueryXHR) => R|JQueryPromise<R>, failCallback?: (jqXHR: JQueryXHR, textStatus: string, errorThrown: any) => void): JQueryPromise<R>;
+    /**
+     * Property containing the parsed response if the response content type is json
+     */
+    responseJSON?: any;
+    /**
+     * A function to be called if the request fails.
+     */
+    error(xhr: JQueryXHR, textStatus: string, errorThrown: string): void;
+}
+
+/**
+ * Interface for the JQuery callback
+ * @see {@link https://api.jquery.com/category/callbacks-object/}
+ */
+interface JQueryCallback {
+    /**
+     * Add a callback or a collection of callbacks to a callback list.
+     *
+     * @param callbacks A function, or array of functions, that are to be added to the callback list.
+     * @see {@link https://api.jquery.com/callbacks.add/}
+     */
+    add(callbacks: Function): JQueryCallback;
+    /**
+     * Add a callback or a collection of callbacks to a callback list.
+     *
+     * @param callbacks A function, or array of functions, that are to be added to the callback list.
+     * @see {@link https://api.jquery.com/callbacks.add/}
+     */
+    add(callbacks: Function[]): JQueryCallback;
+
+    /**
+     * Disable a callback list from doing anything more.
+     * @see {@link https://api.jquery.com/callbacks.disable/}
+     */
+    disable(): JQueryCallback;
+
+    /**
+     * Determine if the callbacks list has been disabled.
+     * @see {@link https://api.jquery.com/callbacks.disabled/}
+     */
+    disabled(): boolean;
+
+    /**
+     * Remove all of the callbacks from a list.
+     * @see {@link https://api.jquery.com/callbacks.empty/}
+     */
+    empty(): JQueryCallback;
+
+    /**
+     * Call all of the callbacks with the given arguments
+     *
+     * @param arguments The argument or list of arguments to pass back to the callback list.
+     * @see {@link https://api.jquery.com/callbacks.fire/}
+     */
+    fire(...arguments: any[]): JQueryCallback;
+
+    /**
+     * Determine if the callbacks have already been called at least once.
+     * @see {@link https://api.jquery.com/callbacks.fired/}
+     */
+    fired(): boolean;
+
+    /**
+     * Call all callbacks in a list with the given context and arguments.
+     *
+     * @param context A reference to the context in which the callbacks in the list should be fired.
+     * @param arguments An argument, or array of arguments, to pass to the callbacks in the list.
+     * @see {@link https://api.jquery.com/callbacks.fireWith/}
+     */
+    fireWith(context?: any, args?: any[]): JQueryCallback;
+
+    /**
+     * Determine whether a supplied callback is in a list
+     *
+     * @param callback The callback to search for.
+     * @see {@link https://api.jquery.com/callbacks.has/}
+     */
+    has(callback: Function): boolean;
+
+    /**
+     * Lock a callback list in its current state.
+     * @see {@link https://api.jquery.com/callbacks.lock/}
+     */
+    lock(): JQueryCallback;
+
+    /**
+     * Determine if the callbacks list has been locked.
+     * @see {@link https://api.jquery.com/callbacks.locked/}
+     */
+    locked(): boolean;
+
+    /**
+     * Remove a callback or a collection of callbacks from a callback list.
+     *
+     * @param callbacks A function, or array of functions, that are to be removed from the callback list.
+     * @see {@link https://api.jquery.com/callbacks.remove/}
+     */
+    remove(callbacks: Function): JQueryCallback;
+    /**
+     * Remove a callback or a collection of callbacks from a callback list.
+     *
+     * @param callbacks A function, or array of functions, that are to be removed from the callback list.
+     * @see {@link https://api.jquery.com/callbacks.remove/}
+     */
+    remove(callbacks: Function[]): JQueryCallback;
+}
+
+/**
+ * Allows jQuery Promises to interop with non-jQuery promises
+ */
+interface JQueryGenericPromise<T> {
+    /**
+     * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
+     *
+     * @param doneFilter A function that is called when the Deferred is resolved.
+     * @param failFilter An optional function that is called when the Deferred is rejected.
+     * @see {@link https://api.jquery.com/deferred.then/#deferred-then-doneFilter-failFilter-progressFilter}
+     */
+    then<U>(doneFilter: (value?: T, ...values: any[]) => U|JQueryPromise<U>, failFilter?: (...reasons: any[]) => any, progressFilter?: (...progression: any[]) => any): JQueryPromise<U>;
+
+    /**
+     * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
+     *
+     * @param doneFilter A function that is called when the Deferred is resolved.
+     * @param failFilter An optional function that is called when the Deferred is rejected.
+     * @see {@link https://api.jquery.com/deferred.then/#deferred-then-doneFilter-failFilter-progressFilter}
+     */
+    then(doneFilter: (value?: T, ...values: any[]) => void, failFilter?: (...reasons: any[]) => any, progressFilter?: (...progression: any[]) => any): JQueryPromise<void>;
+}
+
+/**
+ * Interface for the JQuery promise/deferred callbacks
+ */
+interface JQueryPromiseCallback<T> {
+    (value?: T, ...args: any[]): void;
+}
+
+interface JQueryPromiseOperator<T, U> {
+    (callback1: JQueryPromiseCallback<T>|JQueryPromiseCallback<T>[], ...callbacksN: Array<JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[]>): JQueryPromise<U>;
+}
+
+/**
+ * Interface for the JQuery promise, part of callbacks
+ * @see {@link https://api.jquery.com/category/deferred-object/}
+ */
+interface JQueryPromise<T> extends JQueryGenericPromise<T> {
+    /**
+     * Determine the current state of a Deferred object.
+     * @see {@link https://api.jquery.com/deferred.state/}
+     */
+    state(): string;
+    /**
+     * Add handlers to be called when the Deferred object is either resolved or rejected.
+     *
+     * @param alwaysCallback1 A function, or array of functions, that is called when the Deferred is resolved or rejected.
+     * @param alwaysCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected.
+     * @see {@link https://api.jquery.com/deferred.always/}
+     */
+    always(alwaysCallback1?: JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[], ...alwaysCallbackN: Array<JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[]>): JQueryPromise<T>;
+    /**
+     * Add handlers to be called when the Deferred object is resolved.
+     *
+     * @param doneCallback1 A function, or array of functions, that are called when the Deferred is resolved.
+     * @param doneCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved.
+     * @see {@link https://api.jquery.com/deferred.done/}
+     */
+    done(doneCallback1?: JQueryPromiseCallback<T>|JQueryPromiseCallback<T>[], ...doneCallbackN: Array<JQueryPromiseCallback<T>|JQueryPromiseCallback<T>[]>): JQueryPromise<T>;
+    /**
+     * Add handlers to be called when the Deferred object is rejected.
+     *
+     * @param failCallback1 A function, or array of functions, that are called when the Deferred is rejected.
+     * @param failCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is rejected.
+     * @see {@link https://api.jquery.com/deferred.fail/}
+     */
+    fail(failCallback1?: JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[], ...failCallbackN: Array<JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[]>): JQueryPromise<T>;
+    /**
+     * Add handlers to be called when the Deferred object generates progress notifications.
+     *
+     * @param progressCallback1 A function, or array of functions, to be called when the Deferred generates progress notifications.
+     * @param progressCallbackN Optional additional functions, or arrays of functions, to be called when the Deferred generates progress notifications.
+     * @see {@link https://api.jquery.com/deferred.progress/}
+     */
+    progress(progressCallback1?: JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[], ...progressCallbackN: Array<JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[]>): JQueryPromise<T>;
+
+    // Deprecated - given no typings
+    pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise<any>;
+
+    /**
+     * Return a Deferred's Promise object.
+     *
+     * @param target Object onto which the promise methods have to be attached
+     * @see {@link https://api.jquery.com/deferred.promise/}
+     */
+    promise(target?: any): JQueryPromise<T>;
+}
+
+/**
+ * Interface for the JQuery deferred, part of callbacks
+ * @see {@link https://api.jquery.com/category/deferred-object/}
+ */
+interface JQueryDeferred<T> extends JQueryGenericPromise<T> {
+    /**
+     * Determine the current state of a Deferred object.
+     * @see {@link https://api.jquery.com/deferred.state/}
+     */
+    state(): string;
+    /**
+     * Add handlers to be called when the Deferred object is either resolved or rejected.
+     *
+     * @param alwaysCallback1 A function, or array of functions, that is called when the Deferred is resolved or rejected.
+     * @param alwaysCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected.
+     * @see {@link https://api.jquery.com/deferred.always/}
+     */
+    always(alwaysCallback1?: JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[], ...alwaysCallbackN: Array<JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[]>): JQueryDeferred<T>;
+    /**
+     * Add handlers to be called when the Deferred object is resolved.
+     *
+     * @param doneCallback1 A function, or array of functions, that are called when the Deferred is resolved.
+     * @param doneCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved.
+     * @see {@link https://api.jquery.com/deferred.done/}
+     */
+    done(doneCallback1?: JQueryPromiseCallback<T>|JQueryPromiseCallback<T>[], ...doneCallbackN: Array<JQueryPromiseCallback<T>|JQueryPromiseCallback<T>[]>): JQueryDeferred<T>;
+    /**
+     * Add handlers to be called when the Deferred object is rejected.
+     *
+     * @param failCallback1 A function, or array of functions, that are called when the Deferred is rejected.
+     * @param failCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is rejected.
+     * @see {@link https://api.jquery.com/deferred.fail/}
+     */
+    fail(failCallback1?: JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[], ...failCallbackN: Array<JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[]>): JQueryDeferred<T>;
+    /**
+     * Add handlers to be called when the Deferred object generates progress notifications.
+     *
+     * @param progressCallback1 A function, or array of functions, to be called when the Deferred generates progress notifications.
+     * @param progressCallbackN Optional additional functions, or arrays of functions, to be called when the Deferred generates progress notifications.
+     * @see {@link https://api.jquery.com/deferred.progress/}
+     */
+    progress(progressCallback1?: JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[], ...progressCallbackN: Array<JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[]>): JQueryDeferred<T>;
+
+    /**
+     * Call the progressCallbacks on a Deferred object with the given args.
+     *
+     * @param args Optional arguments that are passed to the progressCallbacks.
+     * @see {@link https://api.jquery.com/deferred.notify/}
+     */
+    notify(value?: any, ...args: any[]): JQueryDeferred<T>;
+
+    /**
+     * Call the progressCallbacks on a Deferred object with the given context and args.
+     *
+     * @param context Context passed to the progressCallbacks as the this object.
+     * @param args Optional arguments that are passed to the progressCallbacks.
+     * @see {@link https://api.jquery.com/deferred.notifyWith/}
+     */
+    notifyWith(context: any, args?: any[]): JQueryDeferred<T>;
+
+    /**
+     * Reject a Deferred object and call any failCallbacks with the given args.
+     *
+     * @param args Optional arguments that are passed to the failCallbacks.
+     * @see {@link https://api.jquery.com/deferred.reject/}
+     */
+    reject(value?: any, ...args: any[]): JQueryDeferred<T>;
+    /**
+     * Reject a Deferred object and call any failCallbacks with the given context and args.
+     *
+     * @param context Context passed to the failCallbacks as the this object.
+     * @param args An optional array of arguments that are passed to the failCallbacks.
+     * @see {@link https://api.jquery.com/deferred.rejectWith/}
+     */
+    rejectWith(context: any, args?: any[]): JQueryDeferred<T>;
+
+    /**
+     * Resolve a Deferred object and call any doneCallbacks with the given args.
+     *
+     * @param value First argument passed to doneCallbacks.
+     * @param args Optional subsequent arguments that are passed to the doneCallbacks.
+     * @see {@link https://api.jquery.com/deferred.resolve/}
+     */
+    resolve(value?: T, ...args: any[]): JQueryDeferred<T>;
+
+    /**
+     * Resolve a Deferred object and call any doneCallbacks with the given context and args.
+     *
+     * @param context Context passed to the doneCallbacks as the this object.
+     * @param args An optional array of arguments that are passed to the doneCallbacks.
+     * @see {@link https://api.jquery.com/deferred.resolveWith/}
+     */
+    resolveWith(context: any, args?: T[]): JQueryDeferred<T>;
+
+    /**
+     * Return a Deferred's Promise object.
+     *
+     * @param target Object onto which the promise methods have to be attached
+     * @see {@link https://api.jquery.com/deferred.promise/}
+     */
+    promise(target?: any): JQueryPromise<T>;
+
+    // Deprecated - given no typings
+    pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise<any>;
+}
+
+/**
+ * Interface of the JQuery extension of the W3C event object
+ * @see {@link https://api.jquery.com/category/events/event-object/}
+ */
+interface BaseJQueryEventObject extends Event {
+    /**
+     * The current DOM element within the event bubbling phase.
+     * @see {@link https://api.jquery.com/event.currentTarget/}
+     */
+    currentTarget: Element;
+    /**
+     * An optional object of data passed to an event method when the current executing handler is bound.
+     * @see {@link https://api.jquery.com/event.data/}
+     */
+    data: any;
+    /**
+     * The element where the currently-called jQuery event handler was attached.
+     * @see {@link https://api.jquery.com/event.delegateTarget/}
+     */
+    delegateTarget: Element;
+    /**
+     * Returns whether event.preventDefault() was ever called on this event object.
+     * @see {@link https://api.jquery.com/event.isDefaultPrevented/}
+     */
+    isDefaultPrevented(): boolean;
+    /**
+     * Returns whether event.stopImmediatePropagation() was ever called on this event object.
+     * @see {@link https://api.jquery.com/event.isImmediatePropagationStopped/}
+     */
+    isImmediatePropagationStopped(): boolean;
+    /**
+     * Returns whether event.stopPropagation() was ever called on this event object.
+     * @see {@link https://api.jquery.com/event.isPropagationStopped/}
+     */
+    isPropagationStopped(): boolean;
+    /**
+     * The namespace specified when the event was triggered.
+     * @see {@link https://api.jquery.com/event.namespace/}
+     */
+    namespace: string;
+    /**
+     * The browser's original Event object.
+     * @see {@link https://api.jquery.com/category/events/event-object/}
+     */
+    originalEvent: Event;
+    /**
+     * If this method is called, the default action of the event will not be triggered.
+     * @see {@link https://api.jquery.com/event.preventDefault/}
+     */
+    preventDefault(): any;
+    /**
+     * The other DOM element involved in the event, if any.
+     * @see {@link https://api.jquery.com/event.relatedTarget/}
+     */
+    relatedTarget: Element;
+    /**
+     * The last value returned by an event handler that was triggered by this event, unless the value was undefined.
+     * @see {@link https://api.jquery.com/event.result/}
+     */
+    result: any;
+    /**
+     * Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree.
+     * @see {@link https://api.jquery.com/event.stopImmediatePropagation/}
+     */
+    stopImmediatePropagation(): void;
+    /**
+     * Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.
+     * @see {@link https://api.jquery.com/event.stopPropagation/}
+     */
+    stopPropagation(): void;
+    /**
+     * The DOM element that initiated the event.
+     * @see {@link https://api.jquery.com/event.target/}
+     */
+    target: Element;
+    /**
+     * The mouse position relative to the left edge of the document.
+     * @see {@link https://api.jquery.com/event.pageX/}
+     */
+    pageX: number;
+    /**
+     * The mouse position relative to the top edge of the document.
+     * @see {@link https://api.jquery.com/event.pageY/}
+     */
+    pageY: number;
+    /**
+     * For key or mouse events, this property indicates the specific key or button that was pressed.
+     * @see {@link https://api.jquery.com/event.which/}
+     */
+    which: number;
+    /**
+     * Indicates whether the META key was pressed when the event fired.
+     * @see {@link https://api.jquery.com/event.metaKey/}
+     */
+    metaKey: boolean;
+}
+
+interface JQueryInputEventObject extends BaseJQueryEventObject {
+    altKey: boolean;
+    ctrlKey: boolean;
+    metaKey: boolean;
+    shiftKey: boolean;
+}
+
+interface JQueryMouseEventObject extends JQueryInputEventObject {
+    button: number;
+    clientX: number;
+    clientY: number;
+    offsetX: number;
+    offsetY: number;
+    pageX: number;
+    pageY: number;
+    screenX: number;
+    screenY: number;
+}
+
+interface JQueryKeyEventObject extends JQueryInputEventObject {
+    char: any;
+    charCode: number;
+    key: any;
+    keyCode: number;
+}
+
+interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject{
+}
+
+/**
+ * A collection of properties that represent the presence of different browser features or bugs.
+ *
+ * Intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally
+ * to improve page startup performance. For your own project's feature-detection needs, we strongly recommend the
+ * use of an external library such as {@link http://modernizr.com/|Modernizr} instead of dependency on properties
+ * in jQuery.support.
+ *
+ * @deprecated since version 1.9
+ */
+interface JQuerySupport {
+    ajax?: boolean;
+    boxModel?: boolean;
+    changeBubbles?: boolean;
+    checkClone?: boolean;
+    checkOn?: boolean;
+    cors?: boolean;
+    cssFloat?: boolean;
+    hrefNormalized?: boolean;
+    htmlSerialize?: boolean;
+    leadingWhitespace?: boolean;
+    noCloneChecked?: boolean;
+    noCloneEvent?: boolean;
+    opacity?: boolean;
+    optDisabled?: boolean;
+    optSelected?: boolean;
+    scriptEval? (): boolean;
+    style?: boolean;
+    submitBubbles?: boolean;
+    tbody?: boolean;
+}
+
+interface JQueryParam {
+    /**
+     * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
+     *
+     * @param obj An array or object to serialize.
+     */
+    (obj: any): string;
+
+    /**
+     * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
+     *
+     * @param obj An array or object to serialize.
+     * @param traditional A Boolean indicating whether to perform a traditional "shallow" serialization.
+     */
+    (obj: any, traditional: boolean): string;
+}
+
+/**
+ * The interface used to construct jQuery events (with $.Event). It is
+ * defined separately instead of inline in JQueryStatic to allow
+ * overriding the construction function with specific strings
+ * returning specific event objects.
+ */
+interface JQueryEventConstructor {
+    (name: string, eventProperties?: any): JQueryEventObject;
+    new (name: string, eventProperties?: any): JQueryEventObject;
+}
+
+/**
+ * The interface used to specify coordinates.
+ */
+interface JQueryCoordinates {
+    left: number;
+    top: number;
+}
+
+/**
+ * Elements in the array returned by serializeArray()
+ */
+interface JQuerySerializeArrayElement {
+    name: string;
+    value: string;
+}
+
+/**
+ * @see {@link https://api.jquery.com/animate/}
+ */
+interface JQueryAnimationOptions {
+    /**
+     * A string or number determining how long the animation will run.
+     */
+    duration?: any;
+    /**
+     * A string indicating which easing function to use for the transition.
+     */
+    easing?: string;
+    /**
+     * A function to call once the animation is complete.
+     */
+    complete?: Function;
+    /**
+     * A function to be called for each animated property of each animated element. This function provides an opportunity to modify the Tween object to change the value of the property before it is set.
+     */
+    step?: (now: number, tween: any) => any;
+    /**
+     * A function to be called after each step of the animation, only once per animated element regardless of the number of animated properties. (version added: 1.8)
+     */
+    progress?: (animation: JQueryPromise<any>, progress: number, remainingMs: number) => any;
+    /**
+     * A function to call when the animation begins. (version added: 1.8)
+     */
+    start?: (animation: JQueryPromise<any>) => any;
+    /**
+     * A function to be called when the animation completes (its Promise object is resolved). (version added: 1.8)
+     */
+    done?: (animation: JQueryPromise<any>, jumpedToEnd: boolean) => any;
+    /**
+     * A function to be called when the animation fails to complete (its Promise object is rejected). (version added: 1.8)
+     */
+    fail?: (animation: JQueryPromise<any>, jumpedToEnd: boolean) => any;
+    /**
+     * A function to be called when the animation completes or stops without completing (its Promise object is either resolved or rejected). (version added: 1.8)
+     */
+    always?: (animation: JQueryPromise<any>, jumpedToEnd: boolean) => any;
+    /**
+     * A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. When a custom queue name is used the animation does not automatically start; you must call .dequeue("queuename") to start it.
+     */
+    queue?: any;
+    /**
+     * A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions. (version added: 1.4)
+     */
+    specialEasing?: Object;
+}
+
+interface JQueryEasingFunction {
+    ( percent: number ): number;
+}
+
+interface JQueryEasingFunctions {
+    [ name: string ]: JQueryEasingFunction;
+    linear: JQueryEasingFunction;
+    swing: JQueryEasingFunction;
+}
+
+/**
+ * Static members of jQuery (those on $ and jQuery themselves)
+ *
+ * @see {@link https://api.jquery.com/Types/#jQuery}
+ */
+interface JQueryStatic {
+
+    /**
+     * Perform an asynchronous HTTP (Ajax) request.
+     *
+     * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup().
+     * @see {@link https://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings}
+     */
+    ajax(settings: JQueryAjaxSettings): JQueryXHR;
+    /**
+     * Perform an asynchronous HTTP (Ajax) request.
+     *
+     * @param url A string containing the URL to which the request is sent.
+     * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup().
+     * @see {@link https://api.jquery.com/jQuery.ajax/#jQuery-ajax-url-settings}
+     */
+    ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR;
+
+    /**
+     * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
+     *
+     * @param dataTypes An optional string containing one or more space-separated dataTypes
+     * @param handler A handler to set default values for future Ajax requests.
+     * @see {@link https://api.jquery.com/jQuery.ajaxPrefilter/}
+     */
+    ajaxPrefilter(dataTypes: string, handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void;
+    /**
+     * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
+     *
+     * @param handler A handler to set default values for future Ajax requests.
+     * @see {@link https://api.jquery.com/jQuery.ajaxPrefilter/}
+     */
+    ajaxPrefilter(handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void;
+
+     /**
+     * Creates an object that handles the actual transmission of Ajax data.
+     *
+     * @param dataType A string identifying the data type to use.
+     * @param handler A handler to return the new transport object to use with the data type provided in the first argument.
+     * @see {@link https://api.jquery.com/jQuery.ajaxTransport/}
+     */
+    ajaxTransport(dataType: string, handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void;
+
+    ajaxSettings: JQueryAjaxSettings;
+
+     /**
+      * Set default values for future Ajax requests. Its use is not recommended.
+      *
+      * @param options A set of key/value pairs that configure the default Ajax request. All options are optional.
+      * @see {@link https://api.jquery.com/jQuery.ajaxSetup/}
+      */
+    ajaxSetup(options: JQueryAjaxSettings): void;
+
+    /**
+     * Load data from the server using a HTTP GET request.
+     *
+     * @param url A string containing the URL to which the request is sent.
+     * @param success A callback function that is executed if the request succeeds.
+     * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
+     * @see {@link https://api.jquery.com/jQuery.get/#jQuery-get-url-data-success-dataType}
+     */
+    get(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
+    /**
+     * Load data from the server using a HTTP GET request.
+     *
+     * @param url A string containing the URL to which the request is sent.
+     * @param data A plain object or string that is sent to the server with the request.
+     * @param success A callback function that is executed if the request succeeds.
+     * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
+     * @see {@link https://api.jquery.com/jQuery.get/#jQuery-get-url-data-success-dataType}
+     */
+    get(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
+    /**
+     * Load data from the server using a HTTP GET request.
+     *
+     * @param settings The JQueryAjaxSettings to be used for the request
+     * @see {@link https://api.jquery.com/jQuery.get/#jQuery-get-settings}
+     */
+    get(settings : JQueryAjaxSettings): JQueryXHR;
+    /**
+     * Load JSON-encoded data from the server using a GET HTTP request.
+     *
+     * @param url A string containing the URL to which the request is sent.
+     * @param success A callback function that is executed if the request succeeds.
+     * @see {@link https://api.jquery.com/jQuery.getJSON/}
+     */
+    getJSON(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
+    /**
+     * Load JSON-encoded data from the server using a GET HTTP request.
+     *
+     * @param url A string containing the URL to which the request is sent.
+     * @param data A plain object or string that is sent to the server with the request.
+     * @param success A callback function that is executed if the request succeeds.
+     * @see {@link https://api.jquery.com/jQuery.getJSON/}
+     */
+    getJSON(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
+    /**
+     * Load a JavaScript file from the server using a GET HTTP request, then execute it.
+     *
+     * @param url A string containing the URL to which the request is sent.
+     * @param success A callback function that is executed if the request succeeds.
+     * @see {@link https://api.jquery.com/jQuery.getScript/}
+     */
+    getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
+
+    /**
+     * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
+     *
+     * @see {@link https://api.jquery.com/jQuery.param/}
+     */
+    param: JQueryParam;
+
+    /**
+     * Load data from the server using a HTTP POST request.
+     *
+     * @param url A string containing the URL to which the request is sent.
+     * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.
+     * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).
+     * @see {@link https://api.jquery.com/jQuery.post/#jQuery-post-url-data-success-dataType}
+     */
+    post(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
+    /**
+     * Load data from the server using a HTTP POST request.
+     *
+     * @param url A string containing the URL to which the request is sent.
+     * @param data A plain object or string that is sent to the server with the request.
+     * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.
+     * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).
+     * @see {@link https://api.jquery.com/jQuery.post/#jQuery-post-url-data-success-dataType}
+     */
+    post(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
+    /**
+     * Load data from the server using a HTTP POST request.
+     *
+     * @param settings The JQueryAjaxSettings to be used for the request
+     * @see {@link https://api.jquery.com/jQuery.post/#jQuery-post-settings}
+     */
+    post(settings : JQueryAjaxSettings): JQueryXHR;
+    /**
+     * A multi-purpose callbacks list object that provides a powerful way to manage callback lists.
+     *
+     * @param flags An optional list of space-separated flags that change how the callback list behaves.
+     * @see {@link https://api.jquery.com/jQuery.Callbacks/}
+     */
+    Callbacks(flags?: string): JQueryCallback;
+
+    /**
+     * Holds or releases the execution of jQuery's ready event.
+     *
+     * @param hold Indicates whether the ready hold is being requested or released
+     * @see {@link https://api.jquery.com/jQuery.holdReady/}
+     */
+    holdReady(hold: boolean): void;
+
+    /**
+     * Accepts a string containing a CSS selector which is then used to match a set of elements.
+     *
+     * @param selector A string containing a selector expression
+     * @param context A DOM Element, Document, or jQuery to use as context
+     * @see {@link https://api.jquery.com/jQuery/#jQuery-selector-context}
+     */
+    (selector: string, context?: Element|JQuery): JQuery;
+
+    /**
+     * Accepts a string containing a CSS selector which is then used to match a set of elements.
+     *
+     * @param element A DOM element to wrap in a jQuery object.
+     * @see {@link https://api.jquery.com/jQuery/#jQuery-element}
+     */
+    (element: Element): JQuery;
+
+    /**
+     * Accepts a string containing a CSS selector which is then used to match a set of elements.
+     *
+     * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object.
+     * @see {@link https://api.jquery.com/jQuery/#jQuery-elementArray}
+     */
+    (elementArray: Element[]): JQuery;
+
+    /**
+     * Binds a function to be executed when the DOM has finished loading.
+     *
+     * @param callback A function to execute after the DOM is ready.
+     * @see {@link https://api.jquery.com/jQuery/#jQuery-callback}
+     */
+    (callback: (jQueryAlias?: JQueryStatic) => any): JQuery;
+
+    /**
+     * Accepts a string containing a CSS selector which is then used to match a set of elements.
+     *
+     * @param object A plain object to wrap in a jQuery object.
+     * @see {@link https://api.jquery.com/jQuery/#jQuery-object}
+     */
+    (object: {}): JQuery;
+
+    /**
+     * Accepts a string containing a CSS selector which is then used to match a set of elements.
+     *
+     * @param object An existing jQuery object to clone.
+     * @see {@link https://api.jquery.com/jQuery/#jQuery-object}
+     */
+    (object: JQuery): JQuery;
+
+    /**
+     * Specify a function to execute when the DOM is fully loaded.
+     * @see {@link https://api.jquery.com/jQuery/#jQuery}
+     */
+    (): JQuery;
+
+    /**
+     * Creates DOM elements on the fly from the provided string of raw HTML.
+     *
+     * @param html A string of HTML to create on the fly. Note that this parses HTML, not XML.
+     * @param ownerDocument A document in which the new elements will be created.
+     * @see {@link https://api.jquery.com/jQuery/#jQuery-html-ownerDocument}
+     */
+    (html: string, ownerDocument?: Document): JQuery;
+
+    /**
+     * Creates DOM elements on the fly from the provided string of raw HTML.
+     *
+     * @param html A string defining a single, standalone, HTML element (e.g. <div/> or <div></div>).
+     * @param attributes An object of attributes, events, and methods to call on the newly-created element.
+     * @see {@link https://api.jquery.com/jQuery/#jQuery-html-attributes}
+     */
+    (html: string, attributes: Object): JQuery;
+
+    /**
+     * Relinquish jQuery's control of the $ variable.
+     *
+     * @param removeAll A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself).
+     * @see {@link https://api.jquery.com/jQuery.noConflict/}
+     */
+    noConflict(removeAll?: boolean): JQueryStatic;
+
+    /**
+     * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.
+     *
+     * @param deferreds One or more Deferred objects, or plain JavaScript objects.
+     * @see {@link https://api.jquery.com/jQuery.when/}
+     */
+    when<T>(...deferreds: Array<T|JQueryPromise<T>/* as JQueryDeferred<T> */>): JQueryPromise<T>;
+
+    /**
+     * Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties.
+     * @see {@link https://api.jquery.com/jQuery.cssHooks/}
+     */
+    cssHooks: { [key: string]: any; };
+
+    /**
+     * An object containing all CSS properties that may be used without a unit. The .css() method uses this object to see if it may append px to unitless values.
+     * @see {@link https://api.jquery.com/jQuery.cssNumber/}
+     */
+    cssNumber: any;
+
+    /**
+     * Store arbitrary data associated with the specified element. Returns the value that was set.
+     *
+     * @param element The DOM element to associate with the data.
+     * @param key A string naming the piece of data to set.
+     * @param value The new data value.
+     * @see {@link https://api.jquery.com/jQuery.data/#jQuery-data-element-key-value}
+     */
+    data<T>(element: Element, key: string, value: T): T;
+    /**
+     * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element.
+     *
+     * @param element The DOM element to associate with the data.
+     * @param key A string naming the piece of data to set.
+     * @see {@link https://api.jquery.com/jQuery.data/#jQuery-data-element-key}
+     */
+    data(element: Element, key: string): any;
+    /**
+     * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element.
+     *
+     * @param element The DOM element to associate with the data.
+     * @see {@link https://api.jquery.com/jQuery.data/#jQuery-data-element}
+     */
+    data(element: Element): any;
+
+    /**
+     * Execute the next function on the queue for the matched element.
+     *
+     * @param element A DOM element from which to remove and execute a queued function.
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @see {@link https://api.jquery.com/jQuery.dequeue/}
+     */
+    dequeue(element: Element, queueName?: string): void;
+
+    /**
+     * Determine whether an element has any jQuery data associated with it.
+     *
+     * @param element A DOM element to be checked for data.
+     * @see {@link https://api.jquery.com/jQuery.hasData/}
+     */
+    hasData(element: Element): boolean;
+
+    /**
+     * Show the queue of functions to be executed on the matched element.
+     *
+     * @param element A DOM element to inspect for an attached queue.
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @see {@link https://api.jquery.com/jQuery.queue/#jQuery-queue-element-queueName}
+     */
+    queue(element: Element, queueName?: string): any[];
+    /**
+     * Manipulate the queue of functions to be executed on the matched element.
+     *
+     * @param element A DOM element where the array of queued functions is attached.
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @param newQueue An array of functions to replace the current queue contents.
+     * @see {@link https://api.jquery.com/jQuery.queue/#jQuery-queue-element-queueName-newQueue}
+     */
+    queue(element: Element, queueName: string, newQueue: Function[]): JQuery;
+    /**
+     * Manipulate the queue of functions to be executed on the matched element.
+     *
+     * @param element A DOM element on which to add a queued function.
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @param callback The new function to add to the queue.
+     * @see {@link https://api.jquery.com/jQuery.queue/#jQuery-queue-element-queueName-callback}
+     */
+    queue(element: Element, queueName: string, callback: Function): JQuery;
+
+    /**
+     * Remove a previously-stored piece of data.
+     *
+     * @param element A DOM element from which to remove data.
+     * @param name A string naming the piece of data to remove.
+     * @see {@link https://api.jquery.com/jQuery.removeData/}
+     */
+    removeData(element: Element, name?: string): JQuery;
+
+    /**
+     * A constructor function that returns a chainable utility object with methods to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.
+     *
+     * @param beforeStart A function that is called just before the constructor returns.
+     * @see {@link https://api.jquery.com/jQuery.Deferred/}
+     */
+    Deferred<T>(beforeStart?: (deferred: JQueryDeferred<T>) => any): JQueryDeferred<T>;
+
+    /**
+     * Effects
+     */
+
+    easing: JQueryEasingFunctions;
+
+    fx: {
+        tick: () => void;
+        /**
+         * The rate (in milliseconds) at which animations fire.
+         * @see {@link https://api.jquery.com/jQuery.fx.interval/}
+         */
+        interval: number;
+        stop: () => void;
+        speeds: { slow: number; fast: number; };
+        /**
+         * Globally disable all animations.
+         * @see {@link https://api.jquery.com/jQuery.fx.off/}
+         */
+        off: boolean;
+        step: any;
+    };
+
+    /**
+     * Takes a function and returns a new one that will always have a particular context.
+     *
+     * @param func The function whose context will be changed.
+     * @param context The object to which the context (this) of the function should be set.
+     * @param additionalArguments Any number of arguments to be passed to the function referenced in the function argument.
+     * @see {@link https://api.jquery.com/jQuery.proxy/#jQuery-proxy-function-context-additionalArguments}
+     */
+    proxy(func: (...args: any[]) => any, context: Object, ...additionalArguments: any[]): any;
+    /**
+     * Takes a function and returns a new one that will always have a particular context.
+     *
+     * @param context The object to which the context (this) of the function should be set.
+     * @param name The name of the function whose context will be changed (should be a property of the context object).
+     * @param additionalArguments Any number of arguments to be passed to the function named in the name argument.
+     * @see {@link https://api.jquery.com/jQuery.proxy/#jQuery-proxy-context-name-additionalArguments}
+     */
+    proxy(context: Object, name: string, ...additionalArguments: any[]): any;
+
+    Event: JQueryEventConstructor;
+
+    /**
+     * Takes a string and throws an exception containing it.
+     *
+     * @param message The message to send out.
+     * @see {@link https://api.jquery.com/jQuery.error/}
+     */
+    error(message: any): JQuery;
+
+    expr: any;
+    fn: any;  //TODO: Decide how we want to type this
+
+    isReady: boolean;
+
+    // Properties
+    support: JQuerySupport;
+
+    /**
+     * Check to see if a DOM element is a descendant of another DOM element.
+     *
+     * @param container The DOM element that may contain the other element.
+     * @param contained The DOM element that may be contained by (a descendant of) the other element.
+     * @see {@link https://api.jquery.com/jQuery.contains/}
+     */
+    contains(container: Element, contained: Element): boolean;
+
+    /**
+     * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.
+     *
+     * @param collection The object or array to iterate over.
+     * @param callback The function that will be executed on every object.
+     * @see {@link https://api.jquery.com/jQuery.each/#jQuery-each-array-callback}
+     */
+    each<T>(
+        collection: T[],
+        callback: (indexInArray: number, valueOfElement: T) => any
+        ): any;
+
+    /**
+     * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.
+     *
+     * @param collection The object or array to iterate over.
+     * @param callback The function that will be executed on every object.
+     * @see {@link https://api.jquery.com/jQuery.each/#jQuery-each-object-callback}
+     */
+    each(
+        collection: any,
+        callback: (indexInArray: any, valueOfElement: any) => any
+        ): any;
+
+    /**
+     * Merge the contents of two or more objects together into the first object.
+     *
+     * @param target An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument.
+     * @param object1 An object containing additional properties to merge in.
+     * @param objectN Additional objects containing properties to merge in.
+     * @see {@link https://api.jquery.com/jQuery.extend/#jQuery-extend-target-object1-objectN}
+     */
+    extend(target: any, object1?: any, ...objectN: any[]): any;
+    /**
+     * Merge the contents of two or more objects together into the first object.
+     *
+     * @param deep If true, the merge becomes recursive (aka. deep copy).
+     * @param target The object to extend. It will receive the new properties.
+     * @param object1 An object containing additional properties to merge in.
+     * @param objectN Additional objects containing properties to merge in.
+     * @see {@link https://api.jquery.com/jQuery.extend/#jQuery-extend-deep-target-object1-objectN}
+     */
+    extend(deep: boolean, target: any, object1?: any, ...objectN: any[]): any;
+
+    /**
+     * Execute some JavaScript code globally.
+     *
+     * @param code The JavaScript code to execute.
+     * @see {@link https://api.jquery.com/jQuery.globalEval/}
+     */
+    globalEval(code: string): any;
+
+    /**
+     * Finds the elements of an array which satisfy a filter function. The original array is not affected.
+     *
+     * @param array The array to search through.
+     * @param func The function to process each item against. The first argument to the function is the item, and the second argument is the index. The function should return a Boolean value.  this will be the global window object.
+     * @param invert If "invert" is false, or not provided, then the function returns an array consisting of all elements for which "callback" returns true. If "invert" is true, then the function returns an array consisting of all elements for which "callback" returns false.
+     * @see {@link https://api.jquery.com/jQuery.grep/}
+     */
+    grep<T>(array: T[], func: (elementOfArray?: T, indexInArray?: number) => boolean, invert?: boolean): T[];
+
+    /**
+     * Search for a specified value within an array and return its index (or -1 if not found).
+     *
+     * @param value The value to search for.
+     * @param array An array through which to search.
+     * @param fromIndex The index of the array at which to begin the search. The default is 0, which will search the whole array.
+     * @see {@link https://api.jquery.com/jQuery.inArray/}
+     */
+    inArray<T>(value: T, array: T[], fromIndex?: number): number;
+
+    /**
+     * Determine whether the argument is an array.
+     *
+     * @param obj Object to test whether or not it is an array.
+     * @see {@link https://api.jquery.com/jQuery.isArray/}
+     */
+    isArray(obj: any): boolean;
+    /**
+     * Check to see if an object is empty (contains no enumerable properties).
+     *
+     * @param obj The object that will be checked to see if it's empty.
+     * @see {@link https://api.jquery.com/jQuery.isEmptyObject/}
+     */
+    isEmptyObject(obj: any): boolean;
+    /**
+     * Determine if the argument passed is a JavaScript function object.
+     *
+     * @param obj Object to test whether or not it is a function.
+     * @see {@link https://api.jquery.com/jQuery.isFunction/}
+     */
+    isFunction(obj: any): boolean;
+    /**
+     * Determines whether its argument is a number.
+     *
+     * @param value The value to be tested.
+     * @see {@link https://api.jquery.com/jQuery.isNumeric/}
+     */
+    isNumeric(value: any): boolean;
+    /**
+     * Check to see if an object is a plain object (created using "{}" or "new Object").
+     *
+     * @param obj The object that will be checked to see if it's a plain object.
+     * @see {@link https://api.jquery.com/jQuery.isPlainObject/}
+     */
+    isPlainObject(obj: any): boolean;
+    /**
+     * Determine whether the argument is a window.
+     *
+     * @param obj Object to test whether or not it is a window.
+     * @see {@link https://api.jquery.com/jQuery.isWindow/}
+     */
+    isWindow(obj: any): boolean;
+    /**
+     * Check to see if a DOM node is within an XML document (or is an XML document).
+     *
+     * @param node The DOM node that will be checked to see if it's in an XML document.
+     * @see {@link https://api.jquery.com/jQuery.isXMLDoc/}
+     */
+    isXMLDoc(node: Node): boolean;
+
+    /**
+     * Convert an array-like object into a true JavaScript array.
+     *
+     * @param obj Any object to turn into a native Array.
+     * @see {@link https://api.jquery.com/jQuery.makeArray/}
+     */
+    makeArray(obj: any): any[];
+
+    /**
+     * Translate all items in an array or object to new array of items.
+     *
+     * @param array The Array to translate.
+     * @param callback The function to process each item against. The first argument to the function is the array item, the second argument is the index in array The function can return any value. Within the function, this refers to the global (window) object.
+     * @see {@link https://api.jquery.com/jQuery.map/#jQuery-map-array-callback}
+     */
+    map<T, U>(array: T[], callback: (elementOfArray?: T, indexInArray?: number) => U): U[];
+    /**
+     * Translate all items in an array or object to new array of items.
+     *
+     * @param arrayOrObject The Array or Object to translate.
+     * @param callback The function to process each item against. The first argument to the function is the value; the second argument is the index or key of the array or object property. The function can return any value to add to the array. A returned array will be flattened into the resulting array. Within the function, this refers to the global (window) object.
+     * @see {@link https://api.jquery.com/jQuery.map/#jQuery-map-object-callback}
+     */
+    map(arrayOrObject: any, callback: (value?: any, indexOrKey?: any) => any): any;
+
+    /**
+     * Merge the contents of two arrays together into the first array.
+     *
+     * @param first The first array to merge, the elements of second added.
+     * @param second The second array to merge into the first, unaltered.
+     * @see {@link https://api.jquery.com/jQuery.merge/}
+     */
+    merge<T>(first: T[], second: T[]): T[];
+
+    /**
+     * An empty function.
+     * @see {@link https://api.jquery.com/jQuery.noop/}
+     */
+    noop(): any;
+
+    /**
+     * Return a number representing the current time.
+     * @see {@link https://api.jquery.com/jQuery.now/}
+     */
+    now(): number;
+
+    /**
+     * Takes a well-formed JSON string and returns the resulting JavaScript object.
+     *
+     * @param json The JSON string to parse.
+     * @see {@link https://api.jquery.com/jQuery.parseJSON/}
+     */
+    parseJSON(json: string): any;
+
+    /**
+     * Parses a string into an XML document.
+     *
+     * @param data a well-formed XML string to be parsed
+     * @see {@link https://api.jquery.com/jQuery.parseXML/}
+     */
+    parseXML(data: string): XMLDocument;
+
+    /**
+     * Remove the whitespace from the beginning and end of a string.
+     *
+     * @param str Remove the whitespace from the beginning and end of a string.
+     * @see {@link https://api.jquery.com/jQuery.trim/}
+     */
+    trim(str: string): string;
+
+    /**
+     * Determine the internal JavaScript [[Class]] of an object.
+     *
+     * @param obj Object to get the internal JavaScript [[Class]] of.
+     * @see {@link https://api.jquery.com/jQuery.type/}
+     */
+    type(obj: any): string;
+
+    /**
+     * Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers.
+     *
+     * @param array The Array of DOM elements.
+     * @see {@link https://api.jquery.com/jQuery.unique/}
+     */
+    unique(array: Element[]): Element[];
+
+    /**
+     * Parses a string into an array of DOM nodes.
+     *
+     * @param data HTML string to be parsed
+     * @param context DOM element to serve as the context in which the HTML fragment will be created
+     * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string
+     * @see {@link https://api.jquery.com/jQuery.parseHTML/}
+     */
+    parseHTML(data: string, context?: HTMLElement, keepScripts?: boolean): any[];
+
+    /**
+     * Parses a string into an array of DOM nodes.
+     *
+     * @param data HTML string to be parsed
+     * @param context DOM element to serve as the context in which the HTML fragment will be created
+     * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string
+     * @see {@link https://api.jquery.com/jQuery.parseHTML/}
+     */
+    parseHTML(data: string, context?: Document, keepScripts?: boolean): any[];
+}
+
+/**
+ * The jQuery instance members
+ *
+ * @see {@link https://api.jquery.com/Types/#jQuery}
+ */
+interface JQuery {
+    /**
+     * Register a handler to be called when Ajax requests complete. This is an AjaxEvent.
+     *
+     * @param handler The function to be invoked.
+     * @see {@link https://api.jquery.com/ajaxComplete/}
+     */
+    ajaxComplete(handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: any) => any): JQuery;
+    /**
+     * Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event.
+     *
+     * @param handler The function to be invoked.
+     * @see {@link https://api.jquery.com/ajaxError/}
+     */
+    ajaxError(handler: (event: JQueryEventObject, jqXHR: JQueryXHR, ajaxSettings: JQueryAjaxSettings, thrownError: any) => any): JQuery;
+    /**
+     * Attach a function to be executed before an Ajax request is sent. This is an Ajax Event.
+     *
+     * @param handler The function to be invoked.
+     * @see {@link https://api.jquery.com/ajaxSend/}
+     */
+    ajaxSend(handler: (event: JQueryEventObject, jqXHR: JQueryXHR, ajaxOptions: JQueryAjaxSettings) => any): JQuery;
+    /**
+     * Register a handler to be called when the first Ajax request begins. This is an Ajax Event.
+     *
+     * @param handler The function to be invoked.
+     * @see {@link https://api.jquery.com/ajaxStart/}
+     */
+    ajaxStart(handler: () => any): JQuery;
+    /**
+     * Register a handler to be called when all Ajax requests have completed. This is an Ajax Event.
+     *
+     * @param handler The function to be invoked.
+     * @see {@link https://api.jquery.com/ajaxStop/}
+     */
+    ajaxStop(handler: () => any): JQuery;
+    /**
+     * Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event.
+     *
+     * @param handler The function to be invoked.
+     * @see {@link https://api.jquery.com/ajaxSuccess/}
+     */
+    ajaxSuccess(handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: JQueryAjaxSettings) => any): JQuery;
+
+    /**
+     * Load data from the server and place the returned HTML into the matched element.
+     *
+     * @param url A string containing the URL to which the request is sent.
+     * @param data A plain object or string that is sent to the server with the request.
+     * @param complete A callback function that is executed when the request completes.
+     * @see {@link https://api.jquery.com/load/}
+     */
+    load(url: string, data?: string|Object, complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any): JQuery;
+
+    /**
+     * Encode a set of form elements as a string for submission.
+     * @see {@link https://api.jquery.com/serialize/}
+     */
+    serialize(): string;
+    /**
+     * Encode a set of form elements as an array of names and values.
+     * @see {@link https://api.jquery.com/serializeArray/}
+     */
+    serializeArray(): JQuerySerializeArrayElement[];
+
+    /**
+     * Adds the specified class(es) to each of the set of matched elements.
+     *
+     * @param className One or more space-separated classes to be added to the class attribute of each matched element.
+     * @see {@link https://api.jquery.com/addClass/#addClass-className}
+     */
+    addClass(className: string): JQuery;
+    /**
+     * Adds the specified class(es) to each of the set of matched elements.
+     *
+     * @param func A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/addClass/#addClass-function}
+     */
+    addClass(func: (index: number, className: string) => string): JQuery;
+
+    /**
+     * Add the previous set of elements on the stack to the current set, optionally filtered by a selector.
+     * @see {@link https://api.jquery.com/addBack/}
+     */
+    addBack(selector?: string): JQuery;
+
+    /**
+     * Get the value of an attribute for the first element in the set of matched elements.
+     *
+     * @param attributeName The name of the attribute to get.
+     * @see {@link https://api.jquery.com/attr/#attr-attributeName}
+     */
+    attr(attributeName: string): string;
+    /**
+     * Set one or more attributes for the set of matched elements.
+     *
+     * @param attributeName The name of the attribute to set.
+     * @param value A value to set for the attribute. If this is `null`, the attribute will be deleted.
+     * @see {@link https://api.jquery.com/attr/#attr-attributeName-value}
+     */
+    attr(attributeName: string, value: string|number|null): JQuery;
+    /**
+     * Set one or more attributes for the set of matched elements.
+     *
+     * @param attributeName The name of the attribute to set.
+     * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments.
+     * @see {@link https://api.jquery.com/attr/#attr-attributeName-function}
+     */
+    attr(attributeName: string, func: (index: number, attr: string) => string|number): JQuery;
+    /**
+     * Set one or more attributes for the set of matched elements.
+     *
+     * @param attributes An object of attribute-value pairs to set.
+     * @see {@link https://api.jquery.com/attr/#attr-attributes}
+     */
+    attr(attributes: Object): JQuery;
+
+    /**
+     * Determine whether any of the matched elements are assigned the given class.
+     *
+     * @param className The class name to search for.
+     * @see {@link https://api.jquery.com/hasClass/}
+     */
+    hasClass(className: string): boolean;
+
+    /**
+     * Get the HTML contents of the first element in the set of matched elements.
+     * @see {@link https://api.jquery.com/html/#html}
+     */
+    html(): string;
+    /**
+     * Set the HTML contents of each element in the set of matched elements.
+     *
+     * @param htmlString A string of HTML to set as the content of each matched element.
+     * @see {@link https://api.jquery.com/html/#html-htmlString}
+     */
+    html(htmlString: string): JQuery;
+    /**
+     * Set the HTML contents of each element in the set of matched elements.
+     *
+     * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/html/#html-function}
+     */
+    html(func: (index: number, oldhtml: string) => string): JQuery;
+
+    /**
+     * Get the value of a property for the first element in the set of matched elements.
+     *
+     * @param propertyName The name of the property to get.
+     * @see {@link https://api.jquery.com/prop/#prop-propertyName}
+     */
+    prop(propertyName: string): any;
+    /**
+     * Set one or more properties for the set of matched elements.
+     *
+     * @param propertyName The name of the property to set.
+     * @param value A value to set for the property.
+     * @see {@link https://api.jquery.com/prop/#prop-propertyName-value}
+     */
+    prop(propertyName: string, value: string|number|boolean): JQuery;
+    /**
+     * Set one or more properties for the set of matched elements.
+     *
+     * @param properties An object of property-value pairs to set.
+     * @see {@link https://api.jquery.com/prop/#prop-properties}
+     */
+    prop(properties: Object): JQuery;
+    /**
+     * Set one or more properties for the set of matched elements.
+     *
+     * @param propertyName The name of the property to set.
+     * @param func A function returning the value to set. Receives the index position of the element in the set and the old property value as arguments. Within the function, the keyword this refers to the current element.
+     * @see {@link https://api.jquery.com/prop/#prop-propertyName-function}
+     */
+    prop(propertyName: string, func: (index: number, oldPropertyValue: any) => any): JQuery;
+
+    /**
+     * Remove an attribute from each element in the set of matched elements.
+     *
+     * @param attributeName An attribute to remove; as of version 1.7, it can be a space-separated list of attributes.
+     * @see {@link https://api.jquery.com/removeAttr/}
+     */
+    removeAttr(attributeName: string): JQuery;
+
+    /**
+     * Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
+     *
+     * @param className One or more space-separated classes to be removed from the class attribute of each matched element.
+     * @see {@link https://api.jquery.com/removeClass/#removeClass-className}
+     */
+    removeClass(className?: string): JQuery;
+    /**
+     * Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
+     *
+     * @param func A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments.
+     * @see {@link https://api.jquery.com/removeClass/#removeClass-function}
+     */
+    removeClass(func: (index: number, className: string) => string): JQuery;
+
+    /**
+     * Remove a property for the set of matched elements.
+     *
+     * @param propertyName The name of the property to remove.
+     * @see {@link https://api.jquery.com/removeProp/}
+     */
+    removeProp(propertyName: string): JQuery;
+
+    /**
+     * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
+     *
+     * @param className One or more class names (separated by spaces) to be toggled for each element in the matched set.
+     * @param swtch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed.
+     * @see {@link https://api.jquery.com/toggleClass/#toggleClass-className}
+     */
+    toggleClass(className: string, swtch?: boolean): JQuery;
+    /**
+     * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
+     *
+     * @param swtch A boolean value to determine whether the class should be added or removed.
+     * @see {@link https://api.jquery.com/toggleClass/#toggleClass-state}
+     */
+    toggleClass(swtch?: boolean): JQuery;
+    /**
+     * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
+     *
+     * @param func A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the switch as arguments.
+     * @param swtch A boolean value to determine whether the class should be added or removed.
+     * @see {@link https://api.jquery.com/toggleClass/#toggleClass-function-state}
+     */
+    toggleClass(func: (index: number, className: string, swtch: boolean) => string, swtch?: boolean): JQuery;
+
+    /**
+     * Get the current value of the first element in the set of matched elements.
+     * @see {@link https://api.jquery.com/val/#val}
+     */
+    val(): any;
+    /**
+     * Set the value of each element in the set of matched elements.
+     *
+     * @param value A string of text, an array of strings or number corresponding to the value of each matched element to set as selected/checked.
+     * @see {@link https://api.jquery.com/val/#val-value}
+     */
+    val(value: string|string[]|number): JQuery;
+    /**
+     * Set the value of each element in the set of matched elements.
+     *
+     * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments.
+     * @see {@link https://api.jquery.com/val/#val-function}
+     */
+    val(func: (index: number, value: string) => string): JQuery;
+
+    /**
+     * Get the value of style properties for the first element in the set of matched elements.
+     *
+     * @param propertyName A CSS property.
+     * @see {@link https://api.jquery.com/css/#css-propertyName}
+     */
+    css(propertyName: string): string;
+    /**
+     * Set one or more CSS properties for the set of matched elements.
+     *
+     * @param propertyName A CSS property name.
+     * @param value A value to set for the property.
+     * @see {@link https://api.jquery.com/css/#css-propertyName-value}
+     */
+    css(propertyName: string, value: string|number): JQuery;
+    /**
+     * Set one or more CSS properties for the set of matched elements.
+     *
+     * @param propertyName A CSS property name.
+     * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments.
+     * @see {@link https://api.jquery.com/css/#css-propertyName-function}
+     */
+    css(propertyName: string, value: (index: number, value: string) => string|number): JQuery;
+    /**
+     * Set one or more CSS properties for the set of matched elements.
+     *
+     * @param properties An object of property-value pairs to set.
+     * @see {@link https://api.jquery.com/css/#css-properties}
+     */
+    css(properties: Object): JQuery;
+
+    /**
+     * Get the current computed height for the first element in the set of matched elements.
+     * @see {@link https://api.jquery.com/height/#height}
+     */
+    height(): number;
+    /**
+     * Set the CSS height of every matched element.
+     *
+     * @param value An integer representing the number of pixels, or an integer with an optional unit of measure appended (as a string).
+     * @see {@link https://api.jquery.com/height/#height-value}
+     */
+    height(value: number|string): JQuery;
+    /**
+     * Set the CSS height of every matched element.
+     *
+     * @param func A function returning the height to set. Receives the index position of the element in the set and the old height as arguments. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/height/#height-function}
+     */
+    height(func: (index: number, height: number) => number|string): JQuery;
+
+    /**
+     * Get the current computed height for the first element in the set of matched elements, including padding but not border.
+     * @see {@link https://api.jquery.com/innerHeight/#innerHeight}
+     */
+    innerHeight(): number;
+
+    /**
+     * Sets the inner height on elements in the set of matched elements, including padding but not border.
+     *
+     * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
+     * @see {@link https://api.jquery.com/innerHeight/#innerHeight-value}
+     */
+    innerHeight(value: number|string): JQuery;
+
+    /**
+     * Get the current computed width for the first element in the set of matched elements, including padding but not border.
+     * @see {@link https://api.jquery.com/innerWidth/#innerWidth}
+     */
+    innerWidth(): number;
+
+    /**
+     * Sets the inner width on elements in the set of matched elements, including padding but not border.
+     *
+     * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
+     * @see {@link https://api.jquery.com/innerWidth/#innerWidth-value}
+     */
+    innerWidth(value: number|string): JQuery;
+
+    /**
+     * Get the current coordinates of the first element in the set of matched elements, relative to the document.
+     * @see {@link https://api.jquery.com/offset/#offset}
+     */
+    offset(): JQueryCoordinates;
+    /**
+     * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
+     *
+     * @param coordinates An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
+     * @see {@link https://api.jquery.com/offset/#offset-coordinates}
+     */
+    offset(coordinates: JQueryCoordinates): JQuery;
+    /**
+     * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
+     *
+     * @param func A function to return the coordinates to set. Receives the index of the element in the collection as the first argument and the current coordinates as the second argument. The function should return an object with the new top and left properties.
+     * @see {@link https://api.jquery.com/offset/#offset-function}
+     */
+    offset(func: (index: number, coords: JQueryCoordinates) => JQueryCoordinates): JQuery;
+
+    /**
+     * Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements.
+     *
+     * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation.
+     * @see {@link https://api.jquery.com/outerHeight/#outerHeight-includeMargin}
+     */
+    outerHeight(includeMargin?: boolean): number;
+
+    /**
+     * Sets the outer height on elements in the set of matched elements, including padding and border.
+     *
+     * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
+     * @see {@link https://api.jquery.com/outerHeight/#outerHeight-value}
+     */
+    outerHeight(value: number|string): JQuery;
+
+    /**
+     * Get the current computed width for the first element in the set of matched elements, including padding and border.
+     *
+     * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation.
+     * @see {@link https://api.jquery.com/outerWidth/#outerWidth-includeMargin}
+     */
+    outerWidth(includeMargin?: boolean): number;
+
+    /**
+     * Sets the outer width on elements in the set of matched elements, including padding and border.
+     *
+     * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
+     * @see {@link https://api.jquery.com/outerWidth/#outerWidth-value}
+     */
+    outerWidth(value: number|string): JQuery;
+
+    /**
+     * Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
+     * @see {@link https://api.jquery.com/position/}
+     */
+    position(): JQueryCoordinates;
+
+    /**
+     * Get the current horizontal position of the scroll bar for the first element in the set of matched elements or set the horizontal position of the scroll bar for every matched element.
+     * @see {@link https://api.jquery.com/scrollLeft/#scrollLeft}
+     */
+    scrollLeft(): number;
+    /**
+     * Set the current horizontal position of the scroll bar for each of the set of matched elements.
+     *
+     * @param value An integer indicating the new position to set the scroll bar to.
+     * @see {@link https://api.jquery.com/scrollLeft/#scrollLeft-value}
+     */
+    scrollLeft(value: number): JQuery;
+
+    /**
+     * Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element.
+     * @see {@link https://api.jquery.com/scrollTop/#scrollTop}
+     */
+    scrollTop(): number;
+    /**
+     * Set the current vertical position of the scroll bar for each of the set of matched elements.
+     *
+     * @param value An integer indicating the new position to set the scroll bar to.
+     * @see {@link https://api.jquery.com/scrollTop/#scrollTop-value}
+     */
+    scrollTop(value: number): JQuery;
+
+    /**
+     * Get the current computed width for the first element in the set of matched elements.
+     * @see {@link https://api.jquery.com/width/#width}
+     */
+    width(): number;
+    /**
+     * Set the CSS width of each element in the set of matched elements.
+     *
+     * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
+     * @see {@link https://api.jquery.com/width/#width-value}
+     */
+    width(value: number|string): JQuery;
+    /**
+     * Set the CSS width of each element in the set of matched elements.
+     *
+     * @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/width/#width-function}
+     */
+    width(func: (index: number, width: number) => number|string): JQuery;
+
+    /**
+     * Remove from the queue all items that have not yet been run.
+     *
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @see {@link https://api.jquery.com/clearQueue/}
+     */
+    clearQueue(queueName?: string): JQuery;
+
+    /**
+     * Store arbitrary data associated with the matched elements.
+     *
+     * @param key A string naming the piece of data to set.
+     * @param value The new data value; it can be any JavaScript type including Array or Object.
+     * @see {@link https://api.jquery.com/data/#data-key-value}
+     */
+    data(key: string, value: any): JQuery;
+    /**
+     * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
+     *
+     * @param key Name of the data stored.
+     * @see {@link https://api.jquery.com/data/#data-key}
+     */
+    data(key: string): any;
+    /**
+     * Store arbitrary data associated with the matched elements.
+     *
+     * @param obj An object of key-value pairs of data to update.
+     * @see {@link https://api.jquery.com/data/#data-obj}
+     */
+    data(obj: { [key: string]: any; }): JQuery;
+    /**
+     * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
+     * @see {@link https://api.jquery.com/data/#data}
+     */
+    data(): any;
+
+    /**
+     * Execute the next function on the queue for the matched elements.
+     *
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @see {@link https://api.jquery.com/dequeue/}
+     */
+    dequeue(queueName?: string): JQuery;
+
+    /**
+     * Remove a previously-stored piece of data.
+     *
+     * @param name A string naming the piece of data to delete or space-separated string naming the pieces of data to delete.
+     * @see {@link https://api.jquery.com/removeData/#removeData-name}
+     */
+    removeData(name: string): JQuery;
+    /**
+     * Remove a previously-stored piece of data.
+     *
+     * @param list An array of strings naming the pieces of data to delete.
+     * @see {@link https://api.jquery.com/removeData/#removeData-list}
+     */
+    removeData(list: string[]): JQuery;
+    /**
+     * Remove all previously-stored piece of data.
+     * @see {@link https://api.jquery.com/removeData/}
+     */
+    removeData(): JQuery;
+
+    /**
+     * Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished.
+     *
+     * @param type The type of queue that needs to be observed. (default: fx)
+     * @param target Object onto which the promise methods have to be attached
+     * @see {@link https://api.jquery.com/promise/}
+     */
+    promise(type?: string, target?: Object): JQueryPromise<any>;
+
+    /**
+     * Perform a custom animation of a set of CSS properties.
+     *
+     * @param properties An object of CSS properties and values that the animation will move toward.
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/animate/#animate-properties-duration-easing-complete}
+     */
+    animate(properties: Object, duration?: string|number, complete?: Function): JQuery;
+    /**
+     * Perform a custom animation of a set of CSS properties.
+     *
+     * @param properties An object of CSS properties and values that the animation will move toward.
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition. (default: swing)
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/animate/#animate-properties-duration-easing-complete}
+     */
+    animate(properties: Object, duration?: string|number, easing?: string, complete?: Function): JQuery;
+    /**
+     * Perform a custom animation of a set of CSS properties.
+     *
+     * @param properties An object of CSS properties and values that the animation will move toward.
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/animate/#animate-properties-options}
+     */
+    animate(properties: Object, options: JQueryAnimationOptions): JQuery;
+
+    /**
+     * Set a timer to delay execution of subsequent items in the queue.
+     *
+     * @param duration An integer indicating the number of milliseconds to delay execution of the next item in the queue.
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @see {@link https://api.jquery.com/delay/}
+     */
+    delay(duration: number, queueName?: string): JQuery;
+
+    /**
+     * Display the matched elements by fading them to opaque.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/fadeIn/#fadeIn-duration-complete}
+     */
+    fadeIn(duration?: number|string, complete?: Function): JQuery;
+    /**
+     * Display the matched elements by fading them to opaque.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/fadeIn/#fadeIn-duration-easing-complete}
+     */
+    fadeIn(duration?: number|string, easing?: string, complete?: Function): JQuery;
+    /**
+     * Display the matched elements by fading them to opaque.
+     *
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/fadeIn/#fadeIn-options}
+     */
+    fadeIn(options: JQueryAnimationOptions): JQuery;
+
+    /**
+     * Hide the matched elements by fading them to transparent.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/fadeOut/#fadeOut-duration-complete}
+     */
+    fadeOut(duration?: number|string, complete?: Function): JQuery;
+    /**
+     * Hide the matched elements by fading them to transparent.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/fadeOut/#fadeOut-duration-easing-complete}
+     */
+    fadeOut(duration?: number|string, easing?: string, complete?: Function): JQuery;
+    /**
+     * Hide the matched elements by fading them to transparent.
+     *
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/fadeOut/#fadeOut-options}
+     */
+    fadeOut(options: JQueryAnimationOptions): JQuery;
+
+    /**
+     * Adjust the opacity of the matched elements.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param opacity A number between 0 and 1 denoting the target opacity.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/fadeTo/#fadeTo-duration-opacity-complete}
+     */
+    fadeTo(duration: string|number, opacity: number, complete?: Function): JQuery;
+    /**
+     * Adjust the opacity of the matched elements.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param opacity A number between 0 and 1 denoting the target opacity.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/fadeTo/#fadeTo-duration-opacity-easing-complete}
+     */
+    fadeTo(duration: string|number, opacity: number, easing?: string, complete?: Function): JQuery;
+
+    /**
+     * Display or hide the matched elements by animating their opacity.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/fadeToggle/#fadeToggle-duration-easing-complete}
+     */
+    fadeToggle(duration?: number|string, complete?: Function): JQuery;
+    /**
+     * Display or hide the matched elements by animating their opacity.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/fadeToggle/#fadeToggle-duration-easing-complete}
+     */
+    fadeToggle(duration?: number|string, easing?: string, complete?: Function): JQuery;
+    /**
+     * Display or hide the matched elements by animating their opacity.
+     *
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/fadeToggle/#fadeToggle-options}
+     */
+    fadeToggle(options: JQueryAnimationOptions): JQuery;
+
+    /**
+     * Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements.
+     *
+     * @param queue The name of the queue in which to stop animations.
+     * @see {@link https://api.jquery.com/finish/}
+     */
+    finish(queue?: string): JQuery;
+
+    /**
+     * Hide the matched elements.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/hide/#hide}
+     */
+    hide(duration?: number|string, complete?: Function): JQuery;
+    /**
+     * Hide the matched elements.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/hide/#hide-duration-easing-complete}
+     */
+    hide(duration?: number|string, easing?: string, complete?: Function): JQuery;
+    /**
+     * Hide the matched elements.
+     *
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/hide/#hide-options}
+     */
+    hide(options: JQueryAnimationOptions): JQuery;
+
+    /**
+     * Display the matched elements.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/show/#show}
+     */
+    show(duration?: number|string, complete?: Function): JQuery;
+    /**
+     * Display the matched elements.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/show/#show-duration-easing-complete}
+     */
+    show(duration?: number|string, easing?: string, complete?: Function): JQuery;
+    /**
+     * Display the matched elements.
+     *
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/show/#show-options}
+     */
+    show(options: JQueryAnimationOptions): JQuery;
+
+    /**
+     * Display the matched elements with a sliding motion.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/slideDown/#slideDown-duration-complete}
+     */
+    slideDown(duration?: number|string, complete?: Function): JQuery;
+    /**
+     * Display the matched elements with a sliding motion.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/slideDown/#slideDown-duration-easing-complete}
+     */
+    slideDown(duration?: number|string, easing?: string, complete?: Function): JQuery;
+    /**
+     * Display the matched elements with a sliding motion.
+     *
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/slideDown/#slideDown-options}
+     */
+    slideDown(options: JQueryAnimationOptions): JQuery;
+
+    /**
+     * Display or hide the matched elements with a sliding motion.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/slideToggle/#slideToggle-duration-complete}
+     */
+    slideToggle(duration?: number|string, complete?: Function): JQuery;
+    /**
+     * Display or hide the matched elements with a sliding motion.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/slideToggle/#slideToggle-duration-easing-complete}
+     */
+    slideToggle(duration?: number|string, easing?: string, complete?: Function): JQuery;
+    /**
+     * Display or hide the matched elements with a sliding motion.
+     *
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/slideToggle/#slideToggle-options}
+     */
+    slideToggle(options: JQueryAnimationOptions): JQuery;
+
+    /**
+     * Hide the matched elements with a sliding motion.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/slideUp/#slideUp-duration-complete}
+     */
+    slideUp(duration?: number|string, complete?: Function): JQuery;
+    /**
+     * Hide the matched elements with a sliding motion.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/slideUp/#slideUp-duration-easing-complete}
+     */
+    slideUp(duration?: number|string, easing?: string, complete?: Function): JQuery;
+    /**
+     * Hide the matched elements with a sliding motion.
+     *
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/slideUp/#slideUp-options}
+     */
+    slideUp(options: JQueryAnimationOptions): JQuery;
+
+    /**
+     * Stop the currently-running animation on the matched elements.
+     *
+     * @param clearQueue A Boolean indicating whether to remove queued animation as well. Defaults to false.
+     * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately. Defaults to false.
+     * @see {@link https://api.jquery.com/stop/#stop-clearQueue-jumpToEnd}
+     */
+    stop(clearQueue?: boolean, jumpToEnd?: boolean): JQuery;
+    /**
+     * Stop the currently-running animation on the matched elements.
+     *
+     * @param queue The name of the queue in which to stop animations.
+     * @param clearQueue A Boolean indicating whether to remove queued animation as well. Defaults to false.
+     * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately. Defaults to false.
+     * @see {@link https://api.jquery.com/stop/#stop-queue-clearQueue-jumpToEnd}
+     */
+    stop(queue?: string, clearQueue?: boolean, jumpToEnd?: boolean): JQuery;
+
+    /**
+     * Display or hide the matched elements.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/toggle/#toggle-duration-complete}
+     */
+    toggle(duration?: number|string, complete?: Function): JQuery;
+    /**
+     * Display or hide the matched elements.
+     *
+     * @param duration A string or number determining how long the animation will run.
+     * @param easing A string indicating which easing function to use for the transition.
+     * @param complete A function to call once the animation is complete.
+     * @see {@link https://api.jquery.com/toggle/#toggle-duration-easing-complete}
+     */
+    toggle(duration?: number|string, easing?: string, complete?: Function): JQuery;
+    /**
+     * Display or hide the matched elements.
+     *
+     * @param options A map of additional options to pass to the method.
+     * @see {@link https://api.jquery.com/toggle/#toggle-options}
+     */
+    toggle(options: JQueryAnimationOptions): JQuery;
+    /**
+     * Display or hide the matched elements.
+     *
+     * @param showOrHide A Boolean indicating whether to show or hide the elements.
+     * @see {@link https://api.jquery.com/toggle/#toggle-display}
+     */
+    toggle(showOrHide: boolean): JQuery;
+
+    /**
+     * Attach a handler to an event for the elements.
+     *
+     * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-handler}
+     */
+    bind(eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Attach a handler to an event for the elements.
+     *
+     * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-handler}
+     */
+    bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Attach a handler to an event for the elements.
+     *
+     * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true.
+     * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-preventBubble}
+     */
+    bind(eventType: string, eventData: any, preventBubble: boolean): JQuery;
+    /**
+     * Attach a handler to an event for the elements.
+     *
+     * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+     * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true.
+     * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-preventBubble}
+     */
+    bind(eventType: string, preventBubble: boolean): JQuery;
+    /**
+     * Attach a handler to an event for the elements.
+     *
+     * @param events An object containing one or more DOM event types and functions to execute for them.
+     * @see {@link https://api.jquery.com/bind/#bind-events}
+     */
+    bind(events: any): JQuery;
+
+    /**
+     * Trigger the "blur" event on an element
+     * @see {@link https://api.jquery.com/blur/#blur}
+     */
+    blur(): JQuery;
+    /**
+     * Bind an event handler to the "blur" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/blur/#blur-handler}
+     */
+    blur(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "blur" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/blur/#blur-eventData-handler}
+     */
+    blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "change" event on an element.
+     * @see {@link https://api.jquery.com/change/#change}
+     */
+    change(): JQuery;
+    /**
+     * Bind an event handler to the "change" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/change/#change-handler}
+     */
+    change(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "change" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/change/#change-eventData-handler}
+     */
+    change(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "click" event on an element.
+     * @see {@link https://api.jquery.com/click/#click}
+     */
+    click(): JQuery;
+    /**
+     * Bind an event handler to the "click" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/click/#click-handler}
+     */
+    click(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "click" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/click/#click-eventData-handler}
+     */
+    click(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "contextmenu" event on an element.
+     * @see {@link https://api.jquery.com/contextmenu/#contextmenu}
+     */
+    contextmenu(): JQuery;
+    /**
+     * Bind an event handler to the "contextmenu" JavaScript event.
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/contextmenu/#contextmenu-handler}
+     */
+    contextmenu(handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "contextmenu" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/contextmenu/#contextmenu-eventData-handler}
+     */
+    contextmenu(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "dblclick" event on an element.
+     * @see {@link https://api.jquery.com/dblclick/#dblclick}
+     */
+    dblclick(): JQuery;
+    /**
+     * Bind an event handler to the "dblclick" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/dblclick/#dblclick-handler}
+     */
+    dblclick(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "dblclick" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/dblclick/#dblclick-eventData-handler}
+     */
+    dblclick(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements.
+     * @see {@link https://api.jquery.com/delegate/#delegate-selector-eventType-handler}
+     */
+    delegate(selector: any, eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements.
+     * @see {@link https://api.jquery.com/delegate/#delegate-selector-eventType-eventData-handler}
+     */
+    delegate(selector: any, eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "focus" event on an element.
+     * @see {@link https://api.jquery.com/focus/#focus}
+     */
+    focus(): JQuery;
+    /**
+     * Bind an event handler to the "focus" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/focus/#focus-handler}
+     */
+    focus(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "focus" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/focus/#focus-eventData-handler}
+     */
+    focus(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "focusin" event on an element.
+     * @see {@link https://api.jquery.com/focusin/#focusin}
+     */
+    focusin(): JQuery;
+    /**
+     * Bind an event handler to the "focusin" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/focusin/#focusin-handler}
+     */
+    focusin(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "focusin" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/focusin/#focusin-eventData-handler}
+     */
+    focusin(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "focusout" event on an element.
+     * @see {@link https://api.jquery.com/focusout/#focusout}
+     */
+    focusout(): JQuery;
+    /**
+     * Bind an event handler to the "focusout" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/focusout/#focusout-handler}
+     */
+    focusout(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "focusout" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/focusout/#focusout-eventData-handler}
+     */
+    focusout(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.
+     *
+     * @param handlerIn A function to execute when the mouse pointer enters the element.
+     * @param handlerOut A function to execute when the mouse pointer leaves the element.
+     * @see {@link https://api.jquery.com/hover/#hover-handlerIn-handlerOut}
+     */
+    hover(handlerIn: (eventObject: JQueryEventObject) => any, handlerOut: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements.
+     *
+     * @param handlerInOut A function to execute when the mouse pointer enters or leaves the element.
+     * @see {@link https://api.jquery.com/hover/#hover-handlerInOut}
+     */
+    hover(handlerInOut: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "keydown" event on an element.
+     * @see {@link https://api.jquery.com/keydown/#keydown}
+     */
+    keydown(): JQuery;
+    /**
+     * Bind an event handler to the "keydown" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/keydown/#keydown-handler}
+     */
+    keydown(handler: (eventObject: JQueryKeyEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "keydown" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/keydown/#keydown-eventData-handler}
+     */
+    keydown(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "keypress" event on an element.
+     * @see {@link https://api.jquery.com/keypress/#keypress}
+     */
+    keypress(): JQuery;
+    /**
+     * Bind an event handler to the "keypress" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/keypress/#keypress-handler}
+     */
+    keypress(handler: (eventObject: JQueryKeyEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "keypress" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/keypress/#keypress-eventData-handler}
+     */
+    keypress(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "keyup" event on an element.
+     * @see {@link https://api.jquery.com/keyup/#keyup}
+     */
+    keyup(): JQuery;
+    /**
+     * Bind an event handler to the "keyup" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/keyup/#keyup-handler}
+     */
+    keyup(handler: (eventObject: JQueryKeyEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "keyup" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/keyup/#keyup-eventData-handler}
+     */
+    keyup(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery;
+
+    /**
+     * Bind an event handler to the "load" JavaScript event.
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/load/}
+     */
+    load(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "load" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/load/}
+     */
+    load(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "mousedown" event on an element.
+     * @see {@link https://api.jquery.com/mousedown/#mousedown}
+     */
+    mousedown(): JQuery;
+    /**
+     * Bind an event handler to the "mousedown" JavaScript event.
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mousedown/#mousedown-handler}
+     */
+    mousedown(handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "mousedown" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mousedown/#mousedown-eventData-handler}
+     */
+    mousedown(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "mouseenter" event on an element.
+     * @see {@link https://api.jquery.com/mouseenter/#mouseenter}
+     */
+    mouseenter(): JQuery;
+    /**
+     * Bind an event handler to be fired when the mouse enters an element.
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseenter/#mouseenter-handler}
+     */
+    mouseenter(handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to be fired when the mouse enters an element.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseenter/#mouseenter-eventData-handler}
+     */
+    mouseenter(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "mouseleave" event on an element.
+     * @see {@link https://api.jquery.com/mouseleave/#mouseleave}
+     */
+    mouseleave(): JQuery;
+    /**
+     * Bind an event handler to be fired when the mouse leaves an element.
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseleave/#mouseleave-handler}
+     */
+    mouseleave(handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to be fired when the mouse leaves an element.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseleave/#mouseleave-eventData-handler}
+     */
+    mouseleave(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "mousemove" event on an element.
+     * @see {@link https://api.jquery.com/mousemove/#mousemove}
+     */
+    mousemove(): JQuery;
+    /**
+     * Bind an event handler to the "mousemove" JavaScript event.
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mousemove/#mousemove-handler}
+     */
+    mousemove(handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "mousemove" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mousemove/#mousemove-eventData-handler}
+     */
+    mousemove(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "mouseout" event on an element.
+     * @see {@link https://api.jquery.com/mouseout/#mouseout}
+     */
+    mouseout(): JQuery;
+    /**
+     * Bind an event handler to the "mouseout" JavaScript event.
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseout/#mouseout-handler}
+     */
+    mouseout(handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "mouseout" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseout/#mouseout-eventData-handler}
+     */
+    mouseout(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "mouseover" event on an element.
+     * @see {@link https://api.jquery.com/mouseover/#mouseover}
+     */
+    mouseover(): JQuery;
+    /**
+     * Bind an event handler to the "mouseover" JavaScript event.
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseover/#mouseover-handler}
+     */
+    mouseover(handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "mouseover" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseover/#mouseover-eventData-handler}
+     */
+    mouseover(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "mouseup" event on an element.
+     * @see {@link https://api.jquery.com/mouseup/#mouseup}
+     */
+    mouseup(): JQuery;
+    /**
+     * Bind an event handler to the "mouseup" JavaScript event.
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseup/#mouseup-handler}
+     */
+    mouseup(handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "mouseup" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/mouseup/#mouseup-eventData-handler}
+     */
+    mouseup(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery;
+
+    /**
+     * Remove an event handler.
+     * @see {@link https://api.jquery.com/off/#off}
+     */
+    off(): JQuery;
+    /**
+     * Remove an event handler.
+     *
+     * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin".
+     * @param selector A selector which should match the one originally passed to .on() when attaching event handlers.
+     * @param handler A handler function previously attached for the event(s), or the special value false.
+     * @see {@link https://api.jquery.com/off/#off-events-selector-handler}
+     */
+    off(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Remove an event handler.
+     *
+     * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin".
+     * @param handler A handler function previously attached for the event(s), or the special value false. Takes handler with extra args that can be attached with on().
+     * @see {@link https://api.jquery.com/off/#off-events-selector-handler}
+     */
+    off(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
+    /**
+     * Remove an event handler.
+     *
+     * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin".
+     * @param handler A handler function previously attached for the event(s), or the special value false.
+     * @see {@link https://api.jquery.com/off/#off-events-selector-handler}
+     */
+    off(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Remove an event handler.
+     *
+     * @param events An object where the string keys represent one or more space-separated event types and optional namespaces, and the values represent handler functions previously attached for the event(s).
+     * @param selector A selector which should match the one originally passed to .on() when attaching event handlers.
+     * @see {@link https://api.jquery.com/off/#off-events-selector}
+     */
+    off(events: { [key: string]: any; }, selector?: string): JQuery;
+
+    /**
+     * Attach an event handler function for one or more events to the selected elements.
+     *
+     * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+     * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
+     * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler}
+     */
+    on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
+    /**
+     * Attach an event handler function for one or more events to the selected elements.
+     *
+     * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+     * @param data Data to be passed to the handler in event.data when an event is triggered.
+     * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+     * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler}
+    */
+    on(events: string, data : any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
+    /**
+     * Attach an event handler function for one or more events to the selected elements.
+     *
+     * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+     * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
+     * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+     * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler}
+     */
+    on(events: string, selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
+    /**
+     * Attach an event handler function for one or more events to the selected elements.
+     *
+     * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+     * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
+     * @param data Data to be passed to the handler in event.data when an event is triggered.
+     * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+     * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler}
+     */
+    on(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
+    /**
+     * Attach an event handler function for one or more events to the selected elements.
+     *
+     * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s).
+     * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element.
+     * @param data Data to be passed to the handler in event.data when an event occurs.
+     * @see {@link https://api.jquery.com/on/#on-events-selector-data}
+     */
+    on(events: { [key: string]: any; }, selector?: string, data?: any): JQuery;
+    /**
+     * Attach an event handler function for one or more events to the selected elements.
+     *
+     * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s).
+     * @param data Data to be passed to the handler in event.data when an event occurs.
+     * @see {@link https://api.jquery.com/on/#on-events-selector-data}
+     */
+    on(events: { [key: string]: any; }, data?: any): JQuery;
+
+    /**
+     * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+     *
+     * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
+     * @param handler A function to execute at the time the event is triggered.
+     * @see {@link https://api.jquery.com/one/#one-events-data-handler}
+     */
+    one(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+     *
+     * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
+     * @param data An object containing data that will be passed to the event handler.
+     * @param handler A function to execute at the time the event is triggered.
+     * @see {@link https://api.jquery.com/one/#one-events-data-handler}
+     */
+    one(events: string, data: Object, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+     *
+     * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+     * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
+     * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+     * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler}
+     */
+    one(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+     *
+     * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+     * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
+     * @param data Data to be passed to the handler in event.data when an event is triggered.
+     * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+     * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler}
+     */
+    one(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+     *
+     * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s).
+     * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element.
+     * @param data Data to be passed to the handler in event.data when an event occurs.
+     * @see {@link https://api.jquery.com/one/#one-events-selector-data}
+     */
+    one(events: { [key: string]: any; }, selector?: string, data?: any): JQuery;
+
+    /**
+     * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+     *
+     * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s).
+     * @param data Data to be passed to the handler in event.data when an event occurs.
+     * @see {@link https://api.jquery.com/one/#one-events-selector-data}
+     */
+    one(events: { [key: string]: any; }, data?: any): JQuery;
+
+
+    /**
+     * Specify a function to execute when the DOM is fully loaded.
+     *
+     * @param handler A function to execute after the DOM is ready.
+     * @see {@link https://api.jquery.com/ready/}
+     */
+    ready(handler: (jQueryAlias?: JQueryStatic) => any): JQuery;
+
+    /**
+     * Trigger the "resize" event on an element.
+     * @see {@link https://api.jquery.com/resize/#resize}
+     */
+    resize(): JQuery;
+    /**
+     * Bind an event handler to the "resize" JavaScript event.
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/resize/#resize-handler}
+     */
+    resize(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "resize" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/resize/#resize-eventData-handler}
+     */
+    resize(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "scroll" event on an element.
+     * @see {@link https://api.jquery.com/scroll/#scroll}
+     */
+    scroll(): JQuery;
+    /**
+     * Bind an event handler to the "scroll" JavaScript event.
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/scroll/#scroll-handler}
+     */
+    scroll(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "scroll" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/scroll/#scroll-eventData-handler}
+     */
+    scroll(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "select" event on an element.
+     * @see {@link https://api.jquery.com/select/#select}
+     */
+    select(): JQuery;
+    /**
+     * Bind an event handler to the "select" JavaScript event.
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/select/#select-handler}
+     */
+    select(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "select" JavaScript event.
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/select/#select-eventData-handler}
+     */
+    select(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Trigger the "submit" event on an element.
+     * @see {@link https://api.jquery.com/submit/#submit}
+     */
+    submit(): JQuery;
+    /**
+     * Bind an event handler to the "submit" JavaScript event
+     *
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/submit/#submit-handler}
+     */
+    submit(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "submit" JavaScript event
+     *
+     * @param eventData An object containing data that will be passed to the event handler.
+     * @param handler A function to execute each time the event is triggered.
+     * @see {@link https://api.jquery.com/submit/#submit-eventData-handler}
+     */
+    submit(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Execute all handlers and behaviors attached to the matched elements for the given event type.
+     *
+     * @param eventType A string containing a JavaScript event type, such as click or submit.
+     * @param extraParameters Additional parameters to pass along to the event handler.
+     * @see {@link https://api.jquery.com/trigger/#trigger-eventType-extraParameters}
+     */
+    trigger(eventType: string, extraParameters?: any[]|Object): JQuery;
+    /**
+     * Execute all handlers and behaviors attached to the matched elements for the given event type.
+     *
+     * @param event A jQuery.Event object.
+     * @param extraParameters Additional parameters to pass along to the event handler.
+     * @see {@link https://api.jquery.com/trigger/#trigger-event-extraParameters}
+     */
+    trigger(event: JQueryEventObject, extraParameters?: any[]|Object): JQuery;
+
+    /**
+     * Execute all handlers attached to an element for an event.
+     *
+     * @param eventType A string containing a JavaScript event type, such as click or submit.
+     * @param extraParameters An array of additional parameters to pass along to the event handler.
+     * @see {@link https://api.jquery.com/triggerHandler/#triggerHandler-eventType-extraParameters}
+     */
+    triggerHandler(eventType: string, ...extraParameters: any[]): Object;
+
+    /**
+     * Execute all handlers attached to an element for an event.
+     *
+     * @param event A jQuery.Event object.
+     * @param extraParameters An array of additional parameters to pass along to the event handler.
+     * @see {@link https://api.jquery.com/triggerHandler/#triggerHandler-event-extraParameters}
+     */
+    triggerHandler(event: JQueryEventObject, ...extraParameters: any[]): Object;
+
+    /**
+     * Remove a previously-attached event handler from the elements.
+     *
+     * @param eventType A string containing a JavaScript event type, such as click or submit.
+     * @param handler The function that is to be no longer executed.
+     * @see {@link https://api.jquery.com/unbind/#unbind-eventType-handler}
+     */
+    unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Remove a previously-attached event handler from the elements.
+     *
+     * @param eventType A string containing a JavaScript event type, such as click or submit.
+     * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ).
+     * @see {@link https://api.jquery.com/unbind/#unbind-eventType-false}
+     */
+    unbind(eventType: string, fls: boolean): JQuery;
+    /**
+     * Remove a previously-attached event handler from the elements.
+     *
+     * @param evt A JavaScript event object as passed to an event handler.
+     * @see {@link https://api.jquery.com/unbind/#unbind-event}
+     */
+    unbind(evt: any): JQuery;
+
+    /**
+     * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
+     * @see {@link https://api.jquery.com/undelegate/#undelegate}
+     */
+    undelegate(): JQuery;
+    /**
+     * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
+     *
+     * @param selector A selector which will be used to filter the event results.
+     * @param eventType A string containing a JavaScript event type, such as "click" or "keydown"
+     * @param handler A function to execute at the time the event is triggered.
+     * @see {@link https://api.jquery.com/undelegate/#undelegate-selector-eventType}
+     */
+    undelegate(selector: string, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
+     *
+     * @param selector A selector which will be used to filter the event results.
+     * @param events An object of one or more event types and previously bound functions to unbind from them.
+     * @see {@link https://api.jquery.com/undelegate/#undelegate-selector-events}
+     */
+    undelegate(selector: string, events: Object): JQuery;
+    /**
+     * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
+     *
+     * @param namespace A string containing a namespace to unbind all events from.
+     * @see {@link https://api.jquery.com/undelegate/#undelegate-namespace}
+     */
+    undelegate(namespace: string): JQuery;
+
+    /**
+     * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8)
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/unload/#unload-handler}
+     */
+    unload(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8)
+     *
+     * @param eventData A plain object of data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/unload/#unload-eventData-handler}
+     */
+    unload(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * The DOM node context originally passed to jQuery(); if none was passed then context will likely be the document. (DEPRECATED from v1.10)
+     * @see {@link https://api.jquery.com/context/}
+     */
+    context: Element;
+
+    jquery: string;
+
+    /**
+     * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8)
+     *
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/error/#error-handler}
+     */
+    error(handler: (eventObject: JQueryEventObject) => any): JQuery;
+    /**
+     * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8)
+     *
+     * @param eventData A plain object of data that will be passed to the event handler.
+     * @param handler A function to execute when the event is triggered.
+     * @see {@link https://api.jquery.com/error/#error-eventData-handler}
+     */
+    error(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+    /**
+     * Add a collection of DOM elements onto the jQuery stack.
+     *
+     * @param elements An array of elements to push onto the stack and make into a new jQuery object.
+     * @see {@link https://api.jquery.com/pushStack/#pushStack-elements}
+     */
+    pushStack(elements: any[]): JQuery;
+    /**
+     * Add a collection of DOM elements onto the jQuery stack.
+     *
+     * @param elements An array of elements to push onto the stack and make into a new jQuery object.
+     * @param name The name of a jQuery method that generated the array of elements.
+     * @param arguments The arguments that were passed in to the jQuery method (for serialization).
+     * @see {@link https://api.jquery.com/pushStack/#pushStack-elements-name-arguments}
+     */
+    pushStack(elements: any[], name: string, arguments: any[]): JQuery;
+
+    /**
+     * Insert content, specified by the parameter, after each element in the set of matched elements.
+     *
+     * @param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert after each element in the set of matched elements.
+     * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements.
+     * @see {@link https://api.jquery.com/after/#after-content-content}
+     */
+    after(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery;
+    /**
+     * Insert content, specified by the parameter, after each element in the set of matched elements.
+     *
+     * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/after/#after-function}
+     */
+    after(func: (index: number, html: string) => string|Element|JQuery): JQuery;
+
+    /**
+     * Insert content, specified by the parameter, to the end of each element in the set of matched elements.
+     *
+     * @param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements.
+     * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements.
+     * @see {@link https://api.jquery.com/append/#append-content-content}
+     */
+    append(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery;
+    /**
+     * Insert content, specified by the parameter, to the end of each element in the set of matched elements.
+     *
+     * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/append/#append-function}
+     */
+    append(func: (index: number, html: string) => string|Element|JQuery): JQuery;
+
+    /**
+     * Insert every element in the set of matched elements to the end of the target.
+     *
+     * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter.
+     * @see {@link https://api.jquery.com/appendTo/}
+     */
+    appendTo(target: JQuery|any[]|Element|string): JQuery;
+
+    /**
+     * Insert content, specified by the parameter, before each element in the set of matched elements.
+     *
+     * @param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert before each element in the set of matched elements.
+     * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements.
+     * @see {@link https://api.jquery.com/before/#before-content-content}
+     */
+    before(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery;
+    /**
+     * Insert content, specified by the parameter, before each element in the set of matched elements.
+     *
+     * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/before/#before-function}
+     */
+    before(func: (index: number, html: string) => string|Element|JQuery): JQuery;
+
+    /**
+     * Create a deep copy of the set of matched elements.
+     *
+     * @param withDataAndEvents A Boolean indicating whether event handlers and data should be copied along with the elements. The default value is false.
+     * @param deepWithDataAndEvents A Boolean indicating whether event handlers and data for all children of the cloned element should be copied. By default its value matches the first argument's value (which defaults to false).
+     * @see {@link https://api.jquery.com/clone/}
+     */
+    clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean): JQuery;
+
+    /**
+     * Remove the set of matched elements from the DOM.
+     *
+     * @param selector A selector expression that filters the set of matched elements to be removed.
+     * @see {@link https://api.jquery.com/detach/}
+     */
+    detach(selector?: string): JQuery;
+
+    /**
+     * Remove all child nodes of the set of matched elements from the DOM.
+     * @see {@link https://api.jquery.com/empty/}
+     */
+    empty(): JQuery;
+
+    /**
+     * Insert every element in the set of matched elements after the target.
+     *
+     * @param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter.
+     * @see {@link https://api.jquery.com/insertAfter/}
+     */
+    insertAfter(target: JQuery|any[]|Element|Text|string): JQuery;
+
+    /**
+     * Insert every element in the set of matched elements before the target.
+     *
+     * @param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter.
+     * @see {@link https://api.jquery.com/insertBefore/}
+     */
+    insertBefore(target: JQuery|any[]|Element|Text|string): JQuery;
+
+    /**
+     * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
+     *
+     * @param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements.
+     * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements.
+     * @see {@link https://api.jquery.com/prepend/#prepend-content-content}
+     */
+    prepend(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery;
+    /**
+     * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
+     *
+     * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/prepend/#prepend-function}
+     */
+    prepend(func: (index: number, html: string) => string|Element|JQuery): JQuery;
+
+    /**
+     * Insert every element in the set of matched elements to the beginning of the target.
+     *
+     * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter.
+     * @see {@link https://api.jquery.com/prependTo/}
+     */
+    prependTo(target: JQuery|any[]|Element|string): JQuery;
+
+    /**
+     * Remove the set of matched elements from the DOM.
+     *
+     * @param selector A selector expression that filters the set of matched elements to be removed.
+     * @see {@link https://api.jquery.com/remove/}
+     */
+    remove(selector?: string): JQuery;
+
+    /**
+     * Replace each target element with the set of matched elements.
+     *
+     * @param target A selector string, jQuery object, DOM element, or array of elements indicating which element(s) to replace.
+     * @see {@link https://api.jquery.com/replaceAll/}
+     */
+    replaceAll(target: JQuery|any[]|Element|string): JQuery;
+
+    /**
+     * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed.
+     *
+     * @param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object.
+     * @see {@link https://api.jquery.com/replaceWith/#replaceWith-newContent}
+     */
+    replaceWith(newContent: JQuery|any[]|Element|Text|string): JQuery;
+    /**
+     * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed.
+     *
+     * @param func A function that returns content with which to replace the set of matched elements.
+     * @see {@link https://api.jquery.com/replaceWith/#replaceWith-function}
+     */
+    replaceWith(func: () => Element|JQuery): JQuery;
+
+    /**
+     * Get the combined text contents of each element in the set of matched elements, including their descendants.
+     * @see {@link https://api.jquery.com/text/#text}
+     */
+    text(): string;
+    /**
+     * Set the content of each element in the set of matched elements to the specified text.
+     *
+     * @param text The text to set as the content of each matched element. When Number or Boolean is supplied, it will be converted to a String representation.
+     * @see {@link https://api.jquery.com/text/#text-text}
+     */
+    text(text: string|number|boolean): JQuery;
+    /**
+     * Set the content of each element in the set of matched elements to the specified text.
+     *
+     * @param func A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments.
+     * @see {@link https://api.jquery.com/text/#text-function}
+     */
+    text(func: (index: number, text: string) => string): JQuery;
+
+    /**
+     * Retrieve all the elements contained in the jQuery set, as an array.
+     * @name toArray
+     * @see {@link https://api.jquery.com/toArray/}
+     */
+    toArray(): HTMLElement[];
+
+    /**
+     * Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
+     * @see {@link https://api.jquery.com/unwrap/}
+     */
+    unwrap(): JQuery;
+
+    /**
+     * Wrap an HTML structure around each element in the set of matched elements.
+     *
+     * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements.
+     * @see {@link https://api.jquery.com/wrap/#wrap-wrappingElement}
+     */
+    wrap(wrappingElement: JQuery|Element|string): JQuery;
+    /**
+     * Wrap an HTML structure around each element in the set of matched elements.
+     *
+     * @param func A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/wrap/#wrap-function}
+     */
+    wrap(func: (index: number) => string|JQuery): JQuery;
+
+    /**
+     * Wrap an HTML structure around all elements in the set of matched elements.
+     *
+     * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements.
+     * @see {@link https://api.jquery.com/wrapAll/#wrapAll-wrappingElement}
+     */
+    wrapAll(wrappingElement: JQuery|Element|string): JQuery;
+    /**
+     * Wrap an HTML structure around all elements in the set of matched elements.
+     *
+     * @param func A callback function returning the HTML content or jQuery object to wrap around all the matched elements. Within the function, this refers to the first element in the set.
+     * @see {@link https://api.jquery.com/wrapAll/#wrapAll-function}
+     */
+    wrapAll(func: (index: number) => string): JQuery;
+
+    /**
+     * Wrap an HTML structure around the content of each element in the set of matched elements.
+     *
+     * @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements.
+     * @see {@link https://api.jquery.com/wrapInner/#wrapInner-wrappingElement}
+     */
+    wrapInner(wrappingElement: JQuery|Element|string): JQuery;
+    /**
+     * Wrap an HTML structure around the content of each element in the set of matched elements.
+     *
+     * @param func A callback function which generates a structure to wrap around the content of the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set.
+     * @see {@link https://api.jquery.com/wrapInner/#wrapInner-function}
+     */
+    wrapInner(func: (index: number) => string): JQuery;
+
+    /**
+     * Iterate over a jQuery object, executing a function for each matched element.
+     *
+     * @param func A function to execute for each matched element.
+     * @see {@link https://api.jquery.com/each/}
+     */
+    each(func: (index: number, elem: Element) => any): JQuery;
+
+    /**
+     * Retrieve one of the elements matched by the jQuery object.
+     *
+     * @param index A zero-based integer indicating which element to retrieve.
+     * @see {@link https://api.jquery.com/get/#get-index}
+     */
+    get(index: number): HTMLElement;
+    /**
+     * Retrieve the elements matched by the jQuery object.
+     * @alias toArray
+     * @see {@link https://api.jquery.com/get/#get}
+     */
+    get(): HTMLElement[];
+
+    /**
+     * Search for a given element from among the matched elements.
+     * @see {@link https://api.jquery.com/index/#index}
+     */
+    index(): number;
+    /**
+     * Search for a given element from among the matched elements.
+     *
+     * @param selector A selector representing a jQuery collection in which to look for an element.
+     * @see {@link https://api.jquery.com/index/#index-selector}
+     */
+    index(selector: string|JQuery|Element): number;
+
+    /**
+     * The number of elements in the jQuery object.
+     * @see {@link https://api.jquery.com/length/}
+     */
+    length: number;
+    /**
+     * A selector representing selector passed to jQuery(), if any, when creating the original set.
+     * version deprecated: 1.7, removed: 1.9
+     * @see {@link https://api.jquery.com/selector/}
+     */
+    selector: string;
+    [index: string]: any;
+    [index: number]: HTMLElement;
+
+    /**
+     * Add elements to the set of matched elements.
+     *
+     * @param selector A string representing a selector expression to find additional elements to add to the set of matched elements.
+     * @param context The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method.
+     * @see {@link https://api.jquery.com/add/#add-selector}
+     */
+    add(selector: string, context?: Element): JQuery;
+    /**
+     * Add elements to the set of matched elements.
+     *
+     * @param elements One or more elements to add to the set of matched elements.
+     * @see {@link https://api.jquery.com/add/#add-elements}
+     */
+    add(...elements: Element[]): JQuery;
+    /**
+     * Add elements to the set of matched elements.
+     *
+     * @param html An HTML fragment to add to the set of matched elements.
+     * @see {@link https://api.jquery.com/add/#add-html}
+     */
+    add(html: string): JQuery;
+    /**
+     * Add elements to the set of matched elements.
+     *
+     * @param obj An existing jQuery object to add to the set of matched elements.
+     * @see {@link https://api.jquery.com/add/#add-selection}
+     */
+    add(obj: JQuery): JQuery;
+
+    /**
+     * Get the children of each element in the set of matched elements, optionally filtered by a selector.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/children/}
+     */
+    children(selector?: string): JQuery;
+
+    /**
+     * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/closest/#closest-selector}
+     */
+    closest(selector: string): JQuery;
+    /**
+     * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead.
+     * @see {@link https://api.jquery.com/closest/#closest-selector-context}
+     */
+    closest(selector: string, context?: Element): JQuery;
+    /**
+     * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
+     *
+     * @param obj A jQuery object to match elements against.
+     * @see {@link https://api.jquery.com/closest/#closest-selection}
+     */
+    closest(obj: JQuery): JQuery;
+    /**
+     * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
+     *
+     * @param element An element to match elements against.
+     * @see {@link https://api.jquery.com/closest/#closest-element}
+     */
+    closest(element: Element): JQuery;
+
+    /**
+     * Get an array of all the elements and selectors matched against the current element up through the DOM tree.
+     *
+     * @param selectors An array or string containing a selector expression to match elements against (can also be a jQuery object).
+     * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead.
+     * @see {@link https://api.jquery.com/closest/#closest-selectors-context}
+     */
+    closest(selectors: any, context?: Element): any[];
+
+    /**
+     * Get the children of each element in the set of matched elements, including text and comment nodes.
+     * @see {@link https://api.jquery.com/contents/}
+     */
+    contents(): JQuery;
+
+    /**
+     * End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.
+     * @see {@link https://api.jquery.com/end/}
+     */
+    end(): JQuery;
+
+    /**
+     * Reduce the set of matched elements to the one at the specified index.
+     *
+     * @param index An integer indicating the 0-based position of the element. OR An integer indicating the position of the element, counting backwards from the last element in the set.
+     * @see {@link https://api.jquery.com/eq/}
+     */
+    eq(index: number): JQuery;
+
+    /**
+     * Reduce the set of matched elements to those that match the selector or pass the function's test.
+     *
+     * @param selector A string containing a selector expression to match the current set of elements against.
+     * @see {@link https://api.jquery.com/filter/#filter-selector}
+     */
+    filter(selector: string): JQuery;
+    /**
+     * Reduce the set of matched elements to those that match the selector or pass the function's test.
+     *
+     * @param func A function used as a test for each element in the set. this is the current DOM element.
+     * @see {@link https://api.jquery.com/filter/#filter-function}
+     */
+    filter(func: (index: number, element: Element) => any): JQuery;
+    /**
+     * Reduce the set of matched elements to those that match the selector or pass the function's test.
+     *
+     * @param element An element to match the current set of elements against.
+     * @see {@link https://api.jquery.com/filter/#filter-elements}
+     */
+    filter(element: Element): JQuery;
+    /**
+     * Reduce the set of matched elements to those that match the selector or pass the function's test.
+     *
+     * @param obj An existing jQuery object to match the current set of elements against.
+     * @see {@link https://api.jquery.com/filter/#filter-selection}
+     */
+    filter(obj: JQuery): JQuery;
+
+    /**
+     * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/find/#find-selector}
+     */
+    find(selector: string): JQuery;
+    /**
+     * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
+     *
+     * @param element An element to match elements against.
+     * @see {@link https://api.jquery.com/find/#find-element}
+     */
+    find(element: Element): JQuery;
+    /**
+     * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
+     *
+     * @param obj A jQuery object to match elements against.
+     * @see {@link https://api.jquery.com/find/#find-element}
+     */
+    find(obj: JQuery): JQuery;
+
+    /**
+     * Reduce the set of matched elements to the first in the set.
+     * @see {@link https://api.jquery.com/first/}
+     */
+    first(): JQuery;
+
+    /**
+     * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/has/#has-selector}
+     */
+    has(selector: string): JQuery;
+    /**
+     * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
+     *
+     * @param contained A DOM element to match elements against.
+     * @see {@link https://api.jquery.com/has/#has-contained}
+     */
+    has(contained: Element): JQuery;
+
+    /**
+     * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/is/#is-selector}
+     */
+    is(selector: string): boolean;
+    /**
+     * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
+     *
+     * @param func A function used as a test for the set of elements. It accepts one argument, index, which is the element's index in the jQuery collection.Within the function, this refers to the current DOM element.
+     * @see {@link https://api.jquery.com/is/#is-function}
+     */
+    is(func: (index: number, element: Element) => boolean): boolean;
+    /**
+     * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
+     *
+     * @param obj An existing jQuery object to match the current set of elements against.
+     * @see {@link https://api.jquery.com/is/#is-selection}
+     */
+    is(obj: JQuery): boolean;
+    /**
+     * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
+     *
+     * @param elements One or more elements to match the current set of elements against.
+     * @see {@link https://api.jquery.com/is/#is-elements}
+     */
+    is(elements: any): boolean;
+
+    /**
+     * Reduce the set of matched elements to the final one in the set.
+     * @see {@link https://api.jquery.com/last/}
+     */
+    last(): JQuery;
+
+    /**
+     * Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.
+     *
+     * @param callback A function object that will be invoked for each element in the current set.
+     * @see {@link https://api.jquery.com/map/}
+     */
+    map(callback: (index: number, domElement: Element) => any): JQuery;
+
+    /**
+     * Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/next/}
+     */
+    next(selector?: string): JQuery;
+
+    /**
+     * Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/nextAll/}
+     */
+    nextAll(selector?: string): JQuery;
+
+    /**
+     * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed.
+     *
+     * @param selector A string containing a selector expression to indicate where to stop matching following sibling elements.
+     * @param filter A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/nextUntil/#nextUntil-selector-filter}
+     */
+    nextUntil(selector?: string, filter?: string): JQuery;
+    /**
+     * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed.
+     *
+     * @param element A DOM node or jQuery object indicating where to stop matching following sibling elements.
+     * @param filter A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/nextUntil/#nextUntil-element-filter}
+     */
+    nextUntil(element?: Element, filter?: string): JQuery;
+    /**
+     * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed.
+     *
+     * @param obj A DOM node or jQuery object indicating where to stop matching following sibling elements.
+     * @param filter A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/nextUntil/#nextUntil-element-filter}
+     */
+    nextUntil(obj?: JQuery, filter?: string): JQuery;
+
+    /**
+     * Remove elements from the set of matched elements.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/not/#not-selector}
+     */
+    not(selector: string): JQuery;
+    /**
+     * Remove elements from the set of matched elements.
+     *
+     * @param func A function used as a test for each element in the set. this is the current DOM element.
+     * @see {@link https://api.jquery.com/not/#not-function}
+     */
+    not(func: (index: number, element: Element) => boolean): JQuery;
+    /**
+     * Remove elements from the set of matched elements.
+     *
+     * @param elements One or more DOM elements to remove from the matched set.
+     * @see {@link https://api.jquery.com/not/#not-selection}
+     */
+    not(elements: Element|Element[]): JQuery;
+    /**
+     * Remove elements from the set of matched elements.
+     *
+     * @param obj An existing jQuery object to match the current set of elements against.
+     * @see {@link https://api.jquery.com/not/#not-selection}
+     */
+    not(obj: JQuery): JQuery;
+
+    /**
+     * Get the closest ancestor element that is positioned.
+     * @see {@link https://api.jquery.com/offsetParent/}
+     */
+    offsetParent(): JQuery;
+
+    /**
+     * Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/parent/}
+     */
+    parent(selector?: string): JQuery;
+
+    /**
+     * Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/parents/}
+     */
+    parents(selector?: string): JQuery;
+
+    /**
+     * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object.
+     *
+     * @param selector A string containing a selector expression to indicate where to stop matching ancestor elements.
+     * @param filter A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/parentsUntil/#parentsUntil-selector-filter}
+     */
+    parentsUntil(selector?: string, filter?: string): JQuery;
+    /**
+     * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object.
+     *
+     * @param element A DOM node or jQuery object indicating where to stop matching ancestor elements.
+     * @param filter A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/parentsUntil/#parentsUntil-element-filter}
+     */
+    parentsUntil(element?: Element, filter?: string): JQuery;
+    /**
+     * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object.
+     *
+     * @param obj A DOM node or jQuery object indicating where to stop matching ancestor elements.
+     * @param filter A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/parentsUntil/#parentsUntil-element-filter}
+     */
+    parentsUntil(obj?: JQuery, filter?: string): JQuery;
+
+    /**
+     * Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/prev/}
+     */
+    prev(selector?: string): JQuery;
+
+    /**
+     * Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/prevAll/}
+     */
+    prevAll(selector?: string): JQuery;
+
+    /**
+     * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object.
+     *
+     * @param selector A string containing a selector expression to indicate where to stop matching preceding sibling elements.
+     * @param filter A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/prevUntil/#prevUntil-selector-filter}
+     */
+    prevUntil(selector?: string, filter?: string): JQuery;
+    /**
+     * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object.
+     *
+     * @param element A DOM node or jQuery object indicating where to stop matching preceding sibling elements.
+     * @param filter A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/prevUntil/#prevUntil-element-filter}
+     */
+    prevUntil(element?: Element, filter?: string): JQuery;
+    /**
+     * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object.
+     *
+     * @param obj A DOM node or jQuery object indicating where to stop matching preceding sibling elements.
+     * @param filter A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/prevUntil/#prevUntil-element-filter}
+     */
+    prevUntil(obj?: JQuery, filter?: string): JQuery;
+
+    /**
+     * Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
+     *
+     * @param selector A string containing a selector expression to match elements against.
+     * @see {@link https://api.jquery.com/siblings/}
+     */
+    siblings(selector?: string): JQuery;
+
+    /**
+     * Reduce the set of matched elements to a subset specified by a range of indices.
+     *
+     * @param start An integer indicating the 0-based position at which the elements begin to be selected. If negative, it indicates an offset from the end of the set.
+     * @param end An integer indicating the 0-based position at which the elements stop being selected. If negative, it indicates an offset from the end of the set. If omitted, the range continues until the end of the set.
+     * @see {@link https://api.jquery.com/slice/}
+     */
+    slice(start: number, end?: number): JQuery;
+
+    /**
+     * Show the queue of functions to be executed on the matched elements.
+     *
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @see {@link https://api.jquery.com/queue/#queue-queueName}
+     */
+    queue(queueName?: string): any[];
+    /**
+     * Manipulate the queue of functions to be executed, once for each matched element.
+     *
+     * @param newQueue An array of functions to replace the current queue contents.
+     * @see {@link https://api.jquery.com/queue/#queue-queueName-newQueue}
+     */
+    queue(newQueue: Function[]): JQuery;
+    /**
+     * Manipulate the queue of functions to be executed, once for each matched element.
+     *
+     * @param callback The new function to add to the queue, with a function to call that will dequeue the next item.
+     * @see {@link https://api.jquery.com/queue/#queue-queueName-callback}
+     */
+    queue(callback: Function): JQuery;
+    /**
+     * Manipulate the queue of functions to be executed, once for each matched element.
+     *
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @param newQueue An array of functions to replace the current queue contents.
+     * @see {@link https://api.jquery.com/queue/#queue-queueName-newQueue}
+     */
+    queue(queueName: string, newQueue: Function[]): JQuery;
+    /**
+     * Manipulate the queue of functions to be executed, once for each matched element.
+     *
+     * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
+     * @param callback The new function to add to the queue, with a function to call that will dequeue the next item.
+     * @see {@link https://api.jquery.com/queue/#queue-queueName-callback}
+     */
+    queue(queueName: string, callback: Function): JQuery;
+}
+declare module "jquery" {
+    export = $;
+}
+declare var jQuery: JQueryStatic;
+declare var $: JQueryStatic;

+ 1913 - 0
Script/AtomicWebViewEditor/typings/jqueryui.d.ts

@@ -0,0 +1,1913 @@
+// Type definitions for jQueryUI 1.11
+// Project: http://jqueryui.com/
+// Definitions by: Boris Yankov <https://github.com/borisyankov/>, John Reilly <https://github.com/johnnyreilly>
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+
+declare namespace JQueryUI {
+    // Accordion //////////////////////////////////////////////////
+
+    interface AccordionOptions extends AccordionEvents {
+        active?: any; // boolean or number
+        animate?: any; // boolean, number, string or object
+        collapsible?: boolean;
+        disabled?: boolean;
+        event?: string;
+        header?: string;
+        heightStyle?: string;
+        icons?: any;
+    }
+
+    interface AccordionUIParams {
+        newHeader: JQuery;
+        oldHeader: JQuery;
+        newPanel: JQuery;
+        oldPanel: JQuery;
+    }
+
+    interface AccordionEvent {
+        (event: Event, ui: AccordionUIParams): void;
+    }
+
+    interface AccordionEvents {
+        activate?: AccordionEvent;
+        beforeActivate?: AccordionEvent;
+        create?: AccordionEvent;
+    }
+
+    interface Accordion extends Widget, AccordionOptions {
+    }
+
+
+    // Autocomplete //////////////////////////////////////////////////
+
+    interface AutocompleteOptions extends AutocompleteEvents {
+        appendTo?: any; //Selector;
+        autoFocus?: boolean;
+        delay?: number;
+        disabled?: boolean;
+        minLength?: number;
+        position?: any; // object
+        source?: any; // [], string or ()
+    }
+
+    interface AutocompleteUIParams {
+        /**
+         * The item selected from the menu, if any. Otherwise the property is null
+         */
+        item?: any;
+    }
+
+    interface AutocompleteEvent {
+        (event: Event, ui: AutocompleteUIParams): void;
+    }
+
+    interface AutocompleteEvents {
+        change?: AutocompleteEvent;
+        close?: AutocompleteEvent;
+        create?: AutocompleteEvent;
+        focus?: AutocompleteEvent;
+        open?: AutocompleteEvent;
+        response?: AutocompleteEvent;
+        search?: AutocompleteEvent;
+        select?: AutocompleteEvent;
+    }
+
+    interface Autocomplete extends Widget, AutocompleteOptions {
+        escapeRegex: (value: string) => string;
+        filter: (array: any, term: string) => any;
+    }
+
+
+    // Button //////////////////////////////////////////////////
+
+    interface ButtonOptions {
+        disabled?: boolean;
+        icons?: any;
+        label?: string;
+        text?: string|boolean;
+        click?: (event?: Event) => void;
+    }
+
+    interface Button extends Widget, ButtonOptions {
+    }
+
+
+    // Datepicker //////////////////////////////////////////////////
+
+    interface DatepickerOptions {
+        /**
+         * An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field.
+         */
+        altField?: any; // Selector, jQuery or Element
+        /**
+         * The dateFormat to be used for the altField option. This allows one date format to be shown to the user for selection purposes, while a different format is actually sent behind the scenes. For a full list of the possible formats see the formatDate function
+         */
+        altFormat?: string;
+        /**
+         * The text to display after each date field, e.g., to show the required format.
+         */
+        appendText?: string;
+        /**
+         * Set to true to automatically resize the input field to accommodate dates in the current dateFormat.
+         */
+        autoSize?: boolean;
+        /**
+         * A function that takes an input field and current datepicker instance and returns an options object to update the datepicker with. It is called just before the datepicker is displayed.
+         */
+        beforeShow?: (input: Element, inst: any) => JQueryUI.DatepickerOptions;
+        /**
+         * A function that takes a date as a parameter and must return an array with:
+         * [0]: true/false indicating whether or not this date is selectable
+         * [1]: a CSS class name to add to the date's cell or "" for the default presentation
+         * [2]: an optional popup tooltip for this date
+         * The function is called for each day in the datepicker before it is displayed.
+         */
+        beforeShowDay?: (date: Date) => any[];
+        /**
+         * A URL of an image to use to display the datepicker when the showOn option is set to "button" or "both". If set, the buttonText option becomes the alt value and is not directly displayed.
+         */
+        buttonImage?: string;
+        /**
+         * Whether the button image should be rendered by itself instead of inside a button element. This option is only relevant if the buttonImage option has also been set.
+         */
+        buttonImageOnly?: boolean;
+        /**
+         * The text to display on the trigger button. Use in conjunction with the showOn option set to "button" or "both".
+         */
+        buttonText?: string;
+        /**
+         * A function to calculate the week of the year for a given date. The default implementation uses the ISO 8601 definition: weeks start on a Monday; the first week of the year contains the first Thursday of the year.
+         */
+        calculateWeek?: (date: Date) => string;
+        /**
+         * Whether the month should be rendered as a dropdown instead of text.
+         */
+        changeMonth?: boolean;
+        /**
+         * Whether the year should be rendered as a dropdown instead of text. Use the yearRange option to control which years are made available for selection.
+         */
+        changeYear?: boolean;
+        /**
+         * The text to display for the close link. Use the showButtonPanel option to display this button.
+         */
+        closeText?: string;
+        /**
+         * When true, entry in the input field is constrained to those characters allowed by the current dateFormat option.
+         */
+        constrainInput?: boolean;
+        /**
+         * The text to display for the current day link. Use the showButtonPanel option to display this button.
+         */
+        currentText?: string;
+        /**
+         * The format for parsed and displayed dates. For a full list of the possible formats see the formatDate function.
+         */
+        dateFormat?: string;
+        /**
+         * The list of long day names, starting from Sunday, for use as requested via the dateFormat option.
+         */
+        dayNames?: string[];
+        /**
+         * The list of minimised day names, starting from Sunday, for use as column headers within the datepicker.
+         */
+        dayNamesMin?: string[];
+        /**
+         * The list of abbreviated day names, starting from Sunday, for use as requested via the dateFormat option.
+         */
+        dayNamesShort?: string[];
+        /**
+         * Set the date to highlight on first opening if the field is blank. Specify either an actual date via a Date object or as a string in the current dateFormat, or a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +7d'), or null for today.
+         * Multiple types supported:
+         * Date: A date object containing the default date.
+         * Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday.
+         * String: A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today.
+         */
+        defaultDate?: any; // Date, number or string
+        /**
+         * Control the speed at which the datepicker appears, it may be a time in milliseconds or a string representing one of the three predefined speeds ("slow", "normal", "fast").
+         */
+        duration?: string;
+        /**
+         * Set the first day of the week: Sunday is 0, Monday is 1, etc.
+         */
+        firstDay?: number;
+        /**
+         * When true, the current day link moves to the currently selected date instead of today.
+         */
+        gotoCurrent?: boolean;
+        /**
+         * Normally the previous and next links are disabled when not applicable (see the minDate and maxDate options). You can hide them altogether by setting this attribute to true.
+         */
+        hideIfNoPrevNext?: boolean;
+        /**
+         * Whether the current language is drawn from right to left.
+         */
+        isRTL?: boolean;
+        /**
+         * The maximum selectable date. When set to null, there is no maximum.
+         * Multiple types supported:
+         * Date: A date object containing the maximum date.
+         * Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday.
+         * String: A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today.
+         */
+        maxDate?: any; // Date, number or string
+        /**
+         * The minimum selectable date. When set to null, there is no minimum.
+         * Multiple types supported:
+         * Date: A date object containing the minimum date.
+         * Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday.
+         * String: A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today.
+         */
+        minDate?: any; // Date, number or string
+        /**
+         * The list of full month names, for use as requested via the dateFormat option.
+         */
+        monthNames?: string[];
+        /**
+         * The list of abbreviated month names, as used in the month header on each datepicker and as requested via the dateFormat option.
+         */
+        monthNamesShort?: string[];
+        /**
+         * Whether the prevText and nextText options should be parsed as dates by the formatDate function, allowing them to display the target month names for example.
+         */
+        navigationAsDateFormat?: boolean;
+        /**
+         * The text to display for the next month link. With the standard ThemeRoller styling, this value is replaced by an icon.
+         */
+        nextText?: string;
+        /**
+         * The number of months to show at once.
+         * Multiple types supported:
+         * Number: The number of months to display in a single row.
+         * Array: An array defining the number of rows and columns to display.
+         */
+        numberOfMonths?: any; // number or number[]
+        /**
+         * Called when the datepicker moves to a new month and/or year. The function receives the selected year, month (1-12), and the datepicker instance as parameters. this refers to the associated input field.
+         */
+        onChangeMonthYear?: (year: number, month: number, inst: any) => void;
+        /**
+         * Called when the datepicker is closed, whether or not a date is selected. The function receives the selected date as text ("" if none) and the datepicker instance as parameters. this refers to the associated input field.
+         */
+        onClose?: (dateText: string, inst: any) => void;
+        /**
+         * Called when the datepicker is selected. The function receives the selected date as text and the datepicker instance as parameters. this refers to the associated input field.
+         */
+        onSelect?: (dateText: string, inst: any) => void;
+        /**
+         * The text to display for the previous month link. With the standard ThemeRoller styling, this value is replaced by an icon.
+         */
+        prevText?: string;
+        /**
+         * Whether days in other months shown before or after the current month are selectable. This only applies if the showOtherMonths option is set to true.
+         */
+        selectOtherMonths?: boolean;
+        /**
+         * The cutoff year for determining the century for a date (used in conjunction with dateFormat 'y'). Any dates entered with a year value less than or equal to the cutoff year are considered to be in the current century, while those greater than it are deemed to be in the previous century.
+         * Multiple types supported:
+         * Number: A value between 0 and 99 indicating the cutoff year.
+         * String: A relative number of years from the current year, e.g., "+3" or "-5".
+         */
+        shortYearCutoff?: any; // number or string
+        /**
+         * The name of the animation used to show and hide the datepicker. Use "show" (the default), "slideDown", "fadeIn", any of the jQuery UI effects. Set to an empty string to disable animation.
+         */
+        showAnim?: string;
+        /**
+         * Whether to display a button pane underneath the calendar. The button pane contains two buttons, a Today button that links to the current day, and a Done button that closes the datepicker. The buttons' text can be customized using the currentText and closeText options respectively.
+         */
+        showButtonPanel?: boolean;
+        /**
+         * When displaying multiple months via the numberOfMonths option, the showCurrentAtPos option defines which position to display the current month in.
+         */
+        showCurrentAtPos?: number;
+        /**
+         * Whether to show the month after the year in the header.
+         */
+        showMonthAfterYear?: boolean;
+        /**
+         * When the datepicker should appear. The datepicker can appear when the field receives focus ("focus"), when a button is clicked ("button"), or when either event occurs ("both").
+         */
+        showOn?: string;
+        /**
+         * If using one of the jQuery UI effects for the showAnim option, you can provide additional settings for that animation via this option.
+         */
+        showOptions?: any; // TODO
+        /**
+         * Whether to display dates in other months (non-selectable) at the start or end of the current month. To make these days selectable use the selectOtherMonths option.
+         */
+        showOtherMonths?: boolean;
+        /**
+         * When true, a column is added to show the week of the year. The calculateWeek option determines how the week of the year is calculated. You may also want to change the firstDay option.
+         */
+        showWeek?: boolean;
+        /**
+         * Set how many months to move when clicking the previous/next links.
+         */
+        stepMonths?: number;
+        /**
+         * The text to display for the week of the year column heading. Use the showWeek option to display this column.
+         */
+        weekHeader?: string;
+        /**
+         * The range of years displayed in the year drop-down: either relative to today's year ("-nn:+nn"), relative to the currently selected year ("c-nn:c+nn"), absolute ("nnnn:nnnn"), or combinations of these formats ("nnnn:-nn"). Note that this option only affects what appears in the drop-down, to restrict which dates may be selected use the minDate and/or maxDate options.
+         */
+        yearRange?: string;
+        /**
+         * Additional text to display after the year in the month headers.
+         */
+        yearSuffix?: string;
+	 /**
+         * Set to true to automatically hide the datepicker.
+         */
+      	autohide?: boolean;
+    	/**
+  	    * Set to date to automatically enddate the datepicker.
+  	    */
+     	endDate?: Date;
+    }
+
+    interface DatepickerFormatDateOptions {
+        dayNamesShort?: string[];
+        dayNames?: string[];
+        monthNamesShort?: string[];
+        monthNames?: string[];
+    }
+
+    interface Datepicker extends Widget, DatepickerOptions {
+        regional: { [languageCod3: string]: any; };
+        setDefaults(defaults: DatepickerOptions): void;
+        formatDate(format: string, date: Date, settings?: DatepickerFormatDateOptions): string;
+        parseDate(format: string, date: string, settings?: DatepickerFormatDateOptions): Date;
+        iso8601Week(date: Date): number;
+        noWeekends(date: Date): any[];
+    }
+
+
+    // Dialog //////////////////////////////////////////////////
+
+    interface DialogOptions extends DialogEvents {
+        autoOpen?: boolean;
+        buttons?: { [buttonText: string]: (event?: Event) => void } | DialogButtonOptions[];
+        closeOnEscape?: boolean;
+        closeText?: string;
+        appendTo?: string;
+        dialogClass?: string;
+        disabled?: boolean;
+        draggable?: boolean;
+        height?: number | string;
+        hide?: boolean | number | string | DialogShowHideOptions;
+        maxHeight?: number;
+        maxWidth?: number;
+        minHeight?: number;
+        minWidth?: number;
+        modal?: boolean;
+        position?: any; // object, string or []
+        resizable?: boolean;
+        show?: boolean | number | string | DialogShowHideOptions;
+        stack?: boolean;
+        title?: string;
+        width?: any; // number or string
+        zIndex?: number;
+
+		open?: DialogEvent;
+        close?: DialogEvent;
+    }
+
+    interface DialogButtonOptions {
+        icons?: any;
+        showText?: string | boolean;
+        text?: string;
+        click?: (eventObject: JQueryEventObject) => any;
+        [attr: string]: any; // attributes for the <button> element
+    }
+
+    interface DialogShowHideOptions {
+        effect: string;
+        delay?: number;
+        duration?: number;
+        easing?: string;
+    }
+
+    interface DialogUIParams {
+    }
+
+    interface DialogEvent {
+        (event: Event, ui: DialogUIParams): void;
+    }
+
+    interface DialogEvents {
+        beforeClose?: DialogEvent;
+        close?: DialogEvent;
+        create?: DialogEvent;
+        drag?: DialogEvent;
+        dragStart?: DialogEvent;
+        dragStop?: DialogEvent;
+        focus?: DialogEvent;
+        open?: DialogEvent;
+        resize?: DialogEvent;
+        resizeStart?: DialogEvent;
+        resizeStop?: DialogEvent;
+    }
+
+    interface Dialog extends Widget, DialogOptions {
+    }
+
+
+    // Draggable //////////////////////////////////////////////////
+
+    interface DraggableEventUIParams {
+        helper: JQuery;
+        position: { top: number; left: number; };
+        offset: { top: number; left: number; };
+    }
+
+    interface DraggableEvent {
+        (event: Event, ui: DraggableEventUIParams): void;
+    }
+
+    interface DraggableOptions extends DraggableEvents {
+        disabled?: boolean;
+        addClasses?: boolean;
+        appendTo?: any;
+        axis?: string;
+        cancel?: string;
+        connectToSortable?: Element | Element[] | JQuery | string;
+        containment?: any;
+        cursor?: string;
+        cursorAt?: any;
+        delay?: number;
+        distance?: number;
+        grid?: number[];
+        handle?: any;
+        helper?: any;
+        iframeFix?: any;
+        opacity?: number;
+        refreshPositions?: boolean;
+        revert?: any;
+        revertDuration?: number;
+        scope?: string;
+        scroll?: boolean;
+        scrollSensitivity?: number;
+        scrollSpeed?: number;
+        snap?: any;
+        snapMode?: string;
+        snapTolerance?: number;
+        stack?: string;
+        zIndex?: number;
+    }
+
+    interface DraggableEvents {
+        create?: DraggableEvent;
+        start?: DraggableEvent;
+        drag?: DraggableEvent;
+        stop?: DraggableEvent;
+    }
+
+    interface Draggable extends Widget, DraggableOptions, DraggableEvent {
+    }
+
+
+    // Droppable //////////////////////////////////////////////////
+
+    interface DroppableEventUIParam {
+        draggable: JQuery;
+        helper: JQuery;
+        position: { top: number; left: number; };
+        offset: { top: number; left: number; };
+    }
+
+    interface DroppableEvent {
+        (event: Event, ui: DroppableEventUIParam): void;
+    }
+
+    interface DroppableOptions extends DroppableEvents {
+        accept?: any;
+        activeClass?: string;
+        addClasses?: boolean;
+        disabled?: boolean;
+        greedy?: boolean;
+        hoverClass?: string;
+        scope?: string;
+        tolerance?: string;
+    }
+
+    interface DroppableEvents {
+        create?: DroppableEvent;
+        activate?: DroppableEvent;
+        deactivate?: DroppableEvent;
+        over?: DroppableEvent;
+        out?: DroppableEvent;
+        drop?: DroppableEvent;
+    }
+
+    interface Droppable extends Widget, DroppableOptions {
+    }
+
+    // Menu //////////////////////////////////////////////////
+
+    interface MenuOptions extends MenuEvents {
+        disabled?: boolean;
+        icons?: any;
+        menus?: string;
+        position?: any; // TODO
+        role?: string;
+    }
+
+    interface MenuUIParams {
+        item?: JQuery;
+    }
+
+    interface MenuEvent {
+        (event: Event, ui: MenuUIParams): void;
+    }
+
+    interface MenuEvents {
+        blur?: MenuEvent;
+        create?: MenuEvent;
+        focus?: MenuEvent;
+        select?: MenuEvent;
+    }
+
+    interface Menu extends Widget, MenuOptions {
+    }
+
+
+    // Progressbar //////////////////////////////////////////////////
+
+    interface ProgressbarOptions extends ProgressbarEvents {
+        disabled?: boolean;
+        value?: number | boolean;
+        max?: number;
+    }
+
+    interface ProgressbarUIParams {
+    }
+
+    interface ProgressbarEvent {
+        (event: Event, ui: ProgressbarUIParams): void;
+    }
+
+    interface ProgressbarEvents {
+        change?: ProgressbarEvent;
+        complete?: ProgressbarEvent;
+        create?: ProgressbarEvent;
+    }
+
+    interface Progressbar extends Widget, ProgressbarOptions {
+    }
+
+
+    // Resizable //////////////////////////////////////////////////
+
+    interface ResizableOptions extends ResizableEvents {
+        alsoResize?: any; // Selector, JQuery or Element
+        animate?: boolean;
+        animateDuration?: any; // number or string
+        animateEasing?: string;
+        aspectRatio?: any; // boolean or number
+        autoHide?: boolean;
+        cancel?: string;
+        containment?: any; // Selector, Element or string
+        delay?: number;
+        disabled?: boolean;
+        distance?: number;
+        ghost?: boolean;
+        grid?: any;
+        handles?: any; // string or object
+        helper?: string;
+        maxHeight?: number;
+        maxWidth?: number;
+        minHeight?: number;
+        minWidth?: number;
+    }
+
+    interface ResizableUIParams {
+        element: JQuery;
+        helper: JQuery;
+        originalElement: JQuery;
+        originalPosition: any;
+        originalSize: any;
+        position: any;
+        size: any;
+    }
+
+    interface ResizableEvent {
+        (event: Event, ui: ResizableUIParams): void;
+    }
+
+    interface ResizableEvents {
+        resize?: ResizableEvent;
+        start?: ResizableEvent;
+        stop?: ResizableEvent;
+        create?: ResizableEvents;
+    }
+
+    interface Resizable extends Widget, ResizableOptions {
+    }
+
+
+    // Selectable //////////////////////////////////////////////////
+
+    interface SelectableOptions extends SelectableEvents {
+        autoRefresh?: boolean;
+        cancel?: string;
+        delay?: number;
+        disabled?: boolean;
+        distance?: number;
+        filter?: string;
+        tolerance?: string;
+    }
+
+    interface SelectableEvents {
+        selected? (event: Event, ui: { selected?: Element; }): void;
+        selecting? (event: Event, ui: { selecting?: Element; }): void;
+        start? (event: Event, ui: any): void;
+        stop? (event: Event, ui: any): void;
+        unselected? (event: Event, ui: { unselected: Element; }): void;
+        unselecting? (event: Event, ui: { unselecting: Element; }): void;
+    }
+
+    interface Selectable extends Widget, SelectableOptions {
+    }
+
+    // SelectMenu //////////////////////////////////////////////////
+
+    interface SelectMenuOptions extends SelectMenuEvents {
+        appendTo?: string;
+        disabled?: boolean;
+        icons?: any;
+        position?: JQueryPositionOptions;
+        width?: number;
+    }
+
+    interface SelectMenuUIParams {
+        item?: JQuery;
+    }
+
+    interface SelectMenuEvent {
+        (event: Event, ui: SelectMenuUIParams): void;
+    }
+
+    interface SelectMenuEvents {
+        change?: SelectMenuEvent;
+        close?: SelectMenuEvent;
+        create?: SelectMenuEvent;
+        focus?: SelectMenuEvent;
+        open?: SelectMenuEvent;
+        select?: SelectMenuEvent;
+    }
+
+    interface SelectMenu extends Widget, SelectMenuOptions {
+    }
+
+    // Slider //////////////////////////////////////////////////
+
+    interface SliderOptions extends SliderEvents {
+        animate?: any; // boolean, string or number
+        disabled?: boolean;
+        max?: number;
+        min?: number;
+        orientation?: string;
+        range?: any; // boolean or string
+        step?: number;
+        value?: number;
+        values?: number[];
+        highlight?: boolean;
+    }
+
+    interface SliderUIParams {
+        handle?: JQuery;
+        value?: number;
+        values?: number[];
+    }
+
+    interface SliderEvent {
+        (event: Event, ui: SliderUIParams): void;
+    }
+
+    interface SliderEvents {
+        change?: SliderEvent;
+        create?: SliderEvent;
+        slide?: SliderEvent;
+        start?: SliderEvent;
+        stop?: SliderEvent;
+    }
+
+    interface Slider extends Widget, SliderOptions {
+    }
+
+
+    // Sortable //////////////////////////////////////////////////
+
+    interface SortableOptions extends SortableEvents {
+        appendTo?: any; // jQuery, Element, Selector or string
+        axis?: string;
+        cancel?: any; // Selector
+        connectWith?: any; // Selector
+        containment?: any; // Element, Selector or string
+        cursor?: string;
+        cursorAt?: any;
+        delay?: number;
+        disabled?: boolean;
+        distance?: number;
+        dropOnEmpty?: boolean;
+        forceHelperSize?: boolean;
+        forcePlaceholderSize?: boolean;
+        grid?: number[];
+        helper?: string | ((event: Event, element: Sortable) => Element);
+        handle?: any; // Selector or Element
+        items?: any; // Selector
+        opacity?: number;
+        placeholder?: string;
+        revert?: any; // boolean or number
+        scroll?: boolean;
+        scrollSensitivity?: number;
+        scrollSpeed?: number;
+        tolerance?: string;
+        zIndex?: number;
+    }
+
+    interface SortableUIParams {
+        helper: JQuery;
+        item: JQuery;
+        offset: any;
+        position: any;
+        originalPosition: any;
+        sender: JQuery;
+        placeholder: JQuery;
+    }
+
+    interface SortableEvent {
+        (event: JQueryEventObject, ui: SortableUIParams): void;
+    }
+
+    interface SortableEvents {
+        activate?: SortableEvent;
+        beforeStop?: SortableEvent;
+        change?: SortableEvent;
+        deactivate?: SortableEvent;
+        out?: SortableEvent;
+        over?: SortableEvent;
+        receive?: SortableEvent;
+        remove?: SortableEvent;
+        sort?: SortableEvent;
+        start?: SortableEvent;
+        stop?: SortableEvent;
+        update?: SortableEvent;
+    }
+
+    interface Sortable extends Widget, SortableOptions, SortableEvents {
+    }
+
+
+    // Spinner //////////////////////////////////////////////////
+
+    interface SpinnerOptions extends SpinnerEvents {
+        culture?: string;
+        disabled?: boolean;
+        icons?: any;
+        incremental?: any; // boolean or ()
+        max?: any; // number or string
+        min?: any; // number or string
+        numberFormat?: string;
+        page?: number;
+        step?: any; // number or string
+    }
+
+    interface SpinnerUIParam {
+        value: number;
+    }
+
+    interface SpinnerEvent<T> {
+        (event: Event, ui: T): void;
+    }
+
+    interface SpinnerEvents {
+        change?: SpinnerEvent<{}>;
+        create?: SpinnerEvent<{}>;
+        spin?: SpinnerEvent<SpinnerUIParam>;
+        start?: SpinnerEvent<{}>;
+        stop?: SpinnerEvent<{}>;
+    }
+
+    interface Spinner extends Widget, SpinnerOptions {
+    }
+
+
+    // Tabs //////////////////////////////////////////////////
+
+    interface TabsOptions extends TabsEvents {
+        active?: any; // boolean or number
+        collapsible?: boolean;
+        disabled?: any; // boolean or []
+        event?: string;
+        heightStyle?: string;
+        hide?: any; // boolean, number, string or object
+        show?: any; // boolean, number, string or object
+    }
+
+    interface TabsActivationUIParams {
+        newTab: JQuery;
+        oldTab: JQuery;
+        newPanel: JQuery;
+        oldPanel: JQuery;
+    }
+
+    interface TabsBeforeLoadUIParams {
+        tab: JQuery;
+        panel: JQuery;
+        jqXHR: JQueryXHR;
+        ajaxSettings: any;
+    }
+
+    interface TabsCreateOrLoadUIParams {
+        tab: JQuery;
+        panel: JQuery;
+    }
+
+    interface TabsEvent<UI> {
+        (event: Event, ui: UI): void;
+    }
+
+    interface TabsEvents {
+        activate?: TabsEvent<TabsActivationUIParams>;
+        beforeActivate?: TabsEvent<TabsActivationUIParams>;
+        beforeLoad?: TabsEvent<TabsBeforeLoadUIParams>;
+        load?: TabsEvent<TabsCreateOrLoadUIParams>;
+        create?: TabsEvent<TabsCreateOrLoadUIParams>;
+    }
+
+    interface Tabs extends Widget, TabsOptions {
+    }
+
+
+    // Tooltip //////////////////////////////////////////////////
+
+    interface TooltipOptions extends TooltipEvents {
+        content?: any; // () or string
+        disabled?: boolean;
+        hide?: any; // boolean, number, string or object
+        items?: string;
+        position?: any; // TODO
+        show?: any; // boolean, number, string or object
+        tooltipClass?: string;
+        track?: boolean;
+    }
+
+    interface TooltipUIParams {
+    }
+
+    interface TooltipEvent {
+        (event: Event, ui: TooltipUIParams): void;
+    }
+
+    interface TooltipEvents {
+        close?: TooltipEvent;
+        open?: TooltipEvent;
+    }
+
+    interface Tooltip extends Widget, TooltipOptions {
+    }
+
+
+    // Effects //////////////////////////////////////////////////
+
+    interface EffectOptions {
+        effect: string;
+        easing?: string;
+        duration?: number;
+        complete: Function;
+    }
+
+    interface BlindEffect {
+        direction?: string;
+    }
+
+    interface BounceEffect {
+        distance?: number;
+        times?: number;
+    }
+
+    interface ClipEffect {
+        direction?: number;
+    }
+
+    interface DropEffect {
+        direction?: number;
+    }
+
+    interface ExplodeEffect {
+        pieces?: number;
+    }
+
+    interface FadeEffect { }
+
+    interface FoldEffect {
+        size?: any;
+        horizFirst?: boolean;
+    }
+
+    interface HighlightEffect {
+        color?: string;
+    }
+
+    interface PuffEffect {
+        percent?: number;
+    }
+
+    interface PulsateEffect {
+        times?: number;
+    }
+
+    interface ScaleEffect {
+        direction?: string;
+        origin?: string[];
+        percent?: number;
+        scale?: string;
+    }
+
+    interface ShakeEffect {
+        direction?: string;
+        distance?: number;
+        times?: number;
+    }
+
+    interface SizeEffect {
+        to?: any;
+        origin?: string[];
+        scale?: string;
+    }
+
+    interface SlideEffect {
+        direction?: string;
+        distance?: number;
+    }
+
+    interface TransferEffect {
+        className?: string;
+        to?: string;
+    }
+
+    interface JQueryPositionOptions {
+        my?: string;
+        at?: string;
+        of?: any;
+        collision?: string;
+        using?: Function;
+        within?: any;
+    }
+
+
+    // UI //////////////////////////////////////////////////
+
+    interface MouseOptions {
+        cancel?: string;
+        delay?: number;
+        distance?: number;
+    }
+
+    interface KeyCode {
+        BACKSPACE: number;
+        COMMA: number;
+        DELETE: number;
+        DOWN: number;
+        END: number;
+        ENTER: number;
+        ESCAPE: number;
+        HOME: number;
+        LEFT: number;
+        NUMPAD_ADD: number;
+        NUMPAD_DECIMAL: number;
+        NUMPAD_DIVIDE: number;
+        NUMPAD_ENTER: number;
+        NUMPAD_MULTIPLY: number;
+        NUMPAD_SUBTRACT: number;
+        PAGE_DOWN: number;
+        PAGE_UP: number;
+        PERIOD: number;
+        RIGHT: number;
+        SPACE: number;
+        TAB: number;
+        UP: number;
+    }
+
+    interface UI {
+        mouse(method: string): JQuery;
+        mouse(options: MouseOptions): JQuery;
+        mouse(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+        mouse(optionLiteral: string, optionValue: any): any;
+
+        accordion: Accordion;
+        autocomplete: Autocomplete;
+        button: Button;
+        buttonset: Button;
+        datepicker: Datepicker;
+        dialog: Dialog;
+        keyCode: KeyCode;
+        menu: Menu;
+        progressbar: Progressbar;
+        slider: Slider;
+        spinner: Spinner;
+        tabs: Tabs;
+        tooltip: Tooltip;
+        version: string;
+    }
+
+
+    // Widget //////////////////////////////////////////////////
+
+    interface WidgetOptions {
+        disabled?: boolean;
+        hide?: any;
+        show?: any;
+    }
+
+    interface Widget {
+        (methodName: string): JQuery;
+        (options: WidgetOptions): JQuery;
+        (options: AccordionOptions): JQuery;
+        (optionLiteral: string, optionName: string): any;
+        (optionLiteral: string, options: WidgetOptions): any;
+        (optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+        (name: string, prototype: any): JQuery;
+        (name: string, base: Function, prototype: any): JQuery;
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////
+
+}
+
+interface JQuery {
+
+    accordion(): JQuery;
+    accordion(methodName: 'destroy'): void;
+    accordion(methodName: 'disable'): void;
+    accordion(methodName: 'enable'): void;
+    accordion(methodName: 'refresh'): void;
+    accordion(methodName: 'widget'): JQuery;
+    accordion(methodName: string): JQuery;
+    accordion(options: JQueryUI.AccordionOptions): JQuery;
+    accordion(optionLiteral: string, optionName: string): any;
+    accordion(optionLiteral: string, options: JQueryUI.AccordionOptions): any;
+    accordion(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    autocomplete(): JQuery;
+    autocomplete(methodName: 'close'): void;
+    autocomplete(methodName: 'destroy'): void;
+    autocomplete(methodName: 'disable'): void;
+    autocomplete(methodName: 'enable'): void;
+    autocomplete(methodName: 'search', value?: string): void;
+    autocomplete(methodName: 'widget'): JQuery;
+    autocomplete(methodName: string): JQuery;
+    autocomplete(options: JQueryUI.AutocompleteOptions): JQuery;
+    autocomplete(optionLiteral: string, optionName: string): any;
+    autocomplete(optionLiteral: string, options: JQueryUI.AutocompleteOptions): any;
+    autocomplete(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    button(): JQuery;
+    button(methodName: 'destroy'): void;
+    button(methodName: 'disable'): void;
+    button(methodName: 'enable'): void;
+    button(methodName: 'refresh'): void;
+    button(methodName: 'widget'): JQuery;
+    button(methodName: string): JQuery;
+    button(options: JQueryUI.ButtonOptions): JQuery;
+    button(optionLiteral: string, optionName: string): any;
+    button(optionLiteral: string, options: JQueryUI.ButtonOptions): any;
+    button(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    buttonset(): JQuery;
+    buttonset(methodName: 'destroy'): void;
+    buttonset(methodName: 'disable'): void;
+    buttonset(methodName: 'enable'): void;
+    buttonset(methodName: 'refresh'): void;
+    buttonset(methodName: 'widget'): JQuery;
+    buttonset(methodName: string): JQuery;
+    buttonset(options: JQueryUI.ButtonOptions): JQuery;
+    buttonset(optionLiteral: string, optionName: string): any;
+    buttonset(optionLiteral: string, options: JQueryUI.ButtonOptions): any;
+    buttonset(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    /**
+     * Initialize a datepicker
+     */
+    datepicker(): JQuery;
+    /**
+     * Removes the datepicker functionality completely. This will return the element back to its pre-init state.
+     *
+     * @param methodName 'destroy'
+     */
+    datepicker(methodName: 'destroy'): JQuery;
+    /**
+     * Opens the datepicker in a dialog box.
+     *
+     * @param methodName 'dialog'
+     * @param date The initial date.
+     * @param onSelect A callback function when a date is selected. The function receives the date text and date picker instance as parameters.
+     * @param settings The new settings for the date picker.
+     * @param pos The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen.
+     */
+    datepicker(methodName: 'dialog', date: Date, onSelect?: () => void, settings?: JQueryUI.DatepickerOptions, pos?: number[]): JQuery;
+    /**
+     * Opens the datepicker in a dialog box.
+     *
+     * @param methodName 'dialog'
+     * @param date The initial date.
+     * @param onSelect A callback function when a date is selected. The function receives the date text and date picker instance as parameters.
+     * @param settings The new settings for the date picker.
+     * @param pos The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen.
+     */
+    datepicker(methodName: 'dialog', date: Date, onSelect?: () => void, settings?: JQueryUI.DatepickerOptions, pos?: MouseEvent): JQuery;
+    /**
+     * Opens the datepicker in a dialog box.
+     *
+     * @param methodName 'dialog'
+     * @param date The initial date.
+     * @param onSelect A callback function when a date is selected. The function receives the date text and date picker instance as parameters.
+     * @param settings The new settings for the date picker.
+     * @param pos The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen.
+     */
+    datepicker(methodName: 'dialog', date: string, onSelect?: () => void, settings?: JQueryUI.DatepickerOptions, pos?: number[]): JQuery;
+    /**
+     * Opens the datepicker in a dialog box.
+     *
+     * @param methodName 'dialog'
+     * @param date The initial date.
+     * @param onSelect A callback function when a date is selected. The function receives the date text and date picker instance as parameters.
+     * @param settings The new settings for the date picker.
+     * @param pos The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen.
+     */
+    datepicker(methodName: 'dialog', date: string, onSelect?: () => void, settings?: JQueryUI.DatepickerOptions, pos?: MouseEvent): JQuery;
+    /**
+     * Returns the current date for the datepicker or null if no date has been selected.
+     *
+     * @param methodName 'getDate'
+     */
+    datepicker(methodName: 'getDate'): Date;
+    /**
+     * Close a previously opened date picker.
+     *
+     * @param methodName 'hide'
+     */
+    datepicker(methodName: 'hide'): JQuery;
+    /**
+     * Determine whether a date picker has been disabled.
+     *
+     * @param methodName 'isDisabled'
+     */
+    datepicker(methodName: 'isDisabled'): boolean;
+    /**
+     * Redraw the date picker, after having made some external modifications.
+     *
+     * @param methodName 'refresh'
+     */
+    datepicker(methodName: 'refresh'): JQuery;
+    /**
+     * Sets the date for the datepicker. The new date may be a Date object or a string in the current date format (e.g., "01/26/2009"), a number of days from today (e.g., +7) or a string of values and periods ("y" for years, "m" for months, "w" for weeks, "d" for days, e.g., "+1m +7d"), or null to clear the selected date.
+     *
+     * @param methodName 'setDate'
+     * @param date The new date.
+     */
+    datepicker(methodName: 'setDate', date: Date): JQuery;
+    /**
+     * Sets the date for the datepicker. The new date may be a Date object or a string in the current date format (e.g., "01/26/2009"), a number of days from today (e.g., +7) or a string of values and periods ("y" for years, "m" for months, "w" for weeks, "d" for days, e.g., "+1m +7d"), or null to clear the selected date.
+     *
+     * @param methodName 'setDate'
+     * @param date The new date.
+     */
+    datepicker(methodName: 'setDate', date: string): JQuery;
+    /**
+     * Open the date picker. If the datepicker is attached to an input, the input must be visible for the datepicker to be shown.
+     *
+     * @param methodName 'show'
+     */
+    datepicker(methodName: 'show'): JQuery;
+    /**
+     * Returns a jQuery object containing the datepicker.
+     *
+     * @param methodName 'widget'
+     */
+    datepicker(methodName: 'widget'): JQuery;
+
+    /**
+     * Get the altField option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'altField'
+     */
+    datepicker(methodName: 'option', optionName: 'altField'): any;
+    /**
+     * Set the altField option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'altField'
+     * @param altFieldValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field.
+     */
+    datepicker(methodName: 'option', optionName: 'altField', altFieldValue: string): JQuery;
+    /**
+     * Set the altField option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'altField'
+     * @param altFieldValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field.
+     */
+    datepicker(methodName: 'option', optionName: 'altField', altFieldValue: JQuery): JQuery;
+    /**
+     * Set the altField option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'altField'
+     * @param altFieldValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field.
+     */
+    datepicker(methodName: 'option', optionName: 'altField', altFieldValue: Element): JQuery;
+
+    /**
+     * Get the altFormat option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'altFormat'
+     */
+    datepicker(methodName: 'option', optionName: 'altFormat'): string;
+    /**
+     * Set the altFormat option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'altFormat'
+     * @param altFormatValue The dateFormat to be used for the altField option. This allows one date format to be shown to the user for selection purposes, while a different format is actually sent behind the scenes. For a full list of the possible formats see the formatDate function
+     */
+    datepicker(methodName: 'option', optionName: 'altFormat', altFormatValue: string): JQuery;
+
+    /**
+     * Get the appendText option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'appendText'
+     */
+    datepicker(methodName: 'option', optionName: 'appendText'): string;
+    /**
+     * Set the appendText option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'appendText'
+     * @param appendTextValue The text to display after each date field, e.g., to show the required format.
+     */
+    datepicker(methodName: 'option', optionName: 'appendText', appendTextValue: string): JQuery;
+
+    /**
+     * Get the autoSize option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'autoSize'
+     */
+    datepicker(methodName: 'option', optionName: 'autoSize'): boolean;
+    /**
+     * Set the autoSize option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'autoSize'
+     * @param autoSizeValue Set to true to automatically resize the input field to accommodate dates in the current dateFormat.
+     */
+    datepicker(methodName: 'option', optionName: 'autoSize', autoSizeValue: boolean): JQuery;
+
+    /**
+     * Get the beforeShow option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'beforeShow'
+     */
+    datepicker(methodName: 'option', optionName: 'beforeShow'): (input: Element, inst: any) => JQueryUI.DatepickerOptions;
+    /**
+     * Set the beforeShow option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'beforeShow'
+     * @param beforeShowValue A function that takes an input field and current datepicker instance and returns an options object to update the datepicker with. It is called just before the datepicker is displayed.
+     */
+    datepicker(methodName: 'option', optionName: 'beforeShow', beforeShowValue: (input: Element, inst: any) => JQueryUI.DatepickerOptions): JQuery;
+
+    /**
+     * Get the beforeShow option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'beforeShowDay'
+     */
+    datepicker(methodName: 'option', optionName: 'beforeShowDay'): (date: Date) => any[];
+    /**
+     * Set the beforeShow option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'beforeShowDay'
+     * @param beforeShowDayValue A function that takes a date as a parameter and must return an array with:
+     * [0]: true/false indicating whether or not this date is selectable
+     * [1]: a CSS class name to add to the date's cell or "" for the default presentation
+     * [2]: an optional popup tooltip for this date
+     * The function is called for each day in the datepicker before it is displayed.
+     */
+    datepicker(methodName: 'option', optionName: 'beforeShowDay', beforeShowDayValue: (date: Date) => any[]): JQuery;
+
+    /**
+     * Get the buttonImage option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'buttonImage'
+     */
+    datepicker(methodName: 'option', optionName: 'buttonImage'): string;
+    /**
+     * Set the buttonImage option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'buttonImage'
+     * @param buttonImageValue A URL of an image to use to display the datepicker when the showOn option is set to "button" or "both". If set, the buttonText option becomes the alt value and is not directly displayed.
+     */
+    datepicker(methodName: 'option', optionName: 'buttonImage', buttonImageValue: string): JQuery;
+
+    /**
+     * Get the buttonImageOnly option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'buttonImageOnly'
+     */
+    datepicker(methodName: 'option', optionName: 'buttonImageOnly'): boolean;
+    /**
+     * Set the buttonImageOnly option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'buttonImageOnly'
+     * @param buttonImageOnlyValue Whether the button image should be rendered by itself instead of inside a button element. This option is only relevant if the buttonImage option has also been set.
+     */
+    datepicker(methodName: 'option', optionName: 'buttonImageOnly', buttonImageOnlyValue: boolean): JQuery;
+
+    /**
+     * Get the buttonText option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'buttonText'
+     */
+    datepicker(methodName: 'option', optionName: 'buttonText'): string;
+
+      /**
+      * Get the autohide option, after initialization
+      *
+      * @param methodName 'option'
+      * @param optionName 'autohide'
+      */
+      datepicker(methodName: 'option', optionName: 'autohide'): boolean;
+
+
+      /**
+      * Get the endDate after initialization
+      *
+      * @param methodName 'option'
+      * @param optionName 'endDate'
+      */
+      datepicker(methodName: 'option', optionName: 'endDate'): Date;
+    /**
+     * Set the buttonText option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'buttonText'
+     * @param buttonTextValue The text to display on the trigger button. Use in conjunction with the showOn option set to "button" or "both".
+     */
+    datepicker(methodName: 'option', optionName: 'buttonText', buttonTextValue: string): JQuery;
+
+    /**
+     * Get the calculateWeek option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'calculateWeek'
+     */
+    datepicker(methodName: 'option', optionName: 'calculateWeek'): (date: Date) => string;
+    /**
+     * Set the calculateWeek option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'calculateWeek'
+     * @param calculateWeekValue A function to calculate the week of the year for a given date. The default implementation uses the ISO 8601 definition: weeks start on a Monday; the first week of the year contains the first Thursday of the year.
+     */
+    datepicker(methodName: 'option', optionName: 'calculateWeek', calculateWeekValue: (date: Date) => string): JQuery;
+
+    /**
+     * Get the changeMonth option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'changeMonth'
+     */
+    datepicker(methodName: 'option', optionName: 'changeMonth'): boolean;
+    /**
+     * Set the changeMonth option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'changeMonth'
+     * @param changeMonthValue Whether the month should be rendered as a dropdown instead of text.
+     */
+    datepicker(methodName: 'option', optionName: 'changeMonth', changeMonthValue: boolean): JQuery;
+
+    /**
+     * Get the changeYear option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'changeYear'
+     */
+    datepicker(methodName: 'option', optionName: 'changeYear'): boolean;
+    /**
+     * Set the changeYear option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'changeYear'
+     * @param changeYearValue Whether the year should be rendered as a dropdown instead of text. Use the yearRange option to control which years are made available for selection.
+     */
+    datepicker(methodName: 'option', optionName: 'changeYear', changeYearValue: boolean): JQuery;
+
+    /**
+     * Get the closeText option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'closeText'
+     */
+    datepicker(methodName: 'option', optionName: 'closeText'): string;
+    /**
+     * Set the closeText option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'closeText'
+     * @param closeTextValue The text to display for the close link. Use the showButtonPanel option to display this button.
+     */
+    datepicker(methodName: 'option', optionName: 'closeText', closeTextValue: string): JQuery;
+
+    /**
+     * Get the constrainInput option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'constrainInput'
+     */
+    datepicker(methodName: 'option', optionName: 'constrainInput'): boolean;
+    /**
+     * Set the constrainInput option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'constrainInput'
+     * @param constrainInputValue When true, entry in the input field is constrained to those characters allowed by the current dateFormat option.
+     */
+    datepicker(methodName: 'option', optionName: 'constrainInput', constrainInputValue: boolean): JQuery;
+
+    /**
+     * Get the currentText option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'currentText'
+     */
+    datepicker(methodName: 'option', optionName: 'currentText'): string;
+    /**
+     * Set the currentText option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'currentText'
+     * @param currentTextValue The text to display for the current day link. Use the showButtonPanel option to display this button.
+     */
+    datepicker(methodName: 'option', optionName: 'currentText', currentTextValue: string): JQuery;
+
+    /**
+     * Get the dateFormat option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'dateFormat'
+     */
+    datepicker(methodName: 'option', optionName: 'dateFormat'): string;
+    /**
+     * Set the dateFormat option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'dateFormat'
+     * @param dateFormatValue The format for parsed and displayed dates. For a full list of the possible formats see the formatDate function.
+     */
+    datepicker(methodName: 'option', optionName: 'dateFormat', dateFormatValue: string): JQuery;
+
+    /**
+     * Get the dayNames option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'dayNames'
+     */
+    datepicker(methodName: 'option', optionName: 'dayNames'): string[];
+    /**
+     * Set the dayNames option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'dayNames'
+     * @param dayNamesValue The list of long day names, starting from Sunday, for use as requested via the dateFormat option.
+     */
+    datepicker(methodName: 'option', optionName: 'dayNames', dayNamesValue: string[]): JQuery;
+
+    /**
+     * Get the dayNamesMin option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'dayNamesMin'
+     */
+    datepicker(methodName: 'option', optionName: 'dayNamesMin'): string[];
+    /**
+     * Set the dayNamesMin option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'dayNamesMin'
+     * @param dayNamesMinValue The list of minimised day names, starting from Sunday, for use as column headers within the datepicker.
+     */
+    datepicker(methodName: 'option', optionName: 'dayNamesMin', dayNamesMinValue: string[]): JQuery;
+
+    /**
+     * Get the dayNamesShort option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'dayNamesShort'
+     */
+    datepicker(methodName: 'option', optionName: 'dayNamesShort'): string[];
+    /**
+     * Set the dayNamesShort option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'dayNamesShort'
+     * @param dayNamesShortValue The list of abbreviated day names, starting from Sunday, for use as requested via the dateFormat option.
+     */
+    datepicker(methodName: 'option', optionName: 'dayNamesShort', dayNamesShortValue: string[]): JQuery;
+
+    /**
+     * Get the defaultDate option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'defaultDate'
+     */
+    datepicker(methodName: 'option', optionName: 'defaultDate'): any;
+    /**
+     * Set the defaultDate option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'defaultDate'
+     * @param defaultDateValue A date object containing the default date.
+     */
+    datepicker(methodName: 'option', optionName: 'defaultDate', defaultDateValue: Date): JQuery;
+    /**
+     * Set the defaultDate option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'defaultDate'
+     * @param defaultDateValue A number of days from today. For example 2 represents two days from today and -1 represents yesterday.
+     */
+    datepicker(methodName: 'option', optionName: 'defaultDate', defaultDateValue: number): JQuery;
+    /**
+     * Set the defaultDate option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'defaultDate'
+     * @param defaultDateValue A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today.
+     */
+    datepicker(methodName: 'option', optionName: 'defaultDate', defaultDateValue: string): JQuery;
+
+    /**
+     * Get the duration option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'duration'
+     */
+    datepicker(methodName: 'option', optionName: 'duration'): string;
+    /**
+     * Set the duration option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'duration'
+     * @param durationValue Control the speed at which the datepicker appears, it may be a time in milliseconds or a string representing one of the three predefined speeds ("slow", "normal", "fast").
+     */
+    datepicker(methodName: 'option', optionName: 'duration', durationValue: string): JQuery;
+
+    /**
+     * Get the firstDay option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'firstDay'
+     */
+    datepicker(methodName: 'option', optionName: 'firstDay'): number;
+    /**
+     * Set the firstDay option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'firstDay'
+     * @param firstDayValue Set the first day of the week: Sunday is 0, Monday is 1, etc.
+     */
+    datepicker(methodName: 'option', optionName: 'firstDay', firstDayValue: number): JQuery;
+
+    /**
+     * Get the gotoCurrent option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'gotoCurrent'
+     */
+    datepicker(methodName: 'option', optionName: 'gotoCurrent'): boolean;
+    /**
+     * Set the gotoCurrent option, after initialization
+     *
+     * @param methodName 'option'
+     * @param optionName 'gotoCurrent'
+     * @param gotoCurrentValue When true, the current day link moves to the currently selected date instead of today.
+     */
+    datepicker(methodName: 'option', optionName: 'gotoCurrent', gotoCurrentValue: boolean): JQuery;
+
+    /**
+     * Gets the value currently associated with the specified optionName.
+     *
+     * @param methodName 'option'
+     * @param optionName The name of the option to get.
+     */
+    datepicker(methodName: 'option', optionName: string): any;
+
+    datepicker(methodName: 'option', optionName: string, ...otherParams: any[]): any; // Used for getting and setting options
+
+    datepicker(methodName: string, ...otherParams: any[]): any;
+
+    /**
+     * Initialize a datepicker with the given options
+     */
+    datepicker(options: JQueryUI.DatepickerOptions): JQuery;
+
+    dialog(): JQuery;
+    dialog(methodName: 'close'): JQuery;
+    dialog(methodName: 'destroy'): JQuery;
+    dialog(methodName: 'isOpen'): boolean;
+    dialog(methodName: 'moveToTop'): JQuery;
+    dialog(methodName: 'open'): JQuery;
+    dialog(methodName: 'widget'): JQuery;
+    dialog(methodName: string): JQuery;
+    dialog(options: JQueryUI.DialogOptions): JQuery;
+    dialog(optionLiteral: string, optionName: string): any;
+    dialog(optionLiteral: string, options: JQueryUI.DialogOptions): any;
+    dialog(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    draggable(): JQuery;
+    draggable(methodName: 'destroy'): void;
+    draggable(methodName: 'disable'): void;
+    draggable(methodName: 'enable'): void;
+    draggable(methodName: 'widget'): JQuery;
+    draggable(methodName: string): JQuery;
+    draggable(options: JQueryUI.DraggableOptions): JQuery;
+    draggable(optionLiteral: string, optionName: string): any;
+    draggable(optionLiteral: string, options: JQueryUI.DraggableOptions): any;
+    draggable(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    droppable(): JQuery;
+    droppable(methodName: 'destroy'): void;
+    droppable(methodName: 'disable'): void;
+    droppable(methodName: 'enable'): void;
+    droppable(methodName: 'widget'): JQuery;
+    droppable(methodName: string): JQuery;
+    droppable(options: JQueryUI.DroppableOptions): JQuery;
+    droppable(optionLiteral: string, optionName: string): any;
+    droppable(optionLiteral: string, options: JQueryUI.DraggableOptions): any;
+    droppable(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    menu: {
+        (): JQuery;
+        (methodName: 'blur'): void;
+        (methodName: 'collapse', event?: JQueryEventObject): void;
+        (methodName: 'collapseAll', event?: JQueryEventObject, all?: boolean): void;
+        (methodName: 'destroy'): void;
+        (methodName: 'disable'): void;
+        (methodName: 'enable'): void;
+        (methodName: string, event: JQueryEventObject, item: JQuery): void;
+        (methodName: 'focus', event: JQueryEventObject, item: JQuery): void;
+        (methodName: 'isFirstItem'): boolean;
+        (methodName: 'isLastItem'): boolean;
+        (methodName: 'next', event?: JQueryEventObject): void;
+        (methodName: 'nextPage', event?: JQueryEventObject): void;
+        (methodName: 'previous', event?: JQueryEventObject): void;
+        (methodName: 'previousPage', event?: JQueryEventObject): void;
+        (methodName: 'refresh'): void;
+        (methodName: 'select', event?: JQueryEventObject): void;
+        (methodName: 'widget'): JQuery;
+        (methodName: string): JQuery;
+        (options: JQueryUI.MenuOptions): JQuery;
+        (optionLiteral: string, optionName: string): any;
+        (optionLiteral: string, options: JQueryUI.MenuOptions): any;
+        (optionLiteral: string, optionName: string, optionValue: any): JQuery;
+        active: boolean;
+    }
+
+    progressbar(): JQuery;
+    progressbar(methodName: 'destroy'): void;
+    progressbar(methodName: 'disable'): void;
+    progressbar(methodName: 'enable'): void;
+    progressbar(methodName: 'refresh'): void;
+    progressbar(methodName: 'value'): any; // number or boolean
+    progressbar(methodName: 'value', value: number): void;
+    progressbar(methodName: 'value', value: boolean): void;
+    progressbar(methodName: 'widget'): JQuery;
+    progressbar(methodName: string): JQuery;
+    progressbar(options: JQueryUI.ProgressbarOptions): JQuery;
+    progressbar(optionLiteral: string, optionName: string): any;
+    progressbar(optionLiteral: string, options: JQueryUI.ProgressbarOptions): any;
+    progressbar(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    resizable(): JQuery;
+    resizable(methodName: 'destroy'): void;
+    resizable(methodName: 'disable'): void;
+    resizable(methodName: 'enable'): void;
+    resizable(methodName: 'widget'): JQuery;
+    resizable(methodName: string): JQuery;
+    resizable(options: JQueryUI.ResizableOptions): JQuery;
+    resizable(optionLiteral: string, optionName: string): any;
+    resizable(optionLiteral: string, options: JQueryUI.ResizableOptions): any;
+    resizable(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    selectable(): JQuery;
+    selectable(methodName: 'destroy'): void;
+    selectable(methodName: 'disable'): void;
+    selectable(methodName: 'enable'): void;
+    selectable(methodName: 'widget'): JQuery;
+    selectable(methodName: string): JQuery;
+    selectable(options: JQueryUI.SelectableOptions): JQuery;
+    selectable(optionLiteral: string, optionName: string): any;
+    selectable(optionLiteral: string, options: JQueryUI.SelectableOptions): any;
+    selectable(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    selectmenu(): JQuery;
+    selectmenu(methodName: 'close'): JQuery;
+    selectmenu(methodName: 'destroy'): JQuery;
+    selectmenu(methodName: 'disable'): JQuery;
+    selectmenu(methodName: 'enable'): JQuery;
+    selectmenu(methodName: 'instance'): any;
+    selectmenu(methodName: 'menuWidget'): JQuery;
+    selectmenu(methodName: 'open'): JQuery;
+    selectmenu(methodName: 'refresh'): JQuery;
+    selectmenu(methodName: 'widget'): JQuery;
+    selectmenu(methodName: string): JQuery;
+    selectmenu(options: JQueryUI.SelectMenuOptions): JQuery;
+    selectmenu(optionLiteral: string, optionName: string): any;
+    selectmenu(optionLiteral: string, options: JQueryUI.SelectMenuOptions): any;
+    selectmenu(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    slider(): JQuery;
+    slider(methodName: 'destroy'): void;
+    slider(methodName: 'disable'): void;
+    slider(methodName: 'enable'): void;
+    slider(methodName: 'refresh'): void;
+    slider(methodName: 'value'): number;
+    slider(methodName: 'value', value: number): void;
+    slider(methodName: 'values'): Array<number>;
+    slider(methodName: 'values', index: number): number;
+    slider(methodName: string, index: number, value: number): void;
+    slider(methodName: 'values', index: number, value: number): void;
+    slider(methodName: string, values: Array<number>): void;
+    slider(methodName: 'values', values: Array<number>): void;
+    slider(methodName: 'widget'): JQuery;
+    slider(methodName: string): JQuery;
+    slider(options: JQueryUI.SliderOptions): JQuery;
+    slider(optionLiteral: string, optionName: string): any;
+    slider(optionLiteral: string, options: JQueryUI.SliderOptions): any;
+    slider(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    sortable(): JQuery;
+    sortable(methodName: 'destroy'): void;
+    sortable(methodName: 'disable'): void;
+    sortable(methodName: 'enable'): void;
+    sortable(methodName: 'widget'): JQuery;
+    sortable(methodName: 'toArray'): string[];
+    sortable(methodName: string): JQuery;
+    sortable(options: JQueryUI.SortableOptions): JQuery;
+    sortable(optionLiteral: string, optionName: string): any;
+    sortable(methodName: 'serialize', options?: { key?: string; attribute?: string; expression?: RegExp }): string;
+    sortable(optionLiteral: string, options: JQueryUI.SortableOptions): any;
+    sortable(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    spinner(): JQuery;
+    spinner(methodName: 'destroy'): void;
+    spinner(methodName: 'disable'): void;
+    spinner(methodName: 'enable'): void;
+    spinner(methodName: 'pageDown', pages?: number): void;
+    spinner(methodName: 'pageUp', pages?: number): void;
+    spinner(methodName: 'stepDown', steps?: number): void;
+    spinner(methodName: 'stepUp', steps?: number): void;
+    spinner(methodName: 'value'): number;
+    spinner(methodName: 'value', value: number): void;
+    spinner(methodName: 'widget'): JQuery;
+    spinner(methodName: string): JQuery;
+    spinner(options: JQueryUI.SpinnerOptions): JQuery;
+    spinner(optionLiteral: string, optionName: string): any;
+    spinner(optionLiteral: string, options: JQueryUI.SpinnerOptions): any;
+    spinner(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    tabs(): JQuery;
+    tabs(methodName: 'destroy'): void;
+    tabs(methodName: 'disable'): void;
+    tabs(methodName: 'enable'): void;
+    tabs(methodName: 'load', index: number): void;
+    tabs(methodName: 'refresh'): void;
+    tabs(methodName: 'widget'): JQuery;
+    tabs(methodName: string): JQuery;
+    tabs(options: JQueryUI.TabsOptions): JQuery;
+    tabs(optionLiteral: string, optionName: string): any;
+    tabs(optionLiteral: string, options: JQueryUI.TabsOptions): any;
+    tabs(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+    tooltip(): JQuery;
+    tooltip(methodName: 'destroy'): void;
+    tooltip(methodName: 'disable'): void;
+    tooltip(methodName: 'enable'): void;
+    tooltip(methodName: 'open'): void;
+    tooltip(methodName: 'close'): void;
+    tooltip(methodName: 'widget'): JQuery;
+    tooltip(methodName: string): JQuery;
+    tooltip(options: JQueryUI.TooltipOptions): JQuery;
+    tooltip(optionLiteral: string, optionName: string): any;
+    tooltip(optionLiteral: string, options: JQueryUI.TooltipOptions): any;
+    tooltip(optionLiteral: string, optionName: string, optionValue: any): JQuery;
+
+
+    addClass(classNames: string, speed?: number, callback?: Function): JQuery;
+    addClass(classNames: string, speed?: string, callback?: Function): JQuery;
+    addClass(classNames: string, speed?: number, easing?: string, callback?: Function): JQuery;
+    addClass(classNames: string, speed?: string, easing?: string, callback?: Function): JQuery;
+
+    removeClass(classNames: string, speed?: number, callback?: Function): JQuery;
+    removeClass(classNames: string, speed?: string, callback?: Function): JQuery;
+    removeClass(classNames: string, speed?: number, easing?: string, callback?: Function): JQuery;
+    removeClass(classNames: string, speed?: string, easing?: string, callback?: Function): JQuery;
+
+    switchClass(removeClassName: string, addClassName: string, duration?: number, easing?: string, complete?: Function): JQuery;
+    switchClass(removeClassName: string, addClassName: string, duration?: string, easing?: string, complete?: Function): JQuery;
+
+    toggleClass(className: string, duration?: number, easing?: string, complete?: Function): JQuery;
+    toggleClass(className: string, duration?: string, easing?: string, complete?: Function): JQuery;
+    toggleClass(className: string, aswitch?: boolean, duration?: number, easing?: string, complete?: Function): JQuery;
+    toggleClass(className: string, aswitch?: boolean, duration?: string, easing?: string, complete?: Function): JQuery;
+
+    effect(options: any): JQuery;
+    effect(effect: string, options?: any, duration?: number, complete?: Function): JQuery;
+    effect(effect: string, options?: any, duration?: string, complete?: Function): JQuery;
+
+    hide(options: any): JQuery;
+    hide(effect: string, options?: any, duration?: number, complete?: Function): JQuery;
+    hide(effect: string, options?: any, duration?: string, complete?: Function): JQuery;
+
+    show(options: any): JQuery;
+    show(effect: string, options?: any, duration?: number, complete?: Function): JQuery;
+    show(effect: string, options?: any, duration?: string, complete?: Function): JQuery;
+
+    toggle(options: any): JQuery;
+    toggle(effect: string, options?: any, duration?: number, complete?: Function): JQuery;
+    toggle(effect: string, options?: any, duration?: string, complete?: Function): JQuery;
+
+    position(options: JQueryUI.JQueryPositionOptions): JQuery;
+
+    enableSelection(): JQuery;
+    disableSelection(): JQuery;
+    focus(delay: number, callback?: Function): JQuery;
+    uniqueId(): JQuery;
+    removeUniqueId(): JQuery;
+    scrollParent(): JQuery;
+    zIndex(): number;
+    zIndex(zIndex: number): JQuery;
+
+    widget: JQueryUI.Widget;
+
+    jQuery: JQueryStatic;
+}
+
+interface JQueryStatic {
+    ui: JQueryUI.UI;
+    datepicker: JQueryUI.Datepicker;
+    widget: JQueryUI.Widget;
+    Widget: JQueryUI.Widget;
+}
+
+interface JQueryEasingFunctions {
+    easeInQuad: JQueryEasingFunction;
+    easeOutQuad: JQueryEasingFunction;
+    easeInOutQuad: JQueryEasingFunction;
+    easeInCubic: JQueryEasingFunction;
+    easeOutCubic: JQueryEasingFunction;
+    easeInOutCubic: JQueryEasingFunction;
+    easeInQuart: JQueryEasingFunction;
+    easeOutQuart: JQueryEasingFunction;
+    easeInOutQuart: JQueryEasingFunction;
+    easeInQuint: JQueryEasingFunction;
+    easeOutQuint: JQueryEasingFunction;
+    easeInOutQuint: JQueryEasingFunction;
+    easeInExpo: JQueryEasingFunction;
+    easeOutExpo: JQueryEasingFunction;
+    easeInOutExpo: JQueryEasingFunction;
+    easeInSine: JQueryEasingFunction;
+    easeOutSine: JQueryEasingFunction;
+    easeInOutSine: JQueryEasingFunction;
+    easeInCirc: JQueryEasingFunction;
+    easeOutCirc: JQueryEasingFunction;
+    easeInOutCirc: JQueryEasingFunction;
+    easeInElastic: JQueryEasingFunction;
+    easeOutElastic: JQueryEasingFunction;
+    easeInOutElastic: JQueryEasingFunction;
+    easeInBack: JQueryEasingFunction;
+    easeOutBack: JQueryEasingFunction;
+    easeInOutBack: JQueryEasingFunction;
+    easeInBounce: JQueryEasingFunction;
+    easeOutBounce: JQueryEasingFunction;
+    easeInOutBounce: JQueryEasingFunction;
+}

+ 45 - 0
Script/AtomicWebViewEditor/typings/socketio.d.ts

@@ -0,0 +1,45 @@
+// Type definitions for socket.io-client 1.2.0
+// Project: http://socket.io/
+// Definitions by: PROGRE <https://github.com/progre/>
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare var io: SocketIOClientStatic;
+
+declare module 'socket.io-client' {
+    export = io;
+}
+
+interface SocketIOClientStatic {
+    (host: string, details?: any): SocketIOClient.Socket;
+    (details?: any): SocketIOClient.Socket;
+    connect(host: string, details?: any): SocketIOClient.Socket;
+    connect(details?: any): SocketIOClient.Socket;
+    protocol: number;
+    Socket: { new (...args: any[]): SocketIOClient.Socket };
+    Manager: SocketIOClient.ManagerStatic;
+}
+
+declare module SocketIOClient {
+    interface Socket {
+        on(event: string, fn: Function): Socket;
+        once(event: string, fn: Function): Socket;
+        off(event?: string, fn?: Function): Socket;
+        emit(event: string, ...args: any[]): Socket;
+        listeners(event: string): Function[];
+        hasListeners(event: string): boolean;
+        connected: boolean;
+    }
+
+    interface ManagerStatic {
+        (url: string, opts: any): SocketIOClient.Manager;
+        new (url: string, opts: any): SocketIOClient.Manager;
+    }
+
+    interface Manager {
+        reconnection(v: boolean): Manager;
+        reconnectionAttempts(v: boolean): Manager;
+        reconnectionDelay(v: boolean): Manager;
+        reconnectionDelayMax(v: boolean): Manager;
+        timeout(v: boolean): Manager;
+    }
+}

+ 384 - 0
Script/DuktapeDebugProxy/README.rst

@@ -0,0 +1,384 @@
+=========================================
+Duktape debug client and JSON debug proxy
+=========================================
+
+Overview
+========
+
+Debugger web UI which connects to the Duktape command line tool or any other
+target supporting the example TCP transport (``examples/debug-trans-socket``)
+on Unix and Windows.
+
+Also provides a JSON debug proxy with a JSON mapping for the Duktape debug
+protocol.
+
+For detailed documentation of the debugger internals, see `debugger.rst`__.
+
+__ https://github.com/svaarala/duktape/blob/master/doc/debugger.rst
+
+Using the debugger web UI
+=========================
+
+Some prerequisites:
+
+* You'll need Node.js v0.10.x or newer.  Older Node.js versions don't support
+  the required packages.
+
+Compile Duktape command line tool with debugger support (for further options
+see http://wiki.duktape.org/FeatureOptions.html):
+
+* ``DUK_OPT_DEBUGGER_SUPPORT``
+
+* ``DUK_OPT_INTERRUPT_COUNTER``
+
+* ``DUK_CMDLINE_DEBUGGER_SUPPORT``
+
+The source distributable contains a Makefile to build a "duk" command with
+debugger support::
+
+    $ cd <duktape dist directory>
+    $ make -f Makefile.dukdebug
+
+The Duktape Git repo "duk" target has debugger support enabled by default::
+
+    $ make clean duk
+
+Start Duktape command line tool so that it waits for a debugger connection::
+
+    # For now we need to be in the directory containing the source files
+    # executed so that the 'fileName' properties of functions will match
+    # that on the debug client.
+
+    # Using source distributable
+    $ cd <duktape dist directory>
+    $ ./duk --debugger mandel.js
+
+    # Using Duktape Git repo
+    $ cd <duktape checkout>/tests/ecmascript/
+    $ ../../duk --debugger test-dev-mandel2-func.js
+
+Start the web UI::
+
+    # Must be in 'debugger' directory.
+
+    $ cd debugger/
+    $ make  # runs 'node duk_debug.js'
+
+Once the required packages are installed, the NodeJS debug client will be
+up and running.  Open the following in your browser and start debugging:
+
+* http://localhost:9092/
+
+The debug client automatically attaches to the debug target on startup.
+If you start the debug target later, you'll need to click "Attach" in the
+web UI.
+
+Using the JSON debug proxy
+==========================
+
+There are two JSON debug proxy implementations: one implemented in DukLuv
+and another in Node.js.
+
+DukLuv JSON proxy
+-----------------
+
+DukLuv (https://github.com/creationix/dukluv) is a small and portable event
+loop based on LibUV and Duktape with MIT license (like Duktape).  As such it's
+easy to embed in a custom debug client: you just include the DukLuv executable
+and the JSON proxy source file in your debug client.
+
+Install DukLuv:
+
+* Ensure ``cmake`` is installed
+
+* ``git clone https://github.com/creationix/dukluv.git``
+
+* ``git submodule init; git submodule update``
+
+* ``make``
+
+* Binary should appear in:
+
+  - ``./build/dukluv`` on Linux
+
+  - ``.\build\Debug\dukluv.exe`` on Windows
+
+Run the proxy::
+
+    # Using Makefile; autogenerates duk_debug_meta.json
+    # (You may need to edit DUKLUV in Makefile to point to your DukLuv)
+    $ make runproxydukluv
+
+    # Manually: see "dukluv duk_debug_proxy.js --help" for help
+    $ .../path/to/dukluv duk_debug_proxy.js
+
+Start Duktape command line (or whatever your target is)::
+
+    $ cd <duktape checkout>/tests/ecmascript/
+    $ ../../duk --debugger test-dev-mandel2-func.js
+
+Now connect to the proxy using e.g. telnet::
+
+    $ telnet localhost 9093
+
+The proxy will then connect to the target and you can start issuing commands::
+
+    $ telnet localhost 9093
+    Trying 127.0.0.1...
+    Connected to localhost.
+    Escape character is '^]'.
+    {"notify":"_TargetConnecting","args":["127.0.0.1",9091]}
+    {"notify":"_TargetConnected","args":["1 10499 v1.4.0-140-gc9a6c7c duk command built from Duktape repo"]}
+    {"notify":"Status","command":1,"args":[1,"test-dev-mandel2-func.js","global",58,0]}
+    {"request":"BasicInfo"}
+    {"reply":true,"args":[10499,"v1.4.0-140-gc9a6c7c","duk command built from Duktape repo",1]}
+    {"request":"Eval","args":["print('Hello world!'); 123;"]}
+    {"notify":"Print","command":2,"args":["Hello world!\n"]}
+    {"reply":true,"args":[0,{"type":"number","data":"405ec00000000000"}]}
+    [...]
+
+The proxy log provides dumps both JSON and dvalue binary traffic which is
+quite useful in development::
+
+    $ make runproxydukluv
+    Running Dukluv based debug proxy
+    "dukluv" duk_debug_proxy.js --log-level 2 --metadata duk_debug_meta.json
+    2016-02-17T13:59:42.308Z INF Proxy: Read proxy metadata from duk_debug_meta.json
+    2016-02-17T13:59:42.325Z INF Proxy: Listening for incoming JSON debug connection on 0.0.0.0:9093, target is 127.0.0.1:9091
+    2016-02-17T13:59:47.994Z INF Proxy: JSON proxy client connected
+    2016-02-17T13:59:47.994Z INF Proxy: Connecting to debug target at 127.0.0.1:9091
+    2016-02-17T13:59:47.994Z INF Proxy: PROXY --> CLIENT: {"notify":"_TargetConnecting","args":["127.0.0.1",9091]}
+    2016-02-17T13:59:47.994Z INF Proxy: Connected to debug target at 127.0.0.1:9091
+    2016-02-17T13:59:48.003Z INF Proxy: PROXY --> CLIENT: {"notify":"_TargetConnected","args":["1 10499 v1.4.0-140-gc9a6c7c duk command built from Duktape repo"]}
+    2016-02-17T13:59:48.003Z INF Proxy: Target handshake: {"line":"1 10499 v1.4.0-140-gc9a6c7c duk command built from Duktape repo","protocolVersion":1,"text":"10499 v1.4.0-140-gc9a6c7c duk command built from Duktape repo","dukVersion":"1","dukGitDescribe":"10499","targetString":"v1.4.0-140-gc9a6c7c"}
+    2016-02-17T13:59:48.151Z INF Proxy: PROXY <-- TARGET: |04|
+    2016-02-17T13:59:48.152Z INF Proxy: PROXY <-- TARGET: |81|
+    2016-02-17T13:59:48.152Z INF Proxy: PROXY <-- TARGET: |81|
+    2016-02-17T13:59:48.160Z INF Proxy: PROXY <-- TARGET: |78746573742d6465762d6d616e64656c322d66756e632e6a73|
+    2016-02-17T13:59:48.161Z INF Proxy: PROXY <-- TARGET: |66676c6f62616c|
+    2016-02-17T13:59:48.165Z INF Proxy: PROXY <-- TARGET: |ba|
+    2016-02-17T13:59:48.165Z INF Proxy: PROXY <-- TARGET: |80|
+    2016-02-17T13:59:48.165Z INF Proxy: PROXY <-- TARGET: |00|
+    2016-02-17T13:59:48.165Z INF Proxy: PROXY --> CLIENT: {"notify":"Status","command":1,"args":[1,"test-dev-mandel2-func.js","global",58,0]}
+    2016-02-17T13:59:51.289Z INF Proxy: PROXY <-- CLIENT: {"request":"BasicInfo"}
+    2016-02-17T13:59:51.289Z INF Proxy: PROXY --> TARGET: |01|
+    2016-02-17T13:59:51.289Z INF Proxy: PROXY --> TARGET: |90|
+    2016-02-17T13:59:51.289Z INF Proxy: PROXY --> TARGET: |00|
+    2016-02-17T13:59:51.291Z INF Proxy: PROXY <-- TARGET: |02|
+    2016-02-17T13:59:51.291Z INF Proxy: PROXY <-- TARGET: |e903|
+    2016-02-17T13:59:51.292Z INF Proxy: PROXY <-- TARGET: |7376312e342e302d3134302d6763396136633763|
+    2016-02-17T13:59:51.293Z INF Proxy: PROXY <-- TARGET: |12002364756b20636f6d6d616e64206275696c742066726f6d2044756b74617065207265706f|
+    2016-02-17T13:59:51.293Z INF Proxy: PROXY <-- TARGET: |81|
+    2016-02-17T13:59:51.293Z INF Proxy: PROXY <-- TARGET: |00|
+    2016-02-17T13:59:51.293Z INF Proxy: PROXY --> CLIENT: {"reply":true,"args":[10499,"v1.4.0-140-gc9a6c7c","duk command built from Duktape repo",1]}
+    2016-02-17T14:00:06.105Z INF Proxy: PROXY <-- CLIENT: {"request":"Eval","args":["print('Hello world!'); 123;"]}
+    2016-02-17T14:00:06.105Z INF Proxy: PROXY --> TARGET: |01|
+    2016-02-17T14:00:06.105Z INF Proxy: PROXY --> TARGET: |9e|
+    2016-02-17T14:00:06.105Z INF Proxy: PROXY --> TARGET: |7b7072696e74282748656c6c6f20776f726c642127293b203132333b|
+    2016-02-17T14:00:06.105Z INF Proxy: PROXY --> TARGET: |00|
+    2016-02-17T14:00:06.167Z INF Proxy: PROXY <-- TARGET: |04|
+    2016-02-17T14:00:06.167Z INF Proxy: PROXY <-- TARGET: |82|
+    2016-02-17T14:00:06.167Z INF Proxy: PROXY <-- TARGET: |6d48656c6c6f20776f726c64210a|
+    2016-02-17T14:00:06.168Z INF Proxy: PROXY <-- TARGET: |00|
+    2016-02-17T14:00:06.168Z INF Proxy: PROXY --> CLIENT: {"notify":"Print","command":2,"args":["Hello world!\n"]}
+    2016-02-17T14:00:06.171Z INF Proxy: PROXY <-- TARGET: |02|
+    2016-02-17T14:00:06.171Z INF Proxy: PROXY <-- TARGET: |80|
+    2016-02-17T14:00:06.173Z INF Proxy: PROXY <-- TARGET: |1a405ec00000000000|
+    2016-02-17T14:00:06.173Z INF Proxy: PROXY <-- TARGET: |00|
+    2016-02-17T14:00:06.174Z INF Proxy: PROXY --> CLIENT: {"reply":true,"args":[0,{"type":"number","data":"405ec00000000000"}]}
+    [...]
+
+Node.js JSON proxy
+------------------
+
+A Node.js-based JSON debug proxy is also provided by ``duk_debug.js``::
+
+    # Same prerequisites as for running the debug client
+    $ make runproxynodejs
+
+Start Duktape command line (or whatever your target is)::
+
+    $ cd <duktape checkout>/tests/ecmascript/
+    $ ../../duk --debugger test-dev-mandel2-func.js
+
+You can then connect to localhost:9093 and interact with the proxy.
+Here's an example session using telnet and manually typed in commands
+The ``-->`` (send) and ``<--`` (receiver) markers have been added for
+readability and are not part of the stream::
+
+    $ telnet localhost 9093
+    Trying 127.0.0.1...
+    Connected to localhost.
+    Escape character is '^]'.
+    <-- {"notify":"_TargetConnected","args":["1 10199 v1.1.0-275-gbd4d610-dirty duk command built from Duktape repo"]}
+    <-- {"notify":"Status","command":1,"args":[1,"test-dev-mandel2-func.js","global",58,0]}
+    --> {"request":"BasicInfo"}
+    <-- {"reply":true,"args":[10199,"v1.1.0-275-gbd4d610-dirty","duk command built from Duktape repo",1]}
+    --> {"request":"Eval", "args":[ "print(Math.PI)" ]}
+    <-- {"notify":"Print","command":2,"args":["3.141592653589793\n"]}
+    <-- {"reply":true,"args":[0,{"type":"undefined"}]}
+    --> {"request":"Resume"}
+    <-- {"reply":true,"args":[]}
+    <-- {"notify":"Status","command":1,"args":[0,"test-dev-mandel2-func.js","global",58,0]}
+    <-- {"notify":"Status","command":1,"args":[0,"test-dev-mandel2-func.js","global",58,0]}
+    <-- {"notify":"Print","command":2,"args":["................................................................................\n"]}
+    <-- {"notify":"Print","command":2,"args":["................................................................................\n"]}
+    <-- {"notify":"Print","command":2,"args":["................................................................................\n"]}
+    [...]
+    <-- {"notify":"_Disconnecting"}
+
+A telnet connection allows you to experiment with debug commands by simply
+copy-pasting debug commands to the telnet session.  This is useful even if
+you decide to implement the binary protocol directly.
+
+The debug target used by the proxy can be configured with ``duk_debug.js``
+command line options.
+
+Source search path
+==================
+
+The NodeJS debug client needs to be able to find source code files matching
+code running on the target ("duk" command line).  **The filenames used on the
+target and on the debug client must match exactly**, because e.g. breakpoints
+are targeted based on the 'fileName' property of Function objects.
+
+The search path can be set using the ``--source-dirs`` option given to
+``duk_debug.js``, with the default search paths including only
+``../tests/ecmascript/``.
+
+The default search path means that if a function on the target has fileName
+``foo/bar.js`` it would be loaded from (relative to the duk_debug.js working
+directory, ``debugger/``)::
+
+    ../tests/ecmascript/foo/bar.js
+
+Similarly, if the filesystem contained::
+
+    ../tests/ecmascript/baz/quux.js
+
+the web UI dropdown would show ``baz/quux.js``.  If you selected that file
+and added a breakpoint, the breakpoint fileName sent to the debug target
+would be ``baz/quux.js``.
+
+.. note:: There's much to improve in the search path.  For instance, it'd
+          be nice to add a certain path to search but exclude files based
+          on paths and patterns, etc.
+
+Architecture
+============
+
+::
+
+    +-------------------+
+    | Web browser       |  [debug UI]
+    +-------------------+
+          |
+          | http (port 9092)
+          | socket.io
+          v
+    +-------------------+
+    | duk_debug.js      |  [debug client]
+    +-------------------+
+          |          /\
+          |          ||
+          +----------||---- [example tcp transport] (port 9091)
+          |          ||     (application provides concrete transport)
+          |          ||
+          |          ||---- [debug protocol stream]
+          |          ||     (between debug client and Duktape)
+          |          ||
+    + - - | - - - - -|| - - +
+    :     v          ||     :
+    :  +-------------||-+   :  [target]
+    :  | application || |   :
+    :  +-------------||-+   :
+    :     ^          ||     :
+    :     |          ||     :   [debug API]
+    :     +----------||-------- debug transport callbacks
+    :     |          ||     :   (read, write, peek, read/write flush)
+    :     |          ||     :   implemented by application
+    :     |          \/     :
+    :  +----------------+   :
+    :  | Duktape        |   :
+    :  +----------------+   :
+    + - - - - - - - - - - - +
+
+The debug transport is application specific:
+
+* Duktape command line ("duk") and this debug client use an **example** TCP
+  transport as a concrete example.
+
+* It is entirely up to the application to come up with the most suitable
+  transport for its environment.  Different mechanisms will be needed for
+  Wi-Fi, serial, etc.
+
+The debug protocol running inside the transport is transport independent:
+
+* The debug protocol is documented in ``doc/debugger.rst``.
+
+* This debug client provides further concrete examples and clarifications
+  on how the protocol can be used.
+
+Using a custom transport
+========================
+
+Quite possibly your target device cannot use the example TCP transport and
+you need to implement your own transport.  You'll need to implement your
+custom transport both for the target device and for the debug client.
+
+Target device
+-------------
+
+Implement the debug transport callbacks needed by ``duk_debugger_attach()``.
+
+See ``doc/debugger.rst`` for details and ``examples/debug-trans-socket``
+for example running code for a TCP transport.
+
+Debug client alternative 1: duk_debug.js + custom TCP proxy
+-----------------------------------------------------------
+
+If you don't want to change ``duk_debug.js`` you can implement a TCP proxy
+which accepts a TCP connection from ``duk_debug.js`` and then uses your
+custom transport to talk to the target::
+
+   +--------------+   TCP   +-------+   custom   +--------+
+   | duk_debug.js | ------> | proxy | ---------> | target |
+   +--------------+         +-------+            +--------+
+
+This is a straightforward option and a proxy can be used with other debug
+clients too (perhaps custom scripts talking to the target etc).
+
+You could also use netcat and implement your proxy so that it talks to
+``duk_debug.js`` using stdin/stdout.
+
+Debug client alternative 2: duk_debug.js + custom NodeJS stream
+---------------------------------------------------------------
+
+To make ``duk_debug.js`` use a custom transport you need to:
+
+* Implement your own transport as NodeJS stream.  You can add it directly to
+  ``duk_debug.js`` but it's probably easiest to use a separate module so that
+  the diff to ``duk_debug.js`` stays minimal.
+
+* Change ``duk_debug.js`` to use the custom transport instead of a TCP
+  stream.  Search for "CUSTOMTRANSPORT" in ``duk_debug.js``.
+
+See:
+
+* http://nodejs.org/api/stream.html
+
+* https://github.com/substack/stream-handbook
+
+Debug client alternative 3: custom debug client
+-----------------------------------------------
+
+You can also implement your own debug client and debug UI with support for
+your custom transport.
+
+You'll also need to implement the client part of the Duktape debugger
+protocol.  See ``doc/debugger.rst`` for the specification and ``duk_debug.js``
+for example running code which should illustrate the protocol in more detail.
+
+The JSON debug proxy allows you to implement a debug client without needing
+to implement the Duktape binary debug protocol.  The JSON protocol provides
+a roughly 1:1 mapping to the binary protocol but with an easier syntax.

+ 32 - 0
Script/DuktapeDebugProxy/duk_classnames.yaml

@@ -0,0 +1,32 @@
+# Must match C header.
+class_names:
+  - unused
+  - Arguments
+  - Array
+  - Boolean
+  - Date
+  - Error
+  - Function
+  - JSON
+  - Math
+  - Number
+  - Object
+  - RegExp
+  - String
+  - global
+  - ObjEnv
+  - DecEnv
+  - Buffer
+  - Pointer
+  - Thread
+  - ArrayBuffer
+  - DataView
+  - Int8Array
+  - Uint8Array
+  - Uint8ClampedArray
+  - Int16Array
+  - Uint16Array
+  - Int32Array
+  - Uint32Array
+  - Float32Array
+  - Float64Array

+ 2473 - 0
Script/DuktapeDebugProxy/duk_debug.js

@@ -0,0 +1,2473 @@
+/*
+ *  Minimal debug web console for Duktape command line tool
+ *
+ *  See debugger/README.rst.
+ *
+ *  The web UI socket.io communication can easily become a bottleneck and
+ *  it's important to ensure that the web UI remains responsive.  Basic rate
+ *  limiting mechanisms (token buckets, suppressing identical messages, etc)
+ *  are used here now.  Ideally the web UI would pull data on its own terms
+ *  which would provide natural rate limiting.
+ *
+ *  Promises are used to structure callback chains.
+ *
+ *  https://github.com/petkaantonov/bluebird
+ *  https://github.com/petkaantonov/bluebird/blob/master/API.md
+ *  https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns
+ */
+
+var Promise = require('bluebird');
+var events = require('events');
+var stream = require('stream');
+var path = require('path');
+var fs = require('fs');
+var net = require('net');
+var byline = require('byline');
+var util = require('util');
+var readline = require('readline');
+var sprintf = require('sprintf').sprintf;
+var utf8 = require('utf8');
+var wrench = require('wrench');  // https://github.com/ryanmcgrath/wrench-js
+var yaml = require('yamljs');
+
+// Command line options (defaults here, overwritten if necessary)
+var optTargetHost = '127.0.0.1';
+var optTargetPort = 9091;
+var optHttpPort = 9092;
+var optJsonProxyPort = 9093;
+var optJsonProxy = false;
+var optSourceSearchDirs = [ '../tests/ecmascript' ];
+var optDumpDebugRead = null;
+var optDumpDebugWrite = null;
+var optDumpDebugPretty = null;
+var optLogMessages = false;
+
+// Constants
+var UI_MESSAGE_CLIPLEN = 128;
+var LOCALS_CLIPLEN = 64;
+var EVAL_CLIPLEN = 4096;
+var GETVAR_CLIPLEN = 4096;
+
+// Commands initiated by Duktape
+var CMD_STATUS = 0x01;
+var CMD_PRINT = 0x02;
+var CMD_ALERT = 0x03;
+var CMD_LOG = 0x04;
+var CMD_THROW = 0x05;
+var CMD_DETACHING = 0x06;
+
+// Commands initiated by the debug client (= us)
+var CMD_BASICINFO = 0x10;
+var CMD_TRIGGERSTATUS = 0x11;
+var CMD_PAUSE = 0x12;
+var CMD_RESUME = 0x13;
+var CMD_STEPINTO = 0x14;
+var CMD_STEPOVER = 0x15;
+var CMD_STEPOUT = 0x16;
+var CMD_LISTBREAK = 0x17;
+var CMD_ADDBREAK = 0x18;
+var CMD_DELBREAK = 0x19;
+var CMD_GETVAR = 0x1a;
+var CMD_PUTVAR = 0x1b;
+var CMD_GETCALLSTACK = 0x1c;
+var CMD_GETLOCALS = 0x1d;
+var CMD_EVAL = 0x1e;
+var CMD_DETACH = 0x1f;
+var CMD_DUMPHEAP = 0x20;
+var CMD_GETBYTECODE = 0x21;
+
+// Errors
+var ERR_UNKNOWN = 0x00;
+var ERR_UNSUPPORTED = 0x01;
+var ERR_TOOMANY = 0x02;
+var ERR_NOTFOUND = 0x03;
+
+// Marker objects for special protocol values
+var DVAL_EOM = { type: 'eom' };
+var DVAL_REQ = { type: 'req' };
+var DVAL_REP = { type: 'rep' };
+var DVAL_ERR = { type: 'err' };
+var DVAL_NFY = { type: 'nfy' };
+
+// String map for commands (debug dumping).  A single map works (instead of
+// separate maps for each direction) because command numbers don't currently
+// overlap.  So merge the YAML metadata.
+var debugCommandMeta = yaml.load('duk_debugcommands.yaml');
+var debugCommandNames = [];  // list of command names, merged client/target
+debugCommandMeta.target_commands.forEach(function (k, i) {
+    debugCommandNames[i] = k;
+});
+debugCommandMeta.client_commands.forEach(function (k, i) {  // override
+    debugCommandNames[i] = k;
+});
+var debugCommandNumbers = {};  // map from (merged) command name to number
+debugCommandNames.forEach(function (k, i) {
+    debugCommandNumbers[k] = i;
+});
+
+// Duktape heaphdr type constants, must match C headers
+var DUK_HTYPE_STRING = 1;
+var DUK_HTYPE_OBJECT = 2;
+var DUK_HTYPE_BUFFER = 3;
+
+// Duktape internal class numbers, must match C headers
+var dukClassNameMeta = yaml.load('duk_classnames.yaml');
+var dukClassNames = dukClassNameMeta.class_names;
+
+// Bytecode opcode/extraop metadata
+var dukOpcodes = yaml.load('duk_opcodes.yaml');
+if (dukOpcodes.opcodes.length != 64) {
+    throw new Error('opcode metadata length incorrect');
+}
+if (dukOpcodes.extra.length != 256) {
+    throw new Error('extraop metadata length incorrect');
+}
+
+/*
+ *  Miscellaneous helpers
+ */
+
+var nybbles = '0123456789abcdef';
+
+/* Convert a buffer into a string using Unicode codepoints U+0000...U+00FF.
+ * This is the NodeJS 'binary' encoding, but since it's being deprecated,
+ * reimplement it here.  We need to avoid parsing strings as e.g. UTF-8:
+ * although Duktape strings are usually UTF-8/CESU-8 that's not always the
+ * case, e.g. for internal strings.  Buffer values are also represented as
+ * strings in the debug protocol, so we must deal accurately with arbitrary
+ * byte arrays.
+ */
+function bufferToDebugString(buf) {
+    var cp = [];
+    var i, n;
+
+/*
+    // This fails with "RangeError: Maximum call stack size exceeded" for some
+    // reason, so use a much slower variant.
+
+    for (i = 0, n = buf.length; i < n; i++) {
+        cp[i] = buf[i];
+    }
+
+    return String.fromCharCode.apply(String, cp);
+*/
+
+    for (i = 0, n = buf.length; i < n; i++) {
+        cp[i] = String.fromCharCode(buf[i]);
+    }
+
+    return cp.join('');
+}
+
+/* Write a string into a buffer interpreting codepoints U+0000...U+00FF
+ * as bytes.  Drop higher bits.
+ */
+function writeDebugStringToBuffer(str, buf, off) {
+    var i, n;
+
+    for (i = 0, n = str.length; i < n; i++) {
+        buf[off + i] = str.charCodeAt(i) & 0xff;  // truncate higher bits
+    }
+}
+
+/* Encode an ordinary Unicode string into a dvalue compatible format, i.e.
+ * into a byte array represented as codepoints U+0000...U+00FF.  Concretely,
+ * encode with UTF-8 and then represent the bytes with U+0000...U+00FF.
+ */
+function stringToDebugString(str) {
+    return utf8.encode(str);
+}
+
+/* Pretty print a dvalue.  Useful for dumping etc. */
+function prettyDebugValue(x) {
+    if (typeof x === 'object' && x !== null) {
+        if (x.type === 'eom') {
+            return 'EOM';
+        } else if (x.type === 'req') {
+            return 'REQ';
+        } else if (x.type === 'rep') {
+            return 'REP';
+        } else if (x.type === 'err') {
+            return 'ERR';
+        } else if (x.type === 'nfy') {
+            return 'NFY';
+        }
+    }
+    return JSON.stringify(x);
+}
+
+/* Pretty print a number for UI usage.  Types and values should be easy to
+ * read and typing should be obvious.  For numbers, support Infinity, NaN,
+ * and signed zeroes properly.
+ */
+function prettyUiNumber(x) {
+    if (x === 1 / 0) { return 'Infinity'; }
+    if (x === -1 / 0) { return '-Infinity'; }
+    if (Number.isNaN(x)) { return 'NaN'; }
+    if (x === 0 && 1 / x > 0) { return '0'; }
+    if (x === 0 && 1 / x < 0) { return '-0'; }
+    return x.toString();
+}
+
+/* Pretty print a dvalue string (bytes represented as U+0000...U+00FF)
+ * for UI usage.  Try UTF-8 decoding to get a nice Unicode string (JSON
+ * encoded) but if that fails, ensure that bytes are encoded transparently.
+ * The result is a quoted string with a special quote marker for a "raw"
+ * string when UTF-8 decoding fails.  Very long strings are optionally
+ * clipped.
+ */
+function prettyUiString(x, cliplen) {
+    var ret;
+
+    if (typeof x !== 'string') {
+        throw new Error('invalid input to prettyUiString: ' + typeof x);
+    }
+    try {
+        // Here utf8.decode() is better than decoding using NodeJS buffer
+        // operations because we want strict UTF-8 interpretation.
+        ret = JSON.stringify(utf8.decode(x));
+    } catch (e) {
+        // When we fall back to representing bytes, indicate that the string
+        // is "raw" with a 'r"' prefix (a somewhat arbitrary convention).
+        // U+0022 = ", U+0027 = '
+        ret = 'r"' + x.replace(/[\u0022\u0027\u0000-\u001f\u0080-\uffff]/g, function (match) {
+            var cp = match.charCodeAt(0);
+            return '\\x' + nybbles[(cp >> 4) & 0x0f] + nybbles[cp & 0x0f];
+        }) + '"';
+    }
+
+    if (cliplen && ret.length > cliplen) {
+        ret = ret.substring(0, cliplen) + '...';  // trailing '"' intentionally missing
+    }
+    return ret;
+}
+
+/* Pretty print a dvalue string (bytes represented as U+0000...U+00FF)
+ * for UI usage without quotes.
+ */
+function prettyUiStringUnquoted(x, cliplen) {
+    var ret;
+
+    if (typeof x !== 'string') {
+        throw new Error('invalid input to prettyUiStringUnquoted: ' + typeof x);
+    }
+
+    try {
+        // Here utf8.decode() is better than decoding using NodeJS buffer
+        // operations because we want strict UTF-8 interpretation.
+
+        // XXX: unprintable characters etc?  In some UI cases we'd want to
+        // e.g. escape newlines and in others not.
+        ret = utf8.decode(x);
+    } catch (e) {
+        // For the unquoted version we don't need to escape single or double
+        // quotes.
+        ret = x.replace(/[\u0000-\u001f\u0080-\uffff]/g, function (match) {
+            var cp = match.charCodeAt(0);
+            return '\\x' + nybbles[(cp >> 4) & 0x0f] + nybbles[cp & 0x0f];
+        });
+    }
+
+    if (cliplen && ret.length > cliplen) {
+        ret = ret.substring(0, cliplen) + '...';
+    }
+    return ret;
+}
+
+/* Pretty print a dvalue for UI usage.  Everything comes out as a ready-to-use
+ * string.
+ *
+ * XXX: Currently the debug client formats all values for UI use.  A better
+ * solution would be to pass values in typed form and let the UI format them,
+ * so that styling etc. could take typing into account.
+ */
+function prettyUiDebugValue(x, cliplen) {
+    if (typeof x === 'object' && x !== null) {
+        // Note: typeof null === 'object', so null special case explicitly
+        if (x.type === 'eom') {
+            return 'EOM';
+        } else if (x.type === 'req') {
+            return 'REQ';
+        } else if (x.type === 'rep') {
+            return 'REP';
+        } else if (x.type === 'err') {
+            return 'ERR';
+        } else if (x.type === 'nfy') {
+            return 'NFY';
+        } else if (x.type === 'unused') {
+            return 'unused';
+        } else if (x.type === 'undefined') {
+            return 'undefined';
+        } else if (x.type === 'buffer') {
+            return '|' + x.data + '|';
+        } else if (x.type === 'object') {
+            return '[object ' + (dukClassNames[x.class] || ('class ' + x.class)) + ' ' + x.pointer + ']';
+        } else if (x.type === 'pointer') {
+            return '<pointer ' + x.pointer + '>';
+        } else if (x.type === 'lightfunc') {
+            return '<lightfunc 0x' + x.flags.toString(16) + ' ' + x.pointer + '>';
+        } else if (x.type === 'number') {
+            // duk_tval number, any IEEE double
+            var tmp = new Buffer(x.data, 'hex');  // decode into hex
+            var val = tmp.readDoubleBE(0);        // big endian ieee double
+            return prettyUiNumber(val);
+        }
+    } else if (x === null) {
+        return 'null';
+    } else if (typeof x === 'boolean') {
+        return x ? 'true' : 'false';
+    } else if (typeof x === 'string') {
+        return prettyUiString(x, cliplen);
+    } else if (typeof x === 'number') {
+        // Debug protocol integer
+        return prettyUiNumber(x);
+    }
+
+    // We shouldn't come here, but if we do, JSON is a reasonable default.
+    return JSON.stringify(x);
+}
+
+/* Pretty print a debugger message given as an array of parsed dvalues.
+ * Result should be a pure ASCII one-liner.
+ */
+function prettyDebugMessage(msg) {
+    return msg.map(prettyDebugValue).join(' ');
+}
+
+/* Pretty print a debugger command. */
+function prettyDebugCommand(cmd) {
+    return debugCommandNames[cmd] || String(cmd);
+}
+
+/* Decode and normalize source file contents: UTF-8, tabs to 8,
+ * CR LF to LF.
+ */
+function decodeAndNormalizeSource(data) {
+    var tmp;
+    var lines, line, repl;
+    var i, n;
+    var j, m;
+
+    try {
+        tmp = data.toString('utf8');
+    } catch (e) {
+        console.log('Failed to UTF-8 decode source file, ignoring: ' + e);
+        tmp = String(data);
+    }
+
+    lines = tmp.split(/\r?\n/);
+    for (i = 0, n = lines.length; i < n; i++) {
+        line = lines[i];
+        if (/\t/.test(line)) {
+            repl = '';
+            for (j = 0, m = line.length; j < m; j++) {
+                if (line.charAt(j) === '\t') {
+                    repl += ' ';
+                    while ((repl.length % 8) != 0) {
+                        repl += ' ';
+                    }
+                } else {
+                    repl += line.charAt(j);
+                }
+            }
+            lines[i] = repl;
+        }
+    }
+
+    // XXX: normalize last newline (i.e. force a newline if contents don't
+    // end with a newline)?
+
+    return lines.join('\n');
+}
+
+/* Token bucket rate limiter for a given callback.  Calling code calls
+ * trigger() to request 'cb' to be called, and the rate limiter ensures
+ * that 'cb' is not called too often.
+ */
+function RateLimited(tokens, rate, cb) {
+    var _this = this;
+    this.maxTokens = tokens;
+    this.tokens = this.maxTokens;
+    this.rate = rate;
+    this.cb = cb;
+    this.delayedCb = false;
+
+    // Right now the implementation is setInterval-based, but could also be
+    // made timerless.  There are so few rate limited resources that this
+    // doesn't matter in practice.
+
+    this.tokenAdder = setInterval(function () {
+        if (_this.tokens < _this.maxTokens) {
+            _this.tokens++;
+        }
+        if (_this.delayedCb) {
+            _this.delayedCb = false;
+            _this.tokens--;
+            _this.cb();
+        }
+    }, this.rate);
+}
+RateLimited.prototype.trigger = function () {
+    if (this.tokens > 0) {
+        this.tokens--;
+        this.cb();
+    } else {
+        this.delayedCb = true;
+    }
+};
+
+/*
+ *  Source file manager
+ *
+ *  Scan the list of search directories for Ecmascript source files and
+ *  build an index of them.  Provides a mechanism to find a source file
+ *  based on a raw 'fileName' property provided by the debug target, and
+ *  to provide a file list for the web UI.
+ *
+ *  NOTE: it's tempting to do loose matching for filenames, but this does
+ *  not work in practice.  Filenames must match 1:1 with the debug target
+ *  so that e.g. breakpoints assigned based on filenames found from the
+ *  search paths will match 1:1 on the debug target.  If this is not the
+ *  case, breakpoints won't work as expected.
+ */
+
+function SourceFileManager(directories) {
+    this.directories = directories;
+    this.extensions = { '.js': true, '.jsm': true };
+    this.files;
+}
+
+SourceFileManager.prototype.scan = function () {
+    var _this = this;
+    var fileMap = {};   // absFn -> true
+    var files;
+
+    this.directories.forEach(function (dir) {
+        console.log('Scanning source files: ' + dir);
+        try {
+            wrench.readdirSyncRecursive(dir).forEach(function (fn) {
+                var absFn = path.normalize(path.join(dir, fn));   // './foo/bar.js' -> 'foo/bar.js'
+                var ent;
+
+                if (fs.existsSync(absFn) &&
+                    fs.lstatSync(absFn).isFile() &&
+                    _this.extensions[path.extname(fn)]) {
+                    // We want the fileMap to contain the filename relative to
+                    // the search dir root.
+                    fileMap[fn] = true;
+                }
+            });
+        } catch (e) {
+            console.log('Failed to scan ' + dir + ': ' + e);
+        }
+    });
+
+    files = Object.keys(fileMap);
+    files.sort();
+    this.files = files;
+
+    console.log('Found ' + files.length + ' source files in ' + this.directories.length + ' search directories');
+};
+
+SourceFileManager.prototype.getFiles = function () {
+    return this.files;
+};
+
+SourceFileManager.prototype.search = function (fileName) {
+    var _this = this;
+
+    // Loose matching is tempting but counterproductive: filenames must
+    // match 1:1 between the debug client and the debug target for e.g.
+    // breakpoints to work as expected.  Note that a breakpoint may be
+    // assigned by selecting a file from a dropdown populated by scanning
+    // the filesystem for available sources and there's no way of knowing
+    // if the debug target uses the exact same name.
+
+    function tryLookup() {
+        var i, fn, data;
+
+        for (i = 0; i < _this.directories.length; i++) {
+            fn = path.join(_this.directories[i], fileName);
+            if (fs.existsSync(fn) && fs.lstatSync(fn).isFile()) {
+                data = fs.readFileSync(fn);             // Raw bytes
+                return decodeAndNormalizeSource(data);  // Unicode string
+            }
+        }
+        return null;
+    }
+
+    return tryLookup(fileName);
+};
+
+/*
+ *  Debug protocol parser
+ *
+ *  The debug protocol parser is an EventEmitter which parses debug messages
+ *  from an input stream and emits 'debug-message' events for completed
+ *  messages ending in an EOM.  The parser also provides debug dumping, stream
+ *  logging functionality, and statistics gathering functionality.
+ *
+ *  This parser is used to parse both incoming and outgoing messages.  For
+ *  outgoing messages the only function is to validate and debug dump the
+ *  messages we're about to send.  The downside of dumping at this low level
+ *  is that we can't match request and reply/error messages here.
+ *
+ *  http://www.sitepoint.com/nodejs-events-and-eventemitter/
+ */
+
+function DebugProtocolParser(inputStream,
+                             protocolVersion,
+                             rawDumpFileName,
+                             textDumpFileName,
+                             textDumpFilePrefix,
+                             hexDumpConsolePrefix,
+                             textDumpConsolePrefix) {
+    var _this = this;
+    this.inputStream = inputStream;
+    this.closed = false;       // stream is closed/broken, don't parse anymore
+    this.bytes = 0;
+    this.dvalues = 0;
+    this.messages = 0;
+    this.requests = 0;
+    this.prevBytes = 0;
+    this.bytesPerSec = 0;
+    this.statsTimer = null;
+    this.readableNumberValue = true;
+
+    events.EventEmitter.call(this);
+
+    var buf = new Buffer(0);    // accumulate data
+    var msg = [];               // accumulated message until EOM
+    var versionIdentification;
+
+    var statsInterval = 2000;
+    var statsIntervalSec = statsInterval / 1000;
+    this.statsTimer = setInterval(function () {
+        _this.bytesPerSec = (_this.bytes - _this.prevBytes) / statsIntervalSec;
+        _this.prevBytes = _this.bytes;
+        _this.emit('stats-update');
+    }, statsInterval);
+
+    function consume(n) {
+        var tmp = new Buffer(buf.length - n);
+        buf.copy(tmp, 0, n);
+        buf = tmp;
+    }
+
+    inputStream.on('data', function (data) {
+        var i, n, x, v, gotValue, len, t, tmpbuf, verstr;
+        var prettyMsg;
+
+        if (_this.closed || !_this.inputStream) {
+            console.log('Ignoring incoming data from closed input stream, len ' + data.length);
+            return;
+        }
+
+        _this.bytes += data.length;
+        if (rawDumpFileName) {
+            fs.appendFileSync(rawDumpFileName, data);
+        }
+        if (hexDumpConsolePrefix) {
+            console.log(hexDumpConsolePrefix + data.toString('hex'));
+        }
+
+        buf = Buffer.concat([ buf, data ]);
+
+        // Protocol version handling.  When dumping an output stream, the
+        // caller gives a non-null protocolVersion so we don't read one here.
+        if (protocolVersion == null) {
+            if (buf.length > 1024) {
+                _this.emit('transport-error', 'Parse error (version identification too long), dropping connection');
+                _this.close();
+                return;
+            }
+
+            for (i = 0, n = buf.length; i < n; i++) {
+                if (buf[i] == 0x0a) {
+                    tmpbuf = new Buffer(i);
+                    buf.copy(tmpbuf, 0, 0, i);
+                    consume(i + 1);
+                    verstr = tmpbuf.toString('utf-8');
+                    t = verstr.split(' ');
+                    protocolVersion = Number(t[0]);
+                    versionIdentification = verstr;
+
+                    _this.emit('protocol-version', {
+                        protocolVersion: protocolVersion,
+                        versionIdentification: versionIdentification
+                    });
+                    break;
+                }
+            }
+
+            if (protocolVersion == null) {
+                // Still waiting for version identification to complete.
+                return;
+            }
+        }
+
+        // Parse complete dvalues (quite inefficient now) by trial parsing.
+        // Consume a value only when it's fully present in 'buf'.
+        // See doc/debugger.rst for format description.
+
+        while (buf.length > 0) {
+            x = buf[0];
+            v = undefined;
+            gotValue = false;  // used to flag special values like undefined
+
+            if (x >= 0xc0) {
+                // 0xc0...0xff: integers 0-16383
+                if (buf.length >= 2) {
+                    v = ((x - 0xc0) << 8) + buf[1];
+                    consume(2);
+                }
+            } else if (x >= 0x80) {
+                // 0x80...0xbf: integers 0-63
+                v = x - 0x80;
+                consume(1);
+            } else if (x >= 0x60) {
+                // 0x60...0x7f: strings with length 0-31
+                len = x - 0x60;
+                if (buf.length >= 1 + len) {
+                    v = new Buffer(len);
+                    buf.copy(v, 0, 1, 1 + len);
+                    v = bufferToDebugString(v);
+                    consume(1 + len);
+                }
+            } else {
+                switch (x) {
+                case 0x00: v = DVAL_EOM; consume(1); break;
+                case 0x01: v = DVAL_REQ; consume(1); break;
+                case 0x02: v = DVAL_REP; consume(1); break;
+                case 0x03: v = DVAL_ERR; consume(1); break;
+                case 0x04: v = DVAL_NFY; consume(1); break;
+                case 0x10:  // 4-byte signed integer
+                    if (buf.length >= 5) {
+                        v = buf.readInt32BE(1);
+                        consume(5);
+                    }
+                    break;
+                case 0x11:  // 4-byte string
+                    if (buf.length >= 5) {
+                        len = buf.readUInt32BE(1);
+                        if (buf.length >= 5 + len) {
+                            v = new Buffer(len);
+                            buf.copy(v, 0, 5, 5 + len);
+                            v = bufferToDebugString(v);
+                            consume(5 + len);
+                        }
+                    }
+                    break;
+                case 0x12:  // 2-byte string
+                    if (buf.length >= 3) {
+                        len = buf.readUInt16BE(1);
+                        if (buf.length >= 3 + len) {
+                            v = new Buffer(len);
+                            buf.copy(v, 0, 3, 3 + len);
+                            v = bufferToDebugString(v);
+                            consume(3 + len);
+                        }
+                    }
+                    break;
+                case 0x13:  // 4-byte buffer
+                    if (buf.length >= 5) {
+                        len = buf.readUInt32BE(1);
+                        if (buf.length >= 5 + len) {
+                            v = new Buffer(len);
+                            buf.copy(v, 0, 5, 5 + len);
+                            v = { type: 'buffer', data: v.toString('hex') };
+                            consume(5 + len);
+                            // Value could be a Node.js buffer directly, but
+                            // we prefer all dvalues to be JSON compatible
+                        }
+                    }
+                    break;
+                case 0x14:  // 2-byte buffer
+                    if (buf.length >= 3) {
+                        len = buf.readUInt16BE(1);
+                        if (buf.length >= 3 + len) {
+                            v = new Buffer(len);
+                            buf.copy(v, 0, 3, 3 + len);
+                            v = { type: 'buffer', data: v.toString('hex') };
+                            consume(3 + len);
+                            // Value could be a Node.js buffer directly, but
+                            // we prefer all dvalues to be JSON compatible
+                        }
+                    }
+                    break;
+                case 0x15:  // unused/none
+                    v = { type: 'unused' };
+                    consume(1);
+                    break;
+                case 0x16:  // undefined
+                    v = { type: 'undefined' };
+                    gotValue = true;  // indicate 'v' is actually set
+                    consume(1);
+                    break;
+                case 0x17:  // null
+                    v = null;
+                    gotValue = true;  // indicate 'v' is actually set
+                    consume(1);
+                    break;
+                case 0x18:  // true
+                    v = true;
+                    consume(1);
+                    break;
+                case 0x19:  // false
+                    v = false;
+                    consume(1);
+                    break;
+                case 0x1a:  // number (IEEE double), big endian
+                    if (buf.length >= 9) {
+                        v = new Buffer(8);
+                        buf.copy(v, 0, 1, 9);
+                        v = { type: 'number', data: v.toString('hex') };
+
+                        if (_this.readableNumberValue) {
+                            // The value key should not be used programmatically,
+                            // it is just there to make the dumps more readable.
+                            v.value = buf.readDoubleBE(1);
+                        }
+                        consume(9);
+                    }
+                    break;
+                case 0x1b:  // object
+                    if (buf.length >= 3) {
+                        len = buf[2];
+                        if (buf.length >= 3 + len) {
+                            v = new Buffer(len);
+                            buf.copy(v, 0, 3, 3 + len);
+                            v = { type: 'object', 'class': buf[1], pointer: v.toString('hex') };
+                            consume(3 + len);
+                        }
+                    }
+                    break;
+                case 0x1c:  // pointer
+                    if (buf.length >= 2) {
+                        len = buf[1];
+                        if (buf.length >= 2 + len) {
+                            v = new Buffer(len);
+                            buf.copy(v, 0, 2, 2 + len);
+                            v = { type: 'pointer', pointer: v.toString('hex') };
+                            consume(2 + len);
+                        }
+                    }
+                    break;
+                case 0x1d:  // lightfunc
+                    if (buf.length >= 4) {
+                        len = buf[3];
+                        if (buf.length >= 4 + len) {
+                            v = new Buffer(len);
+                            buf.copy(v, 0, 4, 4 + len);
+                            v = { type: 'lightfunc', flags: buf.readUInt16BE(1), pointer: v.toString('hex') };
+                            consume(4 + len);
+                        }
+                    }
+                    break;
+                case 0x1e:  // heapptr
+                    if (buf.length >= 2) {
+                        len = buf[1];
+                        if (buf.length >= 2 + len) {
+                            v = new Buffer(len);
+                            buf.copy(v, 0, 2, 2 + len);
+                            v = { type: 'heapptr', pointer: v.toString('hex') };
+                            consume(2 + len);
+                        }
+                    }
+                    break;
+                default:
+                    _this.emit('transport-error', 'Parse error, dropping connection');
+                    _this.close();
+                }
+            }
+
+            if (typeof v === 'undefined' && !gotValue) {
+                break;
+            }
+            msg.push(v);
+            _this.dvalues++;
+
+            // Could emit a 'debug-value' event here, but that's not necessary
+            // because the receiver will just collect statistics which can also
+            // be done using the finished message.
+
+            if (v === DVAL_EOM) {
+                _this.messages++;
+
+                if (textDumpFileName || textDumpConsolePrefix) {
+                    prettyMsg = prettyDebugMessage(msg);
+                    if (textDumpFileName) {
+                        fs.appendFileSync(textDumpFileName, (textDumpFilePrefix || '') + prettyMsg + '\n');
+                    }
+                    if (textDumpConsolePrefix) {
+                        console.log(textDumpConsolePrefix + prettyMsg);
+                    }
+                }
+
+                _this.emit('debug-message', msg);
+                msg = [];  // new object, old may be in circulation for a while
+            }
+        }
+    });
+
+    // Not all streams will emit this.
+    inputStream.on('error', function (err) {
+        _this.emit('transport-error', err);
+        _this.close();
+    });
+
+    // Not all streams will emit this.
+    inputStream.on('close', function () {
+        _this.close();
+    });
+}
+DebugProtocolParser.prototype = Object.create(events.EventEmitter.prototype);
+
+DebugProtocolParser.prototype.close = function () {
+    // Although the underlying transport may not have a close() or destroy()
+    // method or even a 'close' event, this method is always available and
+    // will generate a 'transport-close'.
+    //
+    // The caller is responsible for closing the underlying stream if that
+    // is necessary.
+
+    if (this.closed) { return; }
+
+    this.closed = true;
+    if (this.statsTimer) {
+        clearInterval(this.statsTimer);
+        this.statsTimer = null;
+    }
+    this.emit('transport-close');
+};
+
+/*
+ *  Debugger output formatting
+ */
+
+function formatDebugValue(v) {
+    var buf, dec, len;
+
+    // See doc/debugger.rst for format description.
+
+    if (typeof v === 'object' && v !== null) {
+        // Note: typeof null === 'object', so null special case explicitly
+        if (v.type === 'eom') {
+            return new Buffer([ 0x00 ]);
+        } else if (v.type === 'req') {
+            return new Buffer([ 0x01 ]);
+        } else if (v.type === 'rep') {
+            return new Buffer([ 0x02 ]);
+        } else if (v.type === 'err') {
+            return new Buffer([ 0x03 ]);
+        } else if (v.type === 'nfy') {
+            return new Buffer([ 0x04 ]);
+        } else if (v.type === 'unused') {
+            return new Buffer([ 0x15 ]);
+        } else if (v.type === 'undefined') {
+            return new Buffer([ 0x16 ]);
+        } else if (v.type === 'number') {
+            dec = new Buffer(v.data, 'hex');
+            len = dec.length;
+            if (len !== 8) {
+                throw new TypeError('value cannot be converted to dvalue: ' + JSON.stringify(v));
+            }
+            buf = new Buffer(1 + len);
+            buf[0] = 0x1a;
+            dec.copy(buf, 1);
+            return buf;
+        } else if (v.type === 'buffer') {
+            dec = new Buffer(v.data, 'hex');
+            len = dec.length;
+            if (len <= 0xffff) {
+                buf = new Buffer(3 + len);
+                buf[0] = 0x14;
+                buf[1] = (len >> 8) & 0xff;
+                buf[2] = (len >> 0) & 0xff;
+                dec.copy(buf, 3);
+                return buf;
+            } else {
+                buf = new Buffer(5 + len);
+                buf[0] = 0x13;
+                buf[1] = (len >> 24) & 0xff;
+                buf[2] = (len >> 16) & 0xff;
+                buf[3] = (len >> 8) & 0xff;
+                buf[4] = (len >> 0) & 0xff;
+                dec.copy(buf, 5);
+                return buf;
+            }
+        } else if (v.type === 'object') {
+            dec = new Buffer(v.pointer, 'hex');
+            len = dec.length;
+            buf = new Buffer(3 + len);
+            buf[0] = 0x1b;
+            buf[1] = v.class;
+            buf[2] = len;
+            dec.copy(buf, 3);
+            return buf;
+        } else if (v.type === 'pointer') {
+            dec = new Buffer(v.pointer, 'hex');
+            len = dec.length;
+            buf = new Buffer(2 + len);
+            buf[0] = 0x1c;
+            buf[1] = len;
+            dec.copy(buf, 2);
+            return buf;
+        } else if (v.type === 'lightfunc') {
+            dec = new Buffer(v.pointer, 'hex');
+            len = dec.length;
+            buf = new Buffer(4 + len);
+            buf[0] = 0x1d;
+            buf[1] = (v.flags >> 8) & 0xff;
+            buf[2] = v.flags & 0xff;
+            buf[3] = len;
+            dec.copy(buf, 4);
+            return buf;
+        } else if (v.type === 'heapptr') {
+            dec = new Buffer(v.pointer, 'hex');
+            len = dec.length;
+            buf = new Buffer(2 + len);
+            buf[0] = 0x1e;
+            buf[1] = len;
+            dec.copy(buf, 2);
+            return buf;
+        }
+    } else if (v === null) {
+        return new Buffer([ 0x17 ]);
+    } else if (typeof v === 'boolean') {
+        return new Buffer([ v ? 0x18 : 0x19 ]);
+    } else if (typeof v === 'number') {
+        if (Math.floor(v) === v &&     /* whole */
+            (v !== 0 || 1 / v > 0) &&  /* not negative zero */
+            v >= -0x80000000 && v <= 0x7fffffff) {
+            // Represented signed 32-bit integers as plain integers.
+            // Debugger code expects this for all fields that are not
+            // duk_tval representations (e.g. command numbers and such).
+            if (v >= 0x00 && v <= 0x3f) {
+                return new Buffer([ 0x80 + v ]);
+            } else if (v >= 0x0000 && v <= 0x3fff) {
+                return new Buffer([ 0xc0 + (v >> 8), v & 0xff ]);
+            } else if (v >= -0x80000000 && v <= 0x7fffffff) {
+                return new Buffer([ 0x10,
+                                    (v >> 24) & 0xff,
+                                    (v >> 16) & 0xff,
+                                    (v >> 8) & 0xff,
+                                    (v >> 0) & 0xff ]);
+            } else {
+                throw new Error('internal error when encoding integer to dvalue: ' + v);
+            }
+        } else {
+            // Represent non-integers as IEEE double dvalues
+            buf = new Buffer(1 + 8);
+            buf[0] = 0x1a;
+            buf.writeDoubleBE(v, 1);
+            return buf;
+        }
+    } else if (typeof v === 'string') {
+        if (v.length < 0 || v.length > 0xffffffff) {
+            // Not possible in practice.
+            throw new TypeError('cannot convert to dvalue, invalid string length: ' + v.length);
+        }
+        if (v.length <= 0x1f) {
+            buf = new Buffer(1 + v.length);
+            buf[0] = 0x60 + v.length;
+            writeDebugStringToBuffer(v, buf, 1);
+            return buf;
+        } else if (v.length <= 0xffff) {
+            buf = new Buffer(3 + v.length);
+            buf[0] = 0x12;
+            buf[1] = (v.length >> 8) & 0xff;
+            buf[2] = (v.length >> 0) & 0xff;
+            writeDebugStringToBuffer(v, buf, 3);
+            return buf;
+        } else {
+            buf = new Buffer(5 + v.length);
+            buf[0] = 0x11;
+            buf[1] = (v.length >> 24) & 0xff;
+            buf[2] = (v.length >> 16) & 0xff;
+            buf[3] = (v.length >> 8) & 0xff;
+            buf[4] = (v.length >> 0) & 0xff;
+            writeDebugStringToBuffer(v, buf, 5);
+            return buf;
+        }
+    }
+
+    // Shouldn't come here.
+    throw new TypeError('value cannot be converted to dvalue: ' + JSON.stringify(v));
+}
+
+/*
+ *  Debugger implementation
+ *
+ *  A debugger instance communicates with the debug target and maintains
+ *  persistent debug state so that the current state can be resent to the
+ *  socket.io client (web UI) if it reconnects.  Whenever the debugger state
+ *  is changed an event is generated.  The socket.io handler will listen to
+ *  state change events and push the necessary updates to the web UI, often
+ *  in a rate limited fashion or using a client pull to ensure the web UI
+ *  is not overloaded.
+ *
+ *  The debugger instance assumes that if the debug protocol connection is
+ *  re-established, it is always to the same target.  There is no separate
+ *  abstraction for a debugger session.
+ */
+
+function Debugger() {
+    events.EventEmitter.call(this);
+
+    this.web = null;                      // web UI singleton
+    this.targetStream = null;             // transport connection to target
+    this.outputPassThroughStream = null;  // dummy passthrough for message dumping
+    this.inputParser = null;              // parser for incoming debug messages
+    this.outputParser = null;             // parser for outgoing debug messages (stats, dumping)
+    this.protocolVersion = null;
+    this.dukVersion = null;
+    this.dukGitDescribe = null;
+    this.targetInfo = null;
+    this.attached = false;
+    this.handshook = false;
+    this.reqQueue = null;
+    this.stats = {                        // stats for current debug connection
+        rxBytes: 0, rxDvalues: 0, rxMessages: 0, rxBytesPerSec: 0,
+        txBytes: 0, txDvalues: 0, txMessages: 0, txBytesPerSec: 0
+    };
+    this.execStatus = {
+        attached: false,
+        state: 'detached',
+        fileName: '',
+        funcName: '',
+        line: 0,
+        pc: 0
+    };
+    this.breakpoints = [];
+    this.callstack = [];
+    this.locals = [];
+    this.messageLines = [];
+    this.messageScrollBack = 100;
+}
+Debugger.prototype = events.EventEmitter.prototype;
+
+Debugger.prototype.decodeBytecodeFromBuffer = function (buf, consts, funcs) {
+    var i, j, n, m, ins, pc;
+    var res = [];
+    var op, str, args, comments;
+
+    // XXX: add constants inline to preformatted output (e.g. for strings,
+    // add a short escaped snippet as a comment on the line after the
+    // compact argument list).
+
+    for (i = 0, n = buf.length; i < n; i += 4) {
+        pc = i / 4;
+
+        // shift forces unsigned
+        if (this.endianness === 'little') {
+            ins = buf.readInt32LE(i) >>> 0;
+        } else {
+            ins = buf.readInt32BE(i) >>> 0;
+        }
+
+        op = dukOpcodes.opcodes[ins & 0x3f];
+        if (op.extra) {
+            op = dukOpcodes.extra[(ins >> 6) & 0xff];
+        }
+
+        args = [];
+        comments = [];
+        if (op.args) {
+            for (j = 0, m = op.args.length; j < m; j++) {
+                switch (op.args[j]) {
+                case 'A_R':   args.push('r' + ((ins >>> 6) & 0xff)); break;
+                case 'A_RI':  args.push('r' + ((ins >>> 6) & 0xff) + '(indirect)'); break;
+                case 'A_C':   args.push('c' + ((ins >>> 6) & 0xff)); break;
+                case 'A_H':   args.push('0x' + ((ins >>> 6) & 0xff).toString(16)); break;
+                case 'A_I':   args.push(((ins >>> 6) & 0xff).toString(10)); break;
+                case 'A_B':   args.push(((ins >>> 6) & 0xff) ? 'true' : 'false'); break;
+                case 'B_RC':  args.push((ins & (1 << 22) ? 'c' : 'r') + ((ins >>> 14) & 0x0ff)); break;
+                case 'B_R':   args.push('r' + ((ins >>> 14) & 0x1ff)); break;
+                case 'B_RI':  args.push('r' + ((ins >>> 14) & 0x1ff) + '(indirect)'); break;
+                case 'B_C':   args.push('c' + ((ins >>> 14) & 0x1ff)); break;
+                case 'B_H':   args.push('0x' + ((ins >>> 14) & 0x1ff).toString(16)); break;
+                case 'B_I':   args.push(((ins >>> 14) & 0x1ff).toString(10)); break;
+                case 'C_RC':  args.push((ins & (1 << 31) ? 'c' : 'r') + ((ins >>> 23) & 0x0ff)); break;
+                case 'C_R':   args.push('r' + ((ins >>> 23) & 0x1ff)); break;
+                case 'C_RI':  args.push('r' + ((ins >>> 23) & 0x1ff) + '(indirect)'); break;
+                case 'C_C':   args.push('c' + ((ins >>> 23) & 0x1ff)); break;
+                case 'C_H':   args.push('0x' + ((ins >>> 23) & 0x1ff).toString(16)); break;
+                case 'C_I':   args.push(((ins >>> 23) & 0x1ff).toString(10)); break;
+                case 'BC_R':  args.push('r' + ((ins >>> 14) & 0x3ffff)); break;
+                case 'BC_C':  args.push('c' + ((ins >>> 14) & 0x3ffff)); break;
+                case 'BC_H':  args.push('0x' + ((ins >>> 14) & 0x3ffff).toString(16)); break;
+                case 'BC_I':  args.push(((ins >>> 14) & 0x3ffff).toString(10)); break;
+                case 'ABC_H': args.push(((ins >>> 6) & 0x03ffffff).toString(16)); break;
+                case 'ABC_I': args.push(((ins >>> 6) & 0x03ffffff).toString(10)); break;
+                case 'BC_LDINT': args.push(((ins >>> 14) & 0x3ffff) - (1 << 17)); break;
+                case 'BC_LDINTX': args.push(((ins >>> 14) & 0x3ffff) - 0); break;  // no bias in LDINTX
+                case 'ABC_JUMP': {
+                    var pc_add = ((ins >>> 6) & 0x03ffffff) - (1 << 25) + 1;  // pc is preincremented before adding
+                    var pc_dst = pc + pc_add;
+                    args.push(pc_dst + ' (' + (pc_add >= 0 ? '+' : '') + pc_add + ')');
+                    break;
+                }
+                default:      args.push('?'); break;
+                }
+            }
+        }
+        if (op.flags) {
+            for (j = 0, m = op.flags.length; j < m; j++) {
+                if (ins & op.flags[j].mask) {
+                    comments.push(op.flags[j].name);
+                }
+            }
+        }
+
+        if (args.length > 0) {
+            str = sprintf('%05d %08x   %-10s %s', pc, ins, op.name, args.join(', '));
+        } else {
+            str = sprintf('%05d %08x   %-10s', pc, ins, op.name);
+        }
+        if (comments.length > 0) {
+            str = sprintf('%-44s ; %s', str, comments.join(', '));
+        }
+
+        res.push({
+            str: str,
+            ins: ins
+        });
+    }
+
+    return res;
+};
+
+Debugger.prototype.uiMessage = function (type, val) {
+    var msg;
+    if (typeof type === 'object') {
+        msg = type;
+    } else if (typeof type === 'string') {
+        msg = { type: type, message: val };
+    } else {
+        throw new TypeError('invalid ui message: ' + type);
+    }
+    this.messageLines.push(msg);
+    while (this.messageLines.length > this.messageScrollBack) {
+        this.messageLines.shift();
+    }
+    this.emit('ui-message-update');  // just trigger a sync, gets rate limited
+};
+
+Debugger.prototype.sendRequest = function (msg) {
+    var _this = this;
+    return new Promise(function (resolve, reject) {
+        var dvals = [];
+        var dval;
+        var data;
+        var i;
+
+        if (!_this.attached || !_this.handshook || !_this.reqQueue || !_this.targetStream) {
+            throw new Error('invalid state for sendRequest');
+        }
+
+        for (i = 0; i < msg.length; i++) {
+            try {
+                dval = formatDebugValue(msg[i]);
+            } catch (e) {
+                console.log('Failed to format dvalue, dropping connection: ' + e);
+                console.log(e.stack || e);
+                _this.targetStream.destroy();
+                throw new Error('failed to format dvalue');
+            }
+            dvals.push(dval);
+        }
+
+        data = Buffer.concat(dvals);
+
+        _this.targetStream.write(data);
+        _this.outputPassThroughStream.write(data);  // stats and dumping
+
+        if (optLogMessages) {
+            console.log('Request ' + prettyDebugCommand(msg[1]) + ': ' + prettyDebugMessage(msg));
+        }
+
+        if (!_this.reqQueue) {
+            throw new Error('no reqQueue');
+        }
+
+        _this.reqQueue.push({
+            reqMsg: msg,
+            reqCmd: msg[1],
+            resolveCb: resolve,
+            rejectCb: reject
+        });
+    });
+};
+
+Debugger.prototype.sendBasicInfoRequest = function () {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_BASICINFO, DVAL_EOM ]).then(function (msg) {
+        _this.dukVersion = msg[1];
+        _this.dukGitDescribe = msg[2];
+        _this.targetInfo = msg[3];
+        _this.endianness = { 1: 'little', 2: 'mixed', 3: 'big' }[msg[4]] || 'unknown';
+        _this.emit('basic-info-update');
+        return msg;
+    });
+};
+
+Debugger.prototype.sendGetVarRequest = function (varname, level) {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_GETVAR, varname, (typeof level === 'number' ? level : -1), DVAL_EOM ]).then(function (msg) {
+        return { found: msg[1] === 1, value: msg[2] };
+    });
+};
+
+Debugger.prototype.sendPutVarRequest = function (varname, varvalue, level) {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_PUTVAR, varname, varvalue, (typeof level === 'number' ? level : -1), DVAL_EOM ]);
+};
+
+Debugger.prototype.sendInvalidCommandTestRequest = function () {
+    // Intentional invalid command
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, 0xdeadbeef, DVAL_EOM ]);
+};
+
+Debugger.prototype.sendStatusRequest = function () {
+    // Send a status request to trigger a status notify, result is ignored:
+    // target sends a status notify instead of a meaningful reply
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_TRIGGERSTATUS, DVAL_EOM ]);
+};
+
+Debugger.prototype.sendBreakpointListRequest = function () {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_LISTBREAK, DVAL_EOM ]).then(function (msg) {
+        var i, n;
+        var breakpts = [];
+
+        for (i = 1, n = msg.length - 1; i < n; i += 2) {
+            breakpts.push({ fileName: msg[i], lineNumber: msg[i + 1] });
+        }
+
+        _this.breakpoints = breakpts;
+        _this.emit('breakpoints-update');
+        return msg;
+    });
+};
+
+Debugger.prototype.sendGetLocalsRequest = function (level) {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_GETLOCALS, (typeof level === 'number' ? level : -1), DVAL_EOM ]).then(function (msg) {
+        var i;
+        var locals = [];
+
+        for (i = 1; i <= msg.length - 2; i += 2) {
+            // XXX: do pretty printing in debug client for now
+            locals.push({ key: msg[i], value: prettyUiDebugValue(msg[i + 1], LOCALS_CLIPLEN) });
+        }
+
+        _this.locals = locals;
+        _this.emit('locals-update');
+        return msg;
+    });
+};
+
+Debugger.prototype.sendGetCallStackRequest = function () {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_GETCALLSTACK, DVAL_EOM ]).then(function (msg) {
+        var i;
+        var stack = [];
+
+        for (i = 1; i + 3 <= msg.length - 1; i += 4) {
+            stack.push({
+                fileName: msg[i],
+                funcName: msg[i + 1],
+                lineNumber: msg[i + 2],
+                pc: msg[i + 3]
+            });
+        }
+
+        _this.callstack = stack;
+        _this.emit('callstack-update');
+        return msg;
+    });
+};
+
+Debugger.prototype.sendStepIntoRequest = function () {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_STEPINTO, DVAL_EOM ]);
+};
+
+Debugger.prototype.sendStepOverRequest = function () {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_STEPOVER, DVAL_EOM ]);
+};
+
+Debugger.prototype.sendStepOutRequest = function () {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_STEPOUT, DVAL_EOM ]);
+};
+
+Debugger.prototype.sendPauseRequest = function () {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_PAUSE, DVAL_EOM ]);
+};
+
+Debugger.prototype.sendResumeRequest = function () {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_RESUME, DVAL_EOM ]);
+};
+
+Debugger.prototype.sendEvalRequest = function (evalInput, level) {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_EVAL, evalInput, (typeof level === 'number' ? level : -1), DVAL_EOM ]).then(function (msg) {
+        return { error: msg[1] === 1 /*error*/, value: msg[2] };
+    });
+};
+
+Debugger.prototype.sendDetachRequest = function () {
+    var _this = this;
+    return this.sendRequest([ DVAL_REQ, CMD_DETACH, DVAL_EOM ]);
+};
+
+Debugger.prototype.sendDumpHeapRequest = function () {
+    var _this = this;
+
+    return this.sendRequest([ DVAL_REQ, CMD_DUMPHEAP, DVAL_EOM ]).then(function (msg) {
+        var res = {};
+        var objs = [];
+        var i, j, n, m, o, prop;
+
+        res.type = 'heapDump';
+        res.heapObjects = objs;
+
+        for (i = 1, n = msg.length - 1; i < n; /*nop*/) {
+            o = {};
+            o.ptr = msg[i++];
+            o.type = msg[i++];
+            o.flags = msg[i++] >>> 0;  /* unsigned */
+            o.refc = msg[i++];
+
+            if (o.type === DUK_HTYPE_STRING) {
+                o.blen = msg[i++];
+                o.clen = msg[i++];
+                o.hash = msg[i++] >>> 0;  /* unsigned */
+                o.data = msg[i++];
+            } else if (o.type === DUK_HTYPE_BUFFER) {
+                o.len = msg[i++];
+                o.data = msg[i++];
+            } else if (o.type === DUK_HTYPE_OBJECT) {
+                o['class'] = msg[i++];
+                o.proto = msg[i++];
+                o.esize = msg[i++];
+                o.enext = msg[i++];
+                o.asize = msg[i++];
+                o.hsize = msg[i++];
+                o.props = [];
+                for (j = 0, m = o.enext; j < m; j++) {
+                    prop = {};
+                    prop.flags = msg[i++];
+                    prop.key = msg[i++];
+                    prop.accessor = (msg[i++] == 1);
+                    if (prop.accessor) {
+                        prop.getter = msg[i++];
+                        prop.setter = msg[i++];
+                    } else {
+                        prop.value = msg[i++];
+                    }
+                    o.props.push(prop);
+                }
+                o.array = [];
+                for (j = 0, m = o.asize; j < m; j++) {
+                    prop = {};
+                    prop.value = msg[i++];
+                    o.array.push(prop);
+                }
+            } else {
+                console.log('invalid htype: ' + o.type + ', disconnect');
+                _this.disconnectDebugger();
+                throw new Error('invalid htype');
+                return;
+            }
+
+            objs.push(o);
+        }
+
+        return res;
+    });
+};
+
+Debugger.prototype.sendGetBytecodeRequest = function () {
+    var _this = this;
+
+    return this.sendRequest([ DVAL_REQ, CMD_GETBYTECODE, DVAL_EOM ]).then(function (msg) {
+        var idx = 1;
+        var nconst;
+        var nfunc;
+        var val;
+        var buf;
+        var i, n;
+        var consts = [];
+        var funcs = [];
+        var bcode;
+        var preformatted;
+        var ret;
+        var idxPreformattedInstructions;
+
+        //console.log(JSON.stringify(msg));
+
+        nconst = msg[idx++];
+        for (i = 0; i < nconst; i++) {
+            val = msg[idx++];
+            consts.push(val);
+        }
+
+        nfunc = msg[idx++];
+        for (i = 0; i < nfunc; i++) {
+            val = msg[idx++];
+            funcs.push(val);
+        }
+        val = msg[idx++];
+
+        // Right now bytecode is a string containing a direct dump of the
+        // bytecode in target endianness.  Decode here so that the web UI
+        // doesn't need to.
+
+        buf = new Buffer(val.length);
+        writeDebugStringToBuffer(val, buf, 0);
+        bcode = _this.decodeBytecodeFromBuffer(buf, consts, funcs);
+
+        preformatted = [];
+        consts.forEach(function (v, i) {
+            preformatted.push('; c' + i + ' ' + JSON.stringify(v));
+        });
+        preformatted.push('');
+        idxPreformattedInstructions = preformatted.length;
+        bcode.forEach(function (v) {
+            preformatted.push(v.str);
+        });
+        preformatted = preformatted.join('\n') + '\n';
+
+        ret = {
+            constants: consts,
+            functions: funcs,
+            bytecode: bcode,
+            preformatted: preformatted,
+            idxPreformattedInstructions: idxPreformattedInstructions
+        };
+
+        return ret;
+    });
+};
+
+Debugger.prototype.changeBreakpoint = function (fileName, lineNumber, mode) {
+    var _this = this;
+
+    return this.sendRequest([ DVAL_REQ, CMD_LISTBREAK, DVAL_EOM ]).then(function (msg) {
+        var i, n;
+        var breakpts = [];
+        var deleted = false;
+
+        // Up-to-date list of breakpoints on target
+        for (i = 1, n = msg.length - 1; i < n; i += 2) {
+            breakpts.push({ fileName: msg[i], lineNumber: msg[i + 1] });
+        }
+
+        // Delete matching breakpoints in reverse order so that indices
+        // remain valid.  We do this for all operations so that duplicates
+        // are eliminated if present.
+        for (i = breakpts.length - 1; i >= 0; i--) {
+            var bp = breakpts[i];
+            if (mode === 'deleteall' || (bp.fileName === fileName && bp.lineNumber === lineNumber)) {
+                deleted = true;
+                _this.sendRequest([ DVAL_REQ, CMD_DELBREAK, i, DVAL_EOM ], function (msg) {
+                    // nop
+                }, function (err) {
+                    // nop
+                });
+            }
+        }
+
+        // Technically we should wait for each delbreak reply but because
+        // target processes the requests in order, it doesn't matter.
+        if ((mode === 'add') || (mode === 'toggle' && !deleted)) {
+            _this.sendRequest([ DVAL_REQ, CMD_ADDBREAK, fileName, lineNumber, DVAL_EOM ], function (msg) {
+                // nop
+            }, function (err) {
+                _this.uiMessage('debugger-info', 'Failed to add breakpoint: ' + err);
+            });
+        }
+
+        // Read final, effective breakpoints from the target
+        _this.sendBreakpointListRequest();
+    });
+};
+
+Debugger.prototype.disconnectDebugger = function () {
+    if (this.targetStream) {
+        // We require a destroy() method from the actual target stream
+        this.targetStream.destroy();
+        this.targetStream = null;
+    }
+    if (this.inputParser) {
+        this.inputParser.close();
+        this.inputParser = null;
+    }
+    if (this.outputPassThroughStream) {
+        // There is no close() or destroy() for a passthrough stream, so just
+        // close the outputParser which will cancel timers etc.
+    }
+    if (this.outputParser) {
+        this.outputParser.close();
+        this.outputParser = null;
+    }
+
+    this.attached = false;
+    this.handshook = false;
+    this.reqQueue = null;
+    this.execStatus = {
+        attached: false,
+        state: 'detached',
+        fileName: '',
+        funcName: '',
+        line: 0,
+        pc: 0
+    };
+};
+
+Debugger.prototype.connectDebugger = function () {
+    var _this = this;
+
+    this.disconnectDebugger();  // close previous target connection
+
+    // CUSTOMTRANSPORT: to use a custom transport, change this.targetStream to
+    // use your custom transport.
+
+    console.log('Connecting to ' + optTargetHost + ':' + optTargetPort + '...');
+    this.targetStream = new net.Socket();
+    this.targetStream.connect(optTargetPort, optTargetHost, function () {
+        console.log('Debug transport connected');
+        _this.attached = true;
+        _this.reqQueue = [];
+        _this.uiMessage('debugger-info', 'Debug transport connected');
+    });
+
+    this.inputParser = new DebugProtocolParser(
+        this.targetStream,
+        null,
+        optDumpDebugRead,
+        optDumpDebugPretty,
+        optDumpDebugPretty ? 'Recv: ' : null,
+        null,
+        null   // console logging is done at a higher level to match request/response
+    );
+
+    // Use a PassThrough stream to debug dump and get stats for output messages.
+    // Simply write outgoing data to both the targetStream and this passthrough
+    // separately.
+    this.outputPassThroughStream = stream.PassThrough();
+    this.outputParser = new DebugProtocolParser(
+        this.outputPassThroughStream,
+        1,
+        optDumpDebugWrite,
+        optDumpDebugPretty,
+        optDumpDebugPretty ? 'Send: ' : null,
+        null,
+        null   // console logging is done at a higher level to match request/response
+    );
+
+    this.inputParser.on('transport-close', function () {
+        _this.uiMessage('debugger-info', 'Debug transport closed');
+        _this.disconnectDebugger();
+        _this.emit('exec-status-update');
+        _this.emit('detached');
+    });
+
+    this.inputParser.on('transport-error', function (err) {
+        _this.uiMessage('debugger-info', 'Debug transport error: ' + err);
+        _this.disconnectDebugger();
+    });
+
+    this.inputParser.on('protocol-version', function (msg) {
+        var ver = msg.protocolVersion;
+        console.log('Debug version identification:', msg.versionIdentification);
+        _this.protocolVersion = ver;
+        _this.uiMessage('debugger-info', 'Debug version identification: ' + msg.versionIdentification);
+        if (ver !== 1) {
+            _this.uiMessage('debugger-info', 'Protocol version ' + ver + ' unsupported, dropping connection');
+            _this.targetStream.destroy();
+        } else {
+            _this.uiMessage('debugger-info', 'Debug protocol version: ' + ver);
+            _this.handshook = true;
+            _this.execStatus = {
+                attached: true,
+                state: 'attached',
+                fileName: '',
+                funcName: '',
+                line: 0,
+                pc: 0
+            };
+            _this.emit('exec-status-update');
+            _this.emit('attached');  // inform web UI
+
+            // Fetch basic info right away
+            _this.sendBasicInfoRequest();
+        }
+    });
+
+    this.inputParser.on('debug-message', function (msg) {
+        _this.processDebugMessage(msg);
+    });
+
+    this.inputParser.on('stats-update', function () {
+        _this.stats.rxBytes = this.bytes;
+        _this.stats.rxDvalues = this.dvalues;
+        _this.stats.rxMessages = this.messages;
+        _this.stats.rxBytesPerSec = this.bytesPerSec;
+        _this.emit('debug-stats-update');
+    });
+
+    this.outputParser.on('stats-update', function () {
+        _this.stats.txBytes = this.bytes;
+        _this.stats.txDvalues = this.dvalues;
+        _this.stats.txMessages = this.messages;
+        _this.stats.txBytesPerSec = this.bytesPerSec;
+        _this.emit('debug-stats-update');
+    });
+};
+
+Debugger.prototype.processDebugMessage = function (msg) {
+    var req;
+    var prevState, newState;
+    var err;
+
+    if (msg[0] === DVAL_REQ) {
+        // No actual requests sent by the target right now (just notifys).
+        console.log('Unsolicited reply message, dropping connection: ' + prettyDebugMessage(msg));
+    } else if (msg[0] === DVAL_REP) {
+        if (this.reqQueue.length <= 0) {
+            console.log('Unsolicited reply message, dropping connection: ' + prettyDebugMessage(msg));
+            this.targetStream.destroy();
+        }
+        req = this.reqQueue.shift();
+
+        if (optLogMessages) {
+            console.log('Reply for ' + prettyDebugCommand(req.reqCmd) + ': ' + prettyDebugMessage(msg));
+        }
+
+        if (req.resolveCb) {
+            req.resolveCb(msg);
+        } else {
+            // nop: no callback
+        }
+    } else if (msg[0] === DVAL_ERR) {
+        if (this.reqQueue.length <= 0) {
+            console.log('Unsolicited error message, dropping connection: ' + prettyDebugMessage(msg));
+            this.targetStream.destroy();
+        }
+        err = new Error(String(msg[2]) + ' (code ' + String(msg[1]) + ')');
+        err.errorCode = msg[1] || 0;
+        req = this.reqQueue.shift();
+
+        if (optLogMessages) {
+            console.log('Error for ' + prettyDebugCommand(req.reqCmd) + ': ' + prettyDebugMessage(msg));
+        }
+
+        if (req.rejectCb) {
+            req.rejectCb(err);
+        } else {
+            // nop: no callback
+        }
+    } else if (msg[0] === DVAL_NFY) {
+        if (optLogMessages) {
+            console.log('Notify ' + prettyDebugCommand(msg[1]) + ': ' + prettyDebugMessage(msg));
+        }
+
+        if (msg[1] === CMD_STATUS) {
+            prevState = this.execStatus.state;
+            newState = msg[2] === 0 ? 'running' : 'paused';
+            this.execStatus = {
+                attached: true,
+                state: newState,
+                fileName: msg[3],
+                funcName: msg[4],
+                line: msg[5],
+                pc: msg[6]
+            };
+
+            if (prevState !== newState && newState === 'paused') {
+                // update run state now that we're paused
+                this.sendBreakpointListRequest();
+                this.sendGetLocalsRequest();
+                this.sendGetCallStackRequest();
+            }
+
+            this.emit('exec-status-update');
+        } else if (msg[1] === CMD_PRINT) {
+            this.uiMessage('print', prettyUiStringUnquoted(msg[2], UI_MESSAGE_CLIPLEN));
+        } else if (msg[1] === CMD_ALERT) {
+            this.uiMessage('alert', prettyUiStringUnquoted(msg[2], UI_MESSAGE_CLIPLEN));
+        } else if (msg[1] === CMD_LOG) {
+            this.uiMessage({ type: 'log', level: msg[2], message: prettyUiStringUnquoted(msg[3], UI_MESSAGE_CLIPLEN) });
+        } else if (msg[1] === CMD_THROW) {
+            this.uiMessage({ type: 'throw', fatal: msg[2], message: (msg[2] ? 'UNCAUGHT: ' : 'THROW: ') + prettyUiStringUnquoted(msg[3], UI_MESSAGE_CLIPLEN), fileName: msg[4], lineNumber: msg[5] });
+        } else if (msg[1] === CMD_DETACHING) {
+            this.uiMessage({ type: 'detaching', reason: msg[2], message: 'DETACH: ' + (msg.length >= 5 ? prettyUiStringUnquoted(msg[3]) : 'detaching') });
+        } else {
+            // Ignore unknown notify messages
+            console.log('Unknown notify, ignoring: ' + prettyDebugMessage(msg));
+
+            //this.targetStream.destroy();
+        }
+    } else {
+        console.log('Invalid initial dvalue, dropping connection: ' + prettyDebugMessage(msg));
+        this.targetStream.destroy();
+    }
+};
+
+Debugger.prototype.run = function () {
+    var _this = this;
+
+    // Initial debugger connection
+
+    this.connectDebugger();
+
+    // Poll various state items when running
+
+    var sendRound = 0;
+    var statusPending = false;
+    var bplistPending = false;
+    var localsPending = false;
+    var callStackPending = false;
+
+    setInterval(function () {
+        if (_this.execStatus.state !== 'running') {
+            return;
+        }
+
+        // Could also check for an empty request queue, but that's probably
+        // too strict?
+
+        // Pending flags are used to avoid requesting the same thing twice
+        // while a previous request is pending.  The flag-based approach is
+        // quite awkward.  Rework to use promises.
+
+        switch (sendRound) {
+        case 0:
+            if (!statusPending) {
+                statusPending = true;
+                _this.sendStatusRequest().finally(function () { statusPending = false; });
+            }
+            break;
+        case 1:
+            if (!bplistPending) {
+                bplistPending = true;
+                _this.sendBreakpointListRequest().finally(function () { bplistPending = false; });
+            }
+            break;
+        case 2:
+            if (!localsPending) {
+                localsPending = true;
+                _this.sendGetLocalsRequest().finally(function () { localsPending = false; });
+            }
+            break;
+        case 3:
+            if (!callStackPending) {
+                callStackPending = true;
+                _this.sendGetCallStackRequest().finally(function () { callStackPending = false; });
+            }
+            break;
+        }
+        sendRound = (sendRound + 1) % 4;
+    }, 500);
+};
+
+/*
+ *  Express setup and socket.io
+ */
+
+function DebugWebServer() {
+    this.dbg = null;       // debugger singleton
+    this.socket = null;    // current socket (or null)
+    this.keepaliveTimer = null;
+    this.uiMessageLimiter = null;
+    this.cachedJson = {};  // cache to avoid resending identical data
+    this.sourceFileManager = new SourceFileManager(optSourceSearchDirs);
+    this.sourceFileManager.scan();
+}
+
+DebugWebServer.prototype.handleSourcePost = function (req, res) {
+    var fileName = req.body && req.body.fileName;
+    var fileData;
+
+    console.log('Source request: ' + fileName);
+
+    if (typeof fileName !== 'string') {
+        res.status(500).send('invalid request');
+        return;
+    }
+    fileData = this.sourceFileManager.search(fileName, optSourceSearchDirs);
+    if (typeof fileData !== 'string') {
+        res.status(404).send('not found');
+        return;
+    }
+    res.status(200).send(fileData);  // UTF-8
+};
+
+DebugWebServer.prototype.handleSourceListPost = function (req, res) {
+    console.log('Source list request');
+
+    var files = this.sourceFileManager.getFiles();
+    res.header('Content-Type', 'application/json');
+    res.status(200).json(files);
+};
+
+DebugWebServer.prototype.handleHeapDumpGet = function (req, res) {
+    console.log('Heap dump get');
+
+    this.dbg.sendDumpHeapRequest().then(function (val) {
+        res.header('Content-Type', 'application/json');
+        //res.status(200).json(val);
+        res.status(200).send(JSON.stringify(val, null, 4));
+    }).catch(function (err) {
+        res.status(500).send('Failed to get heap dump: ' + (err.stack || err));
+    });
+};
+
+DebugWebServer.prototype.run = function () {
+    var _this = this;
+
+    var express = require('express');
+    var bodyParser = require('body-parser');
+    var app = express();
+    var http = require('http').Server(app);
+    var io = require('socket.io')(http);
+
+    app.use(bodyParser.json());
+    app.post('/source', this.handleSourcePost.bind(this));
+    app.post('/sourceList', this.handleSourceListPost.bind(this));
+    app.get('/heapDump.json', this.handleHeapDumpGet.bind(this));
+    app.use('/', express.static(__dirname + '/static'));
+
+    http.listen(optHttpPort, function () {
+        console.log('Listening on *:' + optHttpPort);
+    });
+
+    io.on('connection', this.handleNewSocketIoConnection.bind(this));
+
+    this.dbg.on('attached', function () {
+        console.log('Debugger attached');
+    });
+
+    this.dbg.on('detached', function () {
+        console.log('Debugger detached');
+    });
+
+    this.dbg.on('debug-stats-update', function () {
+        _this.debugStatsLimiter.trigger();
+    });
+
+    this.dbg.on('ui-message-update', function () {
+        // Explicit rate limiter because this is a source of a lot of traffic.
+        _this.uiMessageLimiter.trigger();
+    });
+
+    this.dbg.on('basic-info-update', function () {
+        _this.emitBasicInfo();
+    });
+
+    this.dbg.on('breakpoints-update', function () {
+        _this.emitBreakpoints();
+    });
+
+    this.dbg.on('exec-status-update', function () {
+        // Explicit rate limiter because this is a source of a lot of traffic.
+        _this.execStatusLimiter.trigger();
+    });
+
+    this.dbg.on('locals-update', function () {
+        _this.emitLocals();
+    });
+
+    this.dbg.on('callstack-update', function () {
+        _this.emitCallStack();
+    });
+
+    this.uiMessageLimiter = new RateLimited(10, 1000, this.uiMessageLimiterCallback.bind(this));
+    this.execStatusLimiter = new RateLimited(50, 500, this.execStatusLimiterCallback.bind(this));
+    this.debugStatsLimiter = new RateLimited(1, 2000, this.debugStatsLimiterCallback.bind(this));
+
+    this.keepaliveTimer = setInterval(this.emitKeepalive.bind(this), 30000);
+};
+
+DebugWebServer.prototype.handleNewSocketIoConnection = function (socket) {
+    var _this = this;
+
+    console.log('Socket.io connected');
+    if (this.socket) {
+        console.log('Closing previous socket.io socket');
+        this.socket.emit('replaced');
+    }
+    this.socket = socket;
+
+    this.emitKeepalive();
+
+    socket.on('disconnect', function () {
+        console.log('Socket.io disconnected');
+        if (_this.socket === socket) {
+             _this.socket = null;
+        }
+    });
+
+    socket.on('keepalive', function (msg) {
+        // nop
+    });
+
+    socket.on('attach', function (msg) {
+        if (_this.dbg.targetStream) {
+            console.log('Attach request when debugger already has a connection, ignoring');
+        } else {
+            _this.dbg.connectDebugger();
+        }
+    });
+
+    socket.on('detach', function (msg) {
+        // Try to detach cleanly, timeout if no response
+        Promise.any([
+            _this.dbg.sendDetachRequest(),
+            Promise.delay(3000)
+        ]).finally(function () {
+            _this.dbg.disconnectDebugger();
+        });
+    });
+
+    socket.on('stepinto', function (msg) {
+        _this.dbg.sendStepIntoRequest();
+    });
+
+    socket.on('stepover', function (msg) {
+        _this.dbg.sendStepOverRequest();
+    });
+
+    socket.on('stepout', function (msg) {
+        _this.dbg.sendStepOutRequest();
+    });
+
+    socket.on('pause', function (msg) {
+        _this.dbg.sendPauseRequest();
+    });
+
+    socket.on('resume', function (msg) {
+        _this.dbg.sendResumeRequest();
+    });
+
+    socket.on('eval', function (msg) {
+        // msg.input is a proper Unicode strings here, and needs to be
+        // converted into a protocol string (U+0000...U+00FF).
+        var input = stringToDebugString(msg.input);
+        _this.dbg.sendEvalRequest(input, msg.level).then(function (v) {
+            socket.emit('eval-result', { error: v.error, result: prettyUiDebugValue(v.value, EVAL_CLIPLEN) });
+        });
+
+        // An eval call quite possibly changes the local variables so always
+        // re-read locals afterwards.  We don't need to wait for Eval to
+        // complete here; the requests will pipeline automatically and be
+        // executed in order.
+
+        // XXX: move this to the web UI so that the UI can control what
+        // locals are listed (or perhaps show locals for all levels with
+        // an expandable tree view).
+        _this.dbg.sendGetLocalsRequest();
+    });
+
+    socket.on('getvar', function (msg) {
+        // msg.varname is a proper Unicode strings here, and needs to be
+        // converted into a protocol string (U+0000...U+00FF).
+        var varname = stringToDebugString(msg.varname);
+        _this.dbg.sendGetVarRequest(varname, msg.level)
+        .then(function (v) {
+            socket.emit('getvar-result', { found: v.found, result: prettyUiDebugValue(v.value, GETVAR_CLIPLEN) });
+        });
+    });
+
+    socket.on('putvar', function (msg) {
+        // msg.varname and msg.varvalue are proper Unicode strings here, they
+        // need to be converted into protocol strings (U+0000...U+00FF).
+        var varname = stringToDebugString(msg.varname);
+        var varvalue = msg.varvalue;
+
+        // varvalue is JSON parsed by the web UI for now, need special string
+        // encoding here.
+        if (typeof varvalue === 'string') {
+            varvalue = stringToDebugString(msg.varvalue);
+        }
+
+        _this.dbg.sendPutVarRequest(varname, varvalue, msg.level)
+        .then(function (v) {
+            console.log('putvar done');  // XXX: signal success to UI?
+        });
+
+        // A PutVar call quite possibly changes the local variables so always
+        // re-read locals afterwards.  We don't need to wait for PutVar to
+        // complete here; the requests will pipeline automatically and be
+        // executed in order.
+
+        // XXX: make the client do this?
+        _this.dbg.sendGetLocalsRequest();
+    });
+
+    socket.on('add-breakpoint', function (msg) {
+        _this.dbg.changeBreakpoint(msg.fileName, msg.lineNumber, 'add');
+    });
+
+    socket.on('delete-breakpoint', function (msg) {
+        _this.dbg.changeBreakpoint(msg.fileName, msg.lineNumber, 'delete');
+    });
+
+    socket.on('toggle-breakpoint', function (msg) {
+        _this.dbg.changeBreakpoint(msg.fileName, msg.lineNumber, 'toggle');
+    });
+
+    socket.on('delete-all-breakpoints', function (msg) {
+        _this.dbg.changeBreakpoint(null, null, 'deleteall');
+    });
+
+    socket.on('get-bytecode', function (msg) {
+        _this.dbg.sendGetBytecodeRequest().then(function (res) {
+            socket.emit('bytecode', res);
+        });
+    });
+
+    // Resend all debugger state for new client
+    this.cachedJson = {};  // clear client state cache
+    this.emitBasicInfo();
+    this.emitStats();
+    this.emitExecStatus();
+    this.emitUiMessages();
+    this.emitBreakpoints();
+    this.emitCallStack();
+    this.emitLocals();
+};
+
+// Check if 'msg' would encode to the same JSON which was previously sent
+// to the web client.  The caller then avoid resending unnecessary stuff.
+DebugWebServer.prototype.cachedJsonCheck = function (cacheKey, msg) {
+    var newJson = JSON.stringify(msg);
+    if (this.cachedJson[cacheKey] === newJson) {
+        return true;  // cached
+    }
+    this.cachedJson[cacheKey] = newJson;
+    return false;  // not cached, send (cache already updated)
+};
+
+DebugWebServer.prototype.uiMessageLimiterCallback = function () {
+    this.emitUiMessages();
+};
+
+DebugWebServer.prototype.execStatusLimiterCallback = function () {
+    this.emitExecStatus();
+};
+
+DebugWebServer.prototype.debugStatsLimiterCallback = function () {
+    this.emitStats();
+};
+
+DebugWebServer.prototype.emitKeepalive = function () {
+    if (!this.socket) { return; }
+
+    this.socket.emit('keepalive', { nodeVersion: process.version });
+};
+
+DebugWebServer.prototype.emitBasicInfo = function () {
+    if (!this.socket) { return; }
+
+    var newMsg = {
+        duk_version: this.dbg.dukVersion,
+        duk_git_describe: this.dbg.dukGitDescribe,
+        target_info: this.dbg.targetInfo,
+        endianness: this.dbg.endianness
+    };
+    if (this.cachedJsonCheck('basic-info', newMsg)) {
+        return;
+    }
+    this.socket.emit('basic-info', newMsg);
+};
+
+DebugWebServer.prototype.emitStats = function () {
+    if (!this.socket) { return; }
+
+    this.socket.emit('debug-stats', this.dbg.stats);
+};
+
+DebugWebServer.prototype.emitExecStatus = function () {
+    if (!this.socket) { return; }
+
+    var newMsg = this.dbg.execStatus;
+    if (this.cachedJsonCheck('exec-status', newMsg)) {
+        return;
+    }
+    this.socket.emit('exec-status', newMsg);
+};
+
+DebugWebServer.prototype.emitUiMessages = function () {
+    if (!this.socket) { return; }
+
+    var newMsg = this.dbg.messageLines;
+    if (this.cachedJsonCheck('output-lines', newMsg)) {
+        return;
+    }
+    this.socket.emit('output-lines', newMsg);
+};
+
+DebugWebServer.prototype.emitBreakpoints = function () {
+    if (!this.socket) { return; }
+
+    var newMsg = { breakpoints: this.dbg.breakpoints };
+    if (this.cachedJsonCheck('breakpoints', newMsg)) {
+        return;
+    }
+    this.socket.emit('breakpoints', newMsg);
+};
+
+DebugWebServer.prototype.emitCallStack = function () {
+    if (!this.socket) { return; }
+
+    var newMsg = { callstack: this.dbg.callstack };
+    if (this.cachedJsonCheck('callstack', newMsg)) {
+        return;
+    }
+    this.socket.emit('callstack', newMsg);
+};
+
+DebugWebServer.prototype.emitLocals = function () {
+    if (!this.socket) { return; }
+
+    var newMsg = { locals: this.dbg.locals };
+    if (this.cachedJsonCheck('locals', newMsg)) {
+        return;
+    }
+    this.socket.emit('locals', newMsg);
+};
+
+/*
+ *  JSON debug proxy
+ */
+
+function DebugProxy(serverPort) {
+    this.serverPort = serverPort;
+    this.server = null;
+    this.socket = null;
+    this.targetStream = null;
+    this.inputParser = null;
+
+    // preformatted dvalues
+    this.dval_eom = formatDebugValue(DVAL_EOM);
+    this.dval_req = formatDebugValue(DVAL_REQ);
+    this.dval_rep = formatDebugValue(DVAL_REP);
+    this.dval_nfy = formatDebugValue(DVAL_NFY);
+    this.dval_err = formatDebugValue(DVAL_ERR);
+}
+
+DebugProxy.prototype.determineCommandNumber = function (cmdName, cmdNumber) {
+    var ret;
+    if (typeof cmdName === 'string') {
+        ret = debugCommandNumbers[cmdName];
+    } else if (typeof cmdName === 'number') {
+        ret = cmdName;
+    }
+    ret = ret || cmdNumber;
+    if (typeof ret !== 'number') {
+        throw Error('cannot figure out command number for "' + cmdName + '" (' + cmdNumber + ')');
+    }
+    return ret;
+};
+
+DebugProxy.prototype.commandNumberToString = function (id) {
+    return debugCommandNames[id] || String(id);
+};
+
+DebugProxy.prototype.formatDvalues = function (args) {
+    if (!args) {
+        return [];
+    }
+    return args.map(function (v) {
+        return formatDebugValue(v);
+    });
+};
+
+DebugProxy.prototype.writeJson = function (val) {
+    this.socket.write(JSON.stringify(val) + '\n');
+};
+
+DebugProxy.prototype.writeJsonSafe = function (val) {
+    try {
+        this.writeJson(val);
+    } catch (e) {
+        console.log('Failed to write JSON in writeJsonSafe, ignoring: ' + e);
+    }
+};
+
+DebugProxy.prototype.disconnectJsonClient = function () {
+    if (this.socket) {
+        this.socket.destroy();
+        this.socket = null;
+    }
+};
+
+DebugProxy.prototype.disconnectTarget = function () {
+    if (this.inputParser) {
+        this.inputParser.close();
+        this.inputParser = null;
+    }
+    if (this.targetStream) {
+        this.targetStream.destroy();
+        this.targetStream = null;
+    }
+};
+
+DebugProxy.prototype.run = function () {
+    var _this = this;
+
+    console.log('Waiting for client connections on port ' + this.serverPort);
+    this.server = net.createServer(function (socket) {
+        console.log('JSON proxy client connected');
+
+        _this.disconnectJsonClient();
+        _this.disconnectTarget();
+
+        // A byline-parser is simple and good enough for now (assume
+        // compact JSON with no newlines).
+        var socketByline = byline(socket);
+        _this.socket = socket;
+
+        socketByline.on('data', function (line) {
+            try {
+                // console.log('Received json proxy input line: ' + line.toString('utf8'));
+                var msg = JSON.parse(line.toString('utf8'));
+                var first_dval;
+                var args_dvalues = _this.formatDvalues(msg.args);
+                var last_dval = _this.dval_eom;
+                var cmd;
+
+                if (msg.request) {
+                    // "request" can be a string or "true"
+                    first_dval = _this.dval_req;
+                    cmd = _this.determineCommandNumber(msg.request, msg.command);
+                } else if (msg.reply) {
+                    first_dval = _this.dval_rep;
+                } else if (msg.notify) {
+                    // "notify" can be a string or "true"
+                    first_dval = _this.dval_nfy;
+                    cmd = _this.determineCommandNumber(msg.notify, msg.command);
+                } else if (msg.error) {
+                    first_dval = _this.dval_err;
+                } else {
+                    throw new Error('Invalid input JSON message: ' + JSON.stringify(msg));
+                }
+
+                _this.targetStream.write(first_dval);
+                if (cmd) {
+                    _this.targetStream.write(formatDebugValue(cmd));
+                }
+                args_dvalues.forEach(function (v) {
+                    _this.targetStream.write(v);
+                });
+                _this.targetStream.write(last_dval);
+            } catch (e) {
+                console.log(e);
+
+                _this.writeJsonSafe({
+                    notify: '_Error',
+                    args: [ 'Failed to handle input json message: ' + e ]
+                });
+
+                _this.disconnectJsonClient();
+                _this.disconnectTarget();
+            }
+        });
+
+        _this.connectToTarget();
+    }).listen(this.serverPort);
+};
+
+DebugProxy.prototype.connectToTarget = function () {
+    var _this = this;
+
+    console.log('Connecting to ' + optTargetHost + ':' + optTargetPort + '...');
+    this.targetStream = new net.Socket();
+    this.targetStream.connect(optTargetPort, optTargetHost, function () {
+        console.log('Debug transport connected');
+    });
+
+    this.inputParser = new DebugProtocolParser(
+        this.targetStream,
+        null,
+        optDumpDebugRead,
+        optDumpDebugPretty,
+        optDumpDebugPretty ? 'Recv: ' : null,
+        null,
+        null   // console logging is done at a higher level to match request/response
+    );
+
+    // Don't add a 'value' key to numbers.
+    this.inputParser.readableNumberValue = false;
+
+    this.inputParser.on('transport-close', function () {
+        console.log('Debug transport closed');
+
+        _this.writeJsonSafe({
+            notify: '_Disconnecting'
+        });
+
+        _this.disconnectJsonClient();
+        _this.disconnectTarget();
+    });
+
+    this.inputParser.on('transport-error', function (err) {
+        console.log('Debug transport error', err);
+
+        _this.writeJsonSafe({
+            notify: '_Error',
+            args: [ String(err) ]
+        });
+    });
+
+    this.inputParser.on('protocol-version', function (msg) {
+        var ver = msg.protocolVersion;
+        console.log('Debug version identification:', msg.versionIdentification);
+
+        _this.writeJson({
+            notify: '_TargetConnected',
+            args: [ msg.versionIdentification ]  // raw identification string
+        });
+
+        if (ver !== 1) {
+            console.log('Protocol version ' + ver + ' unsupported, dropping connection');
+        }
+    });
+
+    this.inputParser.on('debug-message', function (msg) {
+        var t;
+
+        //console.log(msg);
+
+        if (typeof msg[0] !== 'object' || msg[0] === null) {
+            throw new Error('unexpected initial dvalue: ' + msg[0]);
+        } else if (msg[0].type === 'eom') {
+            throw new Error('unexpected initial dvalue: ' + msg[0]);
+        } else if (msg[0].type === 'req') {
+            if (typeof msg[1] !== 'number') {
+                throw new Error('unexpected request command number: ' + msg[1]);
+            }
+            t = {
+                request: _this.commandNumberToString(msg[1]),
+                command: msg[1],
+                args: msg.slice(2, msg.length - 1)
+            };
+            _this.writeJson(t);
+        } else if (msg[0].type === 'rep') {
+            t = {
+                reply: true,
+                args: msg.slice(1, msg.length - 1)
+            };
+            _this.writeJson(t);
+        } else if (msg[0].type === 'err') {
+            t = {
+                error: true,
+                args: msg.slice(1, msg.length - 1)
+            };
+            _this.writeJson(t);
+        } else if (msg[0].type === 'nfy') {
+            if (typeof msg[1] !== 'number') {
+                throw new Error('unexpected notify command number: ' + msg[1]);
+            }
+            t = {
+                notify: _this.commandNumberToString(msg[1]),
+                command: msg[1],
+                args: msg.slice(2, msg.length - 1)
+            };
+            _this.writeJson(t);
+        } else {
+            throw new Error('unexpected initial dvalue: ' + msg[0]);
+        }
+    });
+
+    this.inputParser.on('stats-update', function () {
+    });
+};
+
+/*
+ *  Command line parsing and initialization
+ */
+
+function main() {
+    console.log('((o) Duktape debugger');
+
+    // Parse arguments.
+
+    var argv = require('minimist')(process.argv.slice(2));
+    //console.dir(argv);
+    if (argv['target-host']) {
+        optTargetHost = argv['target-host'];
+    }
+    if (argv['target-port']) {
+        optTargetPort = argv['target-port'];
+    }
+    if (argv['http-port']) {
+        optHttpPort = argv['http-port'];
+    }
+    if (argv['json-proxy-port']) {
+        optJsonProxyPort = argv['json-proxy-port'];
+    }
+    if (argv['json-proxy']) {
+        optJsonProxy = argv['json-proxy'];
+    }
+    if (argv['source-dirs']) {
+        optSourceSearchDirs = argv['source-dirs'].split(path.delimiter);
+    }
+    if (argv['dump-debug-read']) {
+        optDumpDebugRead = argv['dump-debug-read'];
+    }
+    if (argv['dump-debug-write']) {
+        optDumpDebugWrite = argv['dump-debug-write'];
+    }
+    if (argv['dump-debug-pretty']) {
+        optDumpDebugPretty = argv['dump-debug-pretty'];
+    }
+    if (argv['log-messages']) {
+        optLogMessages = true;
+    }
+
+    // Dump effective options.  Also provides a list of option names.
+
+    console.log('');
+    console.log('Effective options:');
+    console.log('  --target-host:       ' + optTargetHost);
+    console.log('  --target-port:       ' + optTargetPort);
+    console.log('  --http-port:         ' + optHttpPort);
+    console.log('  --json-proxy-port:   ' + optJsonProxyPort);
+    console.log('  --json-proxy:        ' + optJsonProxy);
+    console.log('  --source-dirs:       ' + optSourceSearchDirs.join(' '));
+    console.log('  --dump-debug-read:   ' + optDumpDebugRead);
+    console.log('  --dump-debug-write:  ' + optDumpDebugWrite);
+    console.log('  --dump-debug-pretty: ' + optDumpDebugPretty);
+    console.log('  --log-messages:      ' + optLogMessages);
+    console.log('');
+
+    // Create debugger and web UI singletons, tie them together and
+    // start them.
+
+    if (optJsonProxy) {
+        console.log('Starting in JSON proxy mode, JSON port: ' + optJsonProxyPort);
+
+        var prx = new DebugProxy(optJsonProxyPort);
+        prx.run();
+    } else {
+        var dbg = new Debugger();
+        var web = new DebugWebServer();
+        dbg.web = web;
+        web.dbg = dbg;
+        dbg.run();
+        web.run();
+    }
+}
+
+main();

+ 52 - 0
Script/DuktapeDebugProxy/duk_debugcommands.yaml

@@ -0,0 +1,52 @@
+# Debug request/notify command names provided by the debug client.
+# These are concretely notify names now.
+client_commands:
+  - Reserved_0
+  - Status
+  - Print
+  - Alert
+  - Log
+  - Throw
+  - Detaching
+  - AppNotify
+
+# Debug request/notify command names provided by the debug target (Duktape).
+target_commands:
+  - Reserved_0
+  - Reserved_1
+  - Reserved_2
+  - Reserved_3
+  - Reserved_4
+  - Reserved_5
+  - Reserved_6
+  - Reserved_7
+  - Reserved_8
+  - Reserved_9
+  - Reserved_10
+  - Reserved_11
+  - Reserved_12
+  - Reserved_13
+  - Reserved_14
+  - Reserved_15
+  - BasicInfo
+  - TriggerStatus
+  - Pause
+  - Resume
+  - StepInto
+  - StepOver
+  - StepOut
+  - ListBreak
+  - AddBreak
+  - DelBreak
+  - GetVar
+  - PutVar
+  - GetCallStack
+  - GetLocals
+  - Eval
+  - Detach
+  - DumpHeap
+  - GetBytecode
+  - AppRequest
+  - GetHeapObjInfo
+  - GetObjPropDesc
+  - GetObjPropDescRange

+ 6 - 0
Script/DuktapeDebugProxy/duk_debugerrors.yaml

@@ -0,0 +1,6 @@
+error_codes:
+  - Unknown
+  - UnsupportedCommand
+  - TooMany
+  - NotFound
+  - ApplicationError

+ 658 - 0
Script/DuktapeDebugProxy/duk_opcodes.yaml

@@ -0,0 +1,658 @@
+# Duktape opcode metadata for debugger.
+# - See duk_debug.js for the argument formats (A_R etc).
+# - Flag bits are for the whole instruction as a 32-bit integer,
+#   they are not field shifted
+#
+# NOTE: Use YAML comments only on comment-only lines (not trailing content):
+# Node.js 'yamljs' seems to refuse parsing trailing comments in some cases.
+
+opcodes:
+  - name: LDREG
+    args:
+      - A_R
+      - BC_R
+  - name: STREG
+    args:
+      - A_R
+      - BC_R
+  - name: LDCONST
+    args:
+      - A_R
+      - BC_C
+  - name: LDINT
+    args:
+      - A_R
+      - BC_LDINT
+  - name: LDINTX
+    args:
+      - A_R
+      - BC_LDINTX
+  - name: MPUTOBJ
+    args:
+      - A_R
+      - B_R
+      - C_I
+  - name: MPUTOBJI
+    args:
+      - A_R
+      - B_RI
+      - C_I
+  - name: MPUTARR
+    args:
+      - A_R
+      - B_R
+      - C_I
+  - name: MPUTARRI
+    args:
+      - A_R
+      - B_RI
+      - C_I
+  - name: NEW
+    args:
+      - B_R
+      - C_I
+  - name: NEWI
+    args:
+      - B_RI
+      - C_I
+  - name: REGEXP
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: CSREG
+    args:
+      - A_R
+      - B_R
+  - name: CSREGI
+    args:
+      - A_RI
+      - B_R
+  - name: GETVAR
+    args:
+      - A_R
+      - BC_C
+  - name: PUTVAR
+    args:
+      - A_R
+      - BC_C
+  - name: DECLVAR
+    args:
+      - A_H
+      - B_RC
+      - C_RC
+    flags:
+      - mask: 0x40
+        name: writable
+      - mask: 0x80
+        name: enumerable
+      - mask: 0x100
+        name: configurable
+      - mask: 0x200
+        name: accessor
+      - mask: 0x400
+        name: undef_value
+      - mask: 0x800
+        name: func_decl
+  - name: DELVAR
+    args:
+      - A_R
+      - B_RC
+  - name: CSVAR
+    args:
+      - A_R
+      - B_RC
+  - name: CSVARI
+    args:
+      - A_RI
+      - B_RC
+  - name: CLOSURE
+    args:
+      - A_R
+      - BC_I
+  - name: GETPROP
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: PUTPROP
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: DELPROP
+    args:
+      - A_R
+      - B_R
+      - C_RC
+  - name: CSPROP
+    args:
+      - A_R
+      - B_R
+      - C_RC
+  - name: CSPROPI
+    args:
+      - A_RI
+      - B_R
+      - C_RC
+  - name: ADD
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: SUB
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: MUL
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: DIV
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: MOD
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: BAND
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: BOR
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: BXOR
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: BASL
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: BLSR
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: BASR
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: EQ
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: NEQ
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: SEQ
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: SNEQ
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: GT
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: GE
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: LT
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: LE
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: IF
+    args:
+      - A_B
+      - B_RC
+  - name: JUMP
+    args:
+      - ABC_JUMP
+  - name: RETURN
+    args:
+      - A_H
+      - B_RC
+    flags:
+      - mask: 0x40
+        name: have_retval
+  - name: CALL
+    args:
+      - A_H
+      - B_R
+      - C_I
+    flags:
+      - mask: 0x40
+        name: tailcall
+      - mask: 0x80
+        name: evalcall
+  - name: CALLI
+    args:
+      - A_H
+      - B_RI
+      - C_I
+  - name: TRYCATCH
+    args:
+      - A_H
+      # base register for two consecutive regs (base_reg + 0, base_reg + 1) used for two things:
+      # - input: either 'with' target register or catch varname constant (base_reg + 0), depending on flags
+      # - output: when caught, catch value (base_reg + 0) and type (base_reg + 1)
+      - BC_R
+    flags:
+      - mask: 0x40
+        name: have_catch
+      - mask: 0x80
+        name: have_finally
+      - mask: 0x100
+        name: catch_binding
+      - mask: 0x200
+        name: with_binding
+  - name: EXTRA
+    extra: true
+  - name: PREINCR
+    args:
+      - A_R
+      - BC_R
+  - name: PREDECR
+    args:
+      - A_R
+      - BC_R
+  - name: POSTINCR
+    args:
+      - A_R
+      - BC_R
+  - name: POSTDECR
+    args:
+      - A_R
+      - BC_R
+  - name: PREINCV
+    args:
+      - A_R
+      - BC_C
+  - name: PREDECV
+    args:
+      - A_R
+      - BC_C
+  - name: POSTINCV
+    args:
+      - A_R
+      - BC_C
+  - name: POSTDECV
+    args:
+      - A_R
+      - BC_C
+  - name: PREINCP
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: PREDECP
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: POSTINCP
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+  - name: POSTDECP
+    args:
+      - A_R
+      - B_RC
+      - C_RC
+
+extra:
+  - name: NOP
+  - name: INVALID
+    args:
+      - BC_I
+  - name: LDTHIS
+    args:
+      - BC_R
+  - name: LDUNDEF
+    args:
+      - BC_R
+  - name: LDNULL
+    args:
+      - BC_R
+  - name: LDTRUE
+    args:
+      - BC_R
+  - name: LDFALSE
+    args:
+      - BC_R
+  - name: NEWOBJ
+    args:
+      # XXX: extend to BC?
+      - B_R
+  - name: NEWARR
+    args:
+      # XXX: extend to BC?
+      - B_R
+  - name: SETALEN
+    args:
+      - B_R
+      - C_R
+  - name: TYPEOF
+    args:
+      - BC_R
+  - name: TYPEOFID
+    args:
+      - B_R
+      # maybe changed to C_C later
+      - C_RC
+  - name: INITENUM
+    args:
+      - B_R
+      - C_R
+  - name: NEXTENUM
+    args:
+      - B_R
+      - C_R
+  - name: INITSET
+    args:
+      - B_R
+      - C_R
+  - name: INITSETI
+    args:
+      - B_R
+      - C_RI
+  - name: INITGET
+    args:
+      - B_R
+      - C_RI
+  - name: INITGETI
+    args:
+      - B_R
+      - C_RI
+  - name: ENDTRY
+  - name: ENDCATCH
+  - name: ENDFIN
+  - name: THROW
+    args:
+      - BC_R
+  - name: INVLHS
+  - name: UNM
+    args:
+      - BC_R
+  - name: UNP
+    args:
+      - BC_R
+  - name: DEBUGGER
+  - name: BREAK
+    args:
+      - BC_I
+  - name: CONTINUE
+    args:
+      - BC_I
+  - name: BNOT
+    args:
+      - BC_R
+  - name: LNOT
+    args:
+      - BC_R
+  - name: INSTOF
+    args:
+      - B_R
+      - C_RC
+  - name: IN
+    args:
+      - B_R
+      - C_RC
+  - name: LABEL
+    args:
+      - BC_I
+  - name: ENDLABEL
+    args:
+      - BC_I
+  - name: EXTRA34
+  - name: EXTRA35
+  - name: EXTRA36
+  - name: EXTRA37
+  - name: EXTRA38
+  - name: EXTRA39
+  - name: EXTRA40
+  - name: EXTRA41
+  - name: EXTRA42
+  - name: EXTRA43
+  - name: EXTRA44
+  - name: EXTRA45
+  - name: EXTRA46
+  - name: EXTRA47
+  - name: EXTRA48
+  - name: EXTRA49
+  - name: EXTRA50
+  - name: EXTRA51
+  - name: EXTRA52
+  - name: EXTRA53
+  - name: EXTRA54
+  - name: EXTRA55
+  - name: EXTRA56
+  - name: EXTRA57
+  - name: EXTRA58
+  - name: EXTRA59
+  - name: EXTRA60
+  - name: EXTRA61
+  - name: EXTRA62
+  - name: EXTRA63
+  - name: EXTRA64
+  - name: EXTRA65
+  - name: EXTRA66
+  - name: EXTRA67
+  - name: EXTRA68
+  - name: EXTRA69
+  - name: EXTRA70
+  - name: EXTRA71
+  - name: EXTRA72
+  - name: EXTRA73
+  - name: EXTRA74
+  - name: EXTRA75
+  - name: EXTRA76
+  - name: EXTRA77
+  - name: EXTRA78
+  - name: EXTRA79
+  - name: EXTRA80
+  - name: EXTRA81
+  - name: EXTRA82
+  - name: EXTRA83
+  - name: EXTRA84
+  - name: EXTRA85
+  - name: EXTRA86
+  - name: EXTRA87
+  - name: EXTRA88
+  - name: EXTRA89
+  - name: EXTRA90
+  - name: EXTRA91
+  - name: EXTRA92
+  - name: EXTRA93
+  - name: EXTRA94
+  - name: EXTRA95
+  - name: EXTRA96
+  - name: EXTRA97
+  - name: EXTRA98
+  - name: EXTRA99
+  - name: EXTRA100
+  - name: EXTRA101
+  - name: EXTRA102
+  - name: EXTRA103
+  - name: EXTRA104
+  - name: EXTRA105
+  - name: EXTRA106
+  - name: EXTRA107
+  - name: EXTRA108
+  - name: EXTRA109
+  - name: EXTRA110
+  - name: EXTRA111
+  - name: EXTRA112
+  - name: EXTRA113
+  - name: EXTRA114
+  - name: EXTRA115
+  - name: EXTRA116
+  - name: EXTRA117
+  - name: EXTRA118
+  - name: EXTRA119
+  - name: EXTRA120
+  - name: EXTRA121
+  - name: EXTRA122
+  - name: EXTRA123
+  - name: EXTRA124
+  - name: EXTRA125
+  - name: EXTRA126
+  - name: EXTRA127
+  - name: EXTRA128
+  - name: EXTRA129
+  - name: EXTRA130
+  - name: EXTRA131
+  - name: EXTRA132
+  - name: EXTRA133
+  - name: EXTRA134
+  - name: EXTRA135
+  - name: EXTRA136
+  - name: EXTRA137
+  - name: EXTRA138
+  - name: EXTRA139
+  - name: EXTRA140
+  - name: EXTRA141
+  - name: EXTRA142
+  - name: EXTRA143
+  - name: EXTRA144
+  - name: EXTRA145
+  - name: EXTRA146
+  - name: EXTRA147
+  - name: EXTRA148
+  - name: EXTRA149
+  - name: EXTRA150
+  - name: EXTRA151
+  - name: EXTRA152
+  - name: EXTRA153
+  - name: EXTRA154
+  - name: EXTRA155
+  - name: EXTRA156
+  - name: EXTRA157
+  - name: EXTRA158
+  - name: EXTRA159
+  - name: EXTRA160
+  - name: EXTRA161
+  - name: EXTRA162
+  - name: EXTRA163
+  - name: EXTRA164
+  - name: EXTRA165
+  - name: EXTRA166
+  - name: EXTRA167
+  - name: EXTRA168
+  - name: EXTRA169
+  - name: EXTRA170
+  - name: EXTRA171
+  - name: EXTRA172
+  - name: EXTRA173
+  - name: EXTRA174
+  - name: EXTRA175
+  - name: EXTRA176
+  - name: EXTRA177
+  - name: EXTRA178
+  - name: EXTRA179
+  - name: EXTRA180
+  - name: EXTRA181
+  - name: EXTRA182
+  - name: EXTRA183
+  - name: EXTRA184
+  - name: EXTRA185
+  - name: EXTRA186
+  - name: EXTRA187
+  - name: EXTRA188
+  - name: EXTRA189
+  - name: EXTRA190
+  - name: EXTRA191
+  - name: EXTRA192
+  - name: EXTRA193
+  - name: EXTRA194
+  - name: EXTRA195
+  - name: EXTRA196
+  - name: EXTRA197
+  - name: EXTRA198
+  - name: EXTRA199
+  - name: EXTRA200
+  - name: EXTRA201
+  - name: EXTRA202
+  - name: EXTRA203
+  - name: EXTRA204
+  - name: EXTRA205
+  - name: EXTRA206
+  - name: EXTRA207
+  - name: EXTRA208
+  - name: EXTRA209
+  - name: EXTRA210
+  - name: EXTRA211
+  - name: EXTRA212
+  - name: EXTRA213
+  - name: EXTRA214
+  - name: EXTRA215
+  - name: EXTRA216
+  - name: EXTRA217
+  - name: EXTRA218
+  - name: EXTRA219
+  - name: EXTRA220
+  - name: EXTRA221
+  - name: EXTRA222
+  - name: EXTRA223
+  - name: EXTRA224
+  - name: EXTRA225
+  - name: EXTRA226
+  - name: EXTRA227
+  - name: EXTRA228
+  - name: EXTRA229
+  - name: EXTRA230
+  - name: EXTRA231
+  - name: EXTRA232
+  - name: EXTRA233
+  - name: EXTRA234
+  - name: EXTRA235
+  - name: EXTRA236
+  - name: EXTRA237
+  - name: EXTRA238
+  - name: EXTRA239
+  - name: EXTRA240
+  - name: EXTRA241
+  - name: EXTRA242
+  - name: EXTRA243
+  - name: EXTRA244
+  - name: EXTRA245
+  - name: EXTRA246
+  - name: EXTRA247
+  - name: EXTRA248
+  - name: EXTRA249
+  - name: EXTRA250
+  - name: EXTRA251
+  - name: EXTRA252
+  - name: EXTRA253
+  - name: EXTRA254
+  - name: EXTRA255

+ 28 - 0
Script/DuktapeDebugProxy/package.json

@@ -0,0 +1,28 @@
+{
+  "name": "duk-debug",
+  "version": "0.1.0",
+  "description": "Duktape debugger",
+  "author": {
+    "name": "Sami Vaarala",
+    "email": "[email protected]"
+  },
+  "dependencies": {
+    "bluebird": "~2.6.4",
+    "body-parser": "~1.9.3",
+    "byline": "~4.2.1",
+    "events": "~1.0.2",
+    "express": "~4.10.1",
+    "http": "0.0.0",
+    "minimist": "~1.1.0",
+    "monaco-editor": "^0.8.1",
+    "readline": "0.0.5",
+    "socket.io": "~1.2.1",
+    "sprintf": "~0.1.5",
+    "stream": "0.0.2",
+    "utf8": "~2.0.0",
+    "util": "~0.10.3",
+    "wrench": "~1.5.8",
+    "yamljs": "~0.2.1"
+  },
+  "main": "duk_debug.js"
+}

+ 1 - 0
Script/tsconfig.json

@@ -101,6 +101,7 @@
         "./AtomicEditor/ui/ResourceEditorProvider.ts",
         "./AtomicEditor/ui/ResourceEditorProvider.ts",
         "./AtomicEditor/ui/resourceEditors/AbstractTextResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/AbstractTextResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/CSharpResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/CSharpResourceEditorBuilder.ts",
+        "./AtomicEditor/ui/resourceEditors/DukDebuggerResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/JavascriptResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/JavascriptResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/JsonResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/JsonResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/Scene3dResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/Scene3dResourceEditorBuilder.ts",

+ 9 - 0
Source/AtomicApp/Player/IPCPlayerApp.cpp

@@ -987,6 +987,7 @@ void duk_trans_socket_write_flush_cb(void *udata) {
             {
             {
                 ATOMIC_LOGERROR("IPCPlayerApp::Start() - Unable to initialize IPC Worker");
                 ATOMIC_LOGERROR("IPCPlayerApp::Start() - Unable to initialize IPC Worker");
             }
             }
+
         }
         }
 
 
         if (subprocess_)
         if (subprocess_)
@@ -1005,6 +1006,13 @@ void duk_trans_socket_write_flush_cb(void *udata) {
 
 
         GetSubsystem<Graphics>()->RaiseWindow();
         GetSubsystem<Graphics>()->RaiseWindow();
 
 
+        if (debugPlayer_)
+        {
+            ATOMIC_LOGERROR("Starting Debugger");
+            set_autoreconn (this);  // for auto-reconnect
+            //SendEvent(E_JSDEBUGGER);
+            Reconnect();
+        }
 
 
     }
     }
 
 
@@ -1060,6 +1068,7 @@ void duk_trans_socket_write_flush_cb(void *udata) {
             }
             }
         }
         }
 
 
+
     }
     }
 
 
     void IPCPlayerApp::HandleJSError(StringHash eventType, VariantMap& eventData)
     void IPCPlayerApp::HandleJSError(StringHash eventType, VariantMap& eventData)

部分文件因为文件数量过多而无法显示