{"id":13805203,"url":"https://github.com/sciter-sdk/Sciter-Dport","last_synced_at":"2025-05-13T18:33:21.575Z","repository":{"id":28414489,"uuid":"31928984","full_name":"sciter-sdk/Sciter-Dport","owner":"sciter-sdk","description":"Port of Sciter headers for the D language","archived":false,"fork":false,"pushed_at":"2017-06-12T03:17:04.000Z","size":3093,"stargazers_count":34,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-13T07:36:25.393Z","etag":null,"topics":["dlang","gui","htmlayout","sciter","tiscript"],"latest_commit_sha":null,"homepage":"https://sciter.com","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sciter-sdk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-09T23:54:17.000Z","updated_at":"2024-11-11T00:53:38.000Z","dependencies_parsed_at":"2022-08-17T23:55:18.484Z","dependency_job_id":null,"html_url":"https://github.com/sciter-sdk/Sciter-Dport","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sciter-sdk%2FSciter-Dport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sciter-sdk%2FSciter-Dport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sciter-sdk%2FSciter-Dport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sciter-sdk%2FSciter-Dport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sciter-sdk","download_url":"https://codeload.github.com/sciter-sdk/Sciter-Dport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254003513,"owners_count":21997897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dlang","gui","htmlayout","sciter","tiscript"],"created_at":"2024-08-04T01:00:58.578Z","updated_at":"2025-05-13T18:33:20.337Z","avatar_url":"https://github.com/sciter-sdk.png","language":"D","funding_links":[],"categories":["GUI Libs"],"sub_categories":["XML"],"readme":"ACTUAL SCITER VERSION: 3.3.0.7\n\nOctodeskDesk app made with this lib: https://github.com/midiway/OctoDeskdex\n\nFor quick starting, download a [Sciter Bootstrap](http://misoftware.rs/Bootstrap/Download) package for the D language, which comes with this library already configured.\n\n**Status**: after I started writing the [C# bindings](https://github.com/MISoftware/SciterSharp) for Sciter, I realized how a 100% object-orient wrapper around Sciter API is the best way to go for creating a user friendly abstraction. When I started this D-port, in my mind I would be making the equivalent of the C++ classes found in Sciter SDK which is OO btw but the naming of things is very confusing. So the next step for this D-port is to convert it to equivalent classes and names found in the C# port, however I am prioritizing the C# version which is getting Mono cross-platform support. This port will eventually get more attention for improvements and for having GTK support, but right now I am focusing the C# version.\n\n## About\n\nThis library is a port of Sciter headers to the D language. [Sciter](http://sciter.com/download/) is a multi-platform HTML engine. So with this library you can create D desktop application using not just HTML, but all the features of Sciter: CSS3, SVG, scripintg, AJAX, ...\n\nThe code is very well tested, and constantly used in real world applications, so be assured that it will save you hours and hours of debugging time, AVs and data corruptions (all which I had to face myself =D). Has unittest coverage so, in DMD, compile it with the -unittest flag to run them.\n\nFor more Sciter related content visit my site at: http://misoftware.rs/\n\nPlatforms supported until now: **Windows 32bits only**\n*(Linux GTX support is on the way)*\n\nLicense: MIT License\n\n\n## Structs and classes\n\nThis is a table of the available D classes/structs and their mapping over the types of the official SDK C++ headers:\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003eD type\u003c/th\u003e\n\u003cth\u003eC++ equivalent type\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\u003ci\u003emodule sciter.sciter_dom;\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003estruct node\u003c/b\u003e\u003cbr\u003e\n\u003cb\u003estruct element\u003c/b\u003e\n\u003c/td\u003e\n\n\u003ctd\u003e\n\u003ci\u003e#include \"sciter-x-dom.hpp\"\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003eclass sciter::dom::node\u003c/b\u003e\u003cbr\u003e\n\u003cb\u003eclass sciter::dom::element\u003c/b\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\u003ci\u003emodule sciter.sciter_value;\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003estruct json_value\u003c/b\u003e\n\u003c/td\u003e\n\n\u003ctd\u003e\n\u003ci\u003e#include \"value.hpp\"\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003esciter::value or VALUE\u003c/b\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\u003ci\u003emodule sciter.dbg;\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003eabstract class debug_output\u003c/b\u003e\u003cbr\u003e\n\u003c/td\u003e\n\n\u003ctd\u003e\n\u003ci\u003e#include \"sciter-x-debug.h\"\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003eclass sciter::debug_output\u003c/b\u003e\u003cbr\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\u003ci\u003emodule sciter.host;\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003eclass SciterArchive\u003c/b\u003e\u003cbr\u003e\n\u003cb\u003eabstract class SciterWindowHost\u003c/b\u003e\n\u003c/td\u003e\n\n\u003ctd\u003e\n\u003ci\u003e#include \"sciter-x-host-callback.h\"\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003eclass sciter::archive\u003c/b\u003e\u003cbr\u003e\n\u003cb\u003eclass sciter::host\u0026lt;BASE\u0026gt;\u003c/b\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\u003ci\u003emodule sciter.behavior;\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003eabstract class EventHandler\u003c/b\u003e\n\u003c/td\u003e\n\n\u003ctd\u003e\n\u003ci\u003e#include \"sciter-x-behavior.h\"\u003c/i\u003e\u003cbr\u003e\n\u003cb\u003eclass sciter::event_handler\u003c/b\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Package content\n\n```\ndub.json\t\t\t\t\t-\u003e DUB package manifest\nsciter32-import-lib.lib\t\t-\u003e **win32** only: DLL import lib\n/samples\t\t\t\t\t-\u003e contains sample of complete GUI aplications making use of this library; samples starting with 'u' are universal ones and the same source code should compile in all supported platforms\n/source\t\t\t\t\t\t-\u003e source code of this library, you should add this path to the compiler 'include path'\n/source/sciter\t\t\t\t-\u003e D definitions of classes wraping the Sciter API\n/source/sciter/interop\t\t-\u003e D types for Sciter ABI\n/source/winkit\t\t\t\t-\u003e **win32** only: this are helper classes forming a basic WIN32 user GUI toolkit wrapping common things, like creating and manipulating HWND, message loops, and so on..\n```\n\n## Features\n\n**host \u003c-\u003e UI communication idioms support**\n\nAs can be read [here](http://sciter.com/sciter-ui-application-architecture/), there are 3 commons idioms for information flow between the host application and TIScript UI code, all of which are supported in this D port. Here is how you would implement each one:\n\n*1. get-requests*\n \nTo handle UI-to-logic calls you first define/extend a `EventHandler` class in the native side and attaches it to your `SciterWindowHost` native implementation.\n\nThe `Setup()` function below first creates the `SciterWindowHost` instance and calls `host.setup_callback()` to identify the native HWINDOW attached to it. Then it simply instantiates the `EventHandler` and uses `host.attach_evh()` to attach it to the host in order to start receiving events.\n\n```D\nimport sciter.host;\n\nclass MyHost : SciterWindowHost { ... }\n\nvoid Setup(HWINDOW wnd)\n{\n\tauto host = new MyHost();\n\thost.setup_callback(wnd);\n\n\tauto evh = new MyHostEvh();\n\thost.attach_evh(evh);\n}\n\n```\n\nEach time script executes code like this:\n\n```JavaScript\nvar ret = view.Host_DoSomething(param1, param2);\n```\n\nit will invoke the `on_script_call()` method of your native `EventHandler`:\n\n\n```D\nimport std.conv;\nimport sciter.behavior;\nimport sciter.behavior;\n\nclass MyHostEvh : EventHandler\n{\n\toverride bool on_script_call(HELEMENT he, SCRIPTING_METHOD_PARAMS* prms)\n\t{\n\t\tswitch(to!string(prms.name))\n\t\t{\n\t\tcase \"Host_DoSomething\":\n\t\t\t// TIScript values passed by UI side\n\t\t\tjson_value param1 = json_value(prms.argv[0]);\n\t\t\tjson_value param2 = json_value(prms.argv[1]);\n\t\t\t \n\t\t\tprms.result = json_value(\"Meow!\");// TIScript return value for UI side\n\t\t\treturn true;\n\t\t}\n\t}\n}\n```\n\n*2. application events*\n\nApplication can generate some events by itself to the UI script layer. With your native `SciterWindowHost` in place, you simply call it's `call_function()` method:\n\n```D\nMyHost host = ...;\njson_value ret = host.call_function(\"View_DoSomething\", json_value(true), json_value(1234), json_value(\"from native side\"));// call_function() is a variadic function\n```\n\n*3. post-requests*\n\nUI-to-logic post/asynchronous request allows script to call native side method and receive the result in a later time, asynchronously, preventing the UI thread from blocking. Call to native code includes reference to script function that will be executed when the requested data is available.\n\nYour script side:\n\n```JavaScript\nview.Host_AsyncProcess(function(meow) {\n\t\t$(body).text = \"Host processing done: \" + meow;\n});\n```\n\nYour native `EventHandler` shaw be something like:\n\n```D\nclass PostEvh : EventHandler\n{\n\toverride bool on_script_call(HELEMENT he, SCRIPTING_METHOD_PARAMS* prms)\n\t{\n\t\tjson_value jv_callback = prms.argv[0];\n\n\t\t// TODO:\n\t\t// do expensive work in another thread\n\t\t// or you can save the jv_callback in a global variable and call it in a later time\n\n\t\tjv_callback.call(\n\t\t\tjson_value(\"Meow! from host\")\n\t\t);\n\t\treturn true;\n\t}\n}\n```\n\n\n**`json_value` supports construction through associative arrays, for example:**\n\n```D\nvoid Foo()\n{\n\tjson_value jassoc1 = [\n\t\t\"key1\" : 1,\n\t\t\"key2\" : 2,\n\t];\n\t\n\tjson_value jassoc2 = [\n\t\t\"key1\" : json_value(1),\n\t\t\"key2\" : json_value(2),\n\t];\n}\n```\n\n**`json_value` multi-threading guidelines:**\n\nBe aware that `json_value` is a struct type, and it's destructor clears the associated Sciter VALUE. So if you need a `json_value` to survive when it goes out of scope (mainly in multi-threading scenarios), you must put it in the heap, not it the stack, so instead of:\n\n```D\njson_value jv = json_value(1234);\n```\n\n..you must:\n\n```D\njson_value* jv = new json_value(1234);\n```\n\nThat's D my friend.\n\n\n# Library usage - Win32\n\n## 1. Configuring linker: sciter32-import-lib.lib import lib\n\nYou need to add the file 'sciter32-import-lib.lib' to the linker input in order to it find the functions definitions of the Sciter DLL. This is the import lib that you pass to the linker for making your executable statically link to the sciter32.dll exports.\n\nThis file was generated using 'coffimplib' app (ftp://ftp.digitalmars.com/coffimplib.zip and  http://www.digitalmars.com/ctg/coffimplib.html).\n\n\n## 2. Compiling your code\n\nRequirements:\n\n- add every .d files under /source/sciter directory to the compiler input, that is, compile them together with your app others .d files\n- add /source to the compiler include path\n- add needed import statements like: ```import sciter.api```\n\n\nMinimal code for creating a Sciter based HWND and loading a external .html file:\n\n```D\nimport sciter.interop.sciter_x_types;\nimport sciter.api;\n\nvoid main()\n{\n\tRECT frame;\n\tframe.right = 800;\n\tframe.bottom = 600;\n\n\tHWINDOW wnd = SciterCreateWindow(\n\t\tSCITER_CREATE_WINDOW_FLAGS.SW_TITLEBAR |\n\t\tSCITER_CREATE_WINDOW_FLAGS.SW_RESIZEABLE |\n\t\tSCITER_CREATE_WINDOW_FLAGS.SW_MAIN |\n\t\tSCITER_CREATE_WINDOW_FLAGS.SW_CONTROLS,\n\t\t\u0026frame, null, null, null);\n\t\t\n\tSciterLoadFile(wnd, \"minimal.html\");\n\t\n\t\n\tversion(Windows)\n\t{\n\t\timport core.sys.windows.windows;\n\t\t\n\t\tShowWindow(wnd, 1);\n\t\t\n\t\tMSG msg;\n\t\twhile( GetMessageA(\u0026msg, null, 0, 0) )\n\t\t{\n\t\t\tTranslateMessage(\u0026msg);\n\t\t\tDispatchMessageA(\u0026msg);\n\t\t}\n\t}\n}\n```\n\n# Library usage - Linux\n\nRequirements:\n\nSciter for Linux requires GTK+3 and libcurl. Just make sure to install GTK+3 developer package:\n\n```bash\nsudo apt-get install libgtk-3-dev\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsciter-sdk%2FSciter-Dport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsciter-sdk%2FSciter-Dport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsciter-sdk%2FSciter-Dport/lists"}