git0 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/TypeScript-React-Starter/LICENSE +21 -0
  2. package/TypeScript-React-Starter/README-CRA.md +1281 -0
  3. package/TypeScript-React-Starter/README.md +810 -0
  4. package/TypeScript-React-Starter/package.json +28 -0
  5. package/TypeScript-React-Starter/public/favicon.ico +0 -0
  6. package/TypeScript-React-Starter/public/index.html +31 -0
  7. package/TypeScript-React-Starter/src/App.css +24 -0
  8. package/TypeScript-React-Starter/src/App.test.tsx +8 -0
  9. package/TypeScript-React-Starter/src/App.tsx +23 -0
  10. package/TypeScript-React-Starter/src/actions/index.tsx +24 -0
  11. package/TypeScript-React-Starter/src/components/Hello.css +13 -0
  12. package/TypeScript-React-Starter/src/components/Hello.test.tsx +30 -0
  13. package/TypeScript-React-Starter/src/components/Hello.tsx +35 -0
  14. package/TypeScript-React-Starter/src/constants/index.tsx +6 -0
  15. package/TypeScript-React-Starter/src/containers/Hello.tsx +20 -0
  16. package/TypeScript-React-Starter/src/index.css +5 -0
  17. package/TypeScript-React-Starter/src/index.tsx +22 -0
  18. package/TypeScript-React-Starter/src/logo.svg +7 -0
  19. package/TypeScript-React-Starter/src/reducers/index.tsx +15 -0
  20. package/TypeScript-React-Starter/src/types/index.tsx +5 -0
  21. package/TypeScript-React-Starter/tsconfig.json +29 -0
  22. package/TypeScript-React-Starter/tslint.json +11 -0
  23. package/TypeScript-React-Starter/yarn.lock +4785 -0
  24. package/package.json +2 -2
  25. package/src/github-api.js +1 -0
  26. package/svelte-nodegui/.all-contributorsrc +60 -0
  27. package/svelte-nodegui/.vscode/launch.json +29 -0
  28. package/svelte-nodegui/CHANGELOG.md +153 -0
  29. package/svelte-nodegui/LICENSE +22 -0
  30. package/svelte-nodegui/README.md +151 -0
  31. package/svelte-nodegui/demo/.editorconfig +15 -0
  32. package/svelte-nodegui/demo/.vscode/extensions.json +3 -0
  33. package/svelte-nodegui/demo/livereload.js +29 -0
  34. package/svelte-nodegui/demo/package-lock.json +3514 -0
  35. package/svelte-nodegui/demo/package.json +35 -0
  36. package/svelte-nodegui/demo/src/App.svelte +29 -0
  37. package/svelte-nodegui/demo/src/app.ts +31 -0
  38. package/svelte-nodegui/demo/tsconfig.json +40 -0
  39. package/svelte-nodegui/demo/webpack.config.js +110 -0
  40. package/svelte-nodegui/extras/assets/kitchen.png +0 -0
  41. package/svelte-nodegui/extras/assets/nodegui.png +0 -0
  42. package/svelte-nodegui/extras/assets/nodegui_white.png +0 -0
  43. package/svelte-nodegui/extras/assets/start_icon.png +0 -0
  44. package/svelte-nodegui/extras/legal/logo/thanks.md +13 -0
  45. package/svelte-nodegui/extras/legal/yode/LICENSE +21 -0
  46. package/svelte-nodegui/extras/legal/yoga/LICENSE +0 -0
  47. package/svelte-nodegui/extras/logo/nodegui-circle.png +0 -0
  48. package/svelte-nodegui/extras/logo/nodegui.png +0 -0
  49. package/svelte-nodegui/extras/logo/nodegui.svg +4 -0
  50. package/svelte-nodegui/nativescript-svelte-todo.gif +0 -0
  51. package/svelte-nodegui/package-lock.json +1749 -0
  52. package/svelte-nodegui/package.json +44 -0
  53. package/svelte-nodegui/repl-workers/bundler/commonjs.js +58 -0
  54. package/svelte-nodegui/repl-workers/bundler/index.js +353 -0
  55. package/svelte-nodegui/repl-workers/package-lock.json +484 -0
  56. package/svelte-nodegui/repl-workers/package.json +21 -0
  57. package/svelte-nodegui/repl-workers/rollup.config.js +21 -0
  58. package/svelte-nodegui/rollup.config.js +81 -0
  59. package/svelte-nodegui/scripts/create-pkg.js +42 -0
  60. package/svelte-nodegui/src/components/AsComponent.svelte +16 -0
  61. package/svelte-nodegui/src/components/SlotComponent.svelte +4 -0
  62. package/svelte-nodegui/src/components/Template.svelte +10 -0
  63. package/svelte-nodegui/src/components/Template.svelte.d.ts +6 -0
  64. package/svelte-nodegui/src/components/index.ts +2 -0
  65. package/svelte-nodegui/src/dom/index.ts +132 -0
  66. package/svelte-nodegui/src/dom/nativescript-vue-next/LICENCE +21 -0
  67. package/svelte-nodegui/src/dom/nativescript-vue-next/index.ts +19 -0
  68. package/svelte-nodegui/src/dom/nativescript-vue-next/runtime/index.ts +21 -0
  69. package/svelte-nodegui/src/dom/nativescript-vue-next/runtime/nodes.ts +890 -0
  70. package/svelte-nodegui/src/dom/nativescript-vue-next/runtime/registry.ts +262 -0
  71. package/svelte-nodegui/src/dom/nativescript-vue-next/runtime/runtimeHelpers.ts +20 -0
  72. package/svelte-nodegui/src/dom/react-nodegui/LICENSE +21 -0
  73. package/svelte-nodegui/src/dom/react-nodegui/src/components/AbstractComponents/RNAbstractButton.ts +67 -0
  74. package/svelte-nodegui/src/dom/react-nodegui/src/components/Action/RNAction.ts +146 -0
  75. package/svelte-nodegui/src/dom/react-nodegui/src/components/Action/index.ts +37 -0
  76. package/svelte-nodegui/src/dom/react-nodegui/src/components/AnimatedImage/RNAnimatedImage.ts +76 -0
  77. package/svelte-nodegui/src/dom/react-nodegui/src/components/AnimatedImage/index.ts +45 -0
  78. package/svelte-nodegui/src/dom/react-nodegui/src/components/BoxView/RNBoxView.ts +99 -0
  79. package/svelte-nodegui/src/dom/react-nodegui/src/components/BoxView/index.ts +49 -0
  80. package/svelte-nodegui/src/dom/react-nodegui/src/components/Button/RNButton.ts +71 -0
  81. package/svelte-nodegui/src/dom/react-nodegui/src/components/Button/index.ts +49 -0
  82. package/svelte-nodegui/src/dom/react-nodegui/src/components/CheckBox/RNCheckBox.ts +71 -0
  83. package/svelte-nodegui/src/dom/react-nodegui/src/components/CheckBox/index.ts +50 -0
  84. package/svelte-nodegui/src/dom/react-nodegui/src/components/ComboBox/RNComboBox.ts +118 -0
  85. package/svelte-nodegui/src/dom/react-nodegui/src/components/ComboBox/index.ts +50 -0
  86. package/svelte-nodegui/src/dom/react-nodegui/src/components/Dial/RNDial.ts +69 -0
  87. package/svelte-nodegui/src/dom/react-nodegui/src/components/Dial/index.ts +41 -0
  88. package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/GridColumn/RNGridColumn.ts +95 -0
  89. package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/GridColumn/index.ts +49 -0
  90. package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/GridRow/RNGridRow.ts +141 -0
  91. package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/GridRow/index.ts +47 -0
  92. package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/RNGridView.ts +185 -0
  93. package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/index.ts +51 -0
  94. package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/utils.ts +59 -0
  95. package/svelte-nodegui/src/dom/react-nodegui/src/components/Image/RNImage.ts +135 -0
  96. package/svelte-nodegui/src/dom/react-nodegui/src/components/Image/index.ts +46 -0
  97. package/svelte-nodegui/src/dom/react-nodegui/src/components/LineEdit/RNLineEdit.ts +82 -0
  98. package/svelte-nodegui/src/dom/react-nodegui/src/components/LineEdit/index.ts +41 -0
  99. package/svelte-nodegui/src/dom/react-nodegui/src/components/Menu/RNMenu.ts +49 -0
  100. package/svelte-nodegui/src/dom/react-nodegui/src/components/Menu/index.ts +44 -0
  101. package/svelte-nodegui/src/dom/react-nodegui/src/components/MenuBar/RNMenuBar.ts +51 -0
  102. package/svelte-nodegui/src/dom/react-nodegui/src/components/MenuBar/index.ts +42 -0
  103. package/svelte-nodegui/src/dom/react-nodegui/src/components/PlainTextEdit/RNPlainTextEdit.ts +82 -0
  104. package/svelte-nodegui/src/dom/react-nodegui/src/components/PlainTextEdit/index.ts +44 -0
  105. package/svelte-nodegui/src/dom/react-nodegui/src/components/ProgressBar/RNProgressBar.ts +78 -0
  106. package/svelte-nodegui/src/dom/react-nodegui/src/components/ProgressBar/index.ts +43 -0
  107. package/svelte-nodegui/src/dom/react-nodegui/src/components/RadioButton/RNRadioButton.ts +50 -0
  108. package/svelte-nodegui/src/dom/react-nodegui/src/components/RadioButton/index.ts +43 -0
  109. package/svelte-nodegui/src/dom/react-nodegui/src/components/ScrollArea/RNScrollArea.ts +51 -0
  110. package/svelte-nodegui/src/dom/react-nodegui/src/components/ScrollArea/index.ts +44 -0
  111. package/svelte-nodegui/src/dom/react-nodegui/src/components/Slider/RNSlider.ts +97 -0
  112. package/svelte-nodegui/src/dom/react-nodegui/src/components/Slider/index.ts +46 -0
  113. package/svelte-nodegui/src/dom/react-nodegui/src/components/SpinBox/RNSpinBox.ts +88 -0
  114. package/svelte-nodegui/src/dom/react-nodegui/src/components/SpinBox/index.ts +49 -0
  115. package/svelte-nodegui/src/dom/react-nodegui/src/components/Svg/RNSvg.ts +67 -0
  116. package/svelte-nodegui/src/dom/react-nodegui/src/components/Svg/index.ts +43 -0
  117. package/svelte-nodegui/src/dom/react-nodegui/src/components/SystemTrayIcon/RNSystemTrayIcon.ts +141 -0
  118. package/svelte-nodegui/src/dom/react-nodegui/src/components/SystemTrayIcon/index.ts +43 -0
  119. package/svelte-nodegui/src/dom/react-nodegui/src/components/Tab/RNTab.ts +69 -0
  120. package/svelte-nodegui/src/dom/react-nodegui/src/components/Tab/index.ts +48 -0
  121. package/svelte-nodegui/src/dom/react-nodegui/src/components/TabItem/RNTabItem.ts +72 -0
  122. package/svelte-nodegui/src/dom/react-nodegui/src/components/TabItem/index.ts +40 -0
  123. package/svelte-nodegui/src/dom/react-nodegui/src/components/Text/RNText.ts +65 -0
  124. package/svelte-nodegui/src/dom/react-nodegui/src/components/Text/index.ts +49 -0
  125. package/svelte-nodegui/src/dom/react-nodegui/src/components/View/RNView.ts +306 -0
  126. package/svelte-nodegui/src/dom/react-nodegui/src/components/View/index.ts +44 -0
  127. package/svelte-nodegui/src/dom/react-nodegui/src/components/Window/RNWindow.ts +66 -0
  128. package/svelte-nodegui/src/dom/react-nodegui/src/components/Window/index.ts +50 -0
  129. package/svelte-nodegui/src/dom/react-nodegui/src/components/config.ts +95 -0
  130. package/svelte-nodegui/src/dom/react-nodegui/src/index.ts +52 -0
  131. package/svelte-nodegui/src/dom/react-nodegui/src/reconciler/index.ts +226 -0
  132. package/svelte-nodegui/src/dom/react-nodegui/src/utils/decoupleFromReact.ts +2 -0
  133. package/svelte-nodegui/src/dom/react-nodegui/src/utils/helpers.ts +14 -0
  134. package/svelte-nodegui/src/dom/shared/Logger.ts +16 -0
  135. package/svelte-nodegui/src/dom/shared/index.ts +1 -0
  136. package/svelte-nodegui/src/dom/svelte/HeadElement.ts +41 -0
  137. package/svelte-nodegui/src/dom/svelte/RNObject.ts +95 -0
  138. package/svelte-nodegui/src/dom/svelte/StyleElement.ts +92 -0
  139. package/svelte-nodegui/src/dom/svelte/SvelteNodeGUIDocument.ts +124 -0
  140. package/svelte-nodegui/src/dom/svelte/TemplateElement.ts +16 -0
  141. package/svelte-nodegui/src/dom/svelte-elements.ts +111 -0
  142. package/svelte-nodegui/src/index.ts +62 -0
  143. package/svelte-nodegui/src/svelte-nodegui.ts +159 -0
  144. package/svelte-nodegui/src/transitions/bezier.ts +112 -0
  145. package/svelte-nodegui/src/transitions/index.ts +227 -0
  146. package/svelte-nodegui/tsconfig.json +19 -0
  147. package/svelte-nodegui/website/README.md +33 -0
  148. package/svelte-nodegui/website/blog/2019-05-30-welcome.md +12 -0
  149. package/svelte-nodegui/website/docs/api/classes/renderer.md +49 -0
  150. package/svelte-nodegui/website/docs/api/classes/rnaction.md +608 -0
  151. package/svelte-nodegui/website/docs/api/classes/rngridcolumn.md +232 -0
  152. package/svelte-nodegui/website/docs/api/classes/rngridrow.md +247 -0
  153. package/svelte-nodegui/website/docs/api/classes/rnmenu.md +1337 -0
  154. package/svelte-nodegui/website/docs/api/classes/rnmenubar.md +1341 -0
  155. package/svelte-nodegui/website/docs/api/globals.md +832 -0
  156. package/svelte-nodegui/website/docs/api/index.md +0 -0
  157. package/svelte-nodegui/website/docs/api/interfaces/_react_proxy_.reactproxycomponent.md +38 -0
  158. package/svelte-nodegui/website/docs/api/interfaces/abstractbuttonprops.md +306 -0
  159. package/svelte-nodegui/website/docs/api/interfaces/actionprops.md +115 -0
  160. package/svelte-nodegui/website/docs/api/interfaces/animatedimageprops.md +297 -0
  161. package/svelte-nodegui/website/docs/api/interfaces/boxviewprops.md +245 -0
  162. package/svelte-nodegui/website/docs/api/interfaces/buttonprops.md +313 -0
  163. package/svelte-nodegui/website/docs/api/interfaces/checkboxprops.md +313 -0
  164. package/svelte-nodegui/website/docs/api/interfaces/comboboxprops.md +343 -0
  165. package/svelte-nodegui/website/docs/api/interfaces/datawithoffset.md +32 -0
  166. package/svelte-nodegui/website/docs/api/interfaces/dialprops.md +259 -0
  167. package/svelte-nodegui/website/docs/api/interfaces/gridviewprops.md +273 -0
  168. package/svelte-nodegui/website/docs/api/interfaces/imageprops.md +311 -0
  169. package/svelte-nodegui/website/docs/api/interfaces/lineeditprops.md +266 -0
  170. package/svelte-nodegui/website/docs/api/interfaces/menubarprops.md +245 -0
  171. package/svelte-nodegui/website/docs/api/interfaces/menuprops.md +245 -0
  172. package/svelte-nodegui/website/docs/api/interfaces/plaintexteditprops.md +259 -0
  173. package/svelte-nodegui/website/docs/api/interfaces/progressbarprops.md +266 -0
  174. package/svelte-nodegui/website/docs/api/interfaces/radiobuttonprops.md +282 -0
  175. package/svelte-nodegui/website/docs/api/interfaces/scrollareaprops.md +245 -0
  176. package/svelte-nodegui/website/docs/api/interfaces/sliderprops.md +329 -0
  177. package/svelte-nodegui/website/docs/api/interfaces/spinboxprops.md +273 -0
  178. package/svelte-nodegui/website/docs/api/interfaces/systemtrayiconprops.md +97 -0
  179. package/svelte-nodegui/website/docs/api/interfaces/tabitemprops.md +28 -0
  180. package/svelte-nodegui/website/docs/api/interfaces/tabprops.md +245 -0
  181. package/svelte-nodegui/website/docs/api/interfaces/textprops.md +277 -0
  182. package/svelte-nodegui/website/docs/api/interfaces/viewprops.md +261 -0
  183. package/svelte-nodegui/website/docs/api/interfaces/windowprops.md +245 -0
  184. package/svelte-nodegui/website/docs/api/modules/_react_proxy_.md +29 -0
  185. package/svelte-nodegui/website/docs/doc1.md +162 -0
  186. package/svelte-nodegui/website/docs/guides/custom-nodegui-native-plugin.md +6 -0
  187. package/svelte-nodegui/website/docs/guides/debugging-in-vscode.md +39 -0
  188. package/svelte-nodegui/website/docs/guides/debugging.md +59 -0
  189. package/svelte-nodegui/website/docs/guides/getting-started.md +141 -0
  190. package/svelte-nodegui/website/docs/guides/handle-events.md +188 -0
  191. package/svelte-nodegui/website/docs/guides/images.md +62 -0
  192. package/svelte-nodegui/website/docs/guides/layout.md +281 -0
  193. package/svelte-nodegui/website/docs/guides/networking.md +31 -0
  194. package/svelte-nodegui/website/docs/guides/packaging.md +32 -0
  195. package/svelte-nodegui/website/docs/guides/scroll-view.md +69 -0
  196. package/svelte-nodegui/website/docs/guides/styling.md +208 -0
  197. package/svelte-nodegui/website/docs/guides/tutorial.md +82 -0
  198. package/svelte-nodegui/website/docs/guides/using-native-node-modules.md +55 -0
  199. package/svelte-nodegui/website/docs/mdx.md +22 -0
  200. package/svelte-nodegui/website/docs/scripts/fixdocs.js +21 -0
  201. package/svelte-nodegui/website/docusaurus.config.js +131 -0
  202. package/svelte-nodegui/website/package.json +33 -0
  203. package/svelte-nodegui/website/sidebars.js +77 -0
  204. package/svelte-nodegui/website/src/components/CodeExample.js +42 -0
  205. package/svelte-nodegui/website/src/components/CreateNativeApps.js +46 -0
  206. package/svelte-nodegui/website/src/components/Features.js +62 -0
  207. package/svelte-nodegui/website/src/components/Hero.js +85 -0
  208. package/svelte-nodegui/website/src/components/SplitView.js +18 -0
  209. package/svelte-nodegui/website/src/components/Talks.js +68 -0
  210. package/svelte-nodegui/website/src/components/Try.js +83 -0
  211. package/svelte-nodegui/website/src/components/common.js +41 -0
  212. package/svelte-nodegui/website/src/components/styles.css +61 -0
  213. package/svelte-nodegui/website/src/css/custom.css +34 -0
  214. package/svelte-nodegui/website/src/pages/index.js +32 -0
  215. package/svelte-nodegui/website/src/pages/styles.module.css +35 -0
  216. package/svelte-nodegui/website/static/CNAME +1 -0
  217. package/svelte-nodegui/website/static/img/box-layout-1.png +0 -0
  218. package/svelte-nodegui/website/static/img/box-layout-2.png +0 -0
  219. package/svelte-nodegui/website/static/img/code-sample.png +0 -0
  220. package/svelte-nodegui/website/static/img/demo.png +0 -0
  221. package/svelte-nodegui/website/static/img/favicon.ico +0 -0
  222. package/svelte-nodegui/website/static/img/flex-layout-1.png +0 -0
  223. package/svelte-nodegui/website/static/img/grid-layout-1.png +0 -0
  224. package/svelte-nodegui/website/static/img/logo-circle.png +0 -0
  225. package/svelte-nodegui/website/static/img/logo.png +0 -0
  226. package/svelte-nodegui/website/static/img/logo.svg +5 -0
  227. package/svelte-nodegui/website/static/img/logox200.png +0 -0
  228. package/svelte-nodegui/website/static/img/undraw_building_websites.svg +1 -0
  229. package/svelte-nodegui/website/static/img/undraw_code_review.svg +1 -0
  230. package/svelte-nodegui/website/static/img/undraw_docusaurus_mountain.svg +170 -0
  231. package/svelte-nodegui/website/static/img/undraw_docusaurus_react.svg +169 -0
  232. package/svelte-nodegui/website/static/img/undraw_docusaurus_tree.svg +1 -0
  233. package/svelte-nodegui/website/static/img/undraw_react.svg +1 -0
  234. package/svelte-nodegui/website/static/img/undraw_website_setup.svg +1 -0
  235. package/svelte-nodegui/website/static/img/undraw_windows.svg +11 -0
  236. package/svelte-nodegui/website/website/sidebars.js +32 -0
  237. package/svelte-nodegui/website/yarn.lock +10533 -0
  238. package/bun.lock +0 -159
  239. package/docs-config/bun.lock +0 -6139
