├── .gitignore ├── Extension ├── .eslintrc.json ├── .vscodeignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── css.css-data.json ├── html.html-data.json ├── icon.png ├── package-lock.json ├── package.json ├── src │ ├── extension.ts │ └── test │ │ ├── css.css │ │ ├── html.html │ │ ├── runTest.ts │ │ └── suite │ │ ├── extension.test.ts │ │ └── index.ts ├── tsconfig.json └── vsc-extension-quickstart.md ├── README.md ├── build.sh ├── jsconfig.json ├── sciter.d.ts ├── src ├── 01.d.ts ├── Element.d.ts ├── Element.selection.d.ts ├── Element.state.d.ts ├── Element.style.d.ts ├── Event.d.ts ├── Graphics.d.ts ├── Node.d.ts ├── Window.d.ts ├── behaviors.d.ts ├── document.d.ts ├── global.d.ts ├── jsx.d.ts ├── module-debug.d.ts ├── module-env.d.ts ├── module-sciter.d.ts ├── module-storage.d.ts └── module-sys.d.ts └── test ├── Graphics.js ├── fetch.js └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | .vscode 11 | *.vsix 12 | 13 | # Diagnostic reports (https://nodejs.org/api/report.html) 14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | *.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | *.lcov 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | node_modules/ 46 | jspm_packages/ 47 | 48 | # Snowpack dependency directory (https://snowpack.dev/) 49 | web_modules/ 50 | 51 | # TypeScript cache 52 | *.tsbuildinfo 53 | 54 | # Optional npm cache directory 55 | .npm 56 | 57 | # Optional eslint cache 58 | .eslintcache 59 | 60 | # Optional stylelint cache 61 | .stylelintcache 62 | 63 | # Microbundle cache 64 | .rpt2_cache/ 65 | .rts2_cache_cjs/ 66 | .rts2_cache_es/ 67 | .rts2_cache_umd/ 68 | 69 | # Optional REPL history 70 | .node_repl_history 71 | 72 | # Output of 'npm pack' 73 | *.tgz 74 | 75 | # Yarn Integrity file 76 | .yarn-integrity 77 | 78 | # dotenv environment variable files 79 | .env 80 | .env.development.local 81 | .env.test.local 82 | .env.production.local 83 | .env.local 84 | 85 | # parcel-bundler cache (https://parceljs.org/) 86 | .cache 87 | .parcel-cache 88 | 89 | # Next.js build output 90 | .next 91 | out 92 | 93 | # Nuxt.js build / generate output 94 | .nuxt 95 | dist 96 | 97 | # Gatsby files 98 | .cache/ 99 | # Comment in the public line in if your project uses Gatsby and not Next.js 100 | # https://nextjs.org/blog/next-9-1#public-directory-support 101 | # public 102 | 103 | # vuepress build output 104 | .vuepress/dist 105 | 106 | # vuepress v2.x temp and cache directory 107 | .temp 108 | .cache 109 | 110 | # Docusaurus cache and generated files 111 | .docusaurus 112 | 113 | # Serverless directories 114 | .serverless/ 115 | 116 | # FuseBox cache 117 | .fusebox/ 118 | 119 | # DynamoDB Local files 120 | .dynamodb/ 121 | 122 | # TernJS port file 123 | .tern-port 124 | 125 | # Stores VSCode versions used for testing VSCode extensions 126 | .vscode-test 127 | 128 | # yarn v2 129 | .yarn/cache 130 | .yarn/unplugged 131 | .yarn/build-state.yml 132 | .yarn/install-state.gz 133 | .pnp.* -------------------------------------------------------------------------------- /Extension/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/naming-convention": "warn", 13 | "@typescript-eslint/semi": "warn", 14 | "curly": "warn", 15 | "eqeqeq": "warn", 16 | "no-throw-literal": "warn", 17 | "semi": "off" 18 | }, 19 | "ignorePatterns": [ 20 | "out", 21 | "dist", 22 | "**/*.d.ts" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /Extension/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | src/** 4 | .gitignore 5 | .yarnrc 6 | vsc-extension-quickstart.md 7 | **/tsconfig.json 8 | **/.eslintrc.json 9 | **/*.map 10 | **/*.ts 11 | **/test/** -------------------------------------------------------------------------------- /Extension/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "SciterJS" extension will be documented in this file. 4 | 5 | Request feature and report issues at https://github.com/MustafaHi/Sciter-VSCode 6 | 7 | -------------------------------------------------------------------------------- /Extension/LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | Title : Sciter VSCode 5 | Author: MustafaHi (https://github.com/MustafaHi) 6 | Source: https://github.com/MustafaHi/Sciter-VSCode 7 | 8 | 1. Definitions 9 | -------------- 10 | 11 | 1.1. "Contributor" 12 | means each individual or legal entity that creates, contributes to 13 | the creation of, or owns Covered Software. 14 | 15 | 1.2. "Contributor Version" 16 | means the combination of the Contributions of others (if any) used 17 | by a Contributor and that particular Contributor's Contribution. 18 | 19 | 1.3. "Contribution" 20 | means Covered Software of a particular Contributor. 21 | 22 | 1.4. "Covered Software" 23 | means Source Code Form to which the initial Contributor has attached 24 | the notice in Exhibit A, the Executable Form of such Source Code 25 | Form, and Modifications of such Source Code Form, in each case 26 | including portions thereof. 27 | 28 | 1.5. "Incompatible With Secondary Licenses" 29 | means 30 | 31 | (a) that the initial Contributor has attached the notice described 32 | in Exhibit B to the Covered Software; or 33 | 34 | (b) that the Covered Software was made available under the terms of 35 | version 1.1 or earlier of the License, but not also under the 36 | terms of a Secondary License. 37 | 38 | 1.6. "Executable Form" 39 | means any form of the work other than Source Code Form. 40 | 41 | 1.7. "Larger Work" 42 | means a work that combines Covered Software with other material, in 43 | a separate file or files, that is not Covered Software. 44 | 45 | 1.8. "License" 46 | means this document. 47 | 48 | 1.9. "Licensable" 49 | means having the right to grant, to the maximum extent possible, 50 | whether at the time of the initial grant or subsequently, any and 51 | all of the rights conveyed by this License. 52 | 53 | 1.10. "Modifications" 54 | means any of the following: 55 | 56 | (a) any file in Source Code Form that results from an addition to, 57 | deletion from, or modification of the contents of Covered 58 | Software; or 59 | 60 | (b) any new file in Source Code Form that contains any Covered 61 | Software. 62 | 63 | 1.11. "Patent Claims" of a Contributor 64 | means any patent claim(s), including without limitation, method, 65 | process, and apparatus claims, in any patent Licensable by such 66 | Contributor that would be infringed, but for the grant of the 67 | License, by the making, using, selling, offering for sale, having 68 | made, import, or transfer of either its Contributions or its 69 | Contributor Version. 70 | 71 | 1.12. "Secondary License" 72 | means either the GNU General Public License, Version 2.0, the GNU 73 | Lesser General Public License, Version 2.1, the GNU Affero General 74 | Public License, Version 3.0, or any later versions of those 75 | licenses. 76 | 77 | 1.13. "Source Code Form" 78 | means the form of the work preferred for making modifications. 79 | 80 | 1.14. "You" (or "Your") 81 | means an individual or a legal entity exercising rights under this 82 | License. For legal entities, "You" includes any entity that 83 | controls, is controlled by, or is under common control with You. For 84 | purposes of this definition, "control" means (a) the power, direct 85 | or indirect, to cause the direction or management of such entity, 86 | whether by contract or otherwise, or (b) ownership of more than 87 | fifty percent (50%) of the outstanding shares or beneficial 88 | ownership of such entity. 89 | 90 | 2. License Grants and Conditions 91 | -------------------------------- 92 | 93 | 2.1. Grants 94 | 95 | Each Contributor hereby grants You a world-wide, royalty-free, 96 | non-exclusive license: 97 | 98 | (a) under intellectual property rights (other than patent or trademark) 99 | Licensable by such Contributor to use, reproduce, make available, 100 | modify, display, perform, distribute, and otherwise exploit its 101 | Contributions, either on an unmodified basis, with Modifications, or 102 | as part of a Larger Work; and 103 | 104 | (b) under Patent Claims of such Contributor to make, use, sell, offer 105 | for sale, have made, import, and otherwise transfer either its 106 | Contributions or its Contributor Version. 107 | 108 | 2.2. Effective Date 109 | 110 | The licenses granted in Section 2.1 with respect to any Contribution 111 | become effective for each Contribution on the date the Contributor first 112 | distributes such Contribution. 113 | 114 | 2.3. Limitations on Grant Scope 115 | 116 | The licenses granted in this Section 2 are the only rights granted under 117 | this License. No additional rights or licenses will be implied from the 118 | distribution or licensing of Covered Software under this License. 119 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 120 | Contributor: 121 | 122 | (a) for any code that a Contributor has removed from Covered Software; 123 | or 124 | 125 | (b) for infringements caused by: (i) Your and any other third party's 126 | modifications of Covered Software, or (ii) the combination of its 127 | Contributions with other software (except as part of its Contributor 128 | Version); or 129 | 130 | (c) under Patent Claims infringed by Covered Software in the absence of 131 | its Contributions. 132 | 133 | This License does not grant any rights in the trademarks, service marks, 134 | or logos of any Contributor (except as may be necessary to comply with 135 | the notice requirements in Section 3.4). 136 | 137 | 2.4. Subsequent Licenses 138 | 139 | No Contributor makes additional grants as a result of Your choice to 140 | distribute the Covered Software under a subsequent version of this 141 | License (see Section 10.2) or under the terms of a Secondary License (if 142 | permitted under the terms of Section 3.3). 143 | 144 | 2.5. Representation 145 | 146 | Each Contributor represents that the Contributor believes its 147 | Contributions are its original creation(s) or it has sufficient rights 148 | to grant the rights to its Contributions conveyed by this License. 149 | 150 | 2.6. Fair Use 151 | 152 | This License is not intended to limit any rights You have under 153 | applicable copyright doctrines of fair use, fair dealing, or other 154 | equivalents. 155 | 156 | 2.7. Conditions 157 | 158 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 159 | in Section 2.1. 160 | 161 | 3. Responsibilities 162 | ------------------- 163 | 164 | 3.1. Distribution of Source Form 165 | 166 | All distribution of Covered Software in Source Code Form, including any 167 | Modifications that You create or to which You contribute, must be under 168 | the terms of this License. You must inform recipients that the Source 169 | Code Form of the Covered Software is governed by the terms of this 170 | License, and how they can obtain a copy of this License. You may not 171 | attempt to alter or restrict the recipients' rights in the Source Code 172 | Form. 173 | 174 | 3.2. Distribution of Executable Form 175 | 176 | If You distribute Covered Software in Executable Form then: 177 | 178 | (a) such Covered Software must also be made available in Source Code 179 | Form, as described in Section 3.1, and You must inform recipients of 180 | the Executable Form how they can obtain a copy of such Source Code 181 | Form by reasonable means in a timely manner, at a charge no more 182 | than the cost of distribution to the recipient; and 183 | 184 | (b) You may distribute such Executable Form under the terms of this 185 | License, or sublicense it under different terms, provided that the 186 | license for the Executable Form does not attempt to limit or alter 187 | the recipients' rights in the Source Code Form under this License. 188 | 189 | 3.3. Distribution of a Larger Work 190 | 191 | You may create and distribute a Larger Work under terms of Your choice, 192 | provided that You also comply with the requirements of this License for 193 | the Covered Software. If the Larger Work is a combination of Covered 194 | Software with a work governed by one or more Secondary Licenses, and the 195 | Covered Software is not Incompatible With Secondary Licenses, this 196 | License permits You to additionally distribute such Covered Software 197 | under the terms of such Secondary License(s), so that the recipient of 198 | the Larger Work may, at their option, further distribute the Covered 199 | Software under the terms of either this License or such Secondary 200 | License(s). 201 | 202 | 3.4. Notices 203 | 204 | You may not remove or alter the substance of any license notices 205 | (including copyright notices, patent notices, disclaimers of warranty, 206 | or limitations of liability) contained within the Source Code Form of 207 | the Covered Software, except that You may alter any license notices to 208 | the extent required to remedy known factual inaccuracies. 209 | 210 | 3.5. Application of Additional Terms 211 | 212 | You may choose to offer, and to charge a fee for, warranty, support, 213 | indemnity or liability obligations to one or more recipients of Covered 214 | Software. However, You may do so only on Your own behalf, and not on 215 | behalf of any Contributor. You must make it absolutely clear that any 216 | such warranty, support, indemnity, or liability obligation is offered by 217 | You alone, and You hereby agree to indemnify every Contributor for any 218 | liability incurred by such Contributor as a result of warranty, support, 219 | indemnity or liability terms You offer. You may include additional 220 | disclaimers of warranty and limitations of liability specific to any 221 | jurisdiction. 222 | 223 | 4. Inability to Comply Due to Statute or Regulation 224 | --------------------------------------------------- 225 | 226 | If it is impossible for You to comply with any of the terms of this 227 | License with respect to some or all of the Covered Software due to 228 | statute, judicial order, or regulation then You must: (a) comply with 229 | the terms of this License to the maximum extent possible; and (b) 230 | describe the limitations and the code they affect. Such description must 231 | be placed in a text file included with all distributions of the Covered 232 | Software under this License. Except to the extent prohibited by statute 233 | or regulation, such description must be sufficiently detailed for a 234 | recipient of ordinary skill to be able to understand it. 235 | 236 | 5. Termination 237 | -------------- 238 | 239 | 5.1. The rights granted under this License will terminate automatically 240 | if You fail to comply with any of its terms. However, if You become 241 | compliant, then the rights granted under this License from a particular 242 | Contributor are reinstated (a) provisionally, unless and until such 243 | Contributor explicitly and finally terminates Your grants, and (b) on an 244 | ongoing basis, if such Contributor fails to notify You of the 245 | non-compliance by some reasonable means prior to 60 days after You have 246 | come back into compliance. Moreover, Your grants from a particular 247 | Contributor are reinstated on an ongoing basis if such Contributor 248 | notifies You of the non-compliance by some reasonable means, this is the 249 | first time You have received notice of non-compliance with this License 250 | from such Contributor, and You become compliant prior to 30 days after 251 | Your receipt of the notice. 252 | 253 | 5.2. If You initiate litigation against any entity by asserting a patent 254 | infringement claim (excluding declaratory judgment actions, 255 | counter-claims, and cross-claims) alleging that a Contributor Version 256 | directly or indirectly infringes any patent, then the rights granted to 257 | You by any and all Contributors for the Covered Software under Section 258 | 2.1 of this License shall terminate. 259 | 260 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 261 | end user license agreements (excluding distributors and resellers) which 262 | have been validly granted by You or Your distributors under this License 263 | prior to termination shall survive termination. 264 | 265 | ************************************************************************ 266 | * * 267 | * 6. Disclaimer of Warranty * 268 | * ------------------------- * 269 | * * 270 | * Covered Software is provided under this License on an "as is" * 271 | * basis, without warranty of any kind, either expressed, implied, or * 272 | * statutory, including, without limitation, warranties that the * 273 | * Covered Software is free of defects, merchantable, fit for a * 274 | * particular purpose or non-infringing. The entire risk as to the * 275 | * quality and performance of the Covered Software is with You. * 276 | * Should any Covered Software prove defective in any respect, You * 277 | * (not any Contributor) assume the cost of any necessary servicing, * 278 | * repair, or correction. This disclaimer of warranty constitutes an * 279 | * essential part of this License. No use of any Covered Software is * 280 | * authorized under this License except under this disclaimer. * 281 | * * 282 | ************************************************************************ 283 | 284 | ************************************************************************ 285 | * * 286 | * 7. Limitation of Liability * 287 | * -------------------------- * 288 | * * 289 | * Under no circumstances and under no legal theory, whether tort * 290 | * (including negligence), contract, or otherwise, shall any * 291 | * Contributor, or anyone who distributes Covered Software as * 292 | * permitted above, be liable to You for any direct, indirect, * 293 | * special, incidental, or consequential damages of any character * 294 | * including, without limitation, damages for lost profits, loss of * 295 | * goodwill, work stoppage, computer failure or malfunction, or any * 296 | * and all other commercial damages or losses, even if such party * 297 | * shall have been informed of the possibility of such damages. This * 298 | * limitation of liability shall not apply to liability for death or * 299 | * personal injury resulting from such party's negligence to the * 300 | * extent applicable law prohibits such limitation. Some * 301 | * jurisdictions do not allow the exclusion or limitation of * 302 | * incidental or consequential damages, so this exclusion and * 303 | * limitation may not apply to You. * 304 | * * 305 | ************************************************************************ 306 | 307 | 8. Litigation 308 | ------------- 309 | 310 | Any litigation relating to this License may be brought only in the 311 | courts of a jurisdiction where the defendant maintains its principal 312 | place of business and such litigation shall be governed by laws of that 313 | jurisdiction, without reference to its conflict-of-law provisions. 314 | Nothing in this Section shall prevent a party's ability to bring 315 | cross-claims or counter-claims. 316 | 317 | 9. Miscellaneous 318 | ---------------- 319 | 320 | This License represents the complete agreement concerning the subject 321 | matter hereof. If any provision of this License is held to be 322 | unenforceable, such provision shall be reformed only to the extent 323 | necessary to make it enforceable. Any law or regulation which provides 324 | that the language of a contract shall be construed against the drafter 325 | shall not be used to construe this License against a Contributor. 326 | 327 | 10. Versions of the License 328 | --------------------------- 329 | 330 | 10.1. New Versions 331 | 332 | Mozilla Foundation is the license steward. Except as provided in Section 333 | 10.3, no one other than the license steward has the right to modify or 334 | publish new versions of this License. Each version will be given a 335 | distinguishing version number. 336 | 337 | 10.2. Effect of New Versions 338 | 339 | You may distribute the Covered Software under the terms of the version 340 | of the License under which You originally received the Covered Software, 341 | or under the terms of any subsequent version published by the license 342 | steward. 343 | 344 | 10.3. Modified Versions 345 | 346 | If you create software not governed by this License, and you want to 347 | create a new license for such software, you may create and use a 348 | modified version of this License if you rename the license and remove 349 | any references to the name of the license steward (except to note that 350 | such modified license differs from this License). 351 | 352 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 353 | Licenses 354 | 355 | If You choose to distribute Source Code Form that is Incompatible With 356 | Secondary Licenses under the terms of this version of the License, the 357 | notice described in Exhibit B of this License must be attached. 358 | 359 | Exhibit A - Source Code Form License Notice 360 | ------------------------------------------- 361 | 362 | This Source Code Form is subject to the terms of the Mozilla Public 363 | License, v. 2.0. If a copy of the MPL was not distributed with this 364 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 365 | 366 | If it is not possible or desirable to put the notice in a particular 367 | file, then You may include the notice in a location (such as a LICENSE 368 | file in a relevant directory) where a recipient would be likely to look 369 | for such a notice. 370 | 371 | You may add additional accurate notices of copyright ownership. 372 | 373 | Exhibit B - "Incompatible With Secondary Licenses" Notice 374 | --------------------------------------------------------- 375 | 376 | This Source Code Form is "Incompatible With Secondary Licenses", as 377 | defined by the Mozilla Public License, v. 2.0. 378 | -------------------------------------------------------------------------------- /Extension/README.md: -------------------------------------------------------------------------------- 1 | # SciterJS 2 | 3 | Provide Intellisense and auto-complete for [Sciter](https://sciter.com/) specific JavaScript, CSS and HTML. 4 | 5 | ## Features 6 | 7 | - Intellisense for Sciter specific JavaScript 8 | - Support for Sciter's HTML and CSS properties 9 | - Auto Update Intellisense declarations 10 | 11 | Request feature and report issues at https://github.com/MustafaHi/Sciter-VSCode 12 | 13 | ## Usage 14 | 15 | - To install Intellisense run the command `Initialize Sciter Project` 16 | - Intellisense will auto update after installing, you can disable that in preferences 17 | - CSS and HTML support work by default 18 | 19 | ## Extension Settings 20 | 21 | * `SciterJS.autoUpdate`: `true` | automatically update intellisense on vscode start 22 | 23 | 28 | 29 | -------------------------------------------------------------------------------- /Extension/css.css-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1.1, 3 | "properties": [ 4 | { 5 | "name": "size", 6 | "description": "Define ", 7 | "restrictions": ["length"] 8 | }, 9 | { 10 | "name": "behavior", 11 | "description": { 12 | "kind": "markdown", 13 | "value": "`name url(path)` define native behavior." 14 | } 15 | }, 16 | { 17 | "name": "prototype", 18 | "description": { 19 | "kind": "markdown", 20 | "value": "`name [ url(...) ]` Name of the class in the script, Such a class can define methods, properties and event handling methods of the whole class of elements this style applies to." 21 | } 22 | }, 23 | { 24 | "name": "aspect", 25 | "description": { 26 | "kind": "markdown", 27 | "value": "`functionName [ url(...) ]` One or list of name/url pairs. functions are called once on initialization." 28 | } 29 | }, 30 | { 31 | "name": "font-rendering-mode", 32 | "description": "Font rendering algorithms for quality/speed.", 33 | "values": [ 34 | { 35 | "name": "sub-pixel", 36 | "description": "Higher quality rendering, letters are placed between pixels." 37 | }, 38 | { 39 | "name": "snap-pixel", 40 | "description": "Faster rendering method." 41 | } 42 | ] 43 | }, 44 | { 45 | "name": "hit-margin", 46 | "description": "defines hover area of the element. Positive values increase hover area and negative values decrease it. Hit margins are calculated from border box of the element.", 47 | "restrictions": ["length"] 48 | }, 49 | { 50 | "name": "context-menu", 51 | "description": "Use as custom (right click) context menu", 52 | "syntax": "selector(#element) | url(file.htm)" 53 | }, 54 | { 55 | "name": "vertical-scrollbar", 56 | "description": { 57 | "kind": "markdown", 58 | "value": "`style-set-name` - style set that defines styles of vertical scrollbar." 59 | }, 60 | "restrictions": ["string"] 61 | }, 62 | { 63 | "name": "horizontal-scrollbar", 64 | "description": { 65 | "kind": "markdown", 66 | "value": "`style-set-name` - style set that defines styles of horizontal scrollbar." 67 | }, 68 | "restrictions": ["string"] 69 | }, 70 | { 71 | "name": "flow", 72 | "description": "Direction of child elements flow. This attribute defines type of layout manager (LM) used by the block container.", 73 | "values": [ 74 | { "name": "vertical" }, 75 | { "name": "horizontal" }, 76 | { "name": "vertical-wrap" }, 77 | { "name": "horizontal-wrap" } 78 | ], 79 | "references": [{ 80 | "name": "Documentation", 81 | "url": "https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/css/css-layout.md#basic-flow" 82 | }] 83 | }, 84 | { 85 | "name": "flow-columns", 86 | "description": "Define lists of column size defintions of the grid.", 87 | "syntax": "...", 88 | "restrictions": ["enum"], 89 | "references": [{ 90 | "name": "Documentation", 91 | "url": "https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/css/css-layout.md#flow-columns-and-flow-rows" 92 | }] 93 | }, 94 | { 95 | "name": "flow-rows", 96 | "description": "Define lists of row size defintions of the grid.", 97 | "syntax": "...", 98 | "restrictions": ["enum"], 99 | "references": [{ 100 | "name": "Documentation", 101 | "url": "https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/css/css-layout.md#flow-columns-and-flow-rows" 102 | }] 103 | }, 104 | { 105 | "name": "horizontal-align", 106 | "description": "Horizontal alignment of content", 107 | "values": [ 108 | { "name": "center" }, 109 | { "name": "left" }, 110 | { "name": "right" }, 111 | { "name": "start" }, 112 | { "name": "end" } 113 | ], 114 | "restrictions": ["string"], 115 | "references": [{ 116 | "name": "Documentation", 117 | "url": "https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/css/css-layout.md#basic-content-alignment" 118 | }] 119 | }, 120 | { 121 | "name": "border-spacing", 122 | "description": "Defines spacing between all direct child elements (inter-cell spacing);", 123 | "restrictions": ["length"], 124 | "references": [{ 125 | "name": "Documentation", 126 | "url": "https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/css/css-layout.md#spacing" 127 | }] 128 | }, 129 | { 130 | "name": "style-set", 131 | "description": "named block of style rules declarations that are applied to elements DOM sub-tree.", 132 | "references": [{ 133 | "name": "Documentation", 134 | "url": "https://sciter.com/style-sets-in-h-smile-core/" 135 | }] 136 | }, 137 | 138 | { 139 | "name": "text-selection", 140 | "description": "Define text color and background of selected text.", 141 | "syntax": " ", 142 | "restrictions": ["color"] 143 | }, 144 | { 145 | "name": "text-selection-color", 146 | "description": "Color of selected text.", 147 | "restrictions": ["color"] 148 | }, 149 | { 150 | "name": "text-selection-caret-color", 151 | "description": "Color of cursor(caret).", 152 | "restrictions": ["color"] 153 | }, 154 | { 155 | "name": "text-selection-background-color", 156 | "description": "Background color of text selection.", 157 | "restrictions": ["color"] 158 | }, 159 | 160 | { 161 | "name": "foreground", 162 | "description": "has the same set of attributes as background, but is drawn on top of everything.", 163 | "syntax": "[ , ]* ", 164 | "restrictions": [ 165 | "enum", 166 | "image", 167 | "color", 168 | "position", 169 | "length", 170 | "repeat", 171 | "percentage", 172 | "box" 173 | ], 174 | "references": [ 175 | { 176 | "name": "MDN Reference", 177 | "url": "https://developer.mozilla.org/docs/Web/CSS/background" 178 | } 179 | ] 180 | }, 181 | { 182 | "name": "foreground-color", 183 | "syntax": "", 184 | "description": "Sets the background color of an element.", 185 | "restrictions": [ 186 | "color" 187 | ], 188 | "references": [ 189 | { 190 | "name": "MDN Reference", 191 | "url": "https://developer.mozilla.org/docs/Web/CSS/background-color" 192 | } 193 | ] 194 | }, 195 | { 196 | "name": "foreground-attachment", 197 | "values": [ 198 | { 199 | "name": "fixed", 200 | "description": "The foreground is fixed with regard to the viewport. In paged media where there is no viewport, a 'fixed' foreground is fixed with respect to the page box and therefore replicated on every page." 201 | }, 202 | { 203 | "name": "local", 204 | "description": "The foreground is fixed with regard to the element’s contents: if the element has a scrolling mechanism, the foreground scrolls with the element’s contents." 205 | }, 206 | { 207 | "name": "scroll", 208 | "description": "The foreground is fixed with regard to the element itself and does not scroll with its contents. (It is effectively attached to the element’s border.)" 209 | } 210 | ], 211 | "syntax": "#", 212 | "description": "Specifies whether the foreground images are fixed with regard to the viewport ('fixed') or scroll along with the element ('scroll') or its contents ('local').", 213 | "restrictions": [ 214 | "enum" 215 | ], 216 | "references": [ 217 | { 218 | "name": "MDN Reference", 219 | "url": "https://developer.mozilla.org/docs/Web/CSS/background-attachment" 220 | } 221 | ] 222 | }, 223 | { 224 | "name": "foreground-image", 225 | "values": [ 226 | { 227 | "name": "none", 228 | "description": "Counts as an image layer but draws nothing." 229 | } 230 | ], 231 | "syntax": "#", 232 | "references": [ 233 | { 234 | "name": "MDN Reference", 235 | "url": "https://developer.mozilla.org/docs/Web/CSS/background-image" 236 | } 237 | ], 238 | "description": "Sets the foreground image(s) of an element.", 239 | "restrictions": [ 240 | "image", 241 | "enum" 242 | ] 243 | }, 244 | { 245 | "name": "foreground-position", 246 | "syntax": "#", 247 | "references": [ 248 | { 249 | "name": "MDN Reference", 250 | "url": "https://developer.mozilla.org/docs/Web/CSS/background-position" 251 | } 252 | ], 253 | "description": "Specifies the initial position of the foreground image(s) (after any resizing) within their corresponding foreground positioning area.", 254 | "restrictions": [ 255 | "position", 256 | "length", 257 | "percentage" 258 | ] 259 | }, 260 | { 261 | "name": "foreground-size", 262 | "values": [ 263 | { 264 | "name": "auto", 265 | "description": "Resolved by using the image’s intrinsic ratio and the size of the other dimension, or failing that, using the image’s intrinsic size, or failing that, treating it as 100%." 266 | }, 267 | { 268 | "name": "contain", 269 | "description": "Scale the image, while preserving its intrinsic aspect ratio (if any), to the largest size such that both its width and its height can fit inside the foreground positioning area." 270 | }, 271 | { 272 | "name": "cover", 273 | "description": "Scale the image, while preserving its intrinsic aspect ratio (if any), to the smallest size such that both its width and its height can completely cover the foreground positioning area." 274 | } 275 | ], 276 | "syntax": "#", 277 | "relevance": 85, 278 | "references": [ 279 | { 280 | "name": "MDN Reference", 281 | "url": "https://developer.mozilla.org/docs/Web/CSS/background-size" 282 | } 283 | ], 284 | "description": "Specifies the size of the foreground images.", 285 | "restrictions": [ 286 | "length", 287 | "percentage" 288 | ] 289 | }, 290 | { 291 | "name": "foreground-repeat", 292 | "values": [ 293 | { 294 | "name": "expand", 295 | "description": "Expandable filling mode" 296 | }, 297 | { 298 | "name": "stretch", 299 | "description": "Image is stretched to fill background in full. This is the same mode as rendering of image in element. If stretch is combined with keep-ratio then images is resized with preservation of aspect ratio. To position such an image use foreground-position attribute." 300 | } 301 | ], 302 | "syntax": "#", 303 | "references": [ 304 | { 305 | "name": "MDN Reference", 306 | "url": "https://developer.mozilla.org/docs/Web/CSS/background-repeat" 307 | } 308 | ], 309 | "description": "Specifies how foreground images are tiled after they have been sized and positioned.", 310 | "restrictions": [ 311 | "repeat" 312 | ] 313 | }, 314 | { 315 | "name": "foreground-image-cursor", 316 | "values": [ 317 | { "name": "auto" }, 318 | { "name": "crosshair" }, 319 | { "name": "default" }, 320 | { "name": "pointer" }, 321 | { "name": "move" }, 322 | { "name": "e-resize" }, 323 | { "name": "ne-resize" }, 324 | { "name": "nw-resize" }, 325 | { "name": "n-resize" }, 326 | { "name": "s-resize" }, 327 | { "name": "se-resize" }, 328 | { "name": "sw-resize" }, 329 | { "name": "w-resize" }, 330 | { "name": "text" }, 331 | { "name": "wait" }, 332 | { "name": "help" }, 333 | { "name": "progress" }, 334 | { "name": "no-drop" } 335 | ], 336 | "description": "Used when foreground-repeat has no-repeat value to define when mouse hovers foreground-image area.", 337 | "restrictions": [ 338 | "url" 339 | ] 340 | }, 341 | 342 | { 343 | "name": "list-marker-color", 344 | "description": "Sets the color of the list marker", 345 | "restrictions": ["color"] 346 | }, 347 | { 348 | "name": "list-marker-size", 349 | "description": "Sets the size of the list marker", 350 | "restrictions": ["length"] 351 | }, 352 | { 353 | "name": "list-marker-style", 354 | "description": "Sets the style of the list marker.", 355 | "values": [ 356 | { "name": "none" }, 357 | { "name": "dotted" }, 358 | { "name": "dashed" }, 359 | { "name": "solid" } 360 | ] 361 | }, 362 | 363 | { 364 | "name": "overflow", 365 | "values": [ 366 | { 367 | "name": "hidden-scroll", 368 | "description": "The scrollbar is not shown but content of the element is scrollable." 369 | }, 370 | { 371 | "name": "scroll-indicator", 372 | "description": "Element shows scroll position indicator when mouse is hovering this element." 373 | }, 374 | { 375 | "name": "none", 376 | "description": "That's an equivalent of defining `{ overflow:visible; min-width:min-content; min-height:min-content; }`" 377 | } 378 | ] 379 | }, 380 | 381 | { 382 | "name": "scroll-manner", 383 | "description": { 384 | "kind": "markdown", 385 | "value": "`scroll-manner( animation:false, step:auto... )` define scroll animation and behavior." 386 | } 387 | }, 388 | { 389 | "name": "scroll-manner-x", 390 | "description": { 391 | "kind": "markdown", 392 | "value": "`scroll-manner( animation:false, step:auto... )` define scroll animation and behavior." 393 | } 394 | }, 395 | { 396 | "name": "scroll-manner-y", 397 | "description": { 398 | "kind": "markdown", 399 | "value": "`scroll-manner( animation:false, step:auto... )` define scroll animation and behavior." 400 | } 401 | }, 402 | { 403 | "name": "mapping", 404 | "description": { 405 | "kind": "markdown", 406 | "value": "defines mapping of directional related properties. `left-to-right(border,margin)`" 407 | }, 408 | "syntax": "inherit( ) | none( ) | left-to-right( ) | top-to-right( )", 409 | "values": [ 410 | { "name": "none" }, 411 | { "name": "left-to-right" }, 412 | { "name": "top-to-right" } 413 | ] 414 | }, 415 | 416 | { 417 | "name": "popup-position", 418 | "description": "Popup position relative to the element that requested the popup (anchor element).", 419 | "syntax": " | ", 420 | "values": [ 421 | { 422 | "name": "at-tail", 423 | "description": "popup appears as popup element of the 8 | 9 | 10 | -------------------------------------------------------------------------------- /Extension/src/test/runTest.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | import { runTests } from '@vscode/test-electron'; 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 10 | 11 | // The path to test runner 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests'); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /Extension/src/test/suite/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | import * as vscode from 'vscode'; 6 | // import * as myExtension from '../../extension'; 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5)); 13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /Extension/src/test/suite/index.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import * as Mocha from 'mocha'; 3 | import * as glob from 'glob'; 4 | 5 | export function run(): Promise { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: 'tdd', 9 | color: true 10 | }); 11 | 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | 14 | return new Promise((c, e) => { 15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { 16 | if (err) { 17 | return e(err); 18 | } 19 | 20 | // Add files to the test suite 21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 22 | 23 | try { 24 | // Run the mocha test 25 | mocha.run(failures => { 26 | if (failures > 0) { 27 | e(new Error(`${failures} tests failed.`)); 28 | } else { 29 | c(); 30 | } 31 | }); 32 | } catch (err) { 33 | console.error(err); 34 | e(err); 35 | } 36 | }); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /Extension/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES2020", 5 | "outDir": "out", 6 | "lib": [ 7 | "ES2020" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "strict": true /* enable all strict type-checking options */ 12 | /* Additional Checks */ 13 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 14 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 15 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Extension/vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # REFERENCES 4 | - css properties: https://github.com/microsoft/vscode-css-languageservice/blob/main/src/data/webCustomData.ts 5 | 6 | 7 | 8 | ------------------------ 9 | 10 | # Welcome to your VS Code Extension 11 | 12 | ## What's in the folder 13 | 14 | * This folder contains all of the files necessary for your extension. 15 | * `package.json` - this is the manifest file in which you declare your extension and command. 16 | * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. 17 | * `src/extension.ts` - this is the main file where you will provide the implementation of your command. 18 | * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 19 | * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. 20 | 21 | ## Get up and running straight away 22 | 23 | * Press `F5` to open a new window with your extension loaded. 24 | * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. 25 | * Set breakpoints in your code inside `src/extension.ts` to debug your extension. 26 | * Find output from your extension in the debug console. 27 | 28 | ## Make changes 29 | 30 | * You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`. 31 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 32 | 33 | 34 | ## Explore the API 35 | 36 | * You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. 37 | 38 | ## Run tests 39 | 40 | * Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`. 41 | * Press `F5` to run the tests in a new window with your extension loaded. 42 | * See the output of the test result in the debug console. 43 | * Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder. 44 | * The provided test runner will only consider files matching the name pattern `**.test.ts`. 45 | * You can create folders inside the `test` folder to structure your tests any way you want. 46 | 47 | ## Go further 48 | 49 | * Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). 50 | * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace. 51 | * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sciter JS Extension 2 | 3 | Visual Studio Code extension 4 | 5 | `0.11.2` 6 | 7 | ## Features 8 | 9 | - Intellisense for Sciter specific JavaScript, CSS and HTML 10 | - Auto update for Intellisense 11 | 12 | ## Usage 13 | 14 | - [Download Extension from vscode marketplace](https://marketplace.visualstudio.com/items?itemName=MustafaHi.sciterjs) 15 | - Run the command `Initialize Sciter Project`, CTRL+SHIFT+P then command 16 | - Intellisense will be auto update on every editor start, you can disable that in preferences `SciterJS.autoUpdate` 17 | - HTML and CSS support work with/out the 2nd step 18 | 19 | 20 | 21 | 22 | # sciter.d.ts 23 | 24 | Sciter declaration files for linting intellisense in VSCode 25 | 26 | `0.24.2` 27 | 28 | ### setup 29 | 30 | If you have the extension installed: 31 | Run the command `Initialize Sciter Project`, F1 then command. otherwise 32 | 33 | Include `jsconfig.json` and `sciter.d.ts` to your VSCode workspace, or where the js files reside 34 | 35 | by (default) the default declarations are disabled, and just what Sciter use is implemented in `sciter.d.ts` 36 | 37 | If you want to have the default declarations clear the `jsconfig.json` file (even if it's empty it must exist). 38 | 39 | 40 | ### contribute 41 | 42 | This is not complete or perfect if you find issue report it 43 | with sample code and references to how it should work. 44 | 45 | release version: major.minor.fix 46 | 47 | ### status 48 | 49 | the status of declarations and their documentations as of Sciter specific and default javascript/dom. 50 | | declaration | sciter | default | 51 | | ----------- | ------ | ------- | 52 | | Element | done | done | 53 | | Selection/state/style | done | done | 54 | | Document | done | done | 55 | | Event | done | done | 56 | | modules | done | done | 57 | | Range/Node | done | done | 58 | | Graphic | done | done | 59 | | Window | done | done | 60 | | global | done | done | 61 | | behaviors | done | done | 62 | 63 | initial credit [@patrick](https://sciter.com/forums/topic/typescript/#post-77670) 64 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | cat src/*.ts > sciter.d.ts -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "preserve", 4 | "module": "commonjs", 5 | "target": "ES2020", 6 | "lib": [ 7 | "ES2020" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": ".", 11 | "checkJs": true 12 | }, 13 | "exclude": [ 14 | "node_modules", 15 | "**/node_modules/*" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /src/01.d.ts: -------------------------------------------------------------------------------- 1 | //| Sciter.d.ts v0.24.2 2 | //| https://github.com/MustafaHi/sciter-vscode 3 | 4 | -------------------------------------------------------------------------------- /src/Element.d.ts: -------------------------------------------------------------------------------- 1 | interface Element extends Node, Behaviors { 2 | /** Get element matching the css selector */ 3 | $(query: string): Element; 4 | /** Get array of elements matching the css selector */ 5 | $$(query: string): array; 6 | /** Select parent element that match the query */ 7 | $p(query: string): Element; 8 | /** Owner element selector, useful to get owner of menu */ 9 | $o(query: string): Element; 10 | /** Check element match the selector */ 11 | $is(query: string): boolean; 12 | /** Posts a function or event to event queue. */ 13 | post(eventOrHandler: function(this: Element, ...any) | Event, avoidDuplicates?: boolean): boolean; 14 | /** Fire event asynchronously, `Event.target` will be set to this element, 15 | * use `dispatchEvent` for sync method 16 | * @return `false` if event is canceled with `Event.preventDefault()`. 17 | */ 18 | postEvent(event: Event, avoidDuplicates?: boolean): boolean; 19 | /** jQuery style event subscription: 20 | @param event `^name` for handling events in capturing phase 21 | @param query subscribe to all children that match the css selector otherwise this element 22 | @param handler `Function(Event, Element)` - `this` is set to the element the handler is attached to 23 | */ 24 | on(event: keyof typeof eventType, query: string, handler: eventFunction): Element; 25 | on(event: keyof typeof eventType, handler: eventFunction): Element; 26 | off(eventOrHandler: keyof typeof eventType|string|Function): Element; 27 | /** jQuery style event subscription to application wide events: 28 | * The element gets unsubscribed automatically when it is disconnected from DOM 29 | @param event `^name` for handling events in capturing phase 30 | @param handler `Function(Event, Element)` - `this` is set to the element the handler is attached to 31 | */ 32 | onGlobalEvent(event: string, handler: function(this: Element, ...any)): Element; 33 | /** Unsubscribe this element from particular event, if no argument is provided unsubscribe from all events */ 34 | offGlobalEvent(eventOrHandler?: string | function(this: Element, ...any)): Element; 35 | /** Starts timer on element. 36 | * If the element already has a timer with the same callback, it first gets removed and timer is restarted. 37 | * This allows to implement effective throttling (debounce). 38 | * @param callback `this` is set to the element, `return true` to repeat. */ 39 | timer(milliseconds: number, callback: function(this: Element, ...any): void|boolean): boolean; 40 | /** Removes content of the element, makes it empty. */ 41 | clear(): boolean; 42 | /** Interaction with native behaviors attached to the element. */ 43 | xcall(name: string, ...args): any 44 | /** Removes the element and moves its content in place in the DOM. */ 45 | unwrapElement(): boolean; 46 | /** Wraps range of nodes from start to end into wrap element - opposite action to `unwrapElement()` */ 47 | wrapNodes(start: Node, end: Node, wrap: Element); 48 | /** Reports state and allowance of particular command. The method accepts the same parameters as the `Element.execCommand()`. */ 49 | checkCommand(command: string, params?: object|string): 1|2; 50 | /** Execute undoable behavior specific commands. */ 51 | execCommand(command: string, params?: object|string): boolean; 52 | /** Immediate mode drawing "ports". 53 | * Functions assigned to these properties will be called when the element is rendered on screen 54 | * so they can draw anything on top (or below) of default HTML/CSS rendering. */ 55 | paintBackground: function(Graphics); 56 | /** Immediate mode drawing "ports". 57 | * Functions assigned to these properties will be called when the element is rendered on screen 58 | * so they can draw anything on top (or below) of default HTML/CSS rendering. */ 59 | paintForeground: function(Graphics); 60 | /** Immediate mode drawing "ports". 61 | * Functions assigned to these properties will be called when the element is rendered on screen 62 | * so they can draw anything on top (or below) of default HTML/CSS rendering. */ 63 | paintContent: function(Graphics); 64 | /** Immediate mode drawing "ports". 65 | * Functions assigned to these properties will be called when the element is rendered on screen 66 | * so they can draw anything on top (or below) of default HTML/CSS rendering. */ 67 | paintOutline: function(Graphics); 68 | /** Schedules re-paint of the element. This will trigger `Element.paintXXXX` calls. */ 69 | requestPaint(): void; 70 | /** Force repaint immediately */ 71 | flushPaint(): void; 72 | 73 | /** Shows the popup element or VNode (JSX) in out-of-canvas popup window on desktop. */ 74 | popup(popup: Element | VNode, params?: popupParams): void; 75 | /** Show this element as out-of-canvas popup window on desktop. 76 | * @param referencePoint `1-9`, see keyboard numpad for the meaning. 77 | */ 78 | popupAt(x: number, y: number, referencePoint?: number): void; 79 | /** The method offers "manual" animation support. 80 | * `function(progress: 0.0...1.0)`: true | false 81 | * Sciter will call handler with animation frame rate passing current progress value. 82 | * return false to stop animation. */ 83 | animate(handler: Function, params: animateParams): void; 84 | /** Make the element "airborn" - to be replaced outside of host window */ 85 | takeOff(params: takeoffParams): void; 86 | /** Append element as last child */ 87 | append(JSX: JSX): void; 88 | /** Insert element as the first child */ 89 | prepend(JSX: JSX): void; 90 | /** Replace content by element */ 91 | content(JSX: JSX): void; 92 | /** patches content of the element by JSX using rules of React[or]. 93 | * If second parameter is true the function patches only children but not element itself. */ 94 | patch(JSX: JSX, onlyChildren?: true): void; 95 | /** Patch properties and enqueue rendering */ 96 | componentUpdate(object?: object): Element; 97 | /** Return collapsed range (caret position) at point x/y. 98 | * x/a are local coordinates - relative to origin of element's inner box. */ 99 | rangeFromPoint(x: number, y: number): Range | null; 100 | toString(): string; 101 | 102 | 103 | /* NATIVE */ 104 | 105 | /** Get element matching the css selector */ 106 | querySelector(query: string): Element; 107 | /** Get array of elements matching the css selector */ 108 | querySelectorAll(query: string): Element[]; 109 | getElementById(id: string): Element; 110 | getElementsByClassName(className: string): Element[]; 111 | getElementsByTagName(tag: string): Element[]; 112 | getElementsByName(name: string): Element[]; 113 | /** Find the closest parent element matching the query selector */ 114 | closest(query: string): Element | null; 115 | /** Check element match the selector */ 116 | matches(query: string): boolean; 117 | firstElementChild: Element; 118 | lastElementChild: Element; 119 | nextElementSibling: Element; 120 | previousElementSibling: Element; 121 | childElementCount: number; 122 | children: Element[]; 123 | childElement(index: number): Element; 124 | readonly ownerDocument: Document; 125 | 126 | appendChild(node: Node); 127 | removeChild(node: Node); 128 | insertBefore(node: Node, refNode: Node); 129 | insertAfter(node: Node, refNode: Node); 130 | replaceChild(newNode: Node, refNode: Node); 131 | insertAdjacentHTML(where: InsertPosition, html: string): void; 132 | swapWith(element: Element); 133 | 134 | style: Style; 135 | /** Runtime flags and state on element. 136 | * Most of Element.State reflect so called CSS pseudo-classes (flags): 137 | * `element:visited { color: red; }` 138 | */ 139 | state: State; 140 | /** Represents current selection on elements that supports selection: 141 | ` ` - WYSIWYG HTML editor; 142 | `` - Plain text multiline editor; 143 | any other element with `[selectable]` attribute set; */ 144 | selection: Selection; 145 | 146 | disabled: boolean; 147 | readonly: boolean; 148 | checked: boolean; 149 | src: string; 150 | 151 | readonly attributes: string[]; 152 | hasAttribute(name: string): boolean; 153 | getAttribute(name: string): string; 154 | getAttributeNames(): string[]; 155 | setAttribute(name: string, value: string|number|undefined): void; 156 | removeAttribute(name: string): void; 157 | attributes: string[]|number[]; 158 | classList: { 159 | add(...name: string[]): void; 160 | remove(...name: string[]): void; 161 | toggle(name: string, state?: boolean): boolean; 162 | contains(name: string): boolean; 163 | length: number; 164 | readonly entries(): string[]; 165 | } 166 | /** Returns a drawing context of the canvas, instance of Graphics object. */ 167 | getContext(type: '2d'): Graphics; 168 | 169 | id: string; 170 | name: string; 171 | tagName: string; 172 | tag: string; 173 | className: string; 174 | elementIndex: number; 175 | innerHTML: string; 176 | outerHTML: string; 177 | innerText: string; 178 | value: any; 179 | 180 | scrollBy(x: number, y: number): void; 181 | scrollBy(options: { 182 | left?: number; 183 | top?: number; 184 | behavior?: "instant" | "smooth"; 185 | }): void; 186 | scrollTo(x: number, y: number): void; 187 | scrollTo(options: { 188 | left?: number; 189 | top?: number; 190 | behavior?: "instant" | "smooth"; 191 | }): void; 192 | scrollIntoView(toTop?: true): void; 193 | scrollIntoView(options: { 194 | block?: "start" | "nearest"; 195 | behavior?: "instant" | "smooth"; 196 | }): void; 197 | readonly clientLeft: number; 198 | readonly clientTop : number; 199 | readonly clientWidth: number; 200 | readonly clientHeight: number; 201 | readonly scrollLeft: number; 202 | readonly scrollTop : number; 203 | readonly scrollRight: number; 204 | readonly scrollWidth: number; 205 | readonly scrollHeight: number; 206 | getBoundingClientRect(): DOMRect; 207 | 208 | click(): void; 209 | focus(): void; 210 | /** Call handler each time the event is fired */ 211 | addEventListener(name: string, handler: eventFunction, flags?: object): void; 212 | removeEventListener(name: string, handler: Function): void; 213 | /** Fire event synchronously, `Event.target` will be set to this element, 214 | * use `postEvent` for async method 215 | * @return `false` if event is canceled with `Event.preventDefault()`. 216 | */ 217 | dispatchEvent(event: Event, avoidDuplicates?: boolean): boolean; 218 | 219 | // EventTarget 220 | ready(event: Event, element: Element): void; 221 | onclick(event: Event, element: Element): void; 222 | onchange(event: Event, element: Element): void; 223 | onkeydown(event: Event, element: Element): void; 224 | onwheel(event: Event, element: Element): void; 225 | } 226 | declare var Element: { 227 | new(): Element; 228 | } 229 | 230 | type InsertPosition = "beforebegin" | "afterbegin" | "beforeend" | "afterend"; 231 | interface popupParams { 232 | /** 1..9, reference point on anchor border box (see keyboard numpad for the meaning) */ 233 | anchorAt?: number; 234 | /** 1..9, reference point on popup's margin box. */ 235 | popupAt?: number; 236 | x?: number; 237 | y?: number; 238 | } 239 | interface animateParams { 240 | duration?: number, 241 | ease?: "linear" | "ease" | "ease-in" | "ease-in-out" | "ease-out" | "quad-in" | "quad-out" | "quad-in-out" | "cubic-in" | "cubic-out" | "cubic-in-out" | "quart-in" | "quart-out" | "quart-in-out" | "quint-in" | "quint-out" | "quint-in-out" | "sine-in" | "sine-out" | "sine-in-out" | "expo-in" | "expo-out" | "expo-in-out" | "circ-in" | "circ-out" | "circ-in-out" | "elastic-in" | "elastic-out" | "elastic-in-out" | "back-in" | "back-out" | "back-in-out" | "x-back-in" | "x-back-out" | "x-back-in-out" | "xx-back-in" | "xx-back-out" | "xx-back-in-out" | "bounce-in" | "bounce-out" | "bounce-in-out"; 242 | effect?: "blend" | "blend-atop" | "slide-top" | "slide-bottom" | "slide-left" | "slide-right" | "slide-over-top" | "slide-over-bottom" | "slide-over-left" | "slide-over-right" | "remove-top" | "remove-bottom" | "remove-left" | "remove-right" | "scroll-top" | "scroll-bottom" | "scroll-left" | "scroll-right"; 243 | /** Times per second the function is called */ 244 | FPS?: number; 245 | } 246 | interface takeoffParams { 247 | x?: number; 248 | y?: number; 249 | width?: number; 250 | height?: number; 251 | relativeTo?: "screen" | "document" | "window" | "parent" | "self"; 252 | window?: "attached" | "detached" | "popup"; 253 | } 254 | 255 | interface DOMRect { 256 | readonly bottom: number; 257 | readonly height: number; 258 | readonly left: number; 259 | readonly right: number; 260 | readonly top: number; 261 | readonly width: number; 262 | readonly x: number; 263 | readonly y: number; 264 | } 265 | declare var DOMRect: { 266 | new(x?: number, y?: number, width?: number, height?: number): DOMRect; 267 | fromRect(other?: DOMRect): DOMRect; 268 | }; 269 | 270 | -------------------------------------------------------------------------------- /src/Element.selection.d.ts: -------------------------------------------------------------------------------- 1 | interface Selection 2 | { 3 | /** `true` if selection is collapsed to one position (anchor === focus) */ 4 | readonly isCollapsed: boolean; 5 | /** Nearest container element that encloses as anchor as focus positions */ 6 | readonly commonAncestorContainer: Element; 7 | readonly anchorNode: Node; 8 | readonly anchorOffset: number; 9 | /** Caret position */ 10 | readonly focusNode: Node; 11 | readonly focusOffset: number; 12 | readonly rangeCount: number; 13 | readonly type: "Caret" | "Selection" | "Element" | "TableCells"; 14 | 15 | /** Collapse selection to current focus (caret) position. */ 16 | collapse(): void; 17 | /** Collapse selection to anchor or focus (the last in the DOM). */ 18 | collapseToEnd(): void; 19 | /** Collapse selection to anchor or focus (the first in the DOM). */ 20 | collapseToStart(): void; 21 | /** `true` if the selection contains the node. */ 22 | containsNode(node: Node): boolean; 23 | /** Remove selection (but not its content). */ 24 | empty(): void; 25 | /** Set focus (caret) position without changing anchor position. */ 26 | extend(node: Node, offset: number): void; 27 | getRangeAt(index: number): Range; 28 | selectNodeContent(node: Node): void; 29 | setBaseAndExtent(anchorNode: Node, anchorOffset: number, focusNode: Node, focusOffset: number): void; 30 | /** Return selected text. */ 31 | toString(): string; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/Element.state.d.ts: -------------------------------------------------------------------------------- 1 | /** Runtime flags and state on element. 2 | * Most of Element.State reflect so called CSS pseudo-classes (flags): 3 | * `element:visited { color: red; }`*/ 4 | interface State 5 | { 6 | /** Computes current min and max widths of the element content. */ 7 | contentWidth(): [minWidth: number, maxWidth: number]; 8 | /** Computes current height of the element content with it given width. */ 9 | contentHeight(width: number): number; 10 | /** Set/remove mouse capture(forward mouse event) 11 | * `true` - captures mouse events by the element and its sub elements. 12 | * `false` - remove capture if the element owns capture now. 13 | * `"strict"` - mouse events will be delivered to the element only. */ 14 | capture(state: boolean|"strict"): boolean; 15 | /** Report geometry of the window. 16 | * @param property value type to return. 17 | * @param metric value in relation to. 18 | * @param relativeTo offset x/y are relative to. 19 | * @param asPpx return coordinates in screen pixels otherwise DIPs. 20 | */ 21 | box(property: "xywh"|"rect"|"position"|"dimension", metric: keyof typeof boxMetric, relativeTo?: keyof typeof boxRelativeTo, asPpx?: boolean): number[]; 22 | box(property: keyof typeof boxProperties, metric: keyof typeof boxMetric, relativeTo?: keyof typeof boxRelativeTo, asPpx?: boolean): number; 23 | /** Parses length string as CSS length units or percentage and then converts them to CSS pixels. 24 | * Perecentage values are computed against element dimensions (inner box). */ 25 | pixelsIn(length: string, orientation?: "horizontal" | "vertical"): number | undefined; 26 | /** Maps local element coordinates to window coordinates. 27 | * This method accounts affine 2D transformation the element and its parents may have. */ 28 | mapLocalToWindow(x: number, y: number): [x: number, y: number]; 29 | /** Maps point on window to local coordinates of particular element. 30 | * This method accounts affine 2D transformation the element and its parents may have. */ 31 | mapWindowToLocal(x: number, y: number): [x: number, y: number]; 32 | 33 | focus: boolean; 34 | readonly ownsfocus: boolean; 35 | link: boolean; 36 | visited: boolean; 37 | hover: boolean; 38 | selected: boolean; 39 | current: boolean; 40 | checked: boolean; 41 | disabled: boolean; 42 | readonly: boolean; 43 | expanded: boolean; 44 | collapsed: boolean; 45 | invalid: boolean; 46 | animating: boolean; 47 | focusable: boolean; 48 | anchor: boolean; 49 | popup: boolean; 50 | ownspopup: boolean; 51 | tabfocus: boolean; 52 | empty: boolean; 53 | busy: boolean; 54 | dragover: boolean; 55 | dragsource: boolean; 56 | droptarget: boolean; 57 | moving: boolean; 58 | copying: boolean; 59 | pressed: boolean; 60 | ready: boolean; 61 | active: boolean; 62 | /** `False` will prevent reconciliation of element's content by Reactor */ 63 | reactive: boolean; 64 | /** Runtime value of native behavior attached to the element. Actual for input elements. */ 65 | value: any; 66 | /** Reports visibility status of the element, 67 | * if `0` then the element is visible in full, otherwise combination of these flags: 68 | * `0x1` - left side of border box is clipped out (invisible). 69 | * `0x2` - top side is clipped. 70 | * `0x4` - right side is clipped. 71 | * `0x8` - bottom side is clipped. 72 | * `0xf` - the element is completely clipped out - invisible. */ 73 | occluded: number; 74 | 75 | /** `True` if this is a root document of the window */ 76 | readonly windowroot: boolean; 77 | /** Layout manager used by the element at the moment. */ 78 | readonly flow: "default" | "vertical" | "horizontal" | "horizontal-wrap" | "vertical-wrap" | "grid" | "table" | "table-fixed" | "table-row" | "table-body" | "columns" | "stack" | "text" | "null" | "image" | "svg" | "svg-child" | ""; 79 | readonly visible: boolean; 80 | } 81 | enum boxProperties { "xywh", "rect", "position", "dimension", "left", "right", "top", "bottom", "width", "height" } 82 | enum boxMetric { "inner", "border", "padding", "margin", "client", "caret", "icon" } 83 | enum boxRelativeTo { "element", "screen", "window", "document", "parent", "container", "self" } 84 | 85 | -------------------------------------------------------------------------------- /src/Element.style.d.ts: -------------------------------------------------------------------------------- 1 | interface Style { 2 | getPropertyValue(name: string): string; 3 | setProperty(name: string, value: string|length, important?: boolean): void; 4 | removeProperty(name: string): void; 5 | colorOf(name: string): Color | null; 6 | pixelsOf(name: string): number | null; 7 | imageOf(name: string): Image | null; 8 | /** Get/Set CSS variables applied to the element 9 | * @return `{name: value...}` 10 | */ 11 | variables(variables?: object): object; 12 | setCursor(cursor: Image|null, x: number, y: number): void; 13 | 14 | 15 | behavior: string; 16 | aspect: string; 17 | prototype: string; 18 | size: string; 19 | flow: string; 20 | fontRenderingMode: "sub-pixel" | "snap-pixel"; 21 | imageRendering: "auto" | "inherit" | "default" | "crispy-edges" | "pixelated" | "optimize-quality" | "optimize-speed"; 22 | contextMenu: string; 23 | hitMargin: string; 24 | content: string; 25 | scrollManner: string; 26 | verticalScrollbar: string; 27 | horizontalScrollbar: string; 28 | textOverflow: string; 29 | popupPosition: string; 30 | 31 | 32 | font: string; 33 | fontSize: length; 34 | height: length; 35 | width: length; 36 | 37 | color: string; 38 | background: string; 39 | backgroundColor: string; 40 | backgroundImage: string; 41 | foreground: string; 42 | foregroundColor: string; 43 | foregroundImage: string; 44 | 45 | [name: string]: string|length; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/Event.d.ts: -------------------------------------------------------------------------------- 1 | /** An event which takes place in the DOM. */ 2 | interface Event { 3 | /** True if event goes through its target's ancestors in reverse tree order, and false otherwise. */ 4 | readonly bubbles: boolean; 5 | cancelBubble: boolean; 6 | /** Can be canceled by invoking the preventDefault() method. */ 7 | readonly cancelable: boolean; 8 | /** True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. */ 9 | readonly composed: boolean; 10 | /** Returns the Element whose event listener's callback is currently being invoked. */ 11 | readonly currentTarget: Element | null; 12 | /** Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. */ 13 | readonly defaultPrevented: boolean; 14 | /** Returns the event's phase, which is one of `NONE`, `CAPTURING_PHASE`, `AT_TARGET`, and `BUBBLING_PHASE`. */ 15 | readonly eventPhase: "NONE"|"CAPTURING_PHASE"|"AT_TARGET"|"BUBBLING_PHASE"; 16 | /** Returns true if event was dispatched by the user agent, and false otherwise. */ 17 | readonly isTrusted: boolean; 18 | readonly srcElement: Element | null; 19 | /** The element to which event is dispatched (its target). */ 20 | readonly target: Element | null; 21 | /** The secondary element which is lossing or gaining focus from/to `target` */ 22 | readonly relatedTarget: Element | null; 23 | /** Type of event, e.g. "click", "hashchange", or "submit". */ 24 | readonly type: string; 25 | /** If invoked when the cancelable attribute value is true, 26 | * and while executing a listener for the event with passive set to false, 27 | * signals to the operation that caused event to be dispatched that it needs to be canceled. */ 28 | preventDefault(): void; 29 | /** Invoking this method prevents event from reaching any registered event listeners 30 | * after the current one finishes running and, when dispatched in a tree, 31 | * also prevents event from reaching any other objects. */ 32 | stopImmediatePropagation(): void; 33 | /** When dispatched in a tree, invoking this method prevents event 34 | * from reaching any objects other than the current object. */ 35 | stopPropagation(): void; 36 | /** String representation of keyCode "KeyA", "F1", "Enter"... */ 37 | readonly code: string; 38 | /** keyCode list at [include/sciter-x-key-codes.h](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/include/sciter-x-key-codes.h) */ 39 | readonly keyCode: number; 40 | /** Platform's native key code, e.g, wParam in WM_KEYDOWN on Windows. */ 41 | readonly platformKeyCode: string; 42 | readonly AT_TARGET: number; 43 | readonly BUBBLING_PHASE: number; 44 | readonly CAPTURING_PHASE: number; 45 | readonly NONE: number; 46 | 47 | data, details: any; 48 | 49 | readonly altKey: boolean; 50 | readonly ctrlKey: boolean; 51 | /** `command` key on OSX, `win` on Windows */ 52 | readonly metaKey: boolean; 53 | readonly shiftKey: boolean; 54 | readonly button: number; 55 | readonly buttons: number; 56 | 57 | readonly clientX: number; 58 | readonly clientY: number; 59 | readonly screenX: number; 60 | readonly screenY: number; 61 | readonly windowX: number; 62 | readonly windowY: number; 63 | readonly deltaX: number; 64 | readonly deltaY: number; 65 | /** `0` - `deltaX/Y` are pixels coming from touch devices, 66 | * `1` - `deltaX/Y` are in "lines" (a.k.a. mouse wheel "ticks"). */ 67 | readonly deltaMode: number; 68 | 69 | /** Coordinates relative to `currentTarget` - the element this event handler is attached to. */ 70 | readonly x: number; 71 | /** Coordinates relative to `currentTarget` - the element this event handler is attached to. */ 72 | readonly y: number; 73 | /** Used in some events to indicate auxiliary "source" element. */ 74 | readonly source: Element; 75 | /** Mouse event is on `foreground-image`, return Element containing the image */ 76 | readonly isOnIcon: Element; 77 | 78 | /** Returns pressed status of the key. */ 79 | keyState(key: string): boolean; 80 | } 81 | declare var Event: { 82 | new(type: string, options?: EventOptions): Event; 83 | readonly AT_TARGET: number; 84 | readonly BUBBLING_PHASE: number; 85 | readonly CAPTURING_PHASE: number; 86 | readonly NONE: number; 87 | }; 88 | interface EventOptions { 89 | /** True if event goes through its target's ancestors in reverse tree order, and false otherwise. */ 90 | bubbles?: boolean; 91 | /** Can be canceled by invoking the preventDefault() method. */ 92 | cancelable?: boolean; 93 | /** True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. */ 94 | composed?: boolean; 95 | /** Property passed to event listener. `evt.data/details` */ 96 | data?,details?: any; 97 | } 98 | type eventFunction = function(Event, Element): void; 99 | enum eventType { 100 | ready, 101 | complete, 102 | 103 | click, 104 | input, 105 | change, 106 | press, 107 | changing, 108 | submit, 109 | reset, 110 | expand, 111 | collapse, 112 | statechange, 113 | visualstatechange, 114 | disabledstatechange, 115 | readonlystatechange, 116 | contextmenu, 117 | contextmenusetup, 118 | animationend, 119 | animationstart, 120 | animationloop, 121 | transitionend, 122 | transitionstart, 123 | mediachange, 124 | contentchange, 125 | inputlangchange, 126 | pastehtml, 127 | pastetext, 128 | pasteimage, 129 | popuprequest, 130 | popupready, 131 | popupdismissing, 132 | popupdismissed, 133 | tooltiprequest, 134 | 135 | focus, 136 | focusin, 137 | focusout, 138 | blue, 139 | 140 | mouseMove, 141 | mouseLeave, 142 | mouseIdle, 143 | mousetick, 144 | mousedown, 145 | mouseup, 146 | mousewheel, 147 | mousedragrequest, 148 | dblclick, 149 | doubleclick, 150 | tripleclick, 151 | 152 | keydown, 153 | keyup, 154 | keypress, 155 | compostionstart, 156 | compositionend, 157 | 158 | scroll, 159 | scrollanimationstart, 160 | scrollanimationend, 161 | 162 | sizechange, 163 | visibilitychange, 164 | 165 | load, 166 | error, 167 | 168 | drag, 169 | dragenter, 170 | dragleave, 171 | drop, 172 | dragaccept, 173 | dropcancel, 174 | willacceptdrop, 175 | 176 | play, 177 | ended, 178 | videocoordinate, 179 | videoframeready, 180 | } 181 | 182 | -------------------------------------------------------------------------------- /src/Graphics.d.ts: -------------------------------------------------------------------------------- 1 | declare var Graphics: { 2 | new(): Graphics; 3 | Brush: Brush; 4 | Color: Color; 5 | Image: Image; 6 | Path: Path; 7 | Text: gText; 8 | }; 9 | 10 | interface Graphics 11 | { 12 | lineCap: 'butt'|'round'|'square'; 13 | lineJoin: 'round'|'bevel'|'miter'; 14 | strokeStyle: Color | string | Image; 15 | lineWidth: number; 16 | strokeWidth: number; 17 | fillStyle: Color | string | Image; 18 | font: string; 19 | /** @version 5.0.0.5+ */ 20 | canvas: CanvasElement; 21 | 22 | clearRect(x: number, y: number, w: number, h: number): void; 23 | beginPath(): void; 24 | moveTo(x: number, y: number): void; 25 | lineTo(x: number, y: number): void; 26 | quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; 27 | bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; 28 | arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, antiClockWise?: boolean): void; 29 | arcTo(x: number, y: number, x2: number, y2: number, radius: number): void; 30 | ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, antiClockWise?: boolean): void; 31 | rect(x: number, y: number, w: number, h: number): void; 32 | closePath(): void; 33 | fill(...args): void; 34 | fillRect(x: number, y: number, w: number, h: number): void; 35 | fillText(text: string, x: number, y: number, maxWidth: number): void; 36 | stroke(...args): void; 37 | strokeRect(x: number, y: number, w: number, h: number): void; 38 | setLineDash(...args): void; 39 | save(): void; 40 | restore(): void; 41 | scale(x: number, y: number): void; 42 | translate(x: number, y: number): void; 43 | rotate(radian: number, x?: number, y?: number): void; 44 | transform(a: number, b: number, c: number, d: number, e: number, f: number): void; 45 | setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void; 46 | 47 | draw(path: Path, params: drawPathParams); 48 | draw(image: Image, params: drawImageParams); 49 | draw(text: gText, params: drawTextParams); 50 | 51 | pushLayer(x: number, y: number, w: number, h: number, opacity?: number, filter?: string): void; 52 | pushLayer(clipAreaName: keyof typeof clipAreaName, opacity?: number, filter?: string): void; 53 | pushLayer(path: Path, opacity?: number): void; 54 | pushLayer(mask: Image, useAlpha: boolean, opacity?: number): void; 55 | popLayer(): void; 56 | 57 | createTile(image: Image): Brush; 58 | createSolid(color: Color): Brush; 59 | } 60 | 61 | interface CanvasElement extends Element { 62 | height: number; 63 | width: number; 64 | } 65 | 66 | interface drawPathParams { 67 | x: number; 68 | y: number; 69 | fill?: "evenodd" | "nonzero"; 70 | stroke?: boolean; 71 | } 72 | 73 | interface drawImageParams { 74 | x: number; 75 | y: number; 76 | width?: number; 77 | height?: number; 78 | srcX?: number; 79 | srcY?: number; 80 | srcWidth?: number; 81 | srcHeight?: number; 82 | opacity?: number; 83 | } 84 | 85 | interface drawTextParams { 86 | x: number; 87 | y: number; 88 | /** 1..9, defines meaning of x/y coordinates, see NUMPAD. 89 | * `5` - center of text, 90 | * `7` - left/top corner, etc. */ 91 | alignment: number; 92 | fill?: Color; 93 | } 94 | 95 | type clipAreaName = "background-area" | "border-box" | "padding-box" | "margin-box" | "context-box"; 96 | 97 | interface Brush 98 | { 99 | type: number; 100 | 101 | addColorStop(pos: number, color: Color): Brush; 102 | /** Creates linear gradient brush along the line from x1/y1 to x2/y2 */ 103 | createLinearGradient(x1: number, y1: number, x2: number, y2: number): Brush; 104 | /** Creates radial gradient brush with center at x/y and radius r */ 105 | createRadialGradient(x: number, y: number, r: number): Brush; 106 | } 107 | 108 | interface Color 109 | { 110 | new(color: string): Color; 111 | /** float(0..1.0), red channel. */ 112 | readonly r: number; 113 | /** float(0..1.0), green channel */ 114 | readonly g: number; 115 | /** float(0..1.0), blue channel. */ 116 | readonly b: number; 117 | /** float(0..1.0), alpha channel, 0.0 - fully transparent, 1.0 - fully opaque. */ 118 | readonly a: number; 119 | /** int(0..255), red channel. */ 120 | readonly R: number; 121 | /** int(0..255), green channel. */ 122 | readonly G: number; 123 | /** int(0..255), blue channel. */ 124 | readonly B: number; 125 | /** int(0..255), alpha channel, 0.0 - fully transparent, 1.0 - fully opaque. */ 126 | readonly A: number; 127 | /** [hue:0..360, saturation:0..1, value: 0..1, alpha: 0..1], HSV color representation. */ 128 | readonly hsv: number[]; 129 | /** [hue:0..360, saturation:0..1, lightness: 0..1], HSL color representation. */ 130 | readonly hsl: number[]; 131 | 132 | /** Produces strings in formats 133 | * `#RRGGBB`, `#RRGGBBAA`, `rgb(255,255,255)` or `rgba(255,255,255,1.0)` */ 134 | toString(type?: "RGB" | "RGBA" | "rgb" | "rgba"): string; 135 | /** Color packaged to uint32 as `(a << 24) | (b << 16) | (g << 8) | (r)` */ 136 | valueOf(): number; 137 | } 138 | declare var Color: { 139 | /** Creates `Graphics.Color` instance from r,g,b,a components in float numbers 140 | * in `0.0-1.0` range. */ 141 | rgb(r: number, g: number, b: number, a?: number): Color; 142 | /** Creates `Graphics.Color` instance from r,g,b,a components in integers 143 | * in `0-255` range. */ 144 | RGB(r: number, g: number, b: number, a?: number): Color; 145 | /** Creates `Graphics.Color` instance from HSV components in float numbers 146 | * in `0.0-1.0` range but `h` is in `0.0-360.0` range. */ 147 | hsv(h: number, s: number, v: number, a?: number): Color; 148 | /** Creates `Graphics.Color` instance from HSL components in float numbers 149 | * in `0.0-1.0` range but `h` is in `0.0-360.0` range. */ 150 | hsl(r: number, g: number, b: number, a?: number): Color; 151 | } 152 | 153 | interface Image 154 | { 155 | /** Render DOM element onto bitmap. */ 156 | new(width: number, height: number, element: Element): Image; 157 | /** Render arbitrary graphics on bitmap */ 158 | new(width: number, height: number, canvas: (ctx: Graphics) => void, initColor?: number): Image; 159 | 160 | readonly src: string; 161 | readonly width: number; 162 | readonly height: number; 163 | /** Image format `png`, `webp`, etc. */ 164 | readonly packaging: string; 165 | 166 | /** Static-Method load image from URL return promise of an Image object */ 167 | load(url: string): Promise<Image>; 168 | /** Draw on the image surface. Image must be a bitmap. */ 169 | update(...arg): void; 170 | toBytes(format: "png"|"jpeg"|"webp"|"bgra", compression?: number): ArrayBuffer; 171 | fromBytes(data: ArrayBuffer): Image; 172 | /** Returns pixel color at x/y. */ 173 | colorAt(x: number, y: number): Color; 174 | /** Compose this image with src image. */ 175 | compose(src: Image, operation: keyof typeof composeOps, dstX?: number, dstY?: number, srcX?: number, srcY?: number, srcW?: number, srcH?: number): Image; 176 | /** Return fragment of an image at position. 177 | * @version 5+ 178 | */ 179 | crop(x: number, y: number, width: number, height: number): Image; 180 | } 181 | 182 | enum composeOps { 183 | "src-over", "dst-over", "src-in", "dst-in", "src-out", "dst-out", "src-atop", "dst-atop", "xor", "copy" 184 | } 185 | 186 | interface Path 187 | { 188 | /** Constructs new path object. accepts SVG's <path>s [d attribute](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d) value. */ 189 | new(svgPath?: string): Path; 190 | 191 | moveTo(x: number, y: number): void; 192 | lineTo(x: number, y: number): void; 193 | quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; 194 | bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; 195 | arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, antiClockWise?: boolean): void; 196 | arcTo(x: number, y: number, x2: number, y2: number, radius: number): void; 197 | ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, antiClockWise?: boolean): void; 198 | rect(x: number, y: number, w: number, h: number): void; 199 | closePath(): void; 200 | isPointInside(x: number, y: number): boolean; 201 | bounds(): [x1: number, y1: number, x2: number, y2: number]; 202 | /** */ 203 | combine(type: "union"|"intersect"|"xor"|"exclude", otherPath: Path): Path; 204 | } 205 | 206 | interface gText 207 | { 208 | new(...args: string[]): gText; 209 | /** CSS style rules to decorate the text including fonts, alignment, borders and background.*/ 210 | style: string; 211 | readonly lines: number; 212 | /** Text to render. */ 213 | chars: string; 214 | class: string; 215 | 216 | /** Reports minimal, maximal and used width of the text block. */ 217 | width(): [minWidth: number, maxWidth: number, usedWidth: number]; 218 | /** Sets used width of the text block. Note: `text.lines` property may change after that */ 219 | width(usedWidth: number): void; 220 | /** Reports content and used height of the text block. */ 221 | height(): [contentHeight: number, usedHeight: number]; 222 | /** Sets used height of the text block. Note: `vertical-align` of text style may change location of glyphs on screen. */ 223 | height(usedHeight: number): void; 224 | lineMetrics(lineNo: number): [posY: number, height: number, baselineOffset: number]; 225 | /** Textual content of the line */ 226 | lineChars(lineNo: number): string; 227 | } 228 | 229 | -------------------------------------------------------------------------------- /src/Node.d.ts: -------------------------------------------------------------------------------- 1 | interface Node { 2 | /** Instance of Window that hosts this node; */ 3 | readonly parentWindow: Window; 4 | /** Returns the previous sibling. */ 5 | readonly previousSibling: Node | null; 6 | readonly nodeIndex: number; 7 | remove(): void; 8 | 9 | /** NATIVE */ 10 | 11 | /** Returns the children. */ 12 | readonly childNodes: NodeListOf<Node>; 13 | /** Returns the first child. */ 14 | readonly firstChild: Node | null; 15 | /** Returns the last child. */ 16 | readonly lastChild: Node | null; 17 | /** Returns the next sibling. */ 18 | readonly nextSibling: Node | null; 19 | /** Returns a string appropriate for the type of node. */ 20 | readonly nodeName: string; 21 | /** Returns the type of node: 22 | * `1` : Element 23 | * `2` : Comment 24 | * `3` : Text 25 | */ 26 | readonly nodeType: number; 27 | nodeValue: string | null; 28 | /** Returns the node document. Returns null for documents. */ 29 | readonly ownerDocument: Document | null; 30 | /** Returns the parent element. */ 31 | readonly parentElement: Element | null; 32 | /** Returns the parent. */ 33 | readonly parentNode: Node | null; 34 | /** Textual content of an element and all its descendants */ 35 | textContent: string | null; 36 | appendChild<T extends Node>(node: T): T; 37 | /** Returns a copy of node. If deep is true, the copy also includes the node's descendants. */ 38 | cloneNode(deep?: boolean): Node; 39 | /** Returns a bitmask indicating the position of other relative to node. */ 40 | compareDocumentPosition(other: Node): number; 41 | /** Returns true if other is an inclusive descendant of node, and false otherwise. */ 42 | contains(other: Node | null): boolean; 43 | /** Returns node's root. (\<html/>) */ 44 | getRootNode(options?: GetRootNodeOptions): Node; 45 | /** Does this node have children. */ 46 | hasChildNodes(): boolean; 47 | insertBefore<T extends Node>(node: T, child: Node | null): T; 48 | /** Does this node and otherNode have the same properties. */ 49 | isEqualNode(otherNode: Node | null): boolean; 50 | isSameNode(otherNode: Node | null): boolean; 51 | removeChild<T extends Node>(child: T): T; 52 | replaceChild<T extends Node>(node: Node, child: T): T; 53 | } 54 | declare var Node: { 55 | new(): Node; 56 | }; 57 | 58 | interface Text extends Node 59 | { 60 | data: string; 61 | readonly length: number; 62 | readonly wholeText: string; 63 | } 64 | declare var Text: { 65 | new(): Text; 66 | } 67 | 68 | interface Comment extends Node 69 | { 70 | data: string; 71 | readonly length: number; 72 | } 73 | declare var Comment: { 74 | new(): Comment; 75 | } 76 | 77 | /** NodeList objects are collections of nodes, usually returned by properties such as Node.childNodes and methods such as document.querySelectorAll(). */ 78 | interface NodeList { 79 | /** Returns the number of nodes in the collection. */ 80 | readonly length: number; 81 | /** Returns the node with index index from the collection. The nodes are sorted in tree order. */ 82 | item(index: number): Node | null; 83 | /** 84 | * Performs the specified action for each node in an list. 85 | * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. 86 | * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. 87 | */ 88 | forEach(callbackfn: (value: Node, key: number, parent: NodeList) => void, thisArg?: any): void; 89 | [index: number]: Node; 90 | } 91 | declare var NodeList: { 92 | new(): NodeList; 93 | }; 94 | 95 | interface NodeListOf<TNode extends Node> extends NodeList { 96 | item(index: number): TNode; 97 | /** 98 | * Performs the specified action for each node in an list. 99 | * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. 100 | * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. 101 | */ 102 | forEach(callbackfn: (value: TNode, key: number, parent: NodeListOf<TNode>) => void, thisArg?: any): void; 103 | [index: number]: TNode; 104 | } 105 | 106 | 107 | interface Range 108 | { 109 | /** `true` if selection is collapsed to one position (anchor === focus) */ 110 | readonly isCollapsed: boolean; 111 | /** Nearest container element that encloses as anchor as focus positions */ 112 | readonly commonAncestorContainer: Element; 113 | readonly endContainer: Node; 114 | readonly endOffset: number; 115 | readonly startContainer: Node; 116 | readonly startOffset: number; 117 | readonly start: [node: Node, offset: number]; 118 | readonly end: [node: Node, offset: number]; 119 | 120 | setStart(node: Node, offset: number): void; 121 | setEnd(node: Node, offset: number): void; 122 | setStartBefore(node: Node): void; 123 | setEndBefore(node: Node): void; 124 | setStartAfter(node: Node): void; 125 | setEndAfter(node: Node): void; 126 | selectNode(node: Node): void; 127 | selectNodeContents(node: Node): void; 128 | selectNodeContent(node: Node): void; 129 | getRangeAt(index: number): Range; 130 | /** Set cursor to the start or end of selection. */ 131 | collapse(toStart?: boolean): void; 132 | cloneRange(): Range; 133 | 134 | /** Apply marks to the selected range */ 135 | applyMark(name: string|string[]): void; 136 | /** Apply marks to the selected range */ 137 | highlight(name: string|string[]): void; 138 | /** Remove marks applied to the selected range */ 139 | clearMark(name: string|string[]); 140 | /** Remove marks applied to the selected range */ 141 | clearHighlight(name: string|string[]): void; 142 | /** Return list of the applied mark names inside the range */ 143 | marks(): string[]; 144 | /** Set the range to the start-end of character having the given mark name */ 145 | setToMark(name: string): void; 146 | } 147 | declare var Range: { 148 | new(): Range; 149 | new(start: number, end: number): Range; 150 | } 151 | 152 | -------------------------------------------------------------------------------- /src/Window.d.ts: -------------------------------------------------------------------------------- 1 | interface Window { 2 | /** Window state: hidden, shown, fullscreen... 3 | * use `Window.WINDOW_****` */ 4 | state: number; 5 | 6 | /** Window has input focus. */ 7 | readonly isActive: boolean; 8 | /** The property is false when the window was closed and destroyed. */ 9 | readonly isAlive: boolean; 10 | /** True if window is on active space now. 11 | * the property is undefined if host system does not support spaces (virtual desktops). */ 12 | readonly isOnActiveSpace: boolean|undefined; 13 | 14 | /** Get/Set Window title */ 15 | caption: string; 16 | isResizable: boolean; 17 | isMaximizable: boolean; 18 | isMinimizable: boolean; 19 | /** Window is alway on top */ 20 | isTopmost: boolean; 21 | /** Does the window accept user input. */ 22 | isEnabled: boolean; 23 | /** Width to height ratio to keep on window resizes */ 24 | aspectRatio: number; 25 | 26 | /** If set by element, direct all UI events to that element and its children. */ 27 | eventsRoot: Element|null; 28 | focus: Element; 29 | readonly parent: Window|null; 30 | readonly document: Document; 31 | /** Parameters provided by constructor, available inside the window as they are. */ 32 | parameters: any; 33 | 34 | /** Monitor index where the current window is on */ 35 | readonly screen: number; 36 | /** current graphics backend used: `direct2d`, `Skia/OpenGL`, etc. */ 37 | readonly graphicBackend: string; 38 | /** blur-behind effect 39 | * one of `none` `auto` `dark` `ultra-dark` `light` `ultra-light` */ 40 | blurBehind: "none" | "auto" | "dark" | "ultra-dark" | "light" | "ultra-light"; 41 | 42 | /** Minimal size of resizable window `[width, height]` */ 43 | minSize: [width: number, height: number]; 44 | /** Maximum size of resizable window `[width, height]` */ 45 | maxSize: [width: number, height: number]; 46 | 47 | frameType: keyof typeof frameType; 48 | 49 | /** The function allows to enumerate elements in tab order. 50 | * reference element must be selectable. 51 | * to select element use `window.this.focus = element` 52 | */ 53 | focusable(direction: "next"|"prior"|"first"|"last", reference: Element): Element; 54 | /** Set input focus to window */ 55 | activate(bringToFront: boolean): void; 56 | /** Request to update the window. */ 57 | update(): void; 58 | /** Report geometry and data of the screen (monitor) the window is on. */ 59 | screenBox(type: keyof typeof screenBoxType, property: "xywh"|"rect"|"position"|"dimension", asPpx?: boolean): number[]; 60 | screenBox(type: keyof typeof screenBoxType, property: keyof typeof boxProperties, asPpx?: boolean): number; 61 | /** Return name of device */ 62 | screenBox(type: 'device'): string; 63 | /** Is window on primary monitor. */ 64 | screenBox(type: 'isPrimary'): boolean; 65 | /** Return screenshot of the monitor the window is on. */ 66 | screenBox(type: 'snapshot'): Image; 67 | /** Report geometry of the window. 68 | * @param property value type to return. 69 | * @param metric value in relation to. 70 | * @param relativeTo offset x/y are relative to. 71 | * @param asPpx return coordinates in screen pixels otherwise DIPs. 72 | */ 73 | box(property: "xywh"|"rect"|"position"|"dimension", metric: keyof typeof windowBoxMetric, relativeTo?: keyof typeof windowBoxRelativeTo, asPpx?: boolean): number[]; 74 | box(property: keyof typeof boxProperties, metric: keyof typeof windowBoxMetric, relativeTo?: keyof typeof windowBoxRelativeTo, asPpx?: boolean): number; 75 | /** move/size window. 76 | * x, y, width, height are in PPX (physical screen pixels). 77 | * If `client` is provided then parameters are window client area coordinates. */ 78 | move(x: number, y: number, width?: number, height?: number, client?: boolean): void; 79 | /** move/size window to particular monitor. 80 | * x, y, width, height are in DIPs - device independent pixels (a.k.a. CSS pixels). */ 81 | moveTo(monitor: number, x: number, y: number, width?: number, height?: number, client?: boolean): void; 82 | 83 | /** Subscribe to window related events, init callback everytime the event occurs. */ 84 | addEventHandler(event: windowEvent, handler: function): Window; 85 | /** Subscribe to window related events, init callback everytime the event occurs. */ 86 | on(event: windowEvent, cb: eventFunction): Window; 87 | /** Unsubscribe from event by eventname or handler used by `on()` */ 88 | off(eventOrHandler: windowEvent|function): Window; 89 | /** Send event to the window synchronously. Returns `true` if the window consumes the event. */ 90 | dispatchEvent(event: Event): boolean; 91 | /** Post event to the window asynchronously. The function returns immediately - does not wait for the event consumption. */ 92 | postEvent(event: Event): void; 93 | 94 | /** Load HTML document to Window */ 95 | load(url: string): void; 96 | /** Open file selection dialog */ 97 | selectFile<T extends selectFileParams>(params: T): T extends {'mode': 'open-multiple'} ? string[] : string; 98 | selectFile(mode: "save"|"open", filter: string): string; 99 | selectFile(mode: "open-multiple", filter: string): string[]; 100 | /** Open folder selection dialog */ 101 | selectFolder(params: object): string; 102 | 103 | /** Performs system event(s) in application message queue, mode is one of: 104 | * `wait` - waits for the next event and executes it; 105 | * `noWait` - if next event is available executes it otherwise returns immediately; 106 | * `untilMouseUp` - executes events until mouseup event arrives, used for various drag cases; 107 | * `untilQuit` - performs run loop - executes all events until application quit message arrives; 108 | * `I/O` - performs events associated with I/O; */ 109 | doEvent(mode?: "wait"|"noWait"|"untileMouseUp"|"untilQuit"|"I/O"); 110 | /** Interaction with native behaviors attached to the window. */ 111 | xcall(name: string, ...args): any; 112 | /** Performs drag-and-drop using system D&D mechanism. */ 113 | perfromDrag(data: dragParams, mode: "copy"|"move", dragIcon: Image|Element, 114 | dragIconXoff?: number, dragIconYoff?: number): null|"copy"|"move"; 115 | 116 | /** Show tray icon with the image and tooltip text. 117 | * Tray icon will generate "trayiconclick" event for Window on user clicks */ 118 | trayIcon({image: Image, text: string}): boolean; 119 | /** Remove tray icon */ 120 | trayIcon(command: "remove"): boolean; 121 | /** Report location of the icon on desktop, coordinates are in screen pixels. */ 122 | trayIcon(command: "place"): [x: number, y: number, w: number, h: number]; 123 | /** Request user attention by flashing or bouncing window icon in task/dock bar. */ 124 | requestAttention(command: "info" | "alert" | "stop"): void; 125 | 126 | /** gets/sets media variable that can be used in CSS as `@media name {...}` */ 127 | mediaVar(name: string, value?: string): string|number|void; 128 | /** gets/sets multiple media variables. that can be used in CSS as `@media name {...}`*/ 129 | mediaVars(values?: object): object|void; 130 | /** Show a new window as dialog, returns 131 | * close value of `Window.this.close(valueToReturn)` call inside the window. 132 | * [Documentation](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/Window.md#windowmodaljsx-any)*/ 133 | modal(params: windowParam): any; 134 | modal(params: JSX): any; 135 | 136 | /** Close this window and return the given value to parent window. */ 137 | close(value?: string): boolean; 138 | } 139 | 140 | declare var Window: { 141 | new(param?: windowParam): Window; 142 | readonly this: Window; 143 | /** List of Sciter windows in the current process */ 144 | readonly all: Window[]; 145 | /** share is an object shared between all documents and windows in the application. 146 | * CAUTION: use it responsibly.If temporary window or document populates 147 | * shared object then it should clean it in `beforeunload` document event. */ 148 | share: any; 149 | /** Number of monitors in the system */ 150 | readonly screens: number; 151 | /** Report geometry and information of the given screen (monitor). */ 152 | screenBox(screen: number, type: keyof typeof screenBoxType|'devicePixelRatio', property?: "xywh"|"rect"|"position"|"dimension"): number[]; 153 | screenBox(screen: number, type: keyof typeof screenBoxType|'devicePixelRatio', property?: keyof typeof boxProperties): number; 154 | /** Return name of device */ 155 | screenBox(screen: number, type: 'device'): string; 156 | /** Is this screen the primary screen. */ 157 | screenBox(screen: number, type: 'isPrimary'): boolean; 158 | /** Return screenshot of the monitor. */ 159 | screenBox(screen: number, type: 'snapshot'): Image; 160 | /** Return DOM element under screenX/screenY position. 161 | * @info this method may return DOM element belonging to any Sciter window in current process. */ 162 | elementAt(x: number, y: number): Element; 163 | /** Return value of internal timer. */ 164 | ticks(): number; 165 | /** Post global event to all windows in current process. */ 166 | post(event: Event): void; 167 | /** Synchronously sends global event to all windows in current process. 168 | * Sending stops on first window that will consume the event by returning true from event handler of this event. */ 169 | send(event: Event): void; 170 | /** Get command line arguments in a scapp app */ 171 | scapp: {argv: string[]}; 172 | 173 | 174 | readonly POPUP_WINDOW : 2, 175 | readonly TOOL_WINDOW : 3, 176 | readonly CHILD_WINDOW : 4, // undefined 177 | readonly FRAME_WINDOW : 5, 178 | readonly DIALOG_WINDOW : 6, 179 | 180 | readonly WINDOW_SHOWN : 1; 181 | readonly WINDOW_MINIMIZED : 2; 182 | readonly WINDOW_MAXIMIZED : 3; 183 | readonly WINDOW_HIDDEN : 4; 184 | readonly WINDOW_FULL_SCREEN: 5; 185 | } 186 | 187 | interface windowParam { 188 | /** Windows type use `Window.****_WINDOW` */ 189 | type?: number; 190 | /** When owner closed or minimized this window will be closed/minimized too. */ 191 | parent?: Window; 192 | /** window caption (or title) */ 193 | caption?: string; 194 | x?: number; 195 | y?: number; 196 | width?: number; 197 | height?: number; 198 | /** x,y,w,h are coordinates of desired window client box on the screen; */ 199 | client?: boolean; 200 | /** [1 to 9] alignment of the window on monitor, 201 | * if [-1 to -9] and parent is provided then it aligns the window against parent window. 202 | * (`1` bottom left corner, `2` bottom middle, `3` bottom right corner, 203 | * `4` middle left, `5` center, `6` middle right, `7` top left corner, 204 | * `8` top middle, `9` top right corner) */ 205 | alignment?: number; 206 | /** index of monitor to spawn on. */ 207 | screen?: number; 208 | /** Window state: hidden, shown, fullscreen... 209 | * use `Window.WINDOW_****` */ 210 | state?: number; 211 | /** window html source file */ 212 | url?: string; 213 | /** extra parameters to pass to the new window. */ 214 | parameter?: any; 215 | } 216 | 217 | type windowEvent = "statechange" | "resolutionchange" | "mediachange" | "activate" | "replacementstart" | "replacementend" | "move" | "size" | "trayiconclick" | "spacechange"; 218 | 219 | enum frameType { "standard", "solid", "solid-with-shadow", "extended", "transparent" } 220 | 221 | enum windowBoxMetric { 'border', 'client', 'cursor', 'caret' } 222 | enum windowBoxRelativeTo { 'desktop', 'monitor', 'self' } 223 | enum screenBoxType { 'frame', 'workarea', 'device', 'isPrimary', 'snapshot' } 224 | 225 | interface selectFileParams { 226 | mode?: "save"|"open"|"open-multiple"; 227 | /** File type filter, as "title|ext1;ext2". 228 | * i.e. `"HTML File (*.htm,*.html)|*.html;*.htm|All Files (*.*)|*.*"` */ 229 | filter?: string; 230 | /** Default file extension. */ 231 | extension?: string; 232 | /** Dialog title, "Save As" */ 233 | caption?: string; 234 | /** Initial directory to open the dialog at. */ 235 | path?: string; 236 | } 237 | 238 | interface dragParams { 239 | text?: string; 240 | html?: string; 241 | /** Single or multiple file names; */ 242 | file?: string|string[]; 243 | /** Any data that can be `JSON.stringify`'ed; */ 244 | json: any; 245 | } 246 | 247 | -------------------------------------------------------------------------------- /src/behaviors.d.ts: -------------------------------------------------------------------------------- 1 | interface Behaviors 2 | { 3 | frame: frame; 4 | "frame-set": {state: array}; 5 | history: history; 6 | 7 | from: form; 8 | select: select; 9 | calender: calender 10 | textarea: textarea; 11 | edit: edit; 12 | masked: masked; 13 | 14 | plaintext: plaintext; 15 | richtext: richtext; 16 | 17 | vlist: virtualList; 18 | scrollbar: scrollbar; 19 | 20 | lottie: lottie; 21 | video: video; 22 | } 23 | 24 | interface frame 25 | { 26 | /** Initiates loading of the document from the URL. 27 | * calls `newdocument/complete` events */ 28 | loadFile(path: string): boolean; 29 | /** Initiates loading of the document from the html string or bytes. 30 | * calls `newdocument/complete` events */ 31 | loadHtml(html: string|ArrayBuffer, baseURL?: string): boolean; 32 | /** Clear the content of the frame by loading empty document in it. */ 33 | loadEmpty(): void; 34 | /** Save document to the file in UTF-8 encoding. */ 35 | saveFile(path: string): boolean; 36 | /** Save document into ArrayBuffer as sequence of UTF-8 encoded bytes. */ 37 | saveBytes(): ArrayBuffer; 38 | 39 | readonly document: Document; 40 | /** Get/Set key/value map of media variables used by the document. */ 41 | mediaVars: object; 42 | /** URL of document loaded into the frame. */ 43 | url: string; 44 | } 45 | 46 | interface history 47 | { 48 | /** Goes back in navigational stack, returns true if navigation was successful. */ 49 | back(): boolean; 50 | /** Goes forward in navigational stack, returns true if navigation was successful. */ 51 | forward(): boolean; 52 | 53 | /** Depth of history in backward direction. */ 54 | readonly length: number; 55 | /** Depth of history in forward direction. */ 56 | readonly forwardLength: number; 57 | } 58 | 59 | interface form 60 | { 61 | /** Submits content of the form if its action attribute is defined on the form. */ 62 | submit(): void; 63 | /** Resets input elements to their initial values. */ 64 | reset(): void; 65 | } 66 | 67 | interface select 68 | { 69 | /** Shows popup list of options */ 70 | showPopup(): void; 71 | /** Closes popup list of options if it is open */ 72 | hidePopup(): void; 73 | 74 | /** Reference to DOM element that holds `<option>` list. */ 75 | options: Element; 76 | } 77 | 78 | interface virtualList 79 | { 80 | navigateTo(target: number|"start"|"end"|"pagenext"|"pageprior"|"itemnext"|"itemprior"): void; 81 | /** scroll to given record number. By default it performs animated scroll. 82 | Returns DOM element representing the record. */ 83 | advanceTo(target: number): Element; 84 | 85 | /** Get of first visible item in the buffer. */ 86 | readonly firstVisibleItem: Element; 87 | /** Get of last visible item in the buffer. */ 88 | readonly lastVisibleItem: Element; 89 | readonly firstBufferIndex: number; 90 | readonly lastBufferIndex: number; 91 | readonly itemsTotal: number; 92 | itemsBefore: number; 93 | itemsAfter: number; 94 | } 95 | 96 | interface textarea 97 | { 98 | /** Index of first selected character. */ 99 | readonly selectionStart: number; 100 | /** Index of last select character+1/ */ 101 | readonly selectionEnd: number; 102 | /** selected text or empty sting if there is no selection or selection is collapsed. */ 103 | readonly selectionText: string; 104 | 105 | selectAll(): void; 106 | selectRange(start: number, end: number): void; 107 | appendText(text: string): boolean; 108 | /** Replace select text with given text. */ 109 | insertText(text: string): boolean; 110 | /** Remove selected text. */ 111 | removeText(): boolean; 112 | } 113 | 114 | interface scrollbar 115 | { 116 | /** Sets values of scrollbar element - position, min, max, 117 | * page - reflects to size of scrollbar slider, 118 | * step - increment value of on arrow buttons clicks. */ 119 | values(position:number, min:number, max:number, page:number, step:number): void; 120 | 121 | readonly max: number; 122 | readonly min: number; 123 | /** Page value, size of scrollbar's slider. */ 124 | readonly page: number; 125 | /** Defines position increment/decrement of clicks on arrow buttons. */ 126 | readonly step: number; 127 | 128 | /** Current slider position. */ 129 | position: number; 130 | } 131 | 132 | interface calender 133 | { 134 | /** Gets/Sets current view mode. */ 135 | mode: "days"|"months"|"years"|"century"; 136 | /** Decrements the value by 1 or a specified number. 137 | * Depends of current mode it will advance either day or month or year or decade. */ 138 | stepDown(steps?: number): void; 139 | /** Increments the value by 1 or by a specified number. 140 | * Depends of current mode it will advance either day or month or year or decade. */ 141 | stepUp(steps?: number): void; 142 | } 143 | 144 | interface edit 145 | { 146 | readonly selectionStart, readonly selectionEnd: number; 147 | /** Returns selected text or empty string if there is no selection. */ 148 | readonly selectionText: string; 149 | 150 | /** Select whole content. */ 151 | selectAll(): void; 152 | /** selects text between start (included) 153 | * and end (excluded) position. If start and end are omitted - removes selection. */ 154 | selectRange(start?: number, end?: number): void; 155 | /** Remove selected text. */ 156 | removeText(): void; 157 | /** Insert text at caret position, if selection is not empty removes selected text before insertion. */ 158 | insertText(text: string): void; 159 | /** Appends the text at the end of existing text. */ 160 | appendText(text: string): void; 161 | } 162 | 163 | interface masked 164 | { 165 | /** This property allows to define structure of masked input "manually" and with more control. 166 | * Mask definition is an array of strings (rendered as static separators) and objects. 167 | * Each object defines editable regions and may have following fields: */ 168 | mask: string|array; 169 | type: "integer"|"text"|"enum"; 170 | /** Defines length of the region in characters */ 171 | width: number; 172 | /** Defines CSS class of generated span element */ 173 | class: string; 174 | min, max, step: number; 175 | /** If true then this `type:integer` field is prefixed by zeros */ 176 | "leading-zero": boolean; 177 | /** Defines list of enumerable cases for `type:enum` 178 | * this region allows to input only those predefined cases. */ 179 | items: enum; 180 | /** Defines filter of allowed characters in this `type:text` field. */ 181 | filter: string; 182 | } 183 | 184 | /** Provides playback of Lottie animations. It parses Adobe After Effects 185 | * animations exported as json with Bodymovin and renders them natively inside the Sciter. 186 | * [Documentation](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-lottie.md) */ 187 | interface lottie 188 | { 189 | /** Reports playback status. If true animation is playing at the moment. */ 190 | readonly playing: boolean; 191 | /** float, speed multiplier, 1.0 by default. */ 192 | speed: number; 193 | loop: boolean; 194 | /** Current frame in range [0..frames). */ 195 | frame: number; 196 | /** Total number of frames in animation. */ 197 | readonly frames: number; 198 | /** Current animation position, number in range 0.0 .. 1.0 */ 199 | position: number; 200 | /** Total duration of full animation loop as defined by animation designer. */ 201 | readonly duration: number; 202 | /** Array (list) of marker definitions. 203 | * Each definition is an array (tuple): [tagName:string, startFrame: integer, endFrame: integer]. */ 204 | readonly markers: array; 205 | 206 | /** Load (potentially asynchronously) animation from JSON file at URL. */ 207 | load(url: string): boolean; 208 | /** Start playback. If first/last frame is provided will play only frames in the range. */ 209 | play(firstFrame?: number, lastFrame: number): boolean; 210 | /** Stop (pause) animation. */ 211 | stop(): boolean; 212 | /** Update animation properties dynamically at runtime. */ 213 | update(keyPath: string, propName: string, value: Color|number): boolean; 214 | } 215 | 216 | interface plaintext 217 | { 218 | /** Get/Set text line at given index */ 219 | children: string[]; 220 | /** String content, lines seperated by \r\n */ 221 | content: string|string[]; 222 | readonly lines: number; 223 | readonly selectionStart: [lineNumber: number, linePosition: number]; 224 | readonly selectionEnd : [lineNumber: number, linePosition: number]; 225 | readonly selectionText: string; 226 | 227 | /** Load Content from URL */ 228 | load(url: string): boolean; 229 | /** Save Content to URL(file path) */ 230 | save(url: string): boolean; 231 | /** Select text range; */ 232 | selectRange(startLine: number, startPosition: number, endLine: number, endPosition: number): void; 233 | /** Select all text; */ 234 | selectAll(): boolean; 235 | /** Append line/s at the end of the text; */ 236 | appendLine(text: string|string[]): boolean; 237 | /** Inserts line/s at line index; */ 238 | insertLine(index: number, text: string|string[]): boolean; 239 | /** Remove line/s starting from index */ 240 | removeLine(index: number, count?: number): boolean; 241 | /** Performs transactional (undoable) content update. 242 | * [Documentation](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-richtext.md#richtextupdatemutatorfunctiontctx-bool) */ 243 | update(mutator: (context: Transaction) => {}): boolean; 244 | } 245 | 246 | interface richtext 247 | { 248 | /** Get/Set url of loaded document. */ 249 | url: string; 250 | 251 | /** Load Content from URL */ 252 | load(url: string): boolean; 253 | /** loads content from bytes or string (html source) into the editor; 254 | * url is used to resolve relative URLs (if any). */ 255 | load(html: string|ArrayBuffer, url?: string): boolean; 256 | /** Save Content to URL(file path) */ 257 | save(url: string): boolean; 258 | /** Clear the content by loading empty document in it. */ 259 | loadEmpty(): boolean; 260 | /** Set content to the html at given selection. */ 261 | sourceToContent(html: string, url: string, selectionStart: number, selectionEnd: number): boolean; 262 | /** Return content and selection as an array. */ 263 | contentToSource(): [html: string, url: string, selectionStart: number, selectionEnd: number]; 264 | /** Performs transactional (undoable) content update. 265 | * [Documentation](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-richtext.md#richtextupdatemutatorfunctiontctx-bool) */ 266 | update(mutator: (context: Transaction) => {}): boolean; 267 | } 268 | 269 | interface Transaction 270 | { 271 | /** Add or change value of one attribute. */ 272 | setAttribute(el: Element, name: string, value: string): void; 273 | /** Remove one attribute. */ 274 | removeAttribute(el: Element, name: string): void; 275 | /** Change tag of the element. */ 276 | setTag(el: Element, name: string): void; 277 | /** Change node text. */ 278 | setText(node: Node, text: string): void; 279 | /** splits node at offset position until the parent element. 280 | * Similar to pressing ENTER in the middle of paragraph - 281 | * text node and p[aragraph] element will be split to two paragraphs; */ 282 | split(node: Node, offset: number, parentEl: Element): [node: Node, offset: number]; 283 | /** Wrap the range into element. */ 284 | wrap(startNode: Node, startOffset: number, endNote: Node, endOffset: number, tag: string): void; 285 | /** Remove the element and add it content to parent element. */ 286 | unwrap(el: Element): void; 287 | /** Same as `Element.execCommand()` but all mutations will go into this transaction. */ 288 | execCommand(command: string, params?: object|string): boolean; 289 | 290 | /** Insert text at given node/offset position. */ 291 | insertText(at: Node|number, text: string): [node: Node, offset: number]; 292 | /** Insert HTML at given node/offset position, return list of nodes inserted; */ 293 | insertHTML(at: Node|number, html: string): Node[]; 294 | /** Insert node at given node/offset position. */ 295 | insertNode(at: Node|number, html: string): [node: Node, offset: number]; 296 | 297 | /** Delete current selected range (if any). */ 298 | deleteSelection(): [node: Node, offset: number]; 299 | deleteRange(startNode: Node, startOffset: number, endNote: Node, endOffset: number): void; 300 | /** Delete given node or element. */ 301 | deleteNode(node: Node): void; 302 | } 303 | 304 | interface video 305 | { 306 | /** Report playback status. If true then video is playing at the moment. */ 307 | readonly isPlaying: boolean; 308 | /** If video playback has reached the end of the movie. */ 309 | readonly isEnded: boolean; 310 | /** Duration in seconds of the movie. If duration is not available it returns 0. */ 311 | readonly duration: number; 312 | /** Reports natural width and height of video frame of the movie. */ 313 | readonly height, readonly width: number; 314 | /** Reports video box rectangle in pixels relative to the content box of the element. 315 | * Note if sizing attribute is "cover" then either x or y can be negative. */ 316 | readonly renderingBox: [x, y, width, height]; 317 | /** float (0.0...1.0). Current volume level of audio track. 318 | * 1.0 correspond to 0db, 0.0 (mute) -100db. */ 319 | audioVolume: number; 320 | /** float ( -1.0 ... +1.0 ). Current stereo balance. */ 321 | audioBalance: number; 322 | /** float, Get/Set current playback position, in seconds. */ 323 | position: number; 324 | 325 | /** Loads video file into the player. use `play()` to start. */ 326 | load(url: string): boolean; 327 | /** Stops video playback and unloads the movie. */ 328 | unload(): void; 329 | /** Start playback at current `position` */ 330 | play(): void; 331 | stop(): void; 332 | } 333 | 334 | -------------------------------------------------------------------------------- /src/document.d.ts: -------------------------------------------------------------------------------- 1 | interface Document extends Element { 2 | /** Return image associated with provided arbitrary url, or assign one if image is provided too. 3 | * This method also allow you to use the image in CSS by it URL. 4 | */ 5 | bindImage(url: string, image?: Image): Image; 6 | 7 | /** Returns absolute path of provided relative path using the document URL as a base. */ 8 | url(relpath ?: string): string; 9 | 10 | /** Subscribe to any DOM event */ 11 | on(event: keyof typeof eventType, selector?: string, handler: eventFunction): void; 12 | on(event: keyof typeof domEvent, handler: eventFunction): void; 13 | 14 | /* NATIVE */ 15 | 16 | body: Element; 17 | head: Element; 18 | /** Root(html) element */ 19 | documentElement: Element; 20 | /** document loading state - `complete` | `interactive` */ 21 | readyState: 'complete' | 'interactive'; 22 | createElement(tag: string): Element; 23 | createTextNode(): Node; 24 | createComment(): Comment; 25 | createDocumentFragment(); 26 | createNodeIterator(root: string, whatToShow?: string, filter?: string): NodeIterator; 27 | } 28 | declare var Document: { 29 | new(): Document; 30 | }; 31 | 32 | declare var document: Document; 33 | 34 | enum domEvent { 35 | parsed, 36 | ready, 37 | DOMContentLoaded, 38 | complete, 39 | close, 40 | unload, 41 | beforeunload, 42 | closerequest 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/global.d.ts: -------------------------------------------------------------------------------- 1 | /** Call function after x time 2 | * @return Timeout ID for `clearTimeout(ID)` 3 | */ 4 | declare function setTimeout(cb: Function, milliseconds: number): number; 5 | /** Cancel `setTimeout` function by it returned ID */ 6 | declare function clearTimeout(tID: number): void; 7 | /** Call function every x amount of time 8 | * @return Interval ID for `clearInterval(ID)` 9 | */ 10 | declare function setInterval(cb: Function, milliseconds: number): number; 11 | /** Cancel `setInterval` function by it returned ID */ 12 | declare function clearInterval(iID: number): void; 13 | /** Call function on every frame 14 | * @return function ID for `cancelAnimationFrame(ID)` 15 | */ 16 | declare function requestAnimationFrame(cb: Function): number; 17 | /** Cancel `requestAnimationFrame` function by it returned ID */ 18 | declare function cancelAnimationFrame(aID: number): void; 19 | 20 | declare var console: 21 | { 22 | log(...arg: any): void; 23 | warn(...arg: any): void; 24 | error(...arg: any): void; 25 | } 26 | 27 | declare function getComputedStyle(el: Element, pseudoElement?: Element): Style; 28 | 29 | /** 30 | * Format arguments using [C-style printf conventions](https://en.cppreference.com/w/cpp/io/c/fprintf). 31 | * Sciter specific: 32 | `%v` - print as JSON.stringify(arg); 33 | `%V` - print as JSON.stringify(arg, null, " "); 34 | */ 35 | declare function printf(...args: string[]): string; 36 | 37 | /** 38 | * Format arguments using [C-style scanf conventions](https://en.cppreference.com/w/c/io/fscanf). 39 | */ 40 | declare function scanf(...args: string[]): array<string | number>; 41 | 42 | /** 43 | * "module" version of stock `eval()` function. 44 | * It evaluates the text as a module body. If the url is provided it is used as a base URL 45 | * for resolving relative paths in `import ... from "relpath"` statements inside. 46 | * @return module's exported data as an object. 47 | */ 48 | declare function evalModule(text: string, url?: string): any; 49 | 50 | /** Loads and executes JavaScript at url synchronously. */ 51 | declare function loadScript(url: string): void; 52 | 53 | /** Loads and executes JavaScript module at url synchronously. Returns modules exports object */ 54 | declare function loadScriptModule(url: string): any; 55 | 56 | /** Number of physical screen pixels in logical CSS px (dip) */ 57 | declare var devicePixelRatio: float; 58 | 59 | /** Current document directory */ 60 | declare const __DIR__: string; 61 | 62 | declare var globalThis: object; 63 | declare var window: typeof globalThis; 64 | 65 | 66 | declare function fetch(url: string | Request, params?: fetchParams): Promise<Response>; 67 | 68 | interface fetchParams 69 | { 70 | method?: 'POST'|'GET'|'PUT'|'DELETE'; 71 | mode?: 'cors'|'no-cors'|'same-origin'; 72 | cache?: 'default'|'no-cache'|'reload'|'force-cache'|'only-if-cached'; 73 | credentials?: 'same-origin'|'include'|'omit'; 74 | redirect?: 'follow'|'manual'|'error'; 75 | referrerPolicy?: 'non-referrer-when-downgrade'|'non-referrer'|'origin'|'origin-when-cross-origin'|'same-origin'|'strict-origin'|'strict-origin-when-cross-origin'|'unsafe-url'; 76 | integrity?: string; 77 | keepalive?: boolean; 78 | sync?: boolean; 79 | body?: string|FormData; 80 | headers?: { 81 | Accept?: string; 82 | 'Accept-Language'?: string; 83 | 'Content-Type'?: 'application/json'|'application/x-www-form-urlencoded'|'text/plain'|'multipart/form-data'; 84 | 'Content-Language'?: string; 85 | [name: string]: string|boolean; 86 | } 87 | /** Callback function to be called on download progress. 88 | * Note: total argument can be zero if server does not provide `Content-Length` info. */ 89 | downloadProgress?: (fetched: number, total: number) => void; 90 | } 91 | 92 | interface Response 93 | { 94 | readonly body: string; 95 | readonly bodyUsed: boolean; 96 | readonly headers: any; 97 | readonly ok: boolean; 98 | readonly redirected: boolean; 99 | readonly status: number; 100 | readonly statusText: string; 101 | readonly type: string; 102 | readonly url: string; 103 | /** if true then the request was aborted by `request.abort()` call. 104 | * @version 5.0.1.1+ */ 105 | readonly aborted: boolean; 106 | readonly request: Request; 107 | 108 | arrayBuffer(): Promise<ArrayBuffer>; 109 | blob(): Promise<ArrayBuffer>; 110 | clone(): Response; 111 | error(): Response; 112 | redirect(url: string, status?: number): Response; 113 | formData(): Promise<FormData>; 114 | json(): Promise<any>; 115 | text(): Promise<string>; 116 | } 117 | 118 | interface Request 119 | { 120 | cache: "no-cache" | "reload" | "default"; 121 | context: "html" | "image" | "style" | "cursor" | "script" | "data" | "font" | "audio"; 122 | headers: any; 123 | method: 'POST'|'GET'|'PUT'|'DELETE'; 124 | url: string; 125 | /** Try to abort current request; Response of aborted request will have `response.aborted` property set to true. 126 | * @version 5.0.1.1+ */ 127 | abort(): void; 128 | progress?: (bytesLoaded: number, totalBytes: number) => void; 129 | 130 | /** Appends a new value to existing key inside the object, or adds the key if it does not already exist. 131 | * To overwrite existing key/value use `set()`. 132 | */ 133 | append(key: string, value: any, filename?: string): void; 134 | /** Sets a new value for an existing key inside the object, or adds the key/value if it does not already exist. */ 135 | set(key: string, value: any, filename?: string): void; 136 | delete(key: string): void; 137 | /** Returns an iterator allowing to go through all key/value pairs contained in this object */ 138 | entries(): [key: string, value: any][]; 139 | /** Returns the first value associated with a given key */ 140 | get(key: string): any; 141 | /** Returns all the values associated with a given key */ 142 | getAll(key: string): any[]; 143 | /** Returns a boolean stating whether object contains a certain key. */ 144 | has(key: string): boolean; 145 | /** Returns an iterator allowing to go through all keys contained in this object. */ 146 | keys(): string[]; 147 | /** Returns an iterator allowing to go through all values contained in this object. */ 148 | values(): any[]; 149 | } 150 | declare var Request: 151 | { 152 | new(): Request; 153 | } 154 | interface FormData extends Request 155 | { 156 | 157 | } 158 | declare var FormData: 159 | { 160 | new(): FormData; 161 | } 162 | 163 | interface URL 164 | { 165 | /** `#hash` */ 166 | readonly hash: string; 167 | /** `sub.domain.org` */ 168 | readonly host: string; 169 | readonly hostname: string; 170 | /** Full URL */ 171 | readonly href: string; 172 | /** `https://sub.domain.org` */ 173 | readonly origin: string; 174 | /** `/path/without/host` */ 175 | readonly pathname: string; 176 | readonly port: number; 177 | /** Protocol type: `https:|http:|file:` */ 178 | readonly protocol: string; 179 | /** Query paramters: `?q=1&w=w` */ 180 | readonly search: string; 181 | 182 | readonly filename: string; 183 | readonly dir: string; 184 | readonly extension: string; 185 | 186 | guessMimeType(): string; 187 | } 188 | declare var URL: { 189 | new(url: string): URL; 190 | /** Decode and remove prefix */ 191 | toPath(path: string): string; 192 | /** Encode and prefix path with `file://` */ 193 | fromPath(path: string): string; 194 | } 195 | 196 | /** Creates binary JSON pack/unpack context. */ 197 | interface BJSON 198 | { 199 | /** Serializes JSON data to the ArrayBuffer */ 200 | pack(data: object): ArrayBuffer; 201 | /** Restore data from BJSON blob 202 | * @param data previously packed JSON data 203 | * @param cb function taking `(data)` as argument 204 | */ 205 | unpack(data: ArrayBuffer, cb: Function): void; 206 | } 207 | declare var BJSON: { 208 | new(): BJSON; 209 | } 210 | 211 | declare var Clipboard: 212 | { 213 | read(): clipboardObject; 214 | readText(): string; 215 | write(data: clipboardObject): boolean; 216 | writeText(text: string): boolean; 217 | has(type: "text"|"html"|"image"|"file"|"json"|"link"): boolean; 218 | } 219 | interface clipboardObject 220 | { 221 | text?: string; 222 | html?: string; 223 | json?: any; 224 | /** List of files path */ 225 | file?: string[]; 226 | link?: { caption: string, url: string }; 227 | image?: Image; 228 | } 229 | 230 | /** The Zip class allows access to the content of a zip file or blob. 231 | * @version 5.0.0.2+ 232 | */ 233 | interface Zip 234 | { 235 | /** Number of files(items) in the Zip. */ 236 | readonly length: number; 237 | /** Fetch file by it index. */ 238 | item(index: number): ZipItem; 239 | /** Fetch file by it path (local to the zip). */ 240 | item(path: string ): ZipItem; 241 | } 242 | declare var Zip: 243 | { 244 | openFile(path: string): Zip; 245 | openData(data: ArrayBuffer): Zip; 246 | } 247 | interface ZipItem 248 | { 249 | readonly isDir: boolean; 250 | readonly isFile: boolean; 251 | /** Local path of the item inside the zip. */ 252 | readonly path: string; 253 | /** Data of the item as ArrayBuffer. */ 254 | readonly data: ArrayBuffer; 255 | } 256 | 257 | -------------------------------------------------------------------------------- /src/jsx.d.ts: -------------------------------------------------------------------------------- 1 | /** Enable JSX React support */ 2 | declare var React: any; 3 | 4 | declare namespace JSX { 5 | // Custom Element documentation support 6 | interface IntrinsicElements { 7 | /** Root document element */ 8 | html: any; 9 | [tagName: string]: any; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/module-debug.d.ts: -------------------------------------------------------------------------------- 1 | declare module "@debug" { 2 | /** Gets call stack item at level */ 3 | export function callStackAt(level: number): callStack; 4 | /** Catch unhandled exceptions. pass `0` to get info about current function. 5 | * @param cb function taking (Error) as argument 6 | */ 7 | export function setUnhandledExeceptionHandler(cb: Function): void; 8 | /** Redirect console output. make sure to reset `console.log`... 9 | * @param cb function taking `(subsystem: number, severity: number, msg: any)` as argument 10 | */ 11 | export function setConsoleOutputHandler(cb: Function): void; 12 | export function setBreakpointHandler(cb: Function): void; 13 | export function setBreakpoints(cb: Function): void; 14 | export function getElementByUID(id: number): Element; 15 | export function getUIDofElement(el: Element): number; 16 | export function highlightElement(el: Element): void; 17 | export function getStyleRulesOfElement(el: Element): Style; 18 | export function containerId(): number; 19 | export function objectKind(object: Object): string; 20 | export function sublimatedValue(value: any, expanded: any): any; 21 | export function sublimatedValueElements(): any; 22 | export function frameVariables(id: number): any; 23 | } 24 | 25 | interface callStack { 26 | /** Is that call stack frame is of native function. */ 27 | isNative: boolean; 28 | functionName: string; 29 | /** line number of function declaration */ 30 | functionLineNo: number; 31 | fileName: string; 32 | /** line number inside the function. */ 33 | LineNo: number; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/module-env.d.ts: -------------------------------------------------------------------------------- 1 | declare module "@env" { 2 | /** OS identification name: `"Windows-10.1"`... */ 3 | export const OS: string; 4 | /** OS/platform generic name: `"Windows", "OSX", "Linux", "Android"`, etc. */ 5 | export const PLATFORM: string; 6 | /** Device type */ 7 | export const DEVICE: "desktop" | "mobile"; 8 | /** Returns two-letter language abbreviation of user's default language. */ 9 | export function language(): string; 10 | /** Returns two-letter country abbreviation of the user's country */ 11 | export function country(): string; 12 | export function userName(): string; 13 | /** Machine network name. */ 14 | export function machineName(): string; 15 | /** Machine network domain. */ 16 | export function domainName(): string; 17 | /** 18 | * Launch file/URL with default system application 19 | */ 20 | export function launch(path:string): void; 21 | /** Converts relative path to absolute path using location of `sciter.dll` as a base. */ 22 | export function home(relpath ?: string): string; 23 | /** Converts relative path to absolute path prefixed by `file://` using location of sciter.dll as a base. */ 24 | export function homeURL(relpath ?: string): string; 25 | /** 26 | * Return path of default system folder ie. documents|downloads 27 | * @param name of default system folder 28 | * @param relpath relative path to name 29 | */ 30 | export function path(name: keyof typeof systemPath, relpath ?: string): string; 31 | /** 32 | * Return path of default system folder ie. documents|downloads, prefixed by `file://` 33 | * @param name of default system folder 34 | * @param relpath relative path to name 35 | */ 36 | export function pathURL(name: keyof typeof systemPath): string; 37 | /** Get/Set environment variable */ 38 | export function variable(key: string, value?: string): string; 39 | /** 40 | * Execute comma seperated arguments 41 | */ 42 | export function exec(...args: string[]): void; 43 | } 44 | 45 | enum systemPath { "home", "root", "desktop", "applications", "downloads", "documents", "music", "videos", "pictures", "USER_APPDATA" } 46 | 47 | -------------------------------------------------------------------------------- /src/module-sciter.d.ts: -------------------------------------------------------------------------------- 1 | declare module "@sciter" { 2 | export const VERSION: string; 3 | export const REVISION: string; 4 | export const QUICKJS_VERSION: string; 5 | /** Returns first matched DOM element in current document. */ 6 | export function $(query: string): Element; 7 | /** Returns list (array) of matched DOM elements. */ 8 | export function $$(query: string): array<Element>; 9 | // export function import(path: string): object; 10 | /** 11 | * Load native Sciter extension 12 | * @param name path to library without .dll/.dylib (relative to sciter.dll) 13 | */ 14 | export function loadLibrary(name: string): any; 15 | /** Parses string by "JSON++ rules" returning it actual value: Date, Array, Angle, Hex... */ 16 | export function parseValue(val:string): any; 17 | /** Converts length to device (screen) pixels */ 18 | export function devicePixels(length: number | string, axis: "width" | "height") 19 | /** Generate unique id */ 20 | export function uuid(): string; 21 | /** Subscribe to any DOM event */ 22 | export function on(event: keyof typeof eventType, selector?: string, handler: eventFunction): void; 23 | /** Unsubscribe to any DOM event */ 24 | export function off(eventOrHandler: keyof typeof eventType | function): void; 25 | /** Encodes text to sequence of bytes (ArrayBuffer). Default encoding is "utf-8". */ 26 | export function encode(text: string, encoding ?: string): ArrayBuffer; 27 | /** Decodes sequence of bytes of buffer to string. Default encoding is "utf-8". */ 28 | export function decode(bytes: ArrayBuffer, encoding ?: string): string; 29 | export function compress(input: ArrayBuffer, method?: "gz" | "gzip" | "lzf"): ArrayBuffer; 30 | export function decompress(input: ArrayBuffer, method?: "gz" | "gzip" | "lzf"): ArrayBuffer; 31 | export function toBase64(input:ArrayBuffer): string; 32 | export function fromBase64(input:string): ArrayBuffer; 33 | export function md5(input:ArrayBuffer): string; 34 | export function crc32(input:ArrayBuffer): number; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/module-storage.d.ts: -------------------------------------------------------------------------------- 1 | /** This module provides Sciter's built-in data persistence - data storage and retrieval. */ 2 | declare module '@storage' { 3 | declare interface storage { 4 | /** Storage root object containing the data. 5 | * any modification of this object will result in saving the data to storage file. */ 6 | root: any; 7 | /** 8 | * Create Index to provide effective access and ordering of potentially large data sets. 9 | * @param type defines type of keys in the index. It can be "string", "integer", "long", "float" or "date". 10 | * @param unique `true` if the index supports only unique keys, or `false` if records with the same key values are allowed in the index. 11 | */ 12 | createIndex(type: 'string'|'integer'|'long'|'float'|'date', unique?: boolean): index|null; 13 | /** Closes underlying Storage object. Commits all data before closing. 14 | * After closing the storage all persistent objects that are still in use are set to non-persistent state. */ 15 | close(): void; 16 | /** Commits (writes) all persistent objects reachable from its root into storage. */ 17 | commit(): void; 18 | 19 | /** 20 | * Registers class (a.k.a. constructor function in terms of ES5) of persistable objects. 21 | When an object is stored into DB, name of its class is also stored. 22 | When the object is fetched from the DB, it gets the class assigned automatically if that class was registered before. 23 | @version 5.0.2.4+ 24 | */ 25 | registerClass(cls); 26 | } 27 | /** Index object in persistent storage. provide effective access and ordering of potentially large data sets. */ 28 | interface index { 29 | /** Insert or replace object in index associated with the key value. */ 30 | set(key: any, value: any, replace?: boolean): boolean; 31 | /** Returns object associated with the key or null. key has to be of the same type as the type of the index object. 32 | * If the index was created as non unique then the return value is an array - list of items under the key. */ 33 | get(key: any): any|any[]|null; 34 | /** Returns selection in the Index based on criteria `min-key, max-key` sorted by ascent or descent order, start-inclusive and end-inclusive. 35 | * @info Either `minKey or maxKey` can be `null` that means search from very first or very last key in the index. */ 36 | select(minKey: any, maxKey: any, ascending?: true, startInclusive?: true, endInclusive?: true): any[]; 37 | /** Remove object by it key from the index. If the index is unique, obj is optional. */ 38 | delete(key: any, object?: any): boolean; 39 | /** Removes all items from the index object. */ 40 | clear(): void; 41 | 42 | /** Number of objects associated represented by the index. */ 43 | readonly length: number; 44 | /** `true` if the index was declared as unique. */ 45 | readonly unique: boolean; 46 | /** key type as it was declared at creation time. */ 47 | readonly type: string; 48 | } 49 | 50 | /** Opens the storage and returns an instance of Storage object. If allowWrite is false then storage is opened in read-only mode. */ 51 | export function open(path: string, allowWrite?: true): storage|null; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/module-sys.d.ts: -------------------------------------------------------------------------------- 1 | declare module "@sys" { 2 | export function spawn(args: string[], options?: spawnOptions ): Process; 3 | export function hrtime(): bigint; 4 | export function gettimeofday(): number; 5 | export function uname(): unameObject; 6 | /** Returns `true` if fd is an open file descriptor referring to a terminal. */ 7 | export function isatty(): boolean; 8 | /** Retrieves all environment variables */ 9 | export function environ(): object; 10 | export function getenv(name: string): string; 11 | export function setenv(name: string, value: string): void; 12 | export function unsetenv(name: string): void; 13 | export function cwd(): string; 14 | export function homedir(): string; 15 | export function tmpdir(): string; 16 | /** Return path of this executable file. */ 17 | export function exepath(): string; 18 | export function random(buffer: ArrayBuffer); 19 | 20 | declare var UDP: { 21 | new(): UDPSocket; 22 | }; 23 | declare var TCP: { 24 | new(): TCPSocket; 25 | }; 26 | declare var TTY: { 27 | new(): TTY; 28 | }; 29 | declare var Pipe: { 30 | new(): Pipe; 31 | }; 32 | 33 | namespace fs { 34 | /** 35 | * Monitor files or folders for changes 36 | * @param path 37 | * @param cb callback function 38 | */ 39 | function watch(path:string, cb: (path:string, events: 0x01 | 0x02) => void): WatchFS; 40 | /** 41 | * Open file instance 42 | * @param path 43 | * @param flags method to open the file with read/write 44 | * @param mode file content encoding 45 | */ 46 | function open(path:string, flags: keyof typeof OpenFlagOptions, mode ?: number): Promise<File>; 47 | /** 48 | * Synchronously open file instance 49 | * @param path 50 | * @param flags method to open the file with read/write 51 | * @param mode file content encoding 52 | * @deprecated >5.0.0.5 use `fs.sync.open()` 53 | */ 54 | function $open(path:string, flags: keyof typeof OpenFlagOptions, mode ?: number): File; 55 | function openSync(path:string, flags: keyof typeof OpenFlagOptions, mode ?: number): File; 56 | /** Return information about the file at path. */ 57 | function stat(path:string): Promise<StatStruct>; 58 | /** Return information about the file at path. (sync) 59 | * @deprecated >5.0.0.5 use `fs.sync.stat()` or `fs.statSync()` 60 | */ 61 | function $stat(path:string): StatStruct; 62 | /** Return information about the file at path. (sync) 63 | * @version 5.0.0.6+ 64 | */ 65 | function statSync(path:string): StatStruct; 66 | /** `lstat()` is identical to `stat()`, except that if path is a symbolic link, then the link itself is stat-ed, not the file that it refers to. */ 67 | function lstat(): Promise<StatStruct>; 68 | /** ( sync version of `lstat()` ) `$lstat()` is identical to `$stat()`, except that if path is a symbolic link, then the link itself is stat-ed, not the file that it refers to. 69 | * @deprecated >5.0.0.5 use `fs.sync.lstat()` or `fs.lstatSync()` 70 | */ 71 | function $lstat(): StatStruct; 72 | /** ( sync version of `lstat()` ) `$lstat()` is identical to `$stat()`, except that if path is a symbolic link, then the link itself is stat-ed, not the file that it refers to. 73 | * @version 5.0.0.6+ 74 | */ 75 | function lstatSync(): StatStruct; 76 | /** Expands all symbolic links and resolves references `/./`, `/../` and extra `/` characters in the pathname string to produce a canonicalized absolute pathname. */ 77 | function realpath(pathname: string): string; 78 | /** Splits path to `0`: directory without trailling `/` and `1`: file name and extension */ 79 | function splitpath(path: string): [directory: string, file: string]; 80 | /** Remove file */ 81 | function unlink(path:string): Promise; 82 | function unlinkSync(path:string); 83 | function rename(oldpath:string, newpath: string) : Promise; 84 | /** Creates unique temporary directory. The last six characters of template must be "XXXXXX". */ 85 | function mkdtemp(template:string) : Promise<string>; 86 | /** Creates unique temporary file. The last six characters of template must be "XXXXXX" */ 87 | function mkstemp(template:string) : Promise<string>; 88 | /** Delete directory (async) */ 89 | function rmdir(path:string) : Promise; 90 | /** Delete directory (sync) 91 | * @deprecated >5.0.0.5 use `fs.sync.rmdir()` or `fs.rmdirSync()` 92 | */ 93 | function $rmdir(path:string); 94 | /** Delete directory (sync) 95 | * @version 5.0.0.6+ 96 | */ 97 | function rmdirSync(path:string); 98 | /** Create directory (async) */ 99 | function mkdir(path:string, mode ?: 0o777): Promise; 100 | /** Create directory (sync) 101 | * @deprecated >5.0.0.5 use `fs.sync.mkdir()` or `fs.mkdirSync()` 102 | */ 103 | function $mkdir(path:string, mode ?: 0o777); 104 | /** Create directory (sync) 105 | * @version 5.0.0.6+ 106 | */ 107 | function mkdirSync(path:string, mode ?: 0o777); 108 | /** Change mode command used to manage file system access permissions on Unix and Unix-like systems. 109 | * @version 5.0.0.6+ 110 | * @reference [chmod](https://man7.org/linux/man-pages/man2/chmod.2.html) 111 | */ 112 | function chmod(path: string, mode ?: number): Promise; 113 | /** Change mode command used to manage file system access permissions on Unix and Unix-like systems. (sync) 114 | * @version 5.0.0.6+ 115 | * @reference [chmod](https://man7.org/linux/man-pages/man2/chmod.2.html) 116 | */ 117 | function chmodSync(path: string, mode ?: number); 118 | /** 119 | * Asynchronous file copy. 120 | * @param flag a combination of `fs.UV_FS_COPYFILE_***` 121 | */ 122 | function copyfile(source: string, destination: string, flag?: number): Promise; 123 | function copyfileSync(source: string, destination: string, flag?: number); 124 | /** Read directory contents asynchronously. The promise resolves to file list. */ 125 | function readdir(path: string): Promise<FileList[]>; 126 | /** Read directory contents synchronously. return file list. 127 | * @deprecated >5.0.0.5 use `fs.sync.readdir()` or `fs.readdirSync()` 128 | */ 129 | function $readdir(path: string): FileList[]; 130 | /** Read directory contents synchronously. return file list. 131 | * @version 5.0.0.6+ 132 | */ 133 | function readdirSync(path: string): Promise<FileList[]>; 134 | /** Return file content, check `readfileSync` for sync method. */ 135 | function readFile(path: string): Promise<ArrayBuffer>; 136 | function readfile(path: string): Promise<ArrayBuffer>; 137 | /** Synchronously return file content. 138 | * @deprecated >5.0.0.5 use `fs.sync.readfile()` or `fs.readfileSync()` 139 | */ 140 | function $readfile(path: string): ArrayBuffer; 141 | /** Synchronously return file content. 142 | * @version 5.0.0.6+ 143 | */ 144 | function readFileSync(path: string): ArrayBuffer; 145 | function readfileSync(path: string): ArrayBuffer; 146 | 147 | const UV_DIRENT_UNKNOWN: 0; 148 | const UV_DIRENT_FILE: 1; 149 | const UV_DIRENT_DIR : 2; 150 | const UV_DIRENT_LINK: 3; 151 | const UV_DIRENT_FIFO: 4; 152 | const UV_DIRENT_SOCKET: 5; 153 | /** Character stream device, like terminal. */ 154 | const UV_DIRENT_CHAR: 6; 155 | const UV_DIRENT_BLOCK: 7; 156 | 157 | /** `fs.copyfile()` flag : return an error if the destination already exists */ 158 | const UV_FS_COPYFILE_EXCL: 1; 159 | /** `fs.copyfile()` flag : attempt to create a reflink, if copy-on-write is not supported, a fallback copy mechanism is used. */ 160 | const UV_FS_COPYFILE_FICLONE: 2; 161 | /** `fs.copyfile()` flag : attempt to create a reflink, if copy-on-write is not supported, an error is returned. */ 162 | const UV_FS_COPYFILE_FICLONE_FORCE: 4; 163 | 164 | /** Synchronous methods of existing Asynchronous file system methods. 165 | * @version 5.0.0.6+ 166 | */ 167 | namespace sync { 168 | /** 169 | * Open file instance 170 | * @param path 171 | * @param flags method to open the file with read/write 172 | * @param mode file content encoding 173 | */ 174 | function open(path:string, flags: keyof typeof OpenFlagOptions, mode ?: number): File; 175 | /** Return information about the file at path. */ 176 | function stat(path:string): StatStruct; 177 | /** `lstat()` is identical to `stat()`, except that if path is a symbolic link, then the link itself is stat-ed, not the file that it refers to. */ 178 | function lstat(): StatStruct; 179 | /** Delete directory. */ 180 | function rmdir(path:string); 181 | /** Create directory.*/ 182 | function mkdir(path:string, mode ?: 0o777); 183 | /** Change mode command used to manage file system access permissions on Unix and Unix-like systems. 184 | * @reference [chmod](https://man7.org/linux/man-pages/man2/chmod.2.html) 185 | */ 186 | function chmod(path: string, mode ?: number); 187 | /** Read directory contents. The promise resolves to file list. */ 188 | function readdir(path: string): FileList[]; 189 | /** Return file content. */ 190 | function readfile(path: string): ArrayBuffer; 191 | function unlink(path:string); 192 | function rename(oldpath:string, newpath: string); 193 | function copyfile(source: string, destination: string, flag?: number); 194 | } 195 | } 196 | 197 | interface Dir { 198 | close(); 199 | path: string; 200 | next(); 201 | [async iterator]; 202 | } 203 | 204 | declare interface File { 205 | read (length?:number, fileposition ?: number): Promise<Uint8Array>; 206 | /** @deprecated >5.0.0.5 use `readSync()` */ 207 | $read(length?:number, fileposition ?: number): Uint8Array; 208 | /** @version 5.0.0.5+ */ 209 | readSync(length?:number, fileposition ?: number): Uint8Array; 210 | write (data:string|string[]|ArrayBuffer, filePosition ?: number) : Promise<number>; 211 | /** @deprecated >5.0.0.5 use `writeSync` */ 212 | $write(data:string|string[]|ArrayBuffer, filePosition ?: number) : number; 213 | /** @version 5.0.0.6+ */ 214 | writeSync(data:string|string[]|ArrayBuffer, filePosition ?: number) : number; 215 | close (): Promise<undefined>; 216 | /** @deprecated >5.0.0.5 use `closeSync` */ 217 | $close(): undefined; 218 | /** @version 5.0.0.6+ */ 219 | closeSync(): undefined; 220 | fileno(): number; 221 | stat(): Promise<StatStruct>; 222 | path: string; 223 | } 224 | 225 | interface FileList { 226 | /** local file name + extension (relative to directory) */ 227 | name: string; 228 | /** ORed flags (see `fs.UV_DIRENT_****`) */ 229 | type: number; 230 | } 231 | 232 | declare interface WatchFS { 233 | readonly path: string; 234 | close(): void; 235 | } 236 | 237 | declare interface StatStruct { 238 | isFile ?: boolean; 239 | isDirectory ?: boolean; 240 | isSymbolicLink ?: boolean; 241 | st_dev: number; 242 | st_ino: number; 243 | st_mode: number; 244 | st_nlink: number; 245 | st_uid: number; 246 | st_gid: number; 247 | st_rdev: number; 248 | st_size: number; 249 | st_blksize: number; 250 | st_blocks: number; 251 | st_atime: number; 252 | st_mtime: number; 253 | st_ctime: number; 254 | st_birthtime: number; 255 | } 256 | 257 | interface unameObject { 258 | /** OS code name: Windows_NT */ 259 | sysname: string; 260 | /** OS version: 10.0.19044 */ 261 | release: string; 262 | /** OS type: Windows 10 Enterprise */ 263 | version: string; 264 | /** Processor type: i686 */ 265 | machine: string; 266 | } 267 | 268 | interface spawnOptions { 269 | stdin ?: string; 270 | stdout?: string; 271 | stderr?: string; 272 | } 273 | } 274 | 275 | declare enum OpenFlagOptions { 'a', 'ax', 'a+', 'ax+', 'as', 'as+', 'r', 'r+', 'rs+', 'w', 'wx', 'w+', 'wx+' } 276 | 277 | declare interface Process { 278 | kill(); 279 | wait(): Promise<ProcessStats>; 280 | pid: number; 281 | stdin: Pipe; 282 | stdout: Pipe; 283 | stderr: Pipe; 284 | } 285 | 286 | declare interface ProcessStats { 287 | exit_status: number; 288 | term_signal: number; 289 | exitCode: number; 290 | terminationSignal: number; 291 | } 292 | 293 | declare interface Socket { 294 | close(): void; 295 | fileno(): number; 296 | getsockname(): NetworkParam; 297 | getpeername(): NetworkParam; 298 | connect(param: NetworkParam): Promise<void>; 299 | bind(param: NetworkParam): void; 300 | } 301 | 302 | declare interface UDPSocket extends Socket { 303 | recv(): Promise<{data: ArrayBuffer, flags: number, addr: NetworkParam}>; 304 | send(data: string|ArrayBuffer): Promise<void>; 305 | } 306 | 307 | declare interface TCPSocket extends Socket { 308 | shutdown(): void; 309 | listen(): void; 310 | accept(): Promise<TCPSocket>; 311 | read(): Promise<ArrayBuffer>; 312 | write(data: string|ArrayBuffer): void; 313 | } 314 | 315 | declare interface Pipe extends Socket { 316 | listen(): void; 317 | accept(): Promise<Pipe>; 318 | bind(name: string): void; 319 | getpeername(): string; 320 | getsockname(): string; 321 | read(): Promise<ArrayBuffer>; 322 | write(data: string|ArrayBuffer): void; 323 | } 324 | 325 | declare interface TTY { 326 | close(); 327 | read(); 328 | write(); 329 | fileno(); 330 | setMode(); 331 | getWinSize(); 332 | } 333 | 334 | declare interface NetworkParam { 335 | family?: number; 336 | ip: string; 337 | port: number; 338 | } 339 | 340 | -------------------------------------------------------------------------------- /test/Graphics.js: -------------------------------------------------------------------------------- 1 | let g = new Graphics(); 2 | 3 | let Image = new Graphics.Image(5, 5, (ct) => {ct.beginPath();}) 4 | 5 | let imageload = await Graphics.Image.load('xx'); 6 | let x = 1, y = 1, w = 1, h = 1; 7 | let a = 1, b = 1, c = 1, d = 1, e = 1, f = 1; 8 | let startAngle = 1, endAngle = 1; 9 | let radius = 1, radiusX = 1, radiusY = 1; 10 | 11 | g.pushLayer() 12 | 13 | g.clearRect(x, y, w, h); 14 | g.beginPath(); 15 | g.moveTo(x, y); 16 | g.lineTo(x, y); 17 | g.quadraticCurveTo(cpx, cpy, x, y); 18 | g.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y); 19 | g.arc(x, y, radius, startAngle, endAngle); 20 | g.arcTo(x, y, x2, y2, radius); 21 | g.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle); 22 | g.rect(x, y, w, h); 23 | g.closePath(); 24 | g.stroke(...args); 25 | g.fill(...args); 26 | g.strokeRect(x, y, w, h); 27 | g.fillRect(x, y, w, h); 28 | g.fillText("", x, y, maxWidth); 29 | g.setLineDash(...args); 30 | g.save(); 31 | g.restore(); 32 | g.scale(x, y); 33 | g.translate(x, y); 34 | g.rotate(radian, x, y); 35 | g.transform(a, b, c, d, e, f); 36 | g.setTransform(a, b, c, d, e, f); 37 | 38 | g.draw(Graphics.Path, params: drawPathParams); 39 | g.draw(Graphics.Image, params: drawImageParams); 40 | g.draw(Graphics.Text, params: drawTextParams); 41 | 42 | g.pushLayer(x, y, w, h, 0.5, ""); 43 | g.pushLayer("", 0.5, ""); -------------------------------------------------------------------------------- /test/fetch.js: -------------------------------------------------------------------------------- 1 | 2 | let form = new FormData; 3 | 4 | form.append("key", "value"); 5 | form.append("key", "value", 'filename'); 6 | 7 | for (let e of form.entries()) 8 | { 9 | e[0] // key; 10 | e[1] // value; 11 | } 12 | 13 | (async () => 14 | { 15 | 16 | let r = await fetch('url', { 17 | body: form, 18 | method:"GET", 19 | headers: { 20 | "Content-Type":"application/json" 21 | } 22 | }); 23 | 24 | r.body; 25 | await r.json(); 26 | })(); 27 | 28 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | import { encode, decode } from "@sciter" 2 | import { fs } from "@sys" 3 | import * as env from "@env" 4 | import * as Storage from '@storage'; 5 | 6 | let storage = Storage.open('xx'); 7 | storage.root.d = storage.createIndex('string', true); 8 | 9 | 10 | var x = document.getBoundingClientRect(); 11 | x.bottom; 12 | 13 | document.on('click', 'button1', function (e, button) { 14 | 15 | }); 16 | 17 | document.on('active', 'button1', async function (e, button) { 18 | 19 | }); 20 | 21 | document.on("DOMContentLoaded", () => {}); 22 | 23 | document.selection.empty(); 24 | 25 | document.insertAdjacentHTML("afterend", "wow"); 26 | document.popup(document, {}) 27 | document.removeEventListener("wow", document.popup); 28 | 29 | document.takeOff({window:"attached"}) 30 | console.log(document, "one"); 31 | 32 | document.on("click", "one", (evt, el) => 33 | { 34 | evt.preventDefault(); 35 | return true; 36 | }); 37 | 38 | document.state.occluded = 0x1 | 0x2; 39 | document.state.box("bottom", "border"); 40 | document.style["background"] = "1"; 41 | document.style.fontRenderingMode; 42 | 43 | Window.this.on("activate", () => {}); 44 | Window.this.state = Window.CHILD_WINDOW 45 | Window.this.frameType = "solid"; 46 | Window.this.isActive 47 | Window.screenBox(0, "snapshot"); 48 | Window.this.frameType 49 | const k = new Window({ width: 16, parent: Window.this}); 50 | 51 | const z = Zip.openFile("test.zip"); 52 | z.length; 53 | z.item(0).path; 54 | 55 | document.head.children.item 56 | 57 | document.querySelector 58 | document.bindImage() 59 | document.$() 60 | 61 | document.$$() 62 | 63 | printf 64 | 65 | export async function read(path) 66 | { 67 | try 68 | { 69 | let file = await fs.readfile(path); 70 | let data = decode(file); 71 | return data; 72 | } 73 | catch (error) 74 | { 75 | return false; 76 | } 77 | } 78 | export function readSync(path) 79 | { 80 | let data = decode(fs.$readfile(path)); 81 | return data; 82 | } 83 | 84 | export async function write(path, data) 85 | { 86 | try 87 | { 88 | let file = await fs.open(path, "w"); 89 | await file.write(typeof data == "object" ? JSON.stringify(data) : data); 90 | return await file.close(); 91 | } 92 | catch (error) 93 | { 94 | return false; 95 | } 96 | } 97 | --------------------------------------------------------------------------------