@@ -0,0 +1,188 @@
1
+ ---
2
+ sidebar_label: Handle Events
3
+ title: Handle Events
4
+ ---
5
+
6
+ Svelte NodeGui allows you to listen to various events that might originate from the underlying Qt widgets. These events can either be a simple button click or a text change on a LineEdit or even something like window being hidden and shown.
7
+
8
+ In order to do this we need to attach an event listener to the respective widget.
9
+
10
+ Technically, the event listener is a NodeJs [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) instance that listens to events from the underlying Qt widget. The native Qt widget would send all the events to the event emitter in Svelte NodeGui world and the user can essentially subscribe to it.
11
+
12
+ Lets see an example to see how this looks in practice.
13
+
14
+ ## Event handling
15
+
16
+ The following example demonstrates how to add a clicked event listener to a button widget.
17
+
18
+ <img src="https://github.com/nodegui/react-nodegui/releases/download/assets/events-react.gif" alt="event example" style={{width: '100%', maxWidth: 400}}/>
19
+
20
+ ```html
21
+ <script lang="ts">
22
+ import { onMount } from "svelte";
23
+ let win;
24
+
25
+ function onClicked(checked){
26
+ console.log("the button was clicked", checked);
27
+ }
28
+
29
+ onMount(() => {
30
+ (window as any).win = win; // Prevent garbage collection.
31
+ win.nativeView.show();
32
+ return () => {
33
+ delete (window as any).win;
34
+ };
35
+ });
36
+ </script>
37
+
38
+ <window bind:this={win}>
39
+ <button on:clicked={onClicked} text="Click me"/>
40
+ </window>
41
+ ```
42
+
43
+ The [`on:` directive](https://svelte.dev/docs#on_component_event) accepts an event name (e.g. "clicked") and a corresponding event handler function.
44
+
45
+ Internally, Qt widgets in nodegui has two types of events:
46
+
47
+ - Signals: In short these are basically different for different widgets. So a button may have `clicked` and `pressed` signals, while a LineEdit may have, say, the `textChanged` signal.
48
+ - QEvents: These are common set of events for all the widgets/qobjects in NodeGui world. These are also helpful at times but typically you would end up using signals more than these common events.
49
+
50
+ In Svelte NodeGui you can listen to both Signals and QEvents using the same `on:` directive.
51
+
52
+ <!-- ### useEventHandler hook and typescript support
53
+
54
+ Although you can pass in an object with event handlers to the `on:` directive, its not the most efficient way. This is because everytime the render is called the `on:` directive will get a new object meaning the widget will re-render every time. To solve for this we have `useEventHandler` hook.
55
+
56
+ ```ts
57
+ import React from "react";
58
+ import {
59
+ Renderer,
60
+ Button,
61
+ Window,
62
+ useEventHandler
63
+ } from "@nodegui/react-nodegui";
64
+ import { QPushButtonSignals } from "@nodegui/nodegui";
65
+
66
+ const App = () => {
67
+ const buttonHandler = useEventHandler<QPushButtonSignals>(
68
+ {
69
+ clicked: () => {
70
+ console.log("the button was clicked");
71
+ },
72
+ pressed: () => {
73
+ console.log("button was pressed");
74
+ },
75
+ objectNameChanged: objectName => {
76
+ console.log("new object name", objectName);
77
+ }
78
+ },
79
+ []
80
+ );
81
+
82
+ return (
83
+ <Window>
84
+ <Button text={"Click me"} on={buttonHandler} />
85
+ </Window>
86
+ );
87
+ };
88
+
89
+ Renderer.render(<App />);
90
+ ```
91
+
92
+ In a nutshell, the above code uses the `useEventHandler` hook which is a wrapper over `useMemo`.
93
+ This means, the buttonHandler remains same on every render call and hence the `on:` directive to Button doesnt change.
94
+
95
+ Here `objectNameChanged` is a QEvent while `clicked` and `pressed` are signals. As an app developer it really doesnt mean much but internally they are both two different things in Qt and Svelte NodeGui allows you to use both of them using a single familiar `on:` directive.
96
+
97
+ Also, another point you see in this typescript code is the QPushButtonSignals. The QPushButtonSignals is a type that allows autocompletion of event handlers as you type them. -->
98
+
99
+ ### How do I know which events are supported ?
100
+
101
+ In order to find all the supported events for a widget you can take a look at
102
+
103
+ #### All Signals for the widgets:
104
+
105
+ - [https://docs.nodegui.org/docs/api/generated/globals/#interfaces](https://docs.nodegui.org/docs/api/generated/globals/#interfaces)
106
+ - [https://docs.nodegui.org/docs/api/generated/globals/#type-aliases](https://docs.nodegui.org/docs/api/generated/globals/#type-aliases)
107
+
108
+ <!-- You can subscribe to a signal like so:
109
+
110
+ ```ts
111
+ import React from "react";
112
+ import {
113
+ Renderer,
114
+ Button,
115
+ Window,
116
+ useEventHandler
117
+ } from "@nodegui/react-nodegui";
118
+ import { QPushButtonSignals } from "@nodegui/nodegui";
119
+
120
+ const App = () => {
121
+ const buttonHandler = useEventHandler<QPushButtonSignals>(
122
+ {
123
+ clicked: () => {
124
+ console.log("the button was clicked");
125
+ }
126
+ },
127
+ []
128
+ );
129
+
130
+ return (
131
+ <Window>
132
+ <Button text={"Click me"} on={buttonHandler} />
133
+ </Window>
134
+ );
135
+ };
136
+
137
+ Renderer.render(<App />);
138
+ ```
139
+
140
+ The value you receive in the callback depends on the signal. Refer to respective signal docs for more details. All the handlers are also typed. So if you are using typescript you should get correct autocomplete for it. -->
141
+
142
+ #### All common QEvents for the widgets
143
+
144
+ In nodegui all these common QEvents are represented under an enum type: [WidgetEventTypes](https://docs.nodegui.org/docs/api/generated/enums/widgeteventtypes)
145
+
146
+ You can subscribe to a QEvent like so:
147
+
148
+ ```html
149
+ <script lang="ts">
150
+ import { onMount } from "svelte";
151
+ import { QLabelSignals, QMouseEvent, WidgetEventTypes } from "@nodegui/nodegui";
152
+ let win;
153
+
154
+ function onMouseMove(checked){
155
+ const mouseEvt = new QMouseEvent(nativeEvt);
156
+ console.log("mouseMoved at: ", { x: mouseEvt.x(), y: mouseEvt.y() });
157
+ }
158
+ function onMouseButtonPress(checked){
159
+ console.log("mouse button was pressed");
160
+ }
161
+
162
+ onMount(() => {
163
+ (window as any).win = win; // Prevent garbage collection.
164
+ win.nativeView.show();
165
+ return () => {
166
+ delete (window as any).win;
167
+ };
168
+ });
169
+ </script>
170
+
171
+ <window bind:this={win}>
172
+ <!-- See the WidgetEventTypes interface for the names of all supported events. -->
173
+ <text
174
+ mouseTracking={true}
175
+ on:MouseMove={onMouseMove}
176
+ on:MouseButtonPress={onMouseButtonPress}
177
+ >
178
+ Move your mouse here
179
+ </text>
180
+ </window>
181
+ ```
182
+
183
+ <img src="https://github.com/nodegui/react-nodegui/releases/download/assets/qevents.gif" alt="qevent example" style={{width: '100%', maxWidth: 400}}/>
184
+
185
+ Note here that every QEvent handler gives a reference to native QEvent in the handler callback.
186
+ Not all native QEvent wrappers are implemented yet and we might need your help regarding those. Feel free to jump in and contribute to the nodegui core.
187
+
188
+ Also you can specify the QEvent type as a regular `MouseMove` string or use it directly from the enum `WidgetEventTypes.MouseMove`. They both achieve same things.
@@ -0,0 +1,62 @@
1
+ ---
2
+ sidebar_label: Images
3
+ title: Images
4
+ ---
5
+
6
+ Images are very important for making your app more interesting.
7
+
8
+ In Svelte NodeGui, `<image>` is used to display an image.
9
+
10
+ Internally Image is a QLabel. QLabel is typically used for displaying text, but it can also display an image.
11
+ What this means is that you can pass all the props you pass to a `<text>` to `<image>` also.
12
+
13
+ A very minimal example would look like this:
14
+
15
+ ```html
16
+ <script lang="ts">
17
+ import { onMount } from "svelte";
18
+ import { QLabelSignals, QMouseEvent, WidgetEventTypes } from "@nodegui/nodegui";
19
+ let win;
20
+
21
+ onMount(() => {
22
+ (window as any).win = win; // Prevent garbage collection.
23
+ win.nativeView.show();
24
+ return () => {
25
+ delete (window as any).win;
26
+ };
27
+ });
28
+ </script>
29
+
30
+ <window bind:this={win}>
31
+ <image src="https://docs.nodegui.org/img/logo-circle.png" />
32
+ </window>
33
+ ```
34
+
35
+ Here,
36
+
37
+ - Image is a native QLabel component that sets the image as its pixmap.
38
+
39
+ The result would look like this:
40
+
41
+ <img src="https://github.com/nodegui/react-nodegui/releases/download/assets/images.png" alt="image example" style={{width: '100%', maxWidth: 400}}/>
42
+
43
+ ## Some tips
44
+
45
+ ### Showing large images
46
+
47
+ The above examples wont allow you to show a huge image without either cutting it off or making the widget huge.
48
+
49
+ In order to do that:
50
+
51
+ - You can create the image instance using `<image>`
52
+ - Set the image instance as a child to a `<scrollArea>`
53
+
54
+ ### Animated images
55
+
56
+ In order to use animated images, instead of `<image>` use `<animatedImage>`
57
+
58
+ ### Loading an image from a buffer
59
+
60
+ Lets say we want to load an image from a buffer. In this case we can't use the `src` prop since its only reserved for local file system path or urls.
61
+
62
+ In this case use the `buffer` prop.
@@ -0,0 +1,281 @@
1
+ ---
2
+ sidebar_label: Layout
3
+ title: Layout
4
+ ---
5
+
6
+ Svelte NodeGui uses a layout system to automatically arrange child components within a component to ensure that they make good use of the available space.
7
+
8
+ ## Fixed Dimensions
9
+
10
+ A component's height and width determine its size on the screen. The simplest way to set the dimensions of a component is by adding a fixed width and height to style. Setting dimensions this way is common for components that should always render at exactly the same size, regardless of screen dimensions.
11
+
12
+ ```html
13
+ <script lang="ts">
14
+ import { onMount } from "svelte";
15
+
16
+ onMount(() => {
17
+ (window as any).win = win; // Prevent garbage collection.
18
+ win.nativeView.show();
19
+ return () => {
20
+ delete (window as any).win;
21
+ };
22
+ });
23
+ </script>
24
+
25
+ <window bind:this={win}>
26
+ <view style="width: 50px; height: 30px; background-color: yellow;"/>
27
+ </window>
28
+ ```
29
+
30
+
31
+ ## Dynamic Layouts
32
+
33
+ Dynamic layouts automatically position and resize components when the amount of space available for them changes, ensuring that they are consistently arranged and that the user interface as a whole remains usable.
34
+
35
+ Svelte NodeGui currently supports layouting using FlexLayout.
36
+
37
+ ## FlexLayout
38
+
39
+ FlexLayout allows the children to expand and shrink dynamically based on available space. Normally you will use `flex: 1`, which tells a component to fill all available space, shared evenly amongst other components with the same parent. The larger the flex given, the higher the ratio of space a component will take compared to its siblings.
40
+
41
+ > A component can only expand to fill available space if its parent has dimensions greater than 0. If a parent does not have either a fixed width and height or flex, the parent will have dimensions of 0 and the flex children will not be visible.
42
+
43
+ Flexbox is designed to provide a consistent layout on different screen sizes. You will normally use a combination of flex-direction, align-items,and justify-content to achieve the right layout.
44
+
45
+ ### Example:
46
+
47
+ Lets say you want to build a UI that has a parent view which has two child components. One a label with text Hello and another a view with background color white. Now you want the label to occupy 1/3 of the available space while the white colored child view to occupy the remaining 2/3 space.
48
+
49
+ <img src="https://github.com/nodegui/react-nodegui/raw/gh-pages/img/flex-layout-1.png" alt="flex layout example 1" style={{maxWidth: 700, width:'100%'}}/>
50
+
51
+ The code for that would look something like this:
52
+
53
+ ```html
54
+ <script lang="ts">
55
+ import { onMount } from "svelte";
56
+
57
+ onMount(() => {
58
+ (window as any).win = win; // Prevent garbage collection.
59
+ win.nativeView.show();
60
+ return () => {
61
+ delete (window as any).win;
62
+ };
63
+ });
64
+ </script>
65
+
66
+ <window bind:this={win}>
67
+ <view id="rootView">
68
+ <text id="label">Hello</text>
69
+ <view id="view"/>
70
+ </view>
71
+ </window>
72
+
73
+ <style>
74
+ #rootView{
75
+ height: '100%';
76
+ background-color: blue;
77
+ }
78
+ #label {
79
+ flex: 1;
80
+ color: white;
81
+ background-color: green;
82
+ }
83
+ #view {
84
+ flex: 3;
85
+ background-color: white;
86
+ }
87
+ </style>
88
+ ```
89
+
90
+ > To know more on how FlexBox layout works in depth you can visit: https://facebook.github.io/react-native/docs/0.60/flexbox.
91
+ >
92
+ > NodeGui uses the same library that React Native uses underneath for FlexBox ([Yoga](https://github.com/facebook/yoga)).
93
+
94
+ - You can specify layout properties via inline styles also.
95
+
96
+
97
+ ## BoxView Layout
98
+
99
+ BoxView Layout is an implementation of QBoxLayout of NodeGui.
100
+
101
+ ```html
102
+ <script lang="ts">
103
+ import { onMount } from "svelte";
104
+ import { Direction } from "@nodegui/nodegui";
105
+ import type { QPushButtonSignals } from "@nodegui/nodegui";
106
+
107
+ let additionalButtons: string[] = [];
108
+ let direction: Direction = Direction.LeftToRight;
109
+
110
+ function addHandler(): void {
111
+ additionalButtons = [...additionalButtons, `Button ${additionalButtons.length}`];
112
+ }
113
+ function removeHandler(): void {
114
+ additionalButtons = [...additionalButtons.slice(0, additionalButtons.length - 1)];
115
+ }
116
+ function toggleDirection(): void {
117
+ direction = ((direction + 1) % 4) as Direction;
118
+ }
119
+
120
+ onMount(() => {
121
+ (window as any).win = win; // Prevent garbage collection.
122
+ win.nativeView.show();
123
+ return () => {
124
+ delete (window as any).win;
125
+ };
126
+ });
127
+ </script>
128
+
129
+ <window bind:this={win}>
130
+ <boxView direction={direction}>
131
+ <button text="Add" on={addHandler} />
132
+ <button text="Remove" on={removeHandler} />
133
+ <button text="Toggle direction" on={toggleDirection} />
134
+ {#each additionalButtons as additionalButton (additionalButton)}
135
+ <button text={additionalButton}/>
136
+ {/each}
137
+ </boxView>
138
+ </window>
139
+ ```
140
+
141
+ The above code produces
142
+
143
+ <img src="https://github.com/nodegui/react-nodegui/raw/gh-pages/img/box-layout-1.png" alt="box layout example 1" style={{maxWidth: 700, width:'100%'}}/>
144
+ <img src="https://github.com/nodegui/react-nodegui/raw/gh-pages/img/box-layout-2.png" alt="box layout example 1" style={{maxWidth: 700, width:'100%'}}/>
145
+
146
+
147
+ ## GridView Layout
148
+
149
+ GridView Layout is an implementation of QGridLayout of NodeGui.
150
+
151
+ ```html
152
+ <script lang="ts">
153
+ import { onMount } from "svelte";
154
+ let win;
155
+
156
+ let additionalRows: string[] = [];
157
+ let additionalColumns: string[] = [];
158
+ let rowStretch: boolean = false;
159
+
160
+ function insertRowHandler(): void {
161
+ additionalRows = [...additionalRows, `Row ${additionalRows.length}`];
162
+ }
163
+ function removeRowHandler(): void {
164
+ additionalRows = [...additionalRows.slice(0, additionalRows.length - 1)];
165
+ }
166
+ function insertColumnHandler(): void {
167
+ additionalColumns = [...additionalColumns, `Column ${additionalColumns.length}`];
168
+ }
169
+ function removeColumnsHandler(): void {
170
+ additionalColumns = [...additionalColumns.slice(0, additionalColumns.length - 1)];
171
+ }
172
+ function toggleRowStretch(): void {
173
+ rowStretch = !rowStretch;
174
+ }
175
+
176
+ onMount(() => {
177
+ (window as any).win = win; // Prevent garbage collection.
178
+ win.nativeView.show();
179
+ return () => {
180
+ delete (window as any).win;
181
+ };
182
+ });
183
+ </script>
184
+
185
+ <window bind:this={win}>
186
+ <gridView
187
+ style="flex: 1"
188
+ columnProps={{
189
+ 0: {
190
+ minWidth: 200,
191
+ },
192
+ 1: {
193
+ minWidth: 300,
194
+ },
195
+ }}
196
+ rowProps={{
197
+ 0: {
198
+ stretch: rowStretch ? 2 : undefined,
199
+ minHeight: 400,
200
+ },
201
+ 1: {
202
+ stretch: !rowStretch ? 2 : undefined,
203
+ },
204
+ }}
205
+ >
206
+ <gridRow>
207
+ <gridColumn width={2}>
208
+ <view style="background-color: red">
209
+ <text>Hello</text>
210
+ <button text="Insert row" on:clicked={insertRowHandler} />
211
+ <button text="Remove row" on:clicked={removeRowHandler} />
212
+ <button text="Toggle row stretch" on:clicked={toggleRowStretch} />
213
+ <button text="Insert column" on:clicked={insertColumnHandler} />
214
+ <button text="Remove column" on:clicked={removeColumnsHandler} />
215
+ </view>
216
+ </gridColumn>
217
+ <gridColumn width={2}>
218
+ <view style="background-color: blue">
219
+ <text>Second Column</text>
220
+ </view>
221
+ </gridColumn>
222
+ {#each additionalColumns as column (column)}
223
+ <gridColumn>
224
+ <text>{column}</text>
225
+ </gridColumn>
226
+ {/each}
227
+ </gridRow>
228
+ <gridRow height={2}>
229
+ <gridColumn>
230
+ <view style="background-color: green">
231
+ <text>Second row</text>
232
+ </view>
233
+ </gridColumn>
234
+ <gridColumn>
235
+ <view style="background-color: purple">
236
+ <text>Second Column</text>
237
+ </view>
238
+ </gridColumn>
239
+ <gridColumn>
240
+ <view style="background-color: purple">
241
+ <text>Third Column</text>
242
+ </view>
243
+ </gridColumn>
244
+ <gridColumn>
245
+ <view style="background-color: purple">
246
+ <text>Fourth Column</text>
247
+ </view>
248
+ </gridColumn>
249
+ {#each additionalColumns as column (column)}
250
+ <gridColumn>
251
+ <text>Second {column}</text>
252
+ </gridColumn>
253
+ {/each}
254
+ </gridRow>
255
+ <gridRow>
256
+ <gridColumn>
257
+ <text>Third row</text>
258
+ </gridColumn>
259
+ </gridRow>
260
+ {#each additionalRows as row (row)}
261
+ <gridColumn>
262
+ <gridColumn width={2}>
263
+ <text>{row}</text>
264
+ </gridColumn>
265
+ <gridColumn>
266
+ <text>Second {row}</text>
267
+ </gridColumn>
268
+ </gridColumn>
269
+ {/each}
270
+ </gridView>
271
+ </window>
272
+ ```
273
+
274
+ The above code produces
275
+
276
+ <img src="https://github.com/nodegui/react-nodegui/raw/gh-pages/img/grid-layout-1.png" alt="grid layout example 1" style={{maxWidth: 700, width:'100%'}}/>
277
+
278
+
279
+ ## Conclusion
280
+
281
+ The primary layout in Svelte NodeGui is the Flexbox layout. Flexbox layout can be controlled via stylesheet just as in web. So both paint and layout properties are available at the same place.
@@ -0,0 +1,31 @@
1
+ ---
2
+ sidebar_label: Networking
3
+ title: Networking
4
+ ---
5
+
6
+ Many apps need to load resources from a remote URL. You may want to make a POST request to a REST API, or you may need to fetch a chunk of static content from another server.
7
+
8
+ Remember that NodeGui apps do not run in a browser and hence do not have access to browser apis. NodeGui app is essentially a Node.js app.
9
+
10
+ And in a typical Node.js application you would use a third party library like [axios](https://github.com/axios/axios), [node-fetch](https://github.com/node-fetch/node-fetch) or [frisbee](https://github.com/niftylettuce/frisbee) for achieving this functionality.
11
+
12
+ ## Using Node Fetch
13
+
14
+ [Node Fetch](https://github.com/node-fetch/node-fetch) is a light-weight module that brings window.fetch to Node.js.
15
+
16
+ An example usage would look like this:
17
+
18
+ ```js
19
+ const fetch = require("node-fetch");
20
+ async function getData() {
21
+ try {
22
+ let response = await fetch("https://somewebsite.com/some.json");
23
+ let responseJson = await response.json();
24
+ return responseJson.somecontent;
25
+ } catch (error) {
26
+ console.error(error);
27
+ }
28
+ }
29
+ ```
30
+
31
+ Take a look at the [Node Fetch docs](https://github.com/node-fetch/node-fetch) for a full list of properties.
@@ -0,0 +1,32 @@
1
+ ---
2
+ sidebar_label: Packaging
3
+ title: Packaging
4
+ ---
5
+
6
+ In order to distribute your finished app, you can use [@nodegui/packer](https://github.com/nodegui/packer)
7
+
8
+ - **Step 1: (Run this command only once)**
9
+
10
+ ```sh
11
+ npx nodegui-packer --init MyAppName
12
+ ```
13
+
14
+ This will produce the deploy directory containing the template. You can modify this to suite your needs. Like add icons, change the name, description and add other native features or dependencies. Make sure you commit this directory.
15
+
16
+ - **Step 2: (Run this command every time you want to build a new distributable)**
17
+
18
+ Next you can run the pack command:
19
+
20
+ ```sh
21
+ npm run build
22
+ ```
23
+
24
+ This will produce the js bundle along with assets inside the ./dist directory
25
+
26
+ ```sh
27
+ npx nodegui-packer --pack ./dist
28
+ ```
29
+
30
+ This will build the distributable using @nodegui/packer based on your template. The output of the command is found under the build directory. You should gitignore the build directory.
31
+
32
+ More details about packer can be found here: https://github.com/nodegui/packer
@@ -0,0 +1,69 @@
1
+ ---
2
+ sidebar_label: ScrollArea
3
+ title: Scroll Area
4
+ ---
5
+
6
+ ScrollArea allows you to display a large content (image, list or even plain text) in an area of predefined size. A scroll area is used to display the contents of a child widget within a frame. If the widget exceeds the size of the frame, the view can provide scroll bars so that the entire area of the child widget can be viewed.
7
+
8
+ ## Example
9
+
10
+ ```html
11
+ <script lang="ts">
12
+ import { onMount } from "svelte";
13
+
14
+ onMount(() => {
15
+ (window as any).win = win; // Prevent garbage collection.
16
+ win.nativeView.show();
17
+ return () => {
18
+ delete (window as any).win;
19
+ };
20
+ });
21
+ </script>
22
+
23
+ <window bind:this={win}>
24
+ <scrollArea>
25
+ <text>
26
+ Contrary to popular belief,
27
+ Lorem Ipsum is not simply random text.
28
+ It has roots in a piece of classical Latin literature from 45 BC,
29
+ making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia,
30
+ looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage,
31
+ and going through the cites of the word in classical literature,
32
+ discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32
33
+ and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC.
34
+ This book is a treatise on the theory of ethics, very popular during the Renaissance.
35
+ The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
36
+
37
+ The standard chunk of Lorem Ipsum used since the 1500s
38
+ is reproduced below for those interested.
39
+ Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also
40
+ reproduced in their exact original form, accompanied
41
+ by English versions from the 1914 translation by H. Rackham.
42
+
43
+ Why do we use it?
44
+
45
+ It is a long established
46
+ fact that a reader will be distracted by
47
+ the readable content of a page when looking at its layout.
48
+ The point of using Lorem Ipsum is that it has
49
+ a more-or-less normal distribution of letters,
50
+ as opposed to using 'Content here, content here',
51
+ making it look like readable English.
52
+ Many desktop publishing packages and web page
53
+ editors now use Lorem Ipsum as their default model text,
54
+ and a search for 'lorem ipsum' will uncover many web
55
+ sites still in their infancy. Various versions
56
+ have evolved over the years, sometimes by accident,
57
+ sometimes on purpose (injected humour and the like).
58
+ </text>
59
+ </scrollArea>
60
+ </window>
61
+ ```
62
+
63
+ **TLDR;**
64
+
65
+ We create a `<scrollArea>` instance and then set the target widget as its child.
66
+
67
+ The result would look like this:
68
+
69
+ <img src="https://github.com/nodegui/react-nodegui/releases/download/assets/scrollarea.gif" alt="scroll area" style={{width: '100%', maxWidth: 400}}/>