├── .github └── workflows │ └── main.yml ├── .gitignore ├── LICENSE ├── README.md ├── examples └── create-react-app │ ├── .gitignore │ ├── README.md │ ├── b0x.yml │ ├── go.mod │ ├── main.go │ └── public │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt │ └── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ ├── logo.svg │ ├── reportWebVitals.js │ └── setupTests.js ├── getting-started.md ├── go.mod ├── include ├── AppCore │ └── CAPI.h ├── JavaScriptCore │ ├── JSBase.h │ ├── JSContextRef.h │ ├── JSObjectRef.h │ ├── JSObjectRefPrivate.h │ ├── JSRetainPtr.h │ ├── JSStringRef.h │ ├── JSTypedArray.h │ ├── JSValueRef.h │ ├── JavaScript.h │ └── WebKitAvailability.h └── Ultralight │ └── CAPI.h ├── logo.svg ├── muon.go ├── muon_test.go ├── ultralight.yml └── ultralight ├── cgo_helpers.c ├── cgo_helpers.go ├── cgo_helpers.h ├── const.go ├── doc.go ├── libs ├── EULA.txt ├── LICENSE.txt ├── NOTICES.txt ├── darwin │ └── x64 │ │ ├── libAppCore.dylib │ │ ├── libUltralight.dylib │ │ ├── libUltralightCore.dylib │ │ └── libWebCore.dylib ├── linux │ └── x64 │ │ ├── libAppCore.so │ │ ├── libUltralight.so │ │ ├── libUltralightCore.so │ │ └── libWebCore.so └── windows │ ├── x32 │ ├── AppCore.dll │ ├── Ultralight.dll │ ├── UltralightCore.dll │ └── WebCore.dll │ └── x64 │ ├── AppCore.dll │ ├── Ultralight.dll │ ├── UltralightCore.dll │ └── WebCore.dll ├── types.go └── ultralight.go /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | name: Test 3 | jobs: 4 | Windows_x64: 5 | runs-on: windows-latest 6 | steps: 7 | - name: Install Go 8 | uses: actions/setup-go@v1 9 | with: 10 | go-version: 1.13.x 11 | - name: Checkout code 12 | uses: actions/checkout@v1 13 | - name: Install Deps 14 | shell: pwsh 15 | run: | 16 | Invoke-WebRequest -OutFile ultralight.7z https://ultralight-sdk.sfo2.cdn.digitaloceanspaces.com/ultralight-sdk-latest-win-x64.7z 17 | 7z e ultralight.7z *.dll -r 18 | - name: Test 19 | run: go test 20 | # One day I'll get this working 21 | # Windows_x32: 22 | # runs-on: windows-latest 23 | # steps: 24 | # - name: Install Go 25 | # uses: actions/setup-go@v1 26 | # with: 27 | # go-version: 1.13.x 28 | # - name: Checkout code 29 | # uses: actions/checkout@v1 30 | # - name: Install Deps 31 | # shell: pwsh 32 | # run: | 33 | # choco install mingw --x86 --force 34 | # Invoke-WebRequest -OutFile ultralight.7z https://ultralight-sdk.sfo2.cdn.digitaloceanspaces.com/ultralight-sdk-latest-win-x86.7z 35 | # 7z e ultralight.7z *.dll -r 36 | # - name: Test 37 | # env: 38 | # GOARCH: 386 39 | # CGO_ENABLED: 1 40 | # run: | 41 | # go test 42 | Linux_x64: 43 | runs-on: ubuntu-latest 44 | steps: 45 | - name: Install Go 46 | uses: actions/setup-go@v1 47 | with: 48 | go-version: 1.13.x 49 | - name: Checkout code 50 | uses: actions/checkout@v1 51 | - name: Install Deps 52 | run: | 53 | wget -O ultralight.7z https://ultralight-sdk.sfo2.cdn.digitaloceanspaces.com/ultralight-sdk-latest-linux-x64.7z 54 | 7z e ultralight.7z *.so -r 55 | sudo apt update && sudo apt install -y xorg openbox 56 | sudo nohup Xorg :0 & 57 | - name: Test 58 | env: 59 | LD_LIBRARY_PATH: . 60 | DISPLAY: :0 61 | run: go test -ldflags "-r ." 62 | Mac_x64: 63 | runs-on: macOS-latest 64 | steps: 65 | - name: Install Go 66 | uses: actions/setup-go@v1 67 | with: 68 | go-version: 1.13.x 69 | - name: Checkout code 70 | uses: actions/checkout@v1 71 | - name: Install Deps 72 | run: | 73 | brew install p7zip 74 | wget -O ultralight.7z https://ultralight-sdk.sfo2.cdn.digitaloceanspaces.com/ultralight-sdk-latest-mac-x64.7z 75 | 7z e ultralight.7z *.dylib -r 76 | - name: Test 77 | run: go test -ldflags "-r ." 78 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | go.sum 2 | webfiles/ab0x.go 3 | .vscode/ 4 | /*.dll -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 V-X 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | gnet 3 |

4 | 5 | GitHub code size in bytes 6 |
7 | 8 |

9 | 10 | ---- 11 | 12 | `Muon` is a lightweight alternative to Electron written in Golang in about ~300 LoC, using Ultralight instead of Chromium. [Ultralight](https://ultralig.ht/) is a cross-platform WebKit rewrite using the GPU to target embedded desktop applications that resulted in a fast, lightweight, and low-memory HTML UI solution that blends the power of Chromium with the small footprint of Native UI. 13 | 14 | 15 | # Features 16 | 17 | - Full JS to Go interop 18 | - GPU based rendering 19 | - Cross-platform 20 | - Hot-reloading 21 | - Superior disk size + memory & cpu usage 22 | 23 | Comparison with a "Hello, World!" React App 24 | 25 | | | Muon | Electron | 26 | |:----:|---------|----------| 27 | | CPU | 0.0% | 1.2% | 28 | | MEM | 26.0 MB | 201.7 MB | 29 | | DISK | 42 MB | 136 MB | 30 | 31 | # Example 32 | 33 | From `examples/create-react-app/main.go`: 34 | ```go 35 | package main 36 | 37 | import ( 38 | "github.com/ImVexed/muon" 39 | 40 | "cra-go/webfiles" 41 | "net/http" 42 | ) 43 | 44 | func main() { 45 | // Any static asset packer of your liking (ex. fileb0x) 46 | fileHandler := http.FileServer(webfiles.HTTP) 47 | 48 | cfg := &muon.Config{ 49 | Title: "Hello, World!", 50 | Height: 500, 51 | Width: 500, 52 | Titled: true, 53 | Resizeable: true, 54 | } 55 | 56 | m := muon.New(cfg, fileHandler) 57 | 58 | // Expose our `add` function to the JS runtime 59 | m.Bind("add", add) 60 | 61 | // Show the Window and start the Runtime 62 | if err := m.Start(); err != nil { 63 | panic(err) 64 | } 65 | } 66 | 67 | // Muon automatically handles interop to and from the JS runtime 68 | func add(a float64, b float64) float64 { 69 | return a + b 70 | } 71 | ``` 72 | 73 | # FAQ 74 | 75 | ## Q: *How are JS types translated to Go types?* 76 | - JS: `Boolean` Go: `bool` 77 | - JS: `Number` Go: `float64` 78 | - JS: `String` Go: `string` 79 | - JS: `Object` Go: `struct` via JSON 80 | 81 | ## Q: *How do I setup Ultralight?* 82 | - See our [getting started guide](https://github.com/ImVexed/muon/blob/master/getting-started.md) 83 | 84 | ## Q: *Is there perfect Chrome or Firefox feature parity?* 85 | - No, see [Missing Ultralight Features](https://github.com/ultralight-ux/Ultralight/issues/178) 86 | 87 | ## Q: *How do I get rid of the Console on Windows?* 88 | - Add `-ldflags -H=windowsgui` to either your `go build` or `go run` to get rid of the window. 89 | 90 | ## Q: *I get `exit status 3221225781`* 91 | - Your program likely can't find the Ultralight libraries. Ensure they're either installed on the system, or, in the same folder as your program. Currently, Muon uses the 1.1 Ultralight pre-release that hasn't yet propagated to their main site and can only be downloaded from the [Ultralight](https://github.com/ultralight-ux/Ultralight#getting-the-latest-sdk) github repo. 92 | 93 | ## Q: *I get ` libWebCore.so: cannot open shared object file`* 94 | - If you're attempting to load the libraries out of the same directory as your program add `-ldflags "-r ."` to your `go build` to set `rpath` to the local directory for library resolution. 95 | 96 | ## Q: *I get `symbol not found: ulCreateSettings`* 97 | - This likely means you're not using the 1.1 Ultralight pre-release which can be downloaded only from their [GitHub Repo](https://github.com/ultralight-ux/Ultralight#getting-the-latest-sdk) for now 98 | ## Q: *How do I compile for x86?* 99 | - Currently, Ultralight only supports Windows for x86. Ensure you have a 32-bit `gcc` in your path, and ensure you have `CGO_ENABLED=1` and `GOARCH=386` environment variables set. 100 | 101 | # Licensing 102 | While muon itself is MIT licensed, [Ultralight](https://ultralig.ht/) is not. 103 | ``` 104 | Ultralight is free for non-commercial use, educational use, 105 | and also free for commercial use by small indie developers making 106 | less than US$100,000 a year. You can find full terms in the SDK. 107 | Pricing plans for larger commercial projects will be announced later. 108 | ``` 109 | Their specific license terms can be found [here](https://github.com/ultralight-ux/Ultralight/tree/master/license). 110 | -------------------------------------------------------------------------------- /examples/create-react-app/.gitignore: -------------------------------------------------------------------------------- 1 | go.sum 2 | webfiles/ 3 | .vscode/ 4 | cra-go* 5 | *.dll 6 | cookies.dat -------------------------------------------------------------------------------- /examples/create-react-app/README.md: -------------------------------------------------------------------------------- 1 | # Create-React-App Example 2 | 3 | - Run `yarn && yarn build` inside of `public/` 4 | - Run `go generate && go build` inside this directory. 5 | - Ensure Ultralight libraries are installed -------------------------------------------------------------------------------- /examples/create-react-app/b0x.yml: -------------------------------------------------------------------------------- 1 | # all folders and files are relative to the path 2 | # where fileb0x was run at! 3 | 4 | # default: main 5 | pkg: webfiles 6 | 7 | # destination 8 | dest: "./webfiles/" 9 | 10 | # gofmt 11 | # type: bool 12 | # default: false 13 | fmt: true 14 | 15 | # compress files 16 | # at the moment, only supports gzip 17 | # 18 | # type: object 19 | compression: 20 | # activates the compression 21 | # 22 | # type: bool 23 | # default: false 24 | compress: true 25 | 26 | # valid values are: 27 | # -> "NoCompression" 28 | # -> "BestSpeed" 29 | # -> "BestCompression" 30 | # -> "DefaultCompression" or "" 31 | # 32 | # type: string 33 | # default: "DefaultCompression" # when: Compress == true && Method == "" 34 | method: "BestCompression" 35 | 36 | # true = do it yourself (the file is written as gzip compressed file into the memory file system) 37 | # false = decompress files at run time (while writing file into memory file system) 38 | # 39 | # type: bool 40 | # default: false 41 | keep: false 42 | 43 | # --------------- 44 | # -- DANGEROUS -- 45 | # --------------- 46 | # 47 | # cleans the destination folder (only b0xfiles) 48 | # you should use this when using the spread function 49 | # type: bool 50 | # default: false 51 | clean: false 52 | 53 | # default: ab0x.go 54 | output: "ab0x.go" 55 | 56 | # [unexporTed] builds non-exporTed functions, variables and types... 57 | # type: bool 58 | # default: false 59 | unexporTed: false 60 | 61 | # [spread] means it will make a file to hold all fileb0x data 62 | # and each file into a separaTed .go file 63 | # 64 | # example: 65 | # theres 2 files in the folder assets, they're: hello.json and world.txt 66 | # when spread is activaTed, fileb0x will make a file: 67 | # b0x.go or [output]'s data, assets_hello.json.go and assets_world.txt.go 68 | # 69 | # 70 | # type: bool 71 | # default: false 72 | spread: false 73 | 74 | # [lcf] log changed files when spread is active 75 | lcf: true 76 | 77 | custom: 78 | - files: 79 | - "./public/build/" 80 | base: "public/build/" -------------------------------------------------------------------------------- /examples/create-react-app/go.mod: -------------------------------------------------------------------------------- 1 | module cra-go 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/ImVexed/muon v0.0.0-20191017043257-ae2a6637f296 7 | golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3 8 | ) 9 | -------------------------------------------------------------------------------- /examples/create-react-app/main.go: -------------------------------------------------------------------------------- 1 | //go:generate fileb0x b0x.yml 2 | package main 3 | 4 | import ( 5 | "github.com/ImVexed/muon" 6 | 7 | "cra-go/webfiles" 8 | "net/http" 9 | ) 10 | 11 | func main() { 12 | fileHandler := http.FileServer(webfiles.HTTP) 13 | 14 | cfg := &muon.Config{ 15 | Title: "Hello, World!", 16 | Height: 500, 17 | Width: 500, 18 | Titled: true, 19 | Resizeable: true, 20 | } 21 | 22 | m := muon.New(cfg, fileHandler) 23 | 24 | m.Bind("add", add) 25 | 26 | if err := m.Start(); err != nil { 27 | panic(err) 28 | } 29 | } 30 | 31 | func add(a float64, b float64) float64 { 32 | return a + b 33 | } 34 | -------------------------------------------------------------------------------- /examples/create-react-app/public/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/create-react-app/public/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 13 | 14 | The page will reload when you make changes.\ 15 | You may also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 35 | 36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. 39 | 40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /examples/create-react-app/public/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "public", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.5", 7 | "@testing-library/react": "^13.4.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-scripts": "5.0.1", 12 | "web-vitals": "^2.1.4" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": [ 22 | "react-app", 23 | "react-app/jest" 24 | ] 25 | }, 26 | "browserslist": { 27 | "production": [ 28 | ">0.2%", 29 | "not dead", 30 | "not op_mini all" 31 | ], 32 | "development": [ 33 | "last 1 chrome version", 34 | "last 1 firefox version", 35 | "last 1 safari version" 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/create-react-app/public/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/examples/create-react-app/public/public/favicon.ico -------------------------------------------------------------------------------- /examples/create-react-app/public/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/create-react-app/public/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/examples/create-react-app/public/public/logo192.png -------------------------------------------------------------------------------- /examples/create-react-app/public/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/examples/create-react-app/public/public/logo512.png -------------------------------------------------------------------------------- /examples/create-react-app/public/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/create-react-app/public/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/create-react-app/public/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/create-react-app/public/src/App.js: -------------------------------------------------------------------------------- 1 | import logo from './logo.svg'; 2 | import './App.css'; 3 | 4 | function App() { 5 | return ( 6 |
7 |
8 | logo 9 |

10 | Go: add(1 + 2) = {window.add(1,2)} 11 |

12 | 18 | Learn React 19 | 20 |
21 |
22 | ); 23 | } 24 | 25 | export default App; 26 | -------------------------------------------------------------------------------- /examples/create-react-app/public/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /examples/create-react-app/public/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /examples/create-react-app/public/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | const root = ReactDOM.createRoot(document.getElementById('root')); 8 | root.render( 9 | 10 | 11 | 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /examples/create-react-app/public/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/create-react-app/public/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /examples/create-react-app/public/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /getting-started.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Muon 2 | 3 | While setup varies depending on your operating system, the steps are largely the same no matter what you're on. 4 | 5 | Requirements: 6 | - Go (1.11+) 7 | - gcc 8 | - [Ultralight Libraries](https://github.com/ultralight-ux/ultralight#getting-the-latest-sdk) (`\.\bin\` inside the archive) 9 | 10 | Start by cloning the repository and entering the example repository: 11 | 12 | ``` 13 | git clone https://github.com/ImVexed/muon 14 | cd muon/examples/create-react-app 15 | ``` 16 | 17 | Before we can run our project we first need to build and then package all of our frontend assets into a single Go file. There are [many](https://tech.townsourced.com/post/embedding-static-files-in-go/) static asset packagers you can choose from, however we reccomend [fileb0x](https://github.com/UnnoTed/fileb0x) for ease of use and hot reloading. 18 | 19 | Start by entering the frontend folder and building it: 20 | ``` 21 | cd public/ 22 | yarn 23 | yarn build 24 | ``` 25 | 26 | Ensure you have [fileb0x](https://github.com/UnnoTed/fileb0x) installed and in your `$PATH` variable by running `go install github.com/UnnoTed/fileb0x@latest` 27 | 28 | Now, back in the `create-react-app` directory, package the assets by running either: 29 | ``` 30 | fileb0x b0x.yml 31 | ``` 32 | or 33 | ``` 34 | go generate 35 | ``` 36 | 37 | Which will tell fileb0x to use [b0x.yml](https://github.com/ImVexed/muon/blob/master/examples/create-react-app/b0x.yml) to pack our `public/build` folder into a go file in `webfiles/` 38 | 39 | From there we're good to go as long as we have `gcc` in our path we can run 40 | ``` 41 | go build 42 | ``` 43 | 44 | Now that we have a binary we're almost done. If you try to run it now, or, if you ran 45 | ``` 46 | go run main.go 47 | ``` 48 | 49 | You will likely have ran into an error. This is because we are dynamically linking to Ultralight, meaning that it's libraries are resolved when the application is started. To fix this, you'll need the take the [Ultralight Libraries](https://github.com/ultralight-ux/ultralight#getting-the-latest-sdk) (`.dll` for Windows, `.so` for Unix, `.dylib` for Darwin) and put them in the same directory as your application. 50 | 51 | **Note for Linux users** 52 | - Linux by default only looks for shared objects at a specific system path, if you would preffer to load the shared objects from a different directory, simply set the `LD_LIBRARY_PATH` environment variable to the new directory containing the libraries. (`.` being current directory) 53 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/ImVexed/muon 2 | 3 | go 1.13 4 | -------------------------------------------------------------------------------- /include/AppCore/CAPI.h: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file CAPI.h 3 | /// 4 | /// @brief The C-language API for AppCore 5 | /// 6 | /// @author 7 | /// 8 | /// This file is a part of Ultralight, a fast, lightweight, HTML UI engine 9 | /// 10 | /// Website: 11 | /// 12 | /// Copyright (C) 2019 Ultralight, Inc. All rights reserved. 13 | /// 14 | #ifndef APPCORE_CAPI_H 15 | #define APPCORE_CAPI_H 16 | 17 | #include 18 | 19 | #if defined(__WIN32__) || defined(_WIN32) 20 | # if defined(APPCORE_IMPLEMENTATION) 21 | # define ACExport __declspec(dllexport) 22 | # else 23 | # define ACExport __declspec(dllimport) 24 | # endif 25 | #else 26 | # define ACExport __attribute__((visibility("default"))) 27 | #endif 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | typedef struct C_Settings* ULSettings; 34 | typedef struct C_App* ULApp; 35 | typedef struct C_Window* ULWindow; 36 | typedef struct C_Monitor* ULMonitor; 37 | typedef struct C_Overlay* ULOverlay; 38 | 39 | /// 40 | /// Window creation flags. @see Window::Create 41 | /// 42 | typedef enum { 43 | kWindowFlags_Borderless = 1 << 0, 44 | kWindowFlags_Titled = 1 << 1, 45 | kWindowFlags_Resizable = 1 << 2, 46 | kWindowFlags_Maximizable = 1 << 3, 47 | } ULWindowFlags; 48 | 49 | /// 50 | /// Create settings with default values (see ). 51 | /// 52 | ACExport ULSettings ulCreateSettings(); 53 | 54 | /// 55 | /// Destroy settings. 56 | /// 57 | ACExport void ulDestroySettings(ULSettings settings); 58 | 59 | /// 60 | /// Set the root file path for our file system, you should set this to the 61 | /// relative path where all of your app data is. 62 | /// 63 | /// This will be used to resolve all file URLs, eg file:///page.html 64 | /// 65 | /// @note By default, on macOS we use the app bundle's @resource_path, 66 | /// on all other platforms we use the "./assets/" directory relative 67 | /// to the executable's directory. 68 | /// 69 | ACExport void ulSettingsSetFileSystemPath(ULSettings settings, ULString path); 70 | 71 | /// 72 | /// Set whether or not we should load and compile shaders from the file system 73 | /// (eg, from the /shaders/ path, relative to file_system_path). 74 | /// 75 | /// If this is false (the default), we will instead load pre-compiled shaders 76 | /// from memory which speeds up application startup time. 77 | /// 78 | ACExport void ulSettingsSetLoadShadersFromFileSystem(ULSettings settings, 79 | bool enabled); 80 | 81 | /// 82 | /// Create the App singleton. 83 | /// 84 | /// @param settings Settings to customize App runtime behavior. You can pass 85 | /// NULL for this parameter to use default settings. 86 | /// 87 | /// @param config Config options for the Ultralight renderer. You can pass 88 | /// NULL for this parameter to use default config. 89 | /// 90 | /// @note You should only create one of these per application lifetime. 91 | /// 92 | /// @note Certain Config options may be overridden during App creation, 93 | /// most commonly Config::face_winding and Config::device_scale_hint. 94 | /// 95 | ACExport ULApp ulCreateApp(ULSettings settings, ULConfig config); 96 | 97 | /// 98 | /// Destroy the App instance. 99 | /// 100 | ACExport void ulDestroyApp(ULApp app); 101 | 102 | /// 103 | /// Set the main window, you must set this before calling ulAppRun. 104 | /// 105 | /// @param window The window to use for all rendering. 106 | /// 107 | /// @note We currently only support one Window per App, this will change 108 | /// later once we add support for multiple driver instances. 109 | /// 110 | ACExport void ulAppSetWindow(ULApp app, ULWindow window); 111 | 112 | /// 113 | /// Get the main window. 114 | /// 115 | ACExport ULWindow ulAppGetWindow(ULApp app); 116 | 117 | typedef void 118 | (*ULUpdateCallback) (void* user_data); 119 | 120 | /// 121 | /// Set a callback for whenever the App updates. You should update all app 122 | /// logic here. 123 | /// 124 | /// @note This event is fired right before the run loop calls 125 | /// Renderer::Update and Renderer::Render. 126 | /// 127 | ACExport void ulAppSetUpdateCallback(ULApp app, ULUpdateCallback callback, 128 | void* user_data); 129 | 130 | /// 131 | /// Whether or not the App is running. 132 | /// 133 | ACExport bool ulAppIsRunning(ULApp app); 134 | 135 | /// 136 | /// Get the main monitor (this is never NULL). 137 | /// 138 | /// @note We'll add monitor enumeration later. 139 | /// 140 | ACExport ULMonitor ulAppGetMainMonitor(ULApp app); 141 | 142 | /// 143 | /// Get the underlying Renderer instance. 144 | /// 145 | ACExport ULRenderer ulAppGetRenderer(ULApp app); 146 | 147 | /// 148 | /// Run the main loop, make sure to call ulAppSetWindow before calling this. 149 | /// 150 | ACExport void ulAppRun(ULApp app); 151 | 152 | /// 153 | /// Quit the application. 154 | /// 155 | ACExport void ulAppQuit(ULApp app); 156 | 157 | /// 158 | /// Get the monitor's DPI scale (1.0 = 100%). 159 | /// 160 | ACExport double ulMonitorGetScale(ULMonitor monitor); 161 | 162 | /// 163 | /// Get the width of the monitor (in device coordinates). 164 | /// 165 | ACExport unsigned int ulMonitorGetWidth(ULMonitor monitor); 166 | 167 | /// 168 | /// Get the height of the monitor (in device coordinates). 169 | /// 170 | ACExport unsigned int ulMonitorGetHeight(ULMonitor monitor); 171 | 172 | /// 173 | /// Create a new Window. 174 | /// 175 | /// @param monitor The monitor to create the Window on. 176 | /// 177 | /// @param width The width (in device coordinates). 178 | /// 179 | /// @param height The height (in device coordinates). 180 | /// 181 | /// @param fullscreen Whether or not the window is fullscreen. 182 | /// 183 | /// @param window_flags Various window flags. 184 | /// 185 | ACExport ULWindow ulCreateWindow(ULMonitor monitor, unsigned int width, 186 | unsigned int height, bool fullscreen, 187 | unsigned int window_flags); 188 | 189 | /// 190 | /// Destroy a Window. 191 | /// 192 | ACExport void ulDestroyWindow(ULWindow window); 193 | 194 | typedef void 195 | (*ULCloseCallback) (void* user_data); 196 | 197 | /// 198 | /// Set a callback to be notified when a window closes. 199 | /// 200 | ACExport void ulWindowSetCloseCallback(ULWindow window, 201 | ULCloseCallback callback, 202 | void* user_data); 203 | 204 | typedef void 205 | (*ULResizeCallback) (void* user_data, unsigned int width, unsigned int height); 206 | 207 | /// 208 | /// Set a callback to be notified when a window resizes 209 | /// (parameters are passed back in device coordinates). 210 | /// 211 | ACExport void ulWindowSetResizeCallback(ULWindow window, 212 | ULResizeCallback callback, 213 | void* user_data); 214 | 215 | /// 216 | /// Get window width (in device coordinates). 217 | /// 218 | ACExport unsigned int ulWindowGetWidth(ULWindow window); 219 | 220 | /// 221 | /// Get window height (in device coordinates). 222 | /// 223 | ACExport unsigned int ulWindowGetHeight(ULWindow window); 224 | 225 | /// 226 | /// Get whether or not a window is fullscreen. 227 | /// 228 | ACExport bool ulWindowIsFullscreen(ULWindow window); 229 | 230 | /// 231 | /// Get the DPI scale of a window. 232 | /// 233 | ACExport double ulWindowGetScale(ULWindow window); 234 | 235 | /// 236 | /// Set the window title. 237 | /// 238 | ACExport void ulWindowSetTitle(ULWindow window, const char* title); 239 | 240 | /// 241 | /// Set the cursor for a window. 242 | /// 243 | ACExport void ulWindowSetCursor(ULWindow window, ULCursor cursor); 244 | 245 | /// 246 | /// Close a window. 247 | /// 248 | ACExport void ulWindowClose(ULWindow window); 249 | 250 | /// 251 | /// Convert device coordinates to pixels using the current DPI scale. 252 | /// 253 | ACExport int ulWindowDeviceToPixel(ULWindow window, int val); 254 | 255 | /// 256 | /// Convert pixels to device coordinates using the current DPI scale. 257 | /// 258 | ACExport int ulWindowPixelsToDevice(ULWindow window, int val); 259 | 260 | /// 261 | /// Create a new Overlay. 262 | /// 263 | /// @param window The window to create the Overlay in. (we currently only 264 | /// support one window per application) 265 | /// 266 | /// @param width The width in device coordinates. 267 | /// 268 | /// @param height The height in device coordinates. 269 | /// 270 | /// @param x The x-position (offset from the left of the Window), in 271 | /// device coordinates. 272 | /// 273 | /// @param y The y-position (offset from the top of the Window), in 274 | /// device coordinates. 275 | /// 276 | /// @note Each Overlay is essentially a View and an on-screen quad. You should 277 | /// create the Overlay then load content into the underlying View. 278 | /// 279 | ACExport ULOverlay ulCreateOverlay(ULWindow window, unsigned int width, 280 | unsigned int height, int x, int y); 281 | 282 | /// 283 | /// Destroy an overlay. 284 | /// 285 | ACExport void ulDestroyOverlay(ULOverlay overlay); 286 | 287 | /// 288 | /// Get the underlying View. 289 | /// 290 | ACExport ULView ulOverlayGetView(ULOverlay overlay); 291 | 292 | /// 293 | /// Get the width (in device coordinates). 294 | /// 295 | ACExport unsigned int ulOverlayGetWidth(ULOverlay overlay); 296 | 297 | /// 298 | /// Get the height (in device coordinates). 299 | /// 300 | ACExport unsigned int ulOverlayGetHeight(ULOverlay overlay); 301 | 302 | /// 303 | /// Get the x-position (offset from the left of the Window), in device 304 | /// coordinates. 305 | /// 306 | ACExport int ulOverlayGetX(ULOverlay overlay); 307 | 308 | /// 309 | /// Get the y-position (offset from the top of the Window), in device 310 | /// coordinates. 311 | /// 312 | ACExport int ulOverlayGetY(ULOverlay overlay); 313 | 314 | /// 315 | /// Move the overlay to a new position (in device coordinates). 316 | /// 317 | ACExport void ulOverlayMoveTo(ULOverlay overlay, int x, int y); 318 | 319 | /// 320 | /// Resize the overlay (and underlying View), dimensions should be 321 | /// specified in device coordinates. 322 | /// 323 | ACExport void ulOverlayResize(ULOverlay overlay, unsigned int width, 324 | unsigned int height); 325 | 326 | /// 327 | /// Whether or not the overlay is hidden (not drawn). 328 | /// 329 | ACExport bool ulOverlayIsHidden(ULOverlay overlay); 330 | 331 | /// 332 | /// Hide the overlay (will no longer be drawn). 333 | /// 334 | ACExport void ulOverlayHide(ULOverlay overlay); 335 | 336 | /// 337 | /// Show the overlay. 338 | /// 339 | ACExport void ulOverlayShow(ULOverlay overlay); 340 | 341 | /// 342 | /// Whether or not an overlay has keyboard focus. 343 | /// 344 | ACExport bool ulOverlayHasFocus(ULOverlay overlay); 345 | 346 | /// 347 | /// Grant this overlay exclusive keyboard focus. 348 | /// 349 | ACExport void ulOverlayFocus(ULOverlay overlay); 350 | 351 | /// 352 | /// Remove keyboard focus. 353 | /// 354 | ACExport void ulOverlayUnfocus(ULOverlay overlay); 355 | 356 | #ifdef __cplusplus 357 | } 358 | #endif 359 | 360 | #endif // APPCORE_CAPI_H 361 | -------------------------------------------------------------------------------- /include/JavaScriptCore/JSBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSBase_h 27 | #define JSBase_h 28 | 29 | #ifndef __cplusplus 30 | #include 31 | #endif 32 | 33 | #ifdef __OBJC__ 34 | #import 35 | #endif 36 | 37 | /* JavaScript engine interface */ 38 | 39 | /*! @typedef JSContextGroupRef A group that associates JavaScript contexts with one another. Contexts in the same group may share and exchange JavaScript objects. */ 40 | typedef const struct OpaqueJSContextGroup* JSContextGroupRef; 41 | 42 | /*! @typedef JSContextRef A JavaScript execution context. Holds the global object and other execution state. */ 43 | typedef const struct OpaqueJSContext* JSContextRef; 44 | 45 | /*! @typedef JSGlobalContextRef A global JavaScript execution context. A JSGlobalContext is a JSContext. */ 46 | typedef struct OpaqueJSContext* JSGlobalContextRef; 47 | 48 | /*! @typedef JSStringRef A UTF16 character buffer. The fundamental string representation in JavaScript. */ 49 | typedef struct OpaqueJSString* JSStringRef; 50 | 51 | /*! @typedef JSClassRef A JavaScript class. Used with JSObjectMake to construct objects with custom behavior. */ 52 | typedef struct OpaqueJSClass* JSClassRef; 53 | 54 | /*! @typedef JSPropertyNameArrayRef An array of JavaScript property names. */ 55 | typedef struct OpaqueJSPropertyNameArray* JSPropertyNameArrayRef; 56 | 57 | /*! @typedef JSPropertyNameAccumulatorRef An ordered set used to collect the names of a JavaScript object's properties. */ 58 | typedef struct OpaqueJSPropertyNameAccumulator* JSPropertyNameAccumulatorRef; 59 | 60 | /*! @typedef JSTypedArrayBytesDeallocator A function used to deallocate bytes passed to a Typed Array constructor. The function should take two arguments. The first is a pointer to the bytes that were originally passed to the Typed Array constructor. The second is a pointer to additional information desired at the time the bytes are to be freed. */ 61 | typedef void (*JSTypedArrayBytesDeallocator)(void* bytes, void* deallocatorContext); 62 | 63 | /* JavaScript data types */ 64 | 65 | /*! @typedef JSValueRef A JavaScript value. The base type for all JavaScript values, and polymorphic functions on them. */ 66 | typedef const struct OpaqueJSValue* JSValueRef; 67 | 68 | /*! @typedef JSObjectRef A JavaScript object. A JSObject is a JSValue. */ 69 | typedef struct OpaqueJSValue* JSObjectRef; 70 | 71 | /* JavaScript symbol exports */ 72 | /* These rules should stay the same as in WebKit2/Shared/API/c/WKBase.h */ 73 | 74 | #undef JS_EXPORT 75 | #if defined(JS_NO_EXPORT) 76 | #define JS_EXPORT 77 | #elif defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC__) 78 | #define JS_EXPORT __attribute__((visibility("default"))) 79 | #elif defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE) || defined(__CC_ARM) || defined(__ARMCC__) 80 | #if defined(BUILDING_JavaScriptCore) || defined(STATICALLY_LINKED_WITH_JavaScriptCore) 81 | #define JS_EXPORT __declspec(dllexport) 82 | #else 83 | #define JS_EXPORT __declspec(dllimport) 84 | #endif 85 | #else /* !defined(JS_NO_EXPORT) */ 86 | #define JS_EXPORT 87 | #endif /* defined(JS_NO_EXPORT) */ 88 | 89 | #ifdef __cplusplus 90 | extern "C" { 91 | #endif 92 | 93 | /* Script Evaluation */ 94 | 95 | /*! 96 | @function JSEvaluateScript 97 | @abstract Evaluates a string of JavaScript. 98 | @param ctx The execution context to use. 99 | @param script A JSString containing the script to evaluate. 100 | @param thisObject The object to use as "this," or NULL to use the global object as "this." 101 | @param sourceURL A JSString containing a URL for the script's source file. This is used by debuggers and when reporting exceptions. Pass NULL if you do not care to include source file information. 102 | @param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1. 103 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 104 | @result The JSValue that results from evaluating script, or NULL if an exception is thrown. 105 | */ 106 | JS_EXPORT JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); 107 | 108 | /*! 109 | @function JSCheckScriptSyntax 110 | @abstract Checks for syntax errors in a string of JavaScript. 111 | @param ctx The execution context to use. 112 | @param script A JSString containing the script to check for syntax errors. 113 | @param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. 114 | @param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1. 115 | @param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception. 116 | @result true if the script is syntactically correct, otherwise false. 117 | */ 118 | JS_EXPORT bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); 119 | 120 | /*! 121 | @function JSGarbageCollect 122 | @abstract Performs a JavaScript garbage collection. 123 | @param ctx The execution context to use. 124 | @discussion JavaScript values that are on the machine stack, in a register, 125 | protected by JSValueProtect, set as the global object of an execution context, 126 | or reachable from any such value will not be collected. 127 | 128 | During JavaScript execution, you are not required to call this function; the 129 | JavaScript engine will garbage collect as needed. JavaScript values created 130 | within a context group are automatically destroyed when the last reference 131 | to the context group is released. 132 | */ 133 | JS_EXPORT void JSGarbageCollect(JSContextRef ctx); 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | /* Enable the Objective-C API for platforms with a modern runtime. */ 140 | #if !defined(JSC_OBJC_API_ENABLED) 141 | #define JSC_OBJC_API_ENABLED (defined(__clang__) && defined(__APPLE__) && ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && !defined(__i386__)) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE))) 142 | #endif 143 | 144 | #endif /* JSBase_h */ 145 | -------------------------------------------------------------------------------- /include/JavaScriptCore/JSContextRef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSContextRef_h 27 | #define JSContextRef_h 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #ifndef __cplusplus 34 | #include 35 | #endif 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /*! 42 | @function 43 | @abstract Creates a JavaScript context group. 44 | @discussion A JSContextGroup associates JavaScript contexts with one another. 45 | Contexts in the same group may share and exchange JavaScript objects. Sharing and/or exchanging 46 | JavaScript objects between contexts in different groups will produce undefined behavior. 47 | When objects from the same context group are used in multiple threads, explicit 48 | synchronization is required. 49 | @result The created JSContextGroup. 50 | */ 51 | JS_EXPORT JSContextGroupRef JSContextGroupCreate(void) CF_AVAILABLE(10_6, 7_0); 52 | 53 | /*! 54 | @function 55 | @abstract Retains a JavaScript context group. 56 | @param group The JSContextGroup to retain. 57 | @result A JSContextGroup that is the same as group. 58 | */ 59 | JS_EXPORT JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) CF_AVAILABLE(10_6, 7_0); 60 | 61 | /*! 62 | @function 63 | @abstract Releases a JavaScript context group. 64 | @param group The JSContextGroup to release. 65 | */ 66 | JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) CF_AVAILABLE(10_6, 7_0); 67 | 68 | /*! 69 | @function 70 | @abstract Creates a global JavaScript execution context. 71 | @discussion JSGlobalContextCreate allocates a global object and populates it with all the 72 | built-in JavaScript objects, such as Object, Function, String, and Array. 73 | 74 | In WebKit version 4.0 and later, the context is created in a unique context group. 75 | Therefore, scripts may execute in it concurrently with scripts executing in other contexts. 76 | However, you may not use values created in the context in other contexts. 77 | @param globalObjectClass The class to use when creating the global object. Pass 78 | NULL to use the default object class. 79 | @result A JSGlobalContext with a global object of class globalObjectClass. 80 | */ 81 | JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) CF_AVAILABLE(10_5, 7_0); 82 | 83 | /*! 84 | @function 85 | @abstract Creates a global JavaScript execution context in the context group provided. 86 | @discussion JSGlobalContextCreateInGroup allocates a global object and populates it with 87 | all the built-in JavaScript objects, such as Object, Function, String, and Array. 88 | @param globalObjectClass The class to use when creating the global object. Pass 89 | NULL to use the default object class. 90 | @param group The context group to use. The created global context retains the group. 91 | Pass NULL to create a unique group for the context. 92 | @result A JSGlobalContext with a global object of class globalObjectClass and a context 93 | group equal to group. 94 | */ 95 | JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) CF_AVAILABLE(10_6, 7_0); 96 | 97 | /*! 98 | @function 99 | @abstract Retains a global JavaScript execution context. 100 | @param ctx The JSGlobalContext to retain. 101 | @result A JSGlobalContext that is the same as ctx. 102 | */ 103 | JS_EXPORT JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx); 104 | 105 | /*! 106 | @function 107 | @abstract Releases a global JavaScript execution context. 108 | @param ctx The JSGlobalContext to release. 109 | */ 110 | JS_EXPORT void JSGlobalContextRelease(JSGlobalContextRef ctx); 111 | 112 | /*! 113 | @function 114 | @abstract Gets the global object of a JavaScript execution context. 115 | @param ctx The JSContext whose global object you want to get. 116 | @result ctx's global object. 117 | */ 118 | JS_EXPORT JSObjectRef JSContextGetGlobalObject(JSContextRef ctx); 119 | 120 | /*! 121 | @function 122 | @abstract Gets the context group to which a JavaScript execution context belongs. 123 | @param ctx The JSContext whose group you want to get. 124 | @result ctx's group. 125 | */ 126 | JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) CF_AVAILABLE(10_6, 7_0); 127 | 128 | /*! 129 | @function 130 | @abstract Gets the global context of a JavaScript execution context. 131 | @param ctx The JSContext whose global context you want to get. 132 | @result ctx's global context. 133 | */ 134 | JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) CF_AVAILABLE(10_7, 7_0); 135 | 136 | /*! 137 | @function 138 | @abstract Gets a copy of the name of a context. 139 | @param ctx The JSGlobalContext whose name you want to get. 140 | @result The name for ctx. 141 | @discussion A JSGlobalContext's name is exposed for remote debugging to make it 142 | easier to identify the context you would like to attach to. 143 | */ 144 | JS_EXPORT JSStringRef JSGlobalContextCopyName(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0); 145 | 146 | /*! 147 | @function 148 | @abstract Sets the remote debugging name for a context. 149 | @param ctx The JSGlobalContext that you want to name. 150 | @param name The remote debugging name to set on ctx. 151 | */ 152 | JS_EXPORT void JSGlobalContextSetName(JSGlobalContextRef ctx, JSStringRef name) CF_AVAILABLE(10_10, 8_0); 153 | 154 | #ifdef __cplusplus 155 | } 156 | #endif 157 | 158 | #endif /* JSContextRef_h */ 159 | -------------------------------------------------------------------------------- /include/JavaScriptCore/JSObjectRefPrivate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Apple Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 | * THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSObjectRefPrivate_h 27 | #define JSObjectRefPrivate_h 28 | 29 | #include 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /*! 36 | @function 37 | @abstract Sets a private property on an object. This private property cannot be accessed from within JavaScript. 38 | @param ctx The execution context to use. 39 | @param object The JSObject whose private property you want to set. 40 | @param propertyName A JSString containing the property's name. 41 | @param value A JSValue to use as the property's value. This may be NULL. 42 | @result true if object can store private data, otherwise false. 43 | @discussion This API allows you to store JS values directly an object in a way that will be ensure that they are kept alive without exposing them to JavaScript code and without introducing the reference cycles that may occur when using JSValueProtect. 44 | 45 | The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private properties. 46 | */ 47 | JS_EXPORT bool JSObjectSetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value); 48 | 49 | /*! 50 | @function 51 | @abstract Gets a private property from an object. 52 | @param ctx The execution context to use. 53 | @param object The JSObject whose private property you want to get. 54 | @param propertyName A JSString containing the property's name. 55 | @result The property's value if object has the property, otherwise NULL. 56 | */ 57 | JS_EXPORT JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 58 | 59 | /*! 60 | @function 61 | @abstract Deletes a private property from an object. 62 | @param ctx The execution context to use. 63 | @param object The JSObject whose private property you want to delete. 64 | @param propertyName A JSString containing the property's name. 65 | @result true if object can store private data, otherwise false. 66 | @discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data. 67 | */ 68 | JS_EXPORT bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif // JSObjectRefPrivate_h 75 | -------------------------------------------------------------------------------- /include/JavaScriptCore/JSRetainPtr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of Apple Inc. ("Apple") nor the names of 14 | * its contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef JSRetainPtr_h 30 | #define JSRetainPtr_h 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | inline void JSRetain(JSStringRef string) { JSStringRetain(string); } 37 | inline void JSRelease(JSStringRef string) { JSStringRelease(string); } 38 | inline void JSRetain(JSGlobalContextRef context) { JSGlobalContextRetain(context); } 39 | inline void JSRelease(JSGlobalContextRef context) { JSGlobalContextRelease(context); } 40 | 41 | enum AdoptTag { Adopt }; 42 | 43 | template class JSRetainPtr { 44 | public: 45 | JSRetainPtr() : m_ptr(0) { } 46 | JSRetainPtr(T ptr) : m_ptr(ptr) { if (ptr) JSRetain(ptr); } 47 | JSRetainPtr(AdoptTag, T ptr) : m_ptr(ptr) { } 48 | JSRetainPtr(const JSRetainPtr&); 49 | template JSRetainPtr(const JSRetainPtr&); 50 | ~JSRetainPtr(); 51 | 52 | T get() const { return m_ptr; } 53 | 54 | void clear(); 55 | T leakRef(); 56 | 57 | T operator->() const { return m_ptr; } 58 | 59 | bool operator!() const { return !m_ptr; } 60 | explicit operator bool() const { return m_ptr; } 61 | 62 | JSRetainPtr& operator=(const JSRetainPtr&); 63 | template JSRetainPtr& operator=(const JSRetainPtr&); 64 | JSRetainPtr& operator=(T); 65 | template JSRetainPtr& operator=(U*); 66 | 67 | void adopt(T); 68 | 69 | void swap(JSRetainPtr&); 70 | 71 | private: 72 | T m_ptr; 73 | }; 74 | 75 | inline JSRetainPtr adopt(JSStringRef o) 76 | { 77 | return JSRetainPtr(Adopt, o); 78 | } 79 | 80 | inline JSRetainPtr adopt(JSGlobalContextRef o) 81 | { 82 | return JSRetainPtr(Adopt, o); 83 | } 84 | 85 | template inline JSRetainPtr::JSRetainPtr(const JSRetainPtr& o) 86 | : m_ptr(o.m_ptr) 87 | { 88 | if (m_ptr) 89 | JSRetain(m_ptr); 90 | } 91 | 92 | template template inline JSRetainPtr::JSRetainPtr(const JSRetainPtr& o) 93 | : m_ptr(o.get()) 94 | { 95 | if (m_ptr) 96 | JSRetain(m_ptr); 97 | } 98 | 99 | template inline JSRetainPtr::~JSRetainPtr() 100 | { 101 | if (m_ptr) 102 | JSRelease(m_ptr); 103 | } 104 | 105 | template inline void JSRetainPtr::clear() 106 | { 107 | if (T ptr = m_ptr) { 108 | m_ptr = 0; 109 | JSRelease(ptr); 110 | } 111 | } 112 | 113 | template inline T JSRetainPtr::leakRef() 114 | { 115 | T ptr = m_ptr; 116 | m_ptr = 0; 117 | return ptr; 118 | } 119 | 120 | template inline JSRetainPtr& JSRetainPtr::operator=(const JSRetainPtr& o) 121 | { 122 | T optr = o.get(); 123 | if (optr) 124 | JSRetain(optr); 125 | T ptr = m_ptr; 126 | m_ptr = optr; 127 | if (ptr) 128 | JSRelease(ptr); 129 | return *this; 130 | } 131 | 132 | template template inline JSRetainPtr& JSRetainPtr::operator=(const JSRetainPtr& o) 133 | { 134 | T optr = o.get(); 135 | if (optr) 136 | JSRetain(optr); 137 | T ptr = m_ptr; 138 | m_ptr = optr; 139 | if (ptr) 140 | JSRelease(ptr); 141 | return *this; 142 | } 143 | 144 | template inline JSRetainPtr& JSRetainPtr::operator=(T optr) 145 | { 146 | if (optr) 147 | JSRetain(optr); 148 | T ptr = m_ptr; 149 | m_ptr = optr; 150 | if (ptr) 151 | JSRelease(ptr); 152 | return *this; 153 | } 154 | 155 | template inline void JSRetainPtr::adopt(T optr) 156 | { 157 | T ptr = m_ptr; 158 | m_ptr = optr; 159 | if (ptr) 160 | JSRelease(ptr); 161 | } 162 | 163 | template template inline JSRetainPtr& JSRetainPtr::operator=(U* optr) 164 | { 165 | if (optr) 166 | JSRetain(optr); 167 | T ptr = m_ptr; 168 | m_ptr = optr; 169 | if (ptr) 170 | JSRelease(ptr); 171 | return *this; 172 | } 173 | 174 | template inline void JSRetainPtr::swap(JSRetainPtr& o) 175 | { 176 | std::swap(m_ptr, o.m_ptr); 177 | } 178 | 179 | template inline void swap(JSRetainPtr& a, JSRetainPtr& b) 180 | { 181 | a.swap(b); 182 | } 183 | 184 | template inline bool operator==(const JSRetainPtr& a, const JSRetainPtr& b) 185 | { 186 | return a.get() == b.get(); 187 | } 188 | 189 | template inline bool operator==(const JSRetainPtr& a, U* b) 190 | { 191 | return a.get() == b; 192 | } 193 | 194 | template inline bool operator==(T* a, const JSRetainPtr& b) 195 | { 196 | return a == b.get(); 197 | } 198 | 199 | template inline bool operator!=(const JSRetainPtr& a, const JSRetainPtr& b) 200 | { 201 | return a.get() != b.get(); 202 | } 203 | 204 | template inline bool operator!=(const JSRetainPtr& a, U* b) 205 | { 206 | return a.get() != b; 207 | } 208 | 209 | template inline bool operator!=(T* a, const JSRetainPtr& b) 210 | { 211 | return a != b.get(); 212 | } 213 | 214 | 215 | #endif // JSRetainPtr_h 216 | -------------------------------------------------------------------------------- /include/JavaScriptCore/JSStringRef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSStringRef_h 27 | #define JSStringRef_h 28 | 29 | #include 30 | 31 | #ifndef __cplusplus 32 | #include 33 | #endif 34 | #include /* for size_t */ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #if !defined(_NATIVE_WCHAR_T_DEFINED) /* MSVC */ \ 41 | && (!defined(__WCHAR_MAX__) || (__WCHAR_MAX__ > 0xffffU)) /* ISO C/C++ */ \ 42 | && (!defined(WCHAR_MAX) || (WCHAR_MAX > 0xffffU)) /* RVCT */ 43 | /*! 44 | @typedef JSChar 45 | @abstract A UTF-16 code unit. One, or a sequence of two, can encode any Unicode 46 | character. As with all scalar types, endianness depends on the underlying 47 | architecture. 48 | */ 49 | typedef unsigned short JSChar; 50 | #else 51 | typedef wchar_t JSChar; 52 | #endif 53 | 54 | /*! 55 | @function 56 | @abstract Creates a JavaScript string from a buffer of Unicode characters. 57 | @param chars The buffer of Unicode characters to copy into the new JSString. 58 | @param numChars The number of characters to copy from the buffer pointed to by chars. 59 | @result A JSString containing chars. Ownership follows the Create Rule. 60 | */ 61 | JS_EXPORT JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars); 62 | /*! 63 | @function 64 | @abstract Creates a JavaScript string from a null-terminated UTF8 string. 65 | @param string The null-terminated UTF8 string to copy into the new JSString. 66 | @result A JSString containing string. Ownership follows the Create Rule. 67 | */ 68 | JS_EXPORT JSStringRef JSStringCreateWithUTF8CString(const char* string); 69 | 70 | /*! 71 | @function 72 | @abstract Retains a JavaScript string. 73 | @param string The JSString to retain. 74 | @result A JSString that is the same as string. 75 | */ 76 | JS_EXPORT JSStringRef JSStringRetain(JSStringRef string); 77 | /*! 78 | @function 79 | @abstract Releases a JavaScript string. 80 | @param string The JSString to release. 81 | */ 82 | JS_EXPORT void JSStringRelease(JSStringRef string); 83 | 84 | /*! 85 | @function 86 | @abstract Returns the number of Unicode characters in a JavaScript string. 87 | @param string The JSString whose length (in Unicode characters) you want to know. 88 | @result The number of Unicode characters stored in string. 89 | */ 90 | JS_EXPORT size_t JSStringGetLength(JSStringRef string); 91 | /*! 92 | @function 93 | @abstract Returns a pointer to the Unicode character buffer that 94 | serves as the backing store for a JavaScript string. 95 | @param string The JSString whose backing store you want to access. 96 | @result A pointer to the Unicode character buffer that serves as string's 97 | backing store, which will be deallocated when string is deallocated. 98 | */ 99 | JS_EXPORT const JSChar* JSStringGetCharactersPtr(JSStringRef string); 100 | 101 | /*! 102 | @function 103 | @abstract Returns the maximum number of bytes a JavaScript string will 104 | take up if converted into a null-terminated UTF8 string. 105 | @param string The JSString whose maximum converted size (in bytes) you 106 | want to know. 107 | @result The maximum number of bytes that could be required to convert string into a 108 | null-terminated UTF8 string. The number of bytes that the conversion actually ends 109 | up requiring could be less than this, but never more. 110 | */ 111 | JS_EXPORT size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string); 112 | /*! 113 | @function 114 | @abstract Converts a JavaScript string into a null-terminated UTF8 string, 115 | and copies the result into an external byte buffer. 116 | @param string The source JSString. 117 | @param buffer The destination byte buffer into which to copy a null-terminated 118 | UTF8 representation of string. On return, buffer contains a UTF8 string 119 | representation of string. If bufferSize is too small, buffer will contain only 120 | partial results. If buffer is not at least bufferSize bytes in size, 121 | behavior is undefined. 122 | @param bufferSize The size of the external buffer in bytes. 123 | @result The number of bytes written into buffer (including the null-terminator byte). 124 | */ 125 | JS_EXPORT size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize); 126 | 127 | /*! 128 | @function 129 | @abstract Tests whether two JavaScript strings match. 130 | @param a The first JSString to test. 131 | @param b The second JSString to test. 132 | @result true if the two strings match, otherwise false. 133 | */ 134 | JS_EXPORT bool JSStringIsEqual(JSStringRef a, JSStringRef b); 135 | /*! 136 | @function 137 | @abstract Tests whether a JavaScript string matches a null-terminated UTF8 string. 138 | @param a The JSString to test. 139 | @param b The null-terminated UTF8 string to test. 140 | @result true if the two strings match, otherwise false. 141 | */ 142 | JS_EXPORT bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b); 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif 147 | 148 | #endif /* JSStringRef_h */ 149 | -------------------------------------------------------------------------------- /include/JavaScriptCore/JSTypedArray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Dominic Szablewski (dominic@phoboslab.org) 3 | * Copyright (C) 2015-2016 Apple Inc. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef JSTypedArray_h 28 | #define JSTypedArray_h 29 | 30 | #include 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | // ------------- Typed Array functions -------------- 38 | 39 | /*! 40 | @function 41 | @abstract Creates a JavaScript Typed Array object with the given number of elements. 42 | @param ctx The execution context to use. 43 | @param arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned. 44 | @param length The number of elements to be in the new Typed Array. 45 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 46 | @result A JSObjectRef that is a Typed Array with all elements set to zero or NULL if there was an error. 47 | */ 48 | JS_EXPORT JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType, size_t length, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 49 | 50 | /*! 51 | @function 52 | @abstract Creates a JavaScript Typed Array object from an existing pointer. 53 | @param ctx The execution context to use. 54 | @param arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned. 55 | @param bytes A pointer to the byte buffer to be used as the backing store of the Typed Array object. 56 | @param byteLength The number of bytes pointed to by the parameter bytes. 57 | @param bytesDeallocator The allocator to use to deallocate the external buffer when the JSTypedArrayData object is deallocated. 58 | @param deallocatorContext A pointer to pass back to the deallocator. 59 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 60 | @result A JSObjectRef Typed Array whose backing store is the same as the one pointed to by bytes or NULL if there was an error. 61 | @discussion If an exception is thrown during this function the bytesDeallocator will always be called. 62 | */ 63 | JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithBytesNoCopy(JSContextRef ctx, JSTypedArrayType arrayType, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 64 | 65 | /*! 66 | @function 67 | @abstract Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object. 68 | @param ctx The execution context to use. 69 | @param arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned. 70 | @param buffer An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object. 71 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 72 | @result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer. 73 | */ 74 | JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBuffer(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 75 | 76 | /*! 77 | @function 78 | @abstract Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object with the given offset and length. 79 | @param ctx The execution context to use. 80 | @param arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned. 81 | @param buffer An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object. 82 | @param byteOffset The byte offset for the created Typed Array. byteOffset should aligned with the element size of arrayType. 83 | @param length The number of elements to include in the Typed Array. 84 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 85 | @result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer. 86 | */ 87 | JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBufferAndOffset(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, size_t byteOffset, size_t length, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 88 | 89 | /*! 90 | @function 91 | @abstract Returns a temporary pointer to the backing store of a JavaScript Typed Array object. 92 | @param ctx The execution context to use. 93 | @param object The Typed Array object whose backing store pointer to return. 94 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 95 | @result A pointer to the raw data buffer that serves as object's backing store or NULL if object is not a Typed Array object. 96 | @discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls. 97 | */ 98 | JS_EXPORT void* JSObjectGetTypedArrayBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 99 | 100 | /*! 101 | @function 102 | @abstract Returns the length of a JavaScript Typed Array object. 103 | @param ctx The execution context to use. 104 | @param object The Typed Array object whose length to return. 105 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 106 | @result The length of the Typed Array object or 0 if the object is not a Typed Array object. 107 | */ 108 | JS_EXPORT size_t JSObjectGetTypedArrayLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 109 | 110 | /*! 111 | @function 112 | @abstract Returns the byte length of a JavaScript Typed Array object. 113 | @param ctx The execution context to use. 114 | @param object The Typed Array object whose byte length to return. 115 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 116 | @result The byte length of the Typed Array object or 0 if the object is not a Typed Array object. 117 | */ 118 | JS_EXPORT size_t JSObjectGetTypedArrayByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 119 | 120 | /*! 121 | @function 122 | @abstract Returns the byte offset of a JavaScript Typed Array object. 123 | @param ctx The execution context to use. 124 | @param object The Typed Array object whose byte offset to return. 125 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 126 | @result The byte offset of the Typed Array object or 0 if the object is not a Typed Array object. 127 | */ 128 | JS_EXPORT size_t JSObjectGetTypedArrayByteOffset(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 129 | 130 | /*! 131 | @function 132 | @abstract Returns the JavaScript Array Buffer object that is used as the backing of a JavaScript Typed Array object. 133 | @param ctx The execution context to use. 134 | @param object The JSObjectRef whose Typed Array type data pointer to obtain. 135 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 136 | @result A JSObjectRef with a JSTypedArrayType of kJSTypedArrayTypeArrayBuffer or NULL if object is not a Typed Array. 137 | */ 138 | JS_EXPORT JSObjectRef JSObjectGetTypedArrayBuffer(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 139 | 140 | // ------------- Array Buffer functions ------------- 141 | 142 | /*! 143 | @function 144 | @abstract Creates a JavaScript Array Buffer object from an existing pointer. 145 | @param ctx The execution context to use. 146 | @param bytes A pointer to the byte buffer to be used as the backing store of the Typed Array object. 147 | @param byteLength The number of bytes pointed to by the parameter bytes. 148 | @param bytesDeallocator The allocator to use to deallocate the external buffer when the Typed Array data object is deallocated. 149 | @param deallocatorContext A pointer to pass back to the deallocator. 150 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 151 | @result A JSObjectRef Array Buffer whose backing store is the same as the one pointed to by bytes or NULL if there was an error. 152 | @discussion If an exception is thrown during this function the bytesDeallocator will always be called. 153 | */ 154 | JS_EXPORT JSObjectRef JSObjectMakeArrayBufferWithBytesNoCopy(JSContextRef ctx, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 155 | 156 | /*! 157 | @function 158 | @abstract Returns a pointer to the data buffer that serves as the backing store for a JavaScript Typed Array object. 159 | @param object The Array Buffer object whose internal backing store pointer to return. 160 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 161 | @result A pointer to the raw data buffer that serves as object's backing store or NULL if object is not an Array Buffer object. 162 | @discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls. 163 | */ 164 | JS_EXPORT void* JSObjectGetArrayBufferBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 165 | 166 | /*! 167 | @function 168 | @abstract Returns the number of bytes in a JavaScript data object. 169 | @param ctx The execution context to use. 170 | @param object The JS Arary Buffer object whose length in bytes to return. 171 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 172 | @result The number of bytes stored in the data object. 173 | */ 174 | JS_EXPORT size_t JSObjectGetArrayBufferByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 175 | 176 | #ifdef __cplusplus 177 | } 178 | #endif 179 | 180 | #endif /* JSTypedArray_h */ 181 | -------------------------------------------------------------------------------- /include/JavaScriptCore/JSValueRef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSValueRef_h 27 | #define JSValueRef_h 28 | 29 | #include 30 | #include 31 | 32 | #ifndef __cplusplus 33 | #include 34 | #endif 35 | 36 | /*! 37 | @enum JSType 38 | @abstract A constant identifying the type of a JSValue. 39 | @constant kJSTypeUndefined The unique undefined value. 40 | @constant kJSTypeNull The unique null value. 41 | @constant kJSTypeBoolean A primitive boolean value, one of true or false. 42 | @constant kJSTypeNumber A primitive number value. 43 | @constant kJSTypeString A primitive string value. 44 | @constant kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef). 45 | */ 46 | typedef enum { 47 | kJSTypeUndefined, 48 | kJSTypeNull, 49 | kJSTypeBoolean, 50 | kJSTypeNumber, 51 | kJSTypeString, 52 | kJSTypeObject 53 | } JSType; 54 | 55 | /*! 56 | @enum JSTypedArrayType 57 | @abstract A constant identifying the Typed Array type of a JSObjectRef. 58 | @constant kJSTypedArrayTypeInt8Array Int8Array 59 | @constant kJSTypedArrayTypeInt16Array Int16Array 60 | @constant kJSTypedArrayTypeInt32Array Int32Array 61 | @constant kJSTypedArrayTypeUint8Array Uint8Array 62 | @constant kJSTypedArrayTypeUint8ClampedArray Uint8ClampedArray 63 | @constant kJSTypedArrayTypeUint16Array Uint16Array 64 | @constant kJSTypedArrayTypeUint32Array Uint32Array 65 | @constant kJSTypedArrayTypeFloat32Array Float32Array 66 | @constant kJSTypedArrayTypeFloat64Array Float64Array 67 | @constant kJSTypedArrayTypeArrayBuffer ArrayBuffer 68 | @constant kJSTypedArrayTypeNone Not a Typed Array 69 | 70 | */ 71 | typedef enum { 72 | kJSTypedArrayTypeInt8Array, 73 | kJSTypedArrayTypeInt16Array, 74 | kJSTypedArrayTypeInt32Array, 75 | kJSTypedArrayTypeUint8Array, 76 | kJSTypedArrayTypeUint8ClampedArray, 77 | kJSTypedArrayTypeUint16Array, 78 | kJSTypedArrayTypeUint32Array, 79 | kJSTypedArrayTypeFloat32Array, 80 | kJSTypedArrayTypeFloat64Array, 81 | kJSTypedArrayTypeArrayBuffer, 82 | kJSTypedArrayTypeNone, 83 | } JSTypedArrayType CF_ENUM_AVAILABLE(10_12, 10_0); 84 | 85 | #ifdef __cplusplus 86 | extern "C" { 87 | #endif 88 | 89 | /*! 90 | @function 91 | @abstract Returns a JavaScript value's type. 92 | @param ctx The execution context to use. 93 | @param value The JSValue whose type you want to obtain. 94 | @result A value of type JSType that identifies value's type. 95 | */ 96 | JS_EXPORT JSType JSValueGetType(JSContextRef ctx, JSValueRef value); 97 | 98 | /*! 99 | @function 100 | @abstract Tests whether a JavaScript value's type is the undefined type. 101 | @param ctx The execution context to use. 102 | @param value The JSValue to test. 103 | @result true if value's type is the undefined type, otherwise false. 104 | */ 105 | JS_EXPORT bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value); 106 | 107 | /*! 108 | @function 109 | @abstract Tests whether a JavaScript value's type is the null type. 110 | @param ctx The execution context to use. 111 | @param value The JSValue to test. 112 | @result true if value's type is the null type, otherwise false. 113 | */ 114 | JS_EXPORT bool JSValueIsNull(JSContextRef ctx, JSValueRef value); 115 | 116 | /*! 117 | @function 118 | @abstract Tests whether a JavaScript value's type is the boolean type. 119 | @param ctx The execution context to use. 120 | @param value The JSValue to test. 121 | @result true if value's type is the boolean type, otherwise false. 122 | */ 123 | JS_EXPORT bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value); 124 | 125 | /*! 126 | @function 127 | @abstract Tests whether a JavaScript value's type is the number type. 128 | @param ctx The execution context to use. 129 | @param value The JSValue to test. 130 | @result true if value's type is the number type, otherwise false. 131 | */ 132 | JS_EXPORT bool JSValueIsNumber(JSContextRef ctx, JSValueRef value); 133 | 134 | /*! 135 | @function 136 | @abstract Tests whether a JavaScript value's type is the string type. 137 | @param ctx The execution context to use. 138 | @param value The JSValue to test. 139 | @result true if value's type is the string type, otherwise false. 140 | */ 141 | JS_EXPORT bool JSValueIsString(JSContextRef ctx, JSValueRef value); 142 | 143 | /*! 144 | @function 145 | @abstract Tests whether a JavaScript value's type is the object type. 146 | @param ctx The execution context to use. 147 | @param value The JSValue to test. 148 | @result true if value's type is the object type, otherwise false. 149 | */ 150 | JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value); 151 | 152 | /*! 153 | @function 154 | @abstract Tests whether a JavaScript value is an object with a given class in its class chain. 155 | @param ctx The execution context to use. 156 | @param value The JSValue to test. 157 | @param jsClass The JSClass to test against. 158 | @result true if value is an object and has jsClass in its class chain, otherwise false. 159 | */ 160 | JS_EXPORT bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass); 161 | 162 | /*! 163 | @function 164 | @abstract Tests whether a JavaScript value is an array. 165 | @param ctx The execution context to use. 166 | @param value The JSValue to test. 167 | @result true if value is an array, otherwise false. 168 | */ 169 | JS_EXPORT bool JSValueIsArray(JSContextRef ctx, JSValueRef value) CF_AVAILABLE(10_11, 9_0); 170 | 171 | /*! 172 | @function 173 | @abstract Tests whether a JavaScript value is a date. 174 | @param ctx The execution context to use. 175 | @param value The JSValue to test. 176 | @result true if value is a date, otherwise false. 177 | */ 178 | JS_EXPORT bool JSValueIsDate(JSContextRef ctx, JSValueRef value) CF_AVAILABLE(10_11, 9_0); 179 | 180 | /*! 181 | @function 182 | @abstract Returns a JavaScript value's Typed Array type. 183 | @param ctx The execution context to use. 184 | @param value The JSValue whose Typed Array type to return. 185 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 186 | @result A value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object. 187 | */ 188 | JS_EXPORT JSTypedArrayType JSValueGetTypedArrayType(JSContextRef ctx, JSValueRef value, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 189 | 190 | /* Comparing values */ 191 | 192 | /*! 193 | @function 194 | @abstract Tests whether two JavaScript values are equal, as compared by the JS == operator. 195 | @param ctx The execution context to use. 196 | @param a The first value to test. 197 | @param b The second value to test. 198 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 199 | @result true if the two values are equal, false if they are not equal or an exception is thrown. 200 | */ 201 | JS_EXPORT bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception); 202 | 203 | /*! 204 | @function 205 | @abstract Tests whether two JavaScript values are strict equal, as compared by the JS === operator. 206 | @param ctx The execution context to use. 207 | @param a The first value to test. 208 | @param b The second value to test. 209 | @result true if the two values are strict equal, otherwise false. 210 | */ 211 | JS_EXPORT bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b); 212 | 213 | /*! 214 | @function 215 | @abstract Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator. 216 | @param ctx The execution context to use. 217 | @param value The JSValue to test. 218 | @param constructor The constructor to test against. 219 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 220 | @result true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false. 221 | */ 222 | JS_EXPORT bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception); 223 | 224 | /* Creating values */ 225 | 226 | /*! 227 | @function 228 | @abstract Creates a JavaScript value of the undefined type. 229 | @param ctx The execution context to use. 230 | @result The unique undefined value. 231 | */ 232 | JS_EXPORT JSValueRef JSValueMakeUndefined(JSContextRef ctx); 233 | 234 | /*! 235 | @function 236 | @abstract Creates a JavaScript value of the null type. 237 | @param ctx The execution context to use. 238 | @result The unique null value. 239 | */ 240 | JS_EXPORT JSValueRef JSValueMakeNull(JSContextRef ctx); 241 | 242 | /*! 243 | @function 244 | @abstract Creates a JavaScript value of the boolean type. 245 | @param ctx The execution context to use. 246 | @param boolean The bool to assign to the newly created JSValue. 247 | @result A JSValue of the boolean type, representing the value of boolean. 248 | */ 249 | JS_EXPORT JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool boolean); 250 | 251 | /*! 252 | @function 253 | @abstract Creates a JavaScript value of the number type. 254 | @param ctx The execution context to use. 255 | @param number The double to assign to the newly created JSValue. 256 | @result A JSValue of the number type, representing the value of number. 257 | */ 258 | JS_EXPORT JSValueRef JSValueMakeNumber(JSContextRef ctx, double number); 259 | 260 | /*! 261 | @function 262 | @abstract Creates a JavaScript value of the string type. 263 | @param ctx The execution context to use. 264 | @param string The JSString to assign to the newly created JSValue. The 265 | newly created JSValue retains string, and releases it upon garbage collection. 266 | @result A JSValue of the string type, representing the value of string. 267 | */ 268 | JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string); 269 | 270 | /* Converting to and from JSON formatted strings */ 271 | 272 | /*! 273 | @function 274 | @abstract Creates a JavaScript value from a JSON formatted string. 275 | @param ctx The execution context to use. 276 | @param string The JSString containing the JSON string to be parsed. 277 | @result A JSValue containing the parsed value, or NULL if the input is invalid. 278 | */ 279 | JS_EXPORT JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) CF_AVAILABLE(10_7, 7_0); 280 | 281 | /*! 282 | @function 283 | @abstract Creates a JavaScript string containing the JSON serialized representation of a JS value. 284 | @param ctx The execution context to use. 285 | @param value The value to serialize. 286 | @param indent The number of spaces to indent when nesting. If 0, the resulting JSON will not contains newlines. The size of the indent is clamped to 10 spaces. 287 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 288 | @result A JSString with the result of serialization, or NULL if an exception is thrown. 289 | */ 290 | JS_EXPORT JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef value, unsigned indent, JSValueRef* exception) CF_AVAILABLE(10_7, 7_0); 291 | 292 | /* Converting to primitive values */ 293 | 294 | /*! 295 | @function 296 | @abstract Converts a JavaScript value to boolean and returns the resulting boolean. 297 | @param ctx The execution context to use. 298 | @param value The JSValue to convert. 299 | @result The boolean result of conversion. 300 | */ 301 | JS_EXPORT bool JSValueToBoolean(JSContextRef ctx, JSValueRef value); 302 | 303 | /*! 304 | @function 305 | @abstract Converts a JavaScript value to number and returns the resulting number. 306 | @param ctx The execution context to use. 307 | @param value The JSValue to convert. 308 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 309 | @result The numeric result of conversion, or NaN if an exception is thrown. 310 | */ 311 | JS_EXPORT double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception); 312 | 313 | /*! 314 | @function 315 | @abstract Converts a JavaScript value to string and copies the result into a JavaScript string. 316 | @param ctx The execution context to use. 317 | @param value The JSValue to convert. 318 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 319 | @result A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule. 320 | */ 321 | JS_EXPORT JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception); 322 | 323 | /*! 324 | @function 325 | @abstract Converts a JavaScript value to object and returns the resulting object. 326 | @param ctx The execution context to use. 327 | @param value The JSValue to convert. 328 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 329 | @result The JSObject result of conversion, or NULL if an exception is thrown. 330 | */ 331 | JS_EXPORT JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception); 332 | 333 | /* Garbage collection */ 334 | /*! 335 | @function 336 | @abstract Protects a JavaScript value from garbage collection. 337 | @param ctx The execution context to use. 338 | @param value The JSValue to protect. 339 | @discussion Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it. 340 | 341 | A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection. 342 | */ 343 | JS_EXPORT void JSValueProtect(JSContextRef ctx, JSValueRef value); 344 | 345 | /*! 346 | @function 347 | @abstract Unprotects a JavaScript value from garbage collection. 348 | @param ctx The execution context to use. 349 | @param value The JSValue to unprotect. 350 | @discussion A value may be protected multiple times and must be unprotected an 351 | equal number of times before becoming eligible for garbage collection. 352 | */ 353 | JS_EXPORT void JSValueUnprotect(JSContextRef ctx, JSValueRef value); 354 | 355 | #ifdef __cplusplus 356 | } 357 | #endif 358 | 359 | #endif /* JSValueRef_h */ 360 | -------------------------------------------------------------------------------- /include/JavaScriptCore/JavaScript.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Inc. All rights reserved. 3 | * Copyright (C) 2008 Alp Toker 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef JavaScript_h 28 | #define JavaScript_h 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif /* JavaScript_h */ 38 | -------------------------------------------------------------------------------- /include/JavaScriptCore/WebKitAvailability.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008, 2009, 2010, 2014 Apple Inc. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef __WebKitAvailability__ 27 | #define __WebKitAvailability__ 28 | 29 | #if defined(__APPLE__) && defined(DEFINE_AVAILABILITY_MACROS) 30 | 31 | #include 32 | #include 33 | 34 | #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED < 101100 35 | /* To support availability macros that mention newer OS X versions when building on older OS X versions, 36 | we provide our own definitions of the underlying macros that the availability macros expand to. We're 37 | free to expand the macros as no-ops since frameworks built on older OS X versions only ship bundled with 38 | an application rather than as part of the system. 39 | */ 40 | 41 | #ifndef __NSi_10_10 // Building from trunk rather than SDK. 42 | #define __NSi_10_10 introduced=10.0 // Use 10.0 to indicate that everything is available. 43 | #endif 44 | 45 | #ifndef __NSi_10_11 // Building from trunk rather than SDK. 46 | #define __NSi_10_11 introduced=10.0 // Use 10.0 to indicate that everything is available. 47 | #endif 48 | 49 | #ifndef __NSi_10_12 // Building from trunk rather than SDK. 50 | #define __NSi_10_12 introduced=10.0 // Use 10.0 to indicate that everything is available. 51 | #endif 52 | 53 | #ifndef __AVAILABILITY_INTERNAL__MAC_10_9 54 | #define __AVAILABILITY_INTERNAL__MAC_10_9 55 | #endif 56 | 57 | #ifndef __AVAILABILITY_INTERNAL__MAC_10_10 58 | #define __AVAILABILITY_INTERNAL__MAC_10_10 59 | #endif 60 | 61 | #ifndef AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER 62 | #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER 63 | #endif 64 | 65 | #ifndef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER 66 | #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER 67 | #endif 68 | 69 | #endif /* __MAC_OS_X_VERSION_MIN_REQUIRED <= 101100 */ 70 | 71 | #if defined(BUILDING_GTK__) 72 | #undef CF_AVAILABLE 73 | #define CF_AVAILABLE(_mac, _ios) 74 | #undef CF_ENUM_AVAILABLE 75 | #define CF_ENUM_AVAILABLE(_mac, _ios) 76 | #endif 77 | 78 | #else 79 | #ifndef CF_AVAILABLE 80 | #define CF_AVAILABLE(_mac, _ios) 81 | #define CF_ENUM_AVAILABLE(_mac, _ios) 82 | #endif 83 | #endif 84 | 85 | #endif /* __WebKitAvailability__ */ 86 | -------------------------------------------------------------------------------- /include/Ultralight/CAPI.h: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file CAPI.h 3 | /// 4 | /// @brief The C-language API for Ultralight 5 | /// 6 | /// @author 7 | /// 8 | /// This file is a part of Ultralight, a fast, lightweight, HTML UI engine 9 | /// 10 | /// Website: 11 | /// 12 | /// Copyright (C) 2019 Ultralight, Inc. All rights reserved. 13 | /// 14 | #ifndef ULTRALIGHT_CAPI_H 15 | #define ULTRALIGHT_CAPI_H 16 | 17 | #ifndef __cplusplus 18 | //#include 19 | #endif 20 | 21 | #include 22 | #include 23 | #ifdef __OBJC__ 24 | #import 25 | #endif 26 | 27 | #if defined(__WIN32__) || defined(_WIN32) 28 | # if defined(ULTRALIGHT_IMPLEMENTATION) 29 | # define ULExport __declspec(dllexport) 30 | # else 31 | # define ULExport __declspec(dllimport) 32 | # endif 33 | #define _thread_local __declspec(thread) 34 | #ifndef _NATIVE_WCHAR_T_DEFINED 35 | #define DISABLE_NATIVE_WCHAR_T 36 | typedef unsigned short ULChar16; 37 | #else 38 | typedef wchar_t ULChar16; 39 | #endif 40 | #else 41 | # define ULExport __attribute__((visibility("default"))) 42 | #define _thread_local __thread 43 | typedef unsigned short ULChar16; 44 | #endif 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | typedef struct C_Config* ULConfig; 51 | typedef struct C_Renderer* ULRenderer; 52 | typedef struct C_View* ULView; 53 | typedef struct C_Bitmap* ULBitmap; 54 | typedef struct C_String* ULString; 55 | typedef struct C_Buffer* ULBuffer; 56 | typedef struct C_RenderTarget* ULRenderTarget; 57 | typedef struct C_KeyEvent* ULKeyEvent; 58 | typedef struct C_MouseEvent* ULMouseEvent; 59 | typedef struct C_ScrollEvent* ULScrollEvent; 60 | 61 | typedef enum { 62 | kMessageSource_XML = 0, 63 | kMessageSource_JS, 64 | kMessageSource_Network, 65 | kMessageSource_ConsoleAPI, 66 | kMessageSource_Storage, 67 | kMessageSource_AppCache, 68 | kMessageSource_Rendering, 69 | kMessageSource_CSS, 70 | kMessageSource_Security, 71 | kMessageSource_ContentBlocker, 72 | kMessageSource_Other, 73 | } ULMessageSource; 74 | 75 | typedef enum { 76 | kMessageLevel_Log = 1, 77 | kMessageLevel_Warning = 2, 78 | kMessageLevel_Error = 3, 79 | kMessageLevel_Debug = 4, 80 | kMessageLevel_Info = 5, 81 | } ULMessageLevel; 82 | 83 | typedef enum { 84 | kCursor_Pointer = 0, 85 | kCursor_Cross, 86 | kCursor_Hand, 87 | kCursor_IBeam, 88 | kCursor_Wait, 89 | kCursor_Help, 90 | kCursor_EastResize, 91 | kCursor_NorthResize, 92 | kCursor_NorthEastResize, 93 | kCursor_NorthWestResize, 94 | kCursor_SouthResize, 95 | kCursor_SouthEastResize, 96 | kCursor_SouthWestResize, 97 | kCursor_WestResize, 98 | kCursor_NorthSouthResize, 99 | kCursor_EastWestResize, 100 | kCursor_NorthEastSouthWestResize, 101 | kCursor_NorthWestSouthEastResize, 102 | kCursor_ColumnResize, 103 | kCursor_RowResize, 104 | kCursor_MiddlePanning, 105 | kCursor_EastPanning, 106 | kCursor_NorthPanning, 107 | kCursor_NorthEastPanning, 108 | kCursor_NorthWestPanning, 109 | kCursor_SouthPanning, 110 | kCursor_SouthEastPanning, 111 | kCursor_SouthWestPanning, 112 | kCursor_WestPanning, 113 | kCursor_Move, 114 | kCursor_VerticalText, 115 | kCursor_Cell, 116 | kCursor_ContextMenu, 117 | kCursor_Alias, 118 | kCursor_Progress, 119 | kCursor_NoDrop, 120 | kCursor_Copy, 121 | kCursor_None, 122 | kCursor_NotAllowed, 123 | kCursor_ZoomIn, 124 | kCursor_ZoomOut, 125 | kCursor_Grab, 126 | kCursor_Grabbing, 127 | kCursor_Custom 128 | } ULCursor; 129 | 130 | typedef enum { 131 | kBitmapFormat_A8, 132 | kBitmapFormat_RGBA8 133 | } ULBitmapFormat; 134 | 135 | typedef enum { 136 | kKeyEventType_KeyDown, 137 | kKeyEventType_KeyUp, 138 | kKeyEventType_RawKeyDown, 139 | kKeyEventType_Char, 140 | } ULKeyEventType; 141 | 142 | typedef enum { 143 | kMouseEventType_MouseMoved, 144 | kMouseEventType_MouseDown, 145 | kMouseEventType_MouseUp, 146 | } ULMouseEventType; 147 | 148 | typedef enum { 149 | kMouseButton_None = 0, 150 | kMouseButton_Left, 151 | kMouseButton_Middle, 152 | kMouseButton_Right, 153 | } ULMouseButton; 154 | 155 | typedef enum { 156 | kScrollEventType_ScrollByPixel, 157 | kScrollEventType_ScrollByPage, 158 | } ULScrollEventType; 159 | 160 | /****************************************************************************** 161 | * API Note: 162 | * 163 | * You should only destroy objects that you explicitly create. Do not destroy 164 | * any objects returned from the API or callbacks unless otherwise noted. 165 | *****************************************************************************/ 166 | 167 | /****************************************************************************** 168 | * Config 169 | *****************************************************************************/ 170 | 171 | /// 172 | /// Create config with default values (see ). 173 | /// 174 | ULExport ULConfig ulCreateConfig(); 175 | 176 | /// 177 | /// Destroy config. 178 | /// 179 | ULExport void ulDestroyConfig(ULConfig config); 180 | 181 | /// 182 | /// Set whether images should be enabled (Default = True). 183 | /// 184 | ULExport void ulConfigSetEnableImages(ULConfig config, bool enabled); 185 | 186 | /// 187 | /// Set whether JavaScript should be eanbled (Default = True). 188 | /// 189 | ULExport void ulConfigSetEnableJavaScript(ULConfig config, bool enabled); 190 | 191 | /// 192 | /// Set whether we should use BGRA byte order (instead of RGBA) for View 193 | /// bitmaps (Default = False). 194 | /// 195 | ULExport void ulConfigSetUseBGRAForOffscreenRendering(ULConfig config, 196 | bool enabled); 197 | 198 | /// 199 | /// Set the amount that the application DPI has been scaled, used for 200 | /// scaling device coordinates to pixels and oversampling raster shapes 201 | /// (Default = 1.0). 202 | /// 203 | ULExport void ulConfigSetDeviceScaleHint(ULConfig config, double value); 204 | 205 | /// 206 | /// Set default font-family to use (Default = Times New Roman). 207 | /// 208 | ULExport void ulConfigSetFontFamilyStandard(ULConfig config, 209 | ULString font_name); 210 | 211 | /// 212 | /// Set default font-family to use for fixed fonts, eg
 and 
213 | /// (Default = Courier New).
214 | ///
215 | ULExport void ulConfigSetFontFamilyFixed(ULConfig config, ULString font_name);
216 | 
217 | ///
218 | /// Set default font-family to use for serif fonts (Default = Times New Roman).
219 | ///
220 | ULExport void ulConfigSetFontFamilySerif(ULConfig config, ULString font_name);
221 | 
222 | ///
223 | /// Set default font-family to use for sans-serif fonts (Default = Arial).
224 | ///
225 | ULExport void ulConfigSetFontFamilySansSerif(ULConfig config,
226 |                                              ULString font_name);
227 | 
228 | ///
229 | /// Set user agent string (See  for the default).
230 | ///
231 | ULExport void ulConfigSetUserAgent(ULConfig config, ULString agent_string);
232 | 
233 | ///
234 | /// Set user stylesheet (CSS) (Default = Empty).
235 | ///
236 | ULExport void ulConfigSetUserStylesheet(ULConfig config, ULString css_string);
237 | 
238 | ///
239 | /// Set whether or not we should continuously repaint any Views or compositor
240 | /// layers, regardless if they are dirty or not. This is mainly used to
241 | /// diagnose painting/shader issues. (Default = False)
242 | ///
243 | ULExport void ulConfigSetForceRepaint(ULConfig config, bool enabled);
244 | 
245 | ///
246 | /// Set the amount of time to wait before triggering another repaint when a
247 | /// CSS animation is active. (Default = 1.0 / 60.0)
248 | ///
249 | ULExport void ulConfigSetAnimationTimerDelay(ULConfig config, double delay);
250 | 
251 | ///
252 | /// Set the size of WebCore's memory cache for decoded images, scripts, and
253 | /// other assets in bytes. (Default = 64 * 1024 * 1024)
254 | ///
255 | ULExport void ulConfigSetMemoryCacheSize(ULConfig config, unsigned int size);
256 | 
257 | ///
258 | /// Set the number of pages to keep in the cache. (Default = 0)
259 | ///
260 | ULExport void ulConfigSetPageCacheSize(ULConfig config, unsigned int size);
261 | 
262 | /******************************************************************************
263 |  * Renderer
264 |  *****************************************************************************/
265 | 
266 | ///
267 | /// Create renderer (create this only once per application lifetime).
268 | ///
269 | ULExport ULRenderer ulCreateRenderer(ULConfig config);
270 | 
271 | ///
272 | /// Destroy renderer.
273 | ///
274 | ULExport void ulDestroyRenderer(ULRenderer renderer);
275 | 
276 | ///
277 | /// Update timers and dispatch internal callbacks (JavaScript and network).
278 | ///
279 | ULExport void ulUpdate(ULRenderer renderer);
280 | 
281 | ///
282 | /// Render all active Views to their respective bitmaps.
283 | ///
284 | ULExport void ulRender(ULRenderer renderer);
285 | 
286 | /******************************************************************************
287 |  * View
288 |  *****************************************************************************/
289 | 
290 | ///
291 | /// Create a View with certain size (in device coordinates).
292 | ///
293 | ULExport ULView ulCreateView(ULRenderer renderer, unsigned int width,
294 |                              unsigned int height, bool transparent);
295 | 
296 | ///
297 | /// Destroy a View.
298 | ///
299 | ULExport void ulDestroyView(ULView view);
300 | 
301 | ///
302 | /// Get current URL.
303 | ///
304 | /// @note Don't destroy the returned string, it is owned by the View.
305 | ///
306 | ULExport ULString ulViewGetURL(ULView view);
307 | 
308 | ///
309 | /// Get current title.
310 | ///
311 | /// @note Don't destroy the returned string, it is owned by the View.
312 | ///
313 | ULExport ULString ulViewGetTitle(ULView view);
314 | 
315 | ///
316 | /// Check if main frame is loading.
317 | ///
318 | ULExport bool ulViewIsLoading(ULView view);
319 | 
320 | ///
321 | /// Check if bitmap is dirty (has changed since last call to ulViewGetBitmap).
322 | ///
323 | ULExport bool ulViewIsBitmapDirty(ULView view);
324 | 
325 | ///
326 | /// Get bitmap (will reset the dirty flag).
327 | ///
328 | /// @note Don't destroy the returned bitmap, it is owned by the View.
329 | ///
330 | ULExport ULBitmap ulViewGetBitmap(ULView view);
331 | 
332 | ///
333 | /// Load a raw string of HTML.
334 | ///
335 | ULExport void ulViewLoadHTML(ULView view, ULString html_string);
336 | 
337 | ///
338 | /// Load a URL into main frame.
339 | ///
340 | ULExport void ulViewLoadURL(ULView view, ULString url_string);
341 | 
342 | ///
343 | /// Resize view to a certain width and height (in device coordinates).
344 | ///
345 | ULExport void ulViewResize(ULView view, unsigned int width,
346 |                            unsigned int height);
347 | 
348 | ///
349 | /// Get the page's JSContext for use with JavaScriptCore API.
350 | ///
351 | ULExport JSContextRef ulViewGetJSContext(ULView view);
352 | 
353 | ///
354 | /// Evaluate a raw string of JavaScript and return result.
355 | ///
356 | ULExport JSValueRef ulViewEvaluateScript(ULView view, ULString js_string);
357 | 
358 | ///
359 | /// Check if can navigate backwards in history.
360 | ///
361 | ULExport bool ulViewCanGoBack(ULView view);
362 | 
363 | ///
364 | /// Check if can navigate forwards in history.
365 | ///
366 | ULExport bool ulViewCanGoForward(ULView view);
367 | 
368 | ///
369 | /// Navigate backwards in history.
370 | ///
371 | ULExport void ulViewGoBack(ULView view);
372 | 
373 | ///
374 | /// Navigate forwards in history.
375 | ///
376 | ULExport void ulViewGoForward(ULView view);
377 | 
378 | ///
379 | /// Navigate to arbitrary offset in history.
380 | ///
381 | ULExport void ulViewGoToHistoryOffset(ULView view, int offset);
382 | 
383 | ///
384 | /// Reload current page.
385 | ///
386 | ULExport void ulViewReload(ULView view);
387 | 
388 | ///
389 | /// Stop all page loads.
390 | ///
391 | ULExport void ulViewStop(ULView view);
392 | 
393 | ///
394 | /// Fire a keyboard event.
395 | ///
396 | ULExport void ulViewFireKeyEvent(ULView view, ULKeyEvent key_event);
397 | 
398 | ///
399 | /// Fire a mouse event.
400 | ///
401 | ULExport void ulViewFireMouseEvent(ULView view, ULMouseEvent mouse_event);
402 | 
403 | ///
404 | /// Fire a scroll event.
405 | ///
406 | ULExport void ulViewFireScrollEvent(ULView view, ULScrollEvent scroll_event);
407 | 
408 | typedef void
409 | (*ULChangeTitleCallback) (void* user_data, ULView caller, ULString title);
410 | 
411 | ///
412 | /// Set callback for when the page title changes.
413 | ///
414 | ULExport void ulViewSetChangeTitleCallback(ULView view,
415 |                                            ULChangeTitleCallback callback,
416 |                                            void* user_data);
417 | 
418 | typedef void
419 | (*ULChangeURLCallback) (void* user_data, ULView caller, ULString url);
420 | 
421 | ///
422 | /// Set callback for when the page URL changes.
423 | ///
424 | ULExport void ulViewSetChangeURLCallback(ULView view,
425 |                                          ULChangeURLCallback callback,
426 |                                          void* user_data);
427 | 
428 | typedef void
429 | (*ULChangeTooltipCallback) (void* user_data, ULView caller, ULString tooltip);
430 | 
431 | ///
432 | /// Set callback for when the tooltip changes (usually result of a mouse hover).
433 | ///
434 | ULExport void ulViewSetChangeTooltipCallback(ULView view,
435 |                                              ULChangeTooltipCallback callback,
436 |                                              void* user_data);
437 | 
438 | typedef void
439 | (*ULChangeCursorCallback) (void* user_data, ULView caller, ULCursor cursor);
440 | 
441 | ///
442 | /// Set callback for when the mouse cursor changes.
443 | ///
444 | ULExport void ulViewSetChangeCursorCallback(ULView view,
445 |                                             ULChangeCursorCallback callback,
446 |                                             void* user_data);
447 | 
448 | typedef void
449 | (*ULAddConsoleMessageCallback) (void* user_data, ULView caller,
450 |                                 ULMessageSource source, ULMessageLevel level,
451 |                                 ULString message, unsigned int line_number,
452 |                                 unsigned int column_number,
453 |                                 ULString source_id);
454 | 
455 | ///
456 | /// Set callback for when a message is added to the console (useful for
457 | /// JavaScript / network errors and debugging).
458 | ///
459 | ULExport void ulViewSetAddConsoleMessageCallback(ULView view,
460 |                                           ULAddConsoleMessageCallback callback,
461 |                                           void* user_data);
462 | 
463 | typedef void
464 | (*ULBeginLoadingCallback) (void* user_data, ULView caller);
465 | 
466 | ///
467 | /// Set callback for when the page begins loading new URL into main frame.
468 | ///
469 | ULExport void ulViewSetBeginLoadingCallback(ULView view,
470 |                                             ULBeginLoadingCallback callback,
471 |                                             void* user_data);
472 | 
473 | typedef void
474 | (*ULFinishLoadingCallback) (void* user_data, ULView caller);
475 | 
476 | ///
477 | /// Set callback for when the page finishes loading URL into main frame.
478 | ///
479 | ULExport void ulViewSetFinishLoadingCallback(ULView view,
480 |                                              ULFinishLoadingCallback callback,
481 |                                              void* user_data);
482 | 
483 | typedef void
484 | (*ULUpdateHistoryCallback) (void* user_data, ULView caller);
485 | 
486 | ///
487 | /// Set callback for when the history (back/forward state) is modified.
488 | ///
489 | ULExport void ulViewSetUpdateHistoryCallback(ULView view,
490 |                                              ULUpdateHistoryCallback callback,
491 |                                              void* user_data);
492 | 
493 | typedef void
494 | (*ULDOMReadyCallback) (void* user_data, ULView caller);
495 | 
496 | ///
497 | /// Set callback for when all JavaScript has been parsed and the document is
498 | /// ready. This is the best time to make initial JavaScript calls to your page.
499 | ///
500 | ULExport void ulViewSetDOMReadyCallback(ULView view,
501 |                                         ULDOMReadyCallback callback,
502 |                                         void* user_data);
503 | 
504 | ///
505 | /// Set whether or not a view should be repainted during the next call to
506 | /// ulRender.
507 | ///
508 | /// @note  This flag is automatically set whenever the page content changes
509 | ///        but you can set it directly in case you need to force a repaint.
510 | ///
511 | ULExport void ulViewSetNeedsPaint(ULView view, bool needs_paint);
512 | 
513 | ///
514 | /// Whether or not a view should be painted during the next call to ulRender.
515 | ///
516 | ULExport bool ulViewGetNeedsPaint(ULView view);
517 | 
518 | ///
519 | /// Create an inspector for this View, this is useful for debugging and
520 | /// inspecting pages locally. This will only succeed if you have the
521 | /// inspector assets in your filesystem-- the inspector will look for
522 | /// file:///inspector/Main.html when it loads.
523 | ///
524 | /// @note  The initial dimensions of the returned View are 10x10, you should
525 | ///        call ulViewResize on the returned View to resize it to your desired
526 | ///        dimensions.
527 | ///
528 | /// @note  You will need to call ulDestroyView on the returned instance
529 | ///        when you're done using it.
530 | ///
531 | ULExport ULView ulViewCreateInspectorView(ULView view);
532 | 
533 | /******************************************************************************
534 |  * String
535 |  *****************************************************************************/
536 | 
537 | ///
538 | /// Create string from null-terminated ASCII C-string.
539 | ///
540 | ULExport ULString ulCreateString(const char* str);
541 | 
542 | ///
543 | /// Create string from UTF-8 buffer.
544 | ///
545 | ULExport ULString ulCreateStringUTF8(const char* str, size_t len);
546 | 
547 | ///
548 | /// Create string from UTF-16 buffer.
549 | ///
550 | ULExport ULString ulCreateStringUTF16(ULChar16* str, size_t len);
551 | 
552 | ///
553 | /// Destroy string (you should destroy any strings you explicitly Create).
554 | ///
555 | ULExport void ulDestroyString(ULString str);
556 | 
557 | ///
558 | /// Get internal UTF-16 buffer data.
559 | ///
560 | ULExport ULChar16* ulStringGetData(ULString str);
561 | 
562 | ///
563 | /// Get length in UTF-16 characters.
564 | ///
565 | ULExport size_t ulStringGetLength(ULString str);
566 | 
567 | ///
568 | /// Whether this string is empty or not.
569 | ///
570 | ULExport bool ulStringIsEmpty(ULString str);
571 | 
572 | /******************************************************************************
573 |  * Bitmap
574 |  *****************************************************************************/
575 | 
576 | ///
577 | /// Create empty bitmap.
578 | ///
579 | ULExport ULBitmap ulCreateEmptyBitmap();
580 | 
581 | ///
582 | /// Create bitmap with certain dimensions and pixel format.
583 | ///
584 | ULExport ULBitmap ulCreateBitmap(unsigned int width, unsigned int height,
585 |                                  ULBitmapFormat format);
586 | 
587 | ///
588 | /// Create bitmap from existing pixel buffer. @see Bitmap for help using
589 | /// this function.
590 | ///
591 | ULExport ULBitmap ulCreateBitmapFromPixels(unsigned int width,
592 |                                            unsigned int height,
593 |                                            ULBitmapFormat format, 
594 |                                            unsigned int row_bytes,
595 |                                            const void* pixels, size_t size,
596 |                                            bool should_copy);
597 | 
598 | ///
599 | /// Create bitmap from copy.
600 | ///
601 | ULExport ULBitmap ulCreateBitmapFromCopy(ULBitmap existing_bitmap);
602 | 
603 | ///
604 | /// Destroy a bitmap (you should only destroy Bitmaps you have explicitly
605 | /// created via one of the creation functions above.
606 | ///
607 | ULExport void ulDestroyBitmap(ULBitmap bitmap);
608 | 
609 | ///
610 | /// Get the width in pixels.
611 | ///
612 | ULExport unsigned int ulBitmapGetWidth(ULBitmap bitmap);
613 | 
614 | ///
615 | /// Get the height in pixels.
616 | ///
617 | ULExport unsigned int ulBitmapGetHeight(ULBitmap bitmap);
618 | 
619 | ///
620 | /// Get the pixel format.
621 | ///
622 | ULExport ULBitmapFormat ulBitmapGetFormat(ULBitmap bitmap);
623 | 
624 | ///
625 | /// Get the bytes per pixel.
626 | ///
627 | ULExport unsigned int ulBitmapGetBpp(ULBitmap bitmap);
628 | 
629 | ///
630 | /// Get the number of bytes per row.
631 | ///
632 | ULExport unsigned int ulBitmapGetRowBytes(ULBitmap bitmap);
633 | 
634 | ///
635 | /// Get the size in bytes of the underlying pixel buffer.
636 | ///
637 | ULExport size_t ulBitmapGetSize(ULBitmap bitmap);
638 | 
639 | ///
640 | /// Whether or not this bitmap owns its own pixel buffer.
641 | ///
642 | ULExport bool ulBitmapOwnsPixels(ULBitmap bitmap);
643 | 
644 | ///
645 | /// Lock pixels for reading/writing, returns pointer to pixel buffer.
646 | ///
647 | ULExport void* ulBitmapLockPixels(ULBitmap bitmap);
648 | 
649 | ///
650 | /// Unlock pixels after locking.
651 | ///
652 | ULExport void ulBitmapUnlockPixels(ULBitmap bitmap);
653 | 
654 | ///
655 | /// Get raw pixel buffer-- you should only call this if Bitmap is already
656 | /// locked.
657 | ///
658 | ULExport void* ulBitmapRawPixels(ULBitmap bitmap);
659 | 
660 | ///
661 | /// Whether or not this bitmap is empty.
662 | ///
663 | ULExport bool ulBitmapIsEmpty(ULBitmap bitmap);
664 | 
665 | ///
666 | /// Reset bitmap pixels to 0.
667 | ///
668 | ULExport void ulBitmapErase(ULBitmap bitmap);
669 | 
670 | ///
671 | /// Write bitmap to a PNG on disk.
672 | ///
673 | ULExport bool ulBitmapWritePNG(ULBitmap bitmap, const char* path);
674 | 
675 | /******************************************************************************
676 | * Key Event
677 | ******************************************************************************/
678 | 
679 | ///
680 | /// Create a key event, @see KeyEvent for help with the following parameters.
681 | ///
682 | ULExport ULKeyEvent ulCreateKeyEvent(ULKeyEventType type,
683 |                                      unsigned int modifiers,
684 |                                      int virtual_key_code, int native_key_code,
685 |                                      ULString text, ULString unmodified_text,
686 |                                      bool is_keypad, bool is_auto_repeat,
687 |                                      bool is_system_key);
688 | 
689 | #ifdef _WIN32
690 | ///
691 | /// Create a key event from native Windows event.
692 | ///
693 | ULExport ULKeyEvent ulCreateKeyEventWindows(ULKeyEventType type,
694 |                                             uintptr_t wparam, intptr_t lparam,
695 |                                             bool is_system_key);
696 | #endif
697 | 
698 | #ifdef __OBJC__
699 | ///
700 | /// Create a key event from native macOS event.
701 | ///
702 | ULExport ULKeyEvent ulCreateKeyEventMacOS(NSEvent* evt);
703 | #endif
704 | 
705 | ///
706 | /// Destroy a key event.
707 | ///
708 | ULExport void ulDestroyKeyEvent(ULKeyEvent evt);
709 | 
710 | /******************************************************************************
711 |  * Mouse Event
712 |  *****************************************************************************/
713 | 
714 | ///
715 | /// Create a mouse event, @see MouseEvent for help using this function.
716 | ///
717 | ULExport ULMouseEvent ulCreateMouseEvent(ULMouseEventType type, int x, int y,
718 |                                          ULMouseButton button);
719 | 
720 | ///
721 | /// Destroy a mouse event.
722 | ///
723 | ULExport void ulDestroyMouseEvent(ULMouseEvent evt);
724 | 
725 | /******************************************************************************
726 |  * Scroll Event
727 |  *****************************************************************************/
728 | 
729 | ///
730 | /// Create a scroll event, @see ScrollEvent for help using this function.
731 | ///
732 | ULExport ULScrollEvent ulCreateScrollEvent(ULScrollEventType type, int delta_x,
733 |                                            int delta_y);
734 | 
735 | ///
736 | /// Destroy a scroll event.
737 | ///
738 | ULExport void ulDestroyScrollEvent(ULScrollEvent evt);
739 | 
740 | #ifdef __cplusplus
741 | }
742 | #endif
743 | 
744 | #endif // ULTRALIGHT_CAPI_H
745 | 


--------------------------------------------------------------------------------
/logo.svg:
--------------------------------------------------------------------------------
 1 | 
 2 |  
 3 | 
 4 |  
 5 |   background
 6 |   
 7 |   
 8 |    
 9 |   
10 |  
11 |  
12 |   Layer 1
13 | 
14 |   
15 |    
34 |   
35 |  
36 | 


--------------------------------------------------------------------------------
/muon.go:
--------------------------------------------------------------------------------
  1 | package muon
  2 | 
  3 | import (
  4 | 	"encoding/json"
  5 | 	"errors"
  6 | 	"net"
  7 | 	"net/http"
  8 | 	"reflect"
  9 | 	"unsafe"
 10 | 
 11 | 	. "github.com/ImVexed/muon/ultralight"
 12 | )
 13 | 
 14 | // Window represents a single Ultralight instance
 15 | type Window struct {
 16 | 	wnd       ULWindow
 17 | 	ov        ULOverlay
 18 | 	view      ULView
 19 | 	app       ULApp
 20 | 	handler   http.Handler
 21 | 	cfg       *Config
 22 | 	callbacks map[string]*ipf
 23 | }
 24 | 
 25 | type ipf struct {
 26 | 	Function   reflect.Value
 27 | 	ParamTypes []reflect.Type
 28 | }
 29 | 
 30 | // Config contains configurable controls for the Ultralight engine
 31 | type Config struct {
 32 | 	Title  string
 33 | 	Height uint32
 34 | 	Width  uint32
 35 | 	X      int32
 36 | 	Y      int32
 37 | 
 38 | 	Resizeable  bool
 39 | 	Borderless  bool
 40 | 	Titled      bool
 41 | 	Maximizable bool
 42 | }
 43 | 
 44 | // New creates a Ultralight Window
 45 | func New(cfg *Config, handler http.Handler) *Window {
 46 | 	w := &Window{
 47 | 		cfg:       cfg,
 48 | 		handler:   handler,
 49 | 		callbacks: make(map[string]*ipf),
 50 | 	}
 51 | 
 52 | 	ufg := UlCreateConfig()
 53 | 	std := UlCreateSettings()
 54 | 	w.app = UlCreateApp(std, ufg)
 55 | 	mm := UlAppGetMainMonitor(w.app)
 56 | 
 57 | 	var hint uint32
 58 | 
 59 | 	if cfg.Resizeable {
 60 | 		hint |= 4
 61 | 	}
 62 | 
 63 | 	if cfg.Borderless {
 64 | 		hint |= 1
 65 | 	}
 66 | 
 67 | 	if cfg.Titled {
 68 | 		hint |= 2
 69 | 	} else {
 70 | 		w.cfg.Title = ""
 71 | 	}
 72 | 
 73 | 	if cfg.Maximizable {
 74 | 		hint |= 8
 75 | 	}
 76 | 
 77 | 	w.wnd = UlCreateWindow(mm, w.cfg.Width, w.cfg.Height, false, hint)
 78 | 
 79 | 	UlWindowSetTitle(w.wnd, w.cfg.Title)
 80 | 	UlAppSetWindow(w.app, w.wnd)
 81 | 
 82 | 	w.ov = UlCreateOverlay(w.wnd, w.cfg.Width, w.cfg.Height, w.cfg.X, w.cfg.Y)
 83 | 
 84 | 	UlWindowSetResizeCallback(w.wnd, resizeCallback(w.ov), nil)
 85 | 
 86 | 	w.view = UlOverlayGetView(w.ov)
 87 | 
 88 | 	return w
 89 | }
 90 | 
 91 | // Start sets up the Ultralight runtime and begins showing the Window
 92 | func (w *Window) Start() error {
 93 | 
 94 | 	addr, err := serveHandler(w.handler)
 95 | 
 96 | 	if err != nil {
 97 | 		return err
 98 | 	}
 99 | 
100 | 	url := UlCreateString(addr)
101 | 	defer UlDestroyString(url)
102 | 
103 | 	UlViewLoadURL(w.view, url)
104 | 
105 | 	UlAppRun(w.app)
106 | 
107 | 	return nil
108 | }
109 | 
110 | var registerCount int
111 | 
112 | // Bind registers the given function to the given name in the Window's JS global object
113 | func (w *Window) Bind(name string, function interface{}) {
114 | 	f := &ipf{
115 | 		Function: reflect.ValueOf(function),
116 | 	}
117 | 
118 | 	t := f.Function.Type()
119 | 
120 | 	f.ParamTypes = make([]reflect.Type, t.NumIn())
121 | 
122 | 	for i := 0; i < t.NumIn(); i++ {
123 | 		f.ParamTypes[i] = t.In(i)
124 | 	}
125 | 
126 | 	if t.NumOut() > 1 {
127 | 		panic("Too many return values!")
128 | 	}
129 | 
130 | 	w.callbacks[name] = f
131 | 
132 | 	w.addFunction(name)
133 | }
134 | 
135 | // Eval evaluates a given JavaScript string in the given Window view. `ret` is necessary for JSON serialization if an object is returned.
136 | func (w *Window) Eval(js string, ret reflect.Type) (interface{}, error) {
137 | 	us := UlCreateString(js)
138 | 	defer UlDestroyString(us)
139 | 
140 | 	ref := UlViewEvaluateScript(w.view, us)
141 | 	ctx := UlViewGetJSContext(w.view)
142 | 
143 | 	val, err := fromJSValue(ctx, ref, ret)
144 | 
145 | 	if err != nil {
146 | 		return nil, err
147 | 	}
148 | 
149 | 	return val.Interface(), nil
150 | }
151 | 
152 | // Resize changes the given Window's size
153 | func (w *Window) Resize(width int, height int) {
154 | 	UlOverlayResize(w.ov, uint32(width), uint32(height))
155 | }
156 | 
157 | // Move sets the Window's position to the given coordinates
158 | func (w *Window) Move(x int, y int) {
159 | 	UlOverlayMoveTo(w.ov, int32(x), int32(y))
160 | }
161 | 
162 | func (w *Window) ipcCallback(ctx JSContextRef, functin JSObjectRef, thisObject JSObjectRef, argumentCount uint, arguments []JSValueRef, exception []JSValueRef) JSValueRef {
163 | 	jsName := JSStringCreateWithUTF8CString("name")
164 | 	defer JSStringRelease(jsName)
165 | 
166 | 	prop := JSObjectGetProperty(ctx, functin, jsName, nil)
167 | 	jsProp := JSValueToStringCopy(ctx, prop, nil)
168 | 	defer JSStringRelease(jsProp)
169 | 
170 | 	name := fromJSString(jsProp)
171 | 
172 | 	f, ok := w.callbacks[name]
173 | 
174 | 	if !ok {
175 | 		return JSValueMakeNull(ctx)
176 | 	}
177 | 
178 | 	params := make([]reflect.Value, argumentCount)
179 | 
180 | 	for i := uint(0); i < argumentCount; i++ {
181 | 		val, err := fromJSValue(ctx, arguments[i], f.ParamTypes[i])
182 | 
183 | 		if err != nil {
184 | 			panic(err)
185 | 		}
186 | 
187 | 		params[i] = val
188 | 	}
189 | 
190 | 	val := f.Function.Call(params)
191 | 
192 | 	if len(val) > 1 {
193 | 		panic("Javascript does not support more than 1 return value!")
194 | 	}
195 | 
196 | 	if len(val) == 0 {
197 | 		return JSValueMakeNull(ctx)
198 | 	}
199 | 
200 | 	return toJSValue(ctx, val[0])
201 | }
202 | 
203 | func fromJSValue(ctx JSContextRef, value JSValueRef, rtype reflect.Type) (reflect.Value, error) {
204 | 	if rtype == nil {
205 | 		rtype = reflect.TypeOf(struct{}{})
206 | 	}
207 | 
208 | 	var rv reflect.Value
209 | 	var err error
210 | 
211 | 	if JSValueIsArray(ctx, value) {
212 | 		l := JSStringCreateWithUTF8CString("length")
213 | 		defer JSStringRelease(l)
214 | 
215 | 		obj := *(*JSObjectRef)(unsafe.Pointer(&value))
216 | 
217 | 		prop := JSObjectGetProperty(ctx, obj, l, nil)
218 | 		length := int(JSValueToNumber(ctx, prop, nil))
219 | 
220 | 		if rtype.Kind() != reflect.Slice {
221 | 			return reflect.Zero(rtype), errors.New("JS return is of type Array while Go type target is not")
222 | 		}
223 | 
224 | 		values := reflect.MakeSlice(rtype, length, length)
225 | 
226 | 		for i := 0; i < length; i++ {
227 | 			ref := JSObjectGetPropertyAtIndex(ctx, obj, uint32(i), nil)
228 | 
229 | 			val, err := fromJSValue(ctx, ref, rtype.Elem())
230 | 
231 | 			if err != nil {
232 | 				return reflect.Zero(rtype), err
233 | 			}
234 | 
235 | 			values.Index(i).Set(val)
236 | 		}
237 | 
238 | 		return values, nil
239 | 	}
240 | 
241 | 	switch JSValueGetType(ctx, value) {
242 | 	case KJSTypeBoolean:
243 | 		rv = reflect.ValueOf(JSValueToBoolean(ctx, value))
244 | 	case KJSTypeNumber:
245 | 		rv = reflect.ValueOf(JSValueToNumber(ctx, value, nil))
246 | 	case KJSTypeString:
247 | 		ref := JSValueToStringCopy(ctx, value, nil)
248 | 		rv = reflect.ValueOf(fromJSString(ref))
249 | 		JSStringRelease(ref)
250 | 	case KJSTypeObject:
251 | 		ref := JSValueCreateJSONString(ctx, value, 0, nil)
252 | 		obj := reflect.New(rtype).Interface()
253 | 
254 | 		if err = json.Unmarshal([]byte(fromJSString(ref)), &obj); err == nil {
255 | 			rv = reflect.Indirect(reflect.ValueOf(obj))
256 | 		}
257 | 
258 | 		JSStringRelease(ref)
259 | 	case KJSTypeUndefined, KJSTypeNull:
260 | 		rv = reflect.Zero(rtype)
261 | 	}
262 | 
263 | 	return rv, err
264 | }
265 | 
266 | func fromJSString(str JSStringRef) string {
267 | 	len := JSStringGetMaximumUTF8CStringSize(str)
268 | 	data := make([]byte, len)
269 | 	written := JSStringGetUTF8CString(str, data, len)
270 | 
271 | 	return string(data[:written-1])
272 | }
273 | 
274 | func toJSValue(ctx JSContextRef, value reflect.Value) JSValueRef {
275 | 	var jsv JSValueRef
276 | 	var err error
277 | 
278 | 	switch value.Kind() {
279 | 	case reflect.Float64:
280 | 		jsv = JSValueMakeNumber(ctx, value.Float())
281 | 	case reflect.Bool:
282 | 		jsv = JSValueMakeBoolean(ctx, value.Bool())
283 | 	case reflect.String:
284 | 		str := JSStringCreateWithUTF8CString(value.String())
285 | 		jsv = JSValueMakeString(ctx, str)
286 | 		JSStringRelease(str)
287 | 	case reflect.Ptr:
288 | 		return toJSValue(ctx, reflect.Indirect(value))
289 | 	case reflect.Struct:
290 | 		if json, err := json.Marshal(value.Interface()); err == nil {
291 | 			str := JSStringCreateWithUTF8CString(string(json))
292 | 			jsv = JSValueMakeFromJSONString(ctx, str)
293 | 			JSStringRelease(str)
294 | 		}
295 | 	case reflect.Slice, reflect.Array:
296 | 		rets := make([]JSValueRef, value.Len())
297 | 
298 | 		for i := 0; i < value.Len(); i++ {
299 | 			rets[i] = toJSValue(ctx, value.Index(i))
300 | 		}
301 | 		arr := JSObjectMakeArray(ctx, uint(len(rets)), rets, nil)
302 | 		jsv = *(*JSValueRef)(unsafe.Pointer(&arr))
303 | 	default:
304 | 		panic("Not implemented!")
305 | 	}
306 | 
307 | 	if err != nil {
308 | 		return JSValueMakeNull(ctx)
309 | 	}
310 | 
311 | 	return jsv
312 | }
313 | 
314 | func (w *Window) addFunction(name string) {
315 | 	ctx := UlViewGetJSContext(w.view)
316 | 	gobj := JSContextGetGlobalObject(ctx)
317 | 
318 | 	fn := JSStringCreateWithUTF8CString(name)
319 | 	defer JSStringRelease(fn)
320 | 
321 | 	fname := JSStringCreateWithUTF8CString("name")
322 | 	defer JSStringRelease(fname)
323 | 
324 | 	fob := JSObjectMakeFunctionWithCallback(ctx, fn, w.ipcCallback)
325 | 	JSObjectSetProperty(ctx, fob, fname, JSValueMakeString(ctx, fname), KJSPropertyAttributeNone, []JSValueRef{})
326 | 
327 | 	val := *(*JSValueRef)(unsafe.Pointer(&fob))
328 | 
329 | 	JSObjectSetProperty(ctx, gobj, fn, val, KJSPropertyAttributeNone, []JSValueRef{})
330 | }
331 | 
332 | func resizeCallback(ov ULOverlay) func(userData unsafe.Pointer, width uint32, height uint32) {
333 | 	return func(userData unsafe.Pointer, width uint32, height uint32) {
334 | 		if height > 0 && width > 0 {
335 | 			UlOverlayResize(ov, width, height)
336 | 		}
337 | 	}
338 | }
339 | 
340 | func serveHandler(handler http.Handler) (string, error) {
341 | 	ln, err := net.Listen("tcp", "127.0.0.1:0")
342 | 	if err != nil {
343 | 		return "", err
344 | 	}
345 | 
346 | 	go func() {
347 | 		if err := http.Serve(ln, handler); err != nil {
348 | 			panic(err)
349 | 		}
350 | 	}()
351 | 
352 | 	return "http://" + ln.Addr().String(), nil
353 | }
354 | 


--------------------------------------------------------------------------------
/muon_test.go:
--------------------------------------------------------------------------------
  1 | package muon
  2 | 
  3 | import (
  4 | 	"net/http"
  5 | 	"os"
  6 | 	"reflect"
  7 | 	"testing"
  8 | )
  9 | 
 10 | var w *Window
 11 | 
 12 | func TestMain(m *testing.M) {
 13 | 	cfg := &Config{
 14 | 		Height: 1,
 15 | 		Width:  1,
 16 | 	}
 17 | 
 18 | 	w = New(cfg, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
 19 | 
 20 | 	go func() {
 21 | 		w.Start()
 22 | 	}()
 23 | 
 24 | 	os.Exit(m.Run())
 25 | }
 26 | 
 27 | type testObject struct {
 28 | 	S1 string
 29 | 	F1 float64
 30 | 	B1 bool
 31 | }
 32 | 
 33 | func TestComplexType(t *testing.T) {
 34 | 
 35 | 	w.Bind("complexTest", func(to *testObject) *testObject {
 36 | 		return &testObject{
 37 | 			S1: to.S1 + " World!",
 38 | 			F1: to.F1 + 1,
 39 | 			B1: !to.B1,
 40 | 		}
 41 | 	})
 42 | 
 43 | 	res, err := w.Eval(`complexTest({S1: "Hello,", F1: 9000, B1: false})`, reflect.TypeOf(&testObject{}))
 44 | 
 45 | 	if err != nil {
 46 | 		t.Error(err)
 47 | 	}
 48 | 
 49 | 	to := res.(*testObject)
 50 | 
 51 | 	if to.S1 != "Hello, World!" {
 52 | 		t.Errorf("to.S1 was not correct, got %s", to.S1)
 53 | 	}
 54 | 
 55 | 	if to.F1 != 9001 {
 56 | 		t.Errorf("to.F1 was under 9000, got %f", to.F1)
 57 | 	}
 58 | 
 59 | 	if !to.B1 {
 60 | 		t.Errorf("to.B1 was not True, got false")
 61 | 	}
 62 | }
 63 | 
 64 | func t2(to *testObject) *testObject {
 65 | 	return &testObject{
 66 | 		S1: to.S1 + " World!",
 67 | 		F1: to.F1 + 1,
 68 | 		B1: !to.B1,
 69 | 	}
 70 | }
 71 | 
 72 | func TestArrayType(t *testing.T) {
 73 | 
 74 | 	w.Bind("arrayTest", func(strings []string) []float64 {
 75 | 		if strings[0] != "Hello" {
 76 | 			t.Errorf("strings[0] was not Hello, got %s", strings[0])
 77 | 		}
 78 | 		if strings[1] != "World!" {
 79 | 			t.Errorf("strings[1] was not World!, got %s", strings[1])
 80 | 		}
 81 | 		return []float64{1, 2, 3}
 82 | 	})
 83 | 
 84 | 	res, err := w.Eval(`arrayTest(["Hello","World!"])`, reflect.TypeOf([]float64{}))
 85 | 
 86 | 	if err != nil {
 87 | 		t.Error(err)
 88 | 	}
 89 | 
 90 | 	nums := res.([]float64)
 91 | 
 92 | 	if nums[0] != 1 {
 93 | 		t.Errorf("nums[0] was not 1, got %f", nums[0])
 94 | 	}
 95 | 
 96 | 	if nums[1] != 2 {
 97 | 		t.Errorf("nums[1] was not 2, got %f", nums[1])
 98 | 	}
 99 | 
100 | 	if nums[2] != 3 {
101 | 		t.Errorf("nums[2] was not 3, got %f", nums[2])
102 | 	}
103 | }
104 | 
105 | func TestEmptyType(t *testing.T) {
106 | 
107 | 	w.Bind("emptyTypeTest", func(nullValue string, undefinedValue string) {
108 | 		if nullValue != "" {
109 | 			t.Errorf("nullType was not empty!")
110 | 		}
111 | 		if undefinedValue != "" {
112 | 			t.Errorf("undefinedType was not empty!")
113 | 		}
114 | 	})
115 | 
116 | 	_, err := w.Eval(`emptyTypeTest(null, undefined)`, nil)
117 | 
118 | 	if err != nil {
119 | 		t.Error(err)
120 | 	}
121 | }
122 | 
123 | func TestMultipleFuncs(t *testing.T) {
124 | 	w.Bind("multiple1Test", func(value1 string) {})
125 | 	w.Bind("multiple2Test", func(value2 bool) {})
126 | 
127 | 	_, err := w.Eval(`multiple1Test("Hello, World1")`, nil)
128 | 
129 | 	if err != nil {
130 | 		t.Error(err)
131 | 	}
132 | 
133 | 	_, err = w.Eval(`multiple2Test(true)`, nil)
134 | 
135 | 	if err != nil {
136 | 		t.Error(err)
137 | 	}
138 | }
139 | 


--------------------------------------------------------------------------------
/ultralight.yml:
--------------------------------------------------------------------------------
 1 | GENERATOR: 
 2 |   PackageName: ultralight
 3 |   PackageDescription: "Ultralight bindings for golang"
 4 |   PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
 5 |   FlagGroups:
 6 |     - {name: CFLAGS, flags: [-I../include]}
 7 |     - {name: LDFLAGS, flags: ["-L${SRCDIR}/libs -lUltralightCore -lWebCore -lUltralight -lAppCore"]}
 8 |   Includes: ["AppCore/CAPI.h"]
 9 |   Options:
10 |     SafeStrings: true
11 | 
12 | PARSER: 
13 |   Arch: x86_64
14 |   IncludePaths:
15 |     - include
16 |     - /usr/include
17 |     - /usr/lib/gcc/x86_64-linux-gnu/7/include
18 |   SourcesPaths:
19 |     - AppCore/CAPI.h
20 | 
21 | TRANSLATOR:
22 |     ConstRules:
23 |         defines: eval
24 |     Rules:
25 |         global:
26 |             - {action: accept, from: "^ul"}
27 |             - {action: accept, from: "^UL"}
28 |             - {action: accept, from: "^JS"}
29 |             - {action: accept, from: "^k"}
30 |             - {action: accept, from: "^B"}
31 |             - {action: ignore, from: __size_t__}
32 |             - {action: ignore, from: __SIZE_T__}
33 |             - {action: ignore, from: _BSD_SIZE_T_DEFINED_}
34 |             - {action: ignore, from: _SIZE_T_DECLARED}
35 |             - {action: ignore, from: __wchar_t__}
36 |             - {action: ignore, from: __WCHAR_T__}
37 |             - {transform: export}
38 |         function:
39 |             - {action: ignore, from: __GO__}
40 |             # - {action: ignore, from: JSObjectGetArrayBufferByteLength}
41 |             # - {action: ignore, from: JSObjectGetArrayBufferBytesPtr}
42 |             # - {action: ignore, from: JSObjectGetTypedArrayBuffer}
43 |             # - {action: ignore, from: JSObjectGetTypedArrayByteLength}
44 |             # - {action: ignore, from: JSObjectGetTypedArrayByteOffset}
45 |             # - {action: ignore, from: JSObjectGetTypedArrayBytesPtr}
46 |             # - {action: ignore, from: JSObjectGetTypedArrayLength}
47 |             # - {action: ignore, from: JSObjectMakeArrayBufferWithBytesNoCopy}
48 |             # - {action: ignore, from: JSObjectMakeTypedArray}
49 |             # - {action: ignore, from: JSObjectMakeTypedArrayWithArrayBuffer}
50 |             # - {action: ignore, from: JSObjectMakeTypedArrayWithArrayBufferAndOffset}
51 |             # - {action: ignore, from: JSObjectMakeTypedArrayWithBytesNoCopy}
52 |             # - {action: ignore, from: JSValueGetTypedArrayType}
53 |         private:
54 |             - {transform: unexport}


--------------------------------------------------------------------------------
/ultralight/cgo_helpers.c:
--------------------------------------------------------------------------------
  1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
  2 | 
  3 | // WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
  4 | // Code generated by https://git.io/c-for-go. DO NOT EDIT.
  5 | 
  6 | #include "_cgo_export.h"
  7 | #include "cgo_helpers.h"
  8 | 
  9 | void ULUpdateCallback_7e1c6355(void* user_data) {
 10 | 	uLUpdateCallback7E1C6355(user_data);
 11 | }
 12 | 
 13 | void ULCloseCallback_195b2f9(void* user_data) {
 14 | 	uLCloseCallback195B2F9(user_data);
 15 | }
 16 | 
 17 | void ULResizeCallback_6e7309d9(void* user_data, unsigned int width, unsigned int height) {
 18 | 	uLResizeCallback6E7309D9(user_data, width, height);
 19 | }
 20 | 
 21 | void ULChangeTitleCallback_bd58034c(void* user_data, ULView caller, ULString title) {
 22 | 	uLChangeTitleCallbackBD58034C(user_data, caller, title);
 23 | }
 24 | 
 25 | void ULChangeURLCallback_4ec32b80(void* user_data, ULView caller, ULString url) {
 26 | 	uLChangeURLCallback4EC32B80(user_data, caller, url);
 27 | }
 28 | 
 29 | void ULChangeTooltipCallback_12ca407(void* user_data, ULView caller, ULString tooltip) {
 30 | 	uLChangeTooltipCallback12CA407(user_data, caller, tooltip);
 31 | }
 32 | 
 33 | void ULChangeCursorCallback_1a7011df(void* user_data, ULView caller, ULCursor cursor) {
 34 | 	uLChangeCursorCallback1A7011DF(user_data, caller, cursor);
 35 | }
 36 | 
 37 | void ULAddConsoleMessageCallback_44b8dd01(void* user_data, ULView caller, ULMessageSource source, ULMessageLevel level, ULString message, unsigned int line_number, unsigned int column_number, ULString source_id) {
 38 | 	uLAddConsoleMessageCallback44B8DD01(user_data, caller, source, level, message, line_number, column_number, source_id);
 39 | }
 40 | 
 41 | void ULBeginLoadingCallback_70d8c0ad(void* user_data, ULView caller) {
 42 | 	uLBeginLoadingCallback70D8C0AD(user_data, caller);
 43 | }
 44 | 
 45 | void ULFinishLoadingCallback_1ed4ecae(void* user_data, ULView caller) {
 46 | 	uLFinishLoadingCallback1ED4ECAE(user_data, caller);
 47 | }
 48 | 
 49 | void ULUpdateHistoryCallback_6e105364(void* user_data, ULView caller) {
 50 | 	uLUpdateHistoryCallback6E105364(user_data, caller);
 51 | }
 52 | 
 53 | void ULDOMReadyCallback_6432c207(void* user_data, ULView caller) {
 54 | 	uLDOMReadyCallback6432C207(user_data, caller);
 55 | }
 56 | 
 57 | void JSTypedArrayBytesDeallocator_68d51f83(void* bytes, void* deallocatorContext) {
 58 | 	jSTypedArrayBytesDeallocator68D51F83(bytes, deallocatorContext);
 59 | }
 60 | 
 61 | void JSObjectInitializeCallback_5793b16(JSContextRef ctx, JSObjectRef object) {
 62 | 	jSObjectInitializeCallback5793B16(ctx, object);
 63 | }
 64 | 
 65 | void JSObjectFinalizeCallback_93da0aea(JSObjectRef object) {
 66 | 	jSObjectFinalizeCallback93DA0AEA(object);
 67 | }
 68 | 
 69 | _Bool JSObjectHasPropertyCallback_340bfa95(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) {
 70 | 	return jSObjectHasPropertyCallback340BFA95(ctx, object, propertyName);
 71 | }
 72 | 
 73 | JSValueRef JSObjectGetPropertyCallback_5caec716(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
 74 | 	return jSObjectGetPropertyCallback5CAEC716(ctx, object, propertyName, exception);
 75 | }
 76 | 
 77 | _Bool JSObjectSetPropertyCallback_a684f1fe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {
 78 | 	return jSObjectSetPropertyCallbackA684F1FE(ctx, object, propertyName, value, exception);
 79 | }
 80 | 
 81 | _Bool JSObjectDeletePropertyCallback_b0108ebe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
 82 | 	return jSObjectDeletePropertyCallbackB0108EBE(ctx, object, propertyName, exception);
 83 | }
 84 | 
 85 | void JSObjectGetPropertyNamesCallback_e77d2329(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames) {
 86 | 	jSObjectGetPropertyNamesCallbackE77D2329(ctx, object, propertyNames);
 87 | }
 88 | 
 89 | JSValueRef JSObjectCallAsFunctionCallback_89f9469b(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception) {
 90 | 	return jSObjectCallAsFunctionCallback89F9469B(ctx, function, thisObject, argumentCount, arguments, exception);
 91 | }
 92 | 
 93 | JSObjectRef JSObjectCallAsConstructorCallback_45f4b71f(JSContextRef ctx, JSObjectRef constructor, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception) {
 94 | 	return jSObjectCallAsConstructorCallback45F4B71F(ctx, constructor, argumentCount, arguments, exception);
 95 | }
 96 | 
 97 | _Bool JSObjectHasInstanceCallback_aa527d2e(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
 98 | 	return jSObjectHasInstanceCallbackAA527D2E(ctx, constructor, possibleInstance, exception);
 99 | }
100 | 
101 | JSValueRef JSObjectConvertToTypeCallback_d379d61c(JSContextRef ctx, JSObjectRef object, JSType _type, JSValueRef* exception) {
102 | 	return jSObjectConvertToTypeCallbackD379D61C(ctx, object, _type, exception);
103 | }
104 | 
105 | 


--------------------------------------------------------------------------------
/ultralight/cgo_helpers.h:
--------------------------------------------------------------------------------
 1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
 2 | 
 3 | // WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
 4 | // Code generated by https://git.io/c-for-go. DO NOT EDIT.
 5 | 
 6 | #include "AppCore/CAPI.h"
 7 | #include 
 8 | #pragma once
 9 | 
10 | #define __CGOGEN 1
11 | 
12 | // ULUpdateCallback_7e1c6355 is a proxy for callback ULUpdateCallback.
13 | void ULUpdateCallback_7e1c6355(void* user_data);
14 | 
15 | // ULCloseCallback_195b2f9 is a proxy for callback ULCloseCallback.
16 | void ULCloseCallback_195b2f9(void* user_data);
17 | 
18 | // ULResizeCallback_6e7309d9 is a proxy for callback ULResizeCallback.
19 | void ULResizeCallback_6e7309d9(void* user_data, unsigned int width, unsigned int height);
20 | 
21 | // ULChangeTitleCallback_bd58034c is a proxy for callback ULChangeTitleCallback.
22 | void ULChangeTitleCallback_bd58034c(void* user_data, ULView caller, ULString title);
23 | 
24 | // ULChangeURLCallback_4ec32b80 is a proxy for callback ULChangeURLCallback.
25 | void ULChangeURLCallback_4ec32b80(void* user_data, ULView caller, ULString url);
26 | 
27 | // ULChangeTooltipCallback_12ca407 is a proxy for callback ULChangeTooltipCallback.
28 | void ULChangeTooltipCallback_12ca407(void* user_data, ULView caller, ULString tooltip);
29 | 
30 | // ULChangeCursorCallback_1a7011df is a proxy for callback ULChangeCursorCallback.
31 | void ULChangeCursorCallback_1a7011df(void* user_data, ULView caller, ULCursor cursor);
32 | 
33 | // ULAddConsoleMessageCallback_44b8dd01 is a proxy for callback ULAddConsoleMessageCallback.
34 | void ULAddConsoleMessageCallback_44b8dd01(void* user_data, ULView caller, ULMessageSource source, ULMessageLevel level, ULString message, unsigned int line_number, unsigned int column_number, ULString source_id);
35 | 
36 | // ULBeginLoadingCallback_70d8c0ad is a proxy for callback ULBeginLoadingCallback.
37 | void ULBeginLoadingCallback_70d8c0ad(void* user_data, ULView caller);
38 | 
39 | // ULFinishLoadingCallback_1ed4ecae is a proxy for callback ULFinishLoadingCallback.
40 | void ULFinishLoadingCallback_1ed4ecae(void* user_data, ULView caller);
41 | 
42 | // ULUpdateHistoryCallback_6e105364 is a proxy for callback ULUpdateHistoryCallback.
43 | void ULUpdateHistoryCallback_6e105364(void* user_data, ULView caller);
44 | 
45 | // ULDOMReadyCallback_6432c207 is a proxy for callback ULDOMReadyCallback.
46 | void ULDOMReadyCallback_6432c207(void* user_data, ULView caller);
47 | 
48 | // JSTypedArrayBytesDeallocator_68d51f83 is a proxy for callback JSTypedArrayBytesDeallocator.
49 | void JSTypedArrayBytesDeallocator_68d51f83(void* bytes, void* deallocatorContext);
50 | 
51 | // JSObjectInitializeCallback_5793b16 is a proxy for callback JSObjectInitializeCallback.
52 | void JSObjectInitializeCallback_5793b16(JSContextRef ctx, JSObjectRef object);
53 | 
54 | // JSObjectFinalizeCallback_93da0aea is a proxy for callback JSObjectFinalizeCallback.
55 | void JSObjectFinalizeCallback_93da0aea(JSObjectRef object);
56 | 
57 | // JSObjectHasPropertyCallback_340bfa95 is a proxy for callback JSObjectHasPropertyCallback.
58 | _Bool JSObjectHasPropertyCallback_340bfa95(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
59 | 
60 | // JSObjectGetPropertyCallback_5caec716 is a proxy for callback JSObjectGetPropertyCallback.
61 | JSValueRef JSObjectGetPropertyCallback_5caec716(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
62 | 
63 | // JSObjectSetPropertyCallback_a684f1fe is a proxy for callback JSObjectSetPropertyCallback.
64 | _Bool JSObjectSetPropertyCallback_a684f1fe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
65 | 
66 | // JSObjectDeletePropertyCallback_b0108ebe is a proxy for callback JSObjectDeletePropertyCallback.
67 | _Bool JSObjectDeletePropertyCallback_b0108ebe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
68 | 
69 | // JSObjectGetPropertyNamesCallback_e77d2329 is a proxy for callback JSObjectGetPropertyNamesCallback.
70 | void JSObjectGetPropertyNamesCallback_e77d2329(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
71 | 
72 | // JSObjectCallAsFunctionCallback_89f9469b is a proxy for callback JSObjectCallAsFunctionCallback.
73 | JSValueRef JSObjectCallAsFunctionCallback_89f9469b(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception);
74 | 
75 | // JSObjectCallAsConstructorCallback_45f4b71f is a proxy for callback JSObjectCallAsConstructorCallback.
76 | JSObjectRef JSObjectCallAsConstructorCallback_45f4b71f(JSContextRef ctx, JSObjectRef constructor, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception);
77 | 
78 | // JSObjectHasInstanceCallback_aa527d2e is a proxy for callback JSObjectHasInstanceCallback.
79 | _Bool JSObjectHasInstanceCallback_aa527d2e(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
80 | 
81 | // JSObjectConvertToTypeCallback_d379d61c is a proxy for callback JSObjectConvertToTypeCallback.
82 | JSValueRef JSObjectConvertToTypeCallback_d379d61c(JSContextRef ctx, JSObjectRef object, JSType _type, JSValueRef* exception);
83 | 
84 | 


--------------------------------------------------------------------------------
/ultralight/const.go:
--------------------------------------------------------------------------------
  1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
  2 | 
  3 | // WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
  4 | // Code generated by https://git.io/c-for-go. DO NOT EDIT.
  5 | 
  6 | package ultralight
  7 | 
  8 | /*
  9 | #cgo CFLAGS: -I../include
 10 | #cgo windows,386 LDFLAGS: -L${SRCDIR}/libs/windows/x32
 11 | #cgo windows,amd64 LDFLAGS: -L${SRCDIR}/libs/windows/x64 
 12 | #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/libs/darwin/x64 
 13 | #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/libs/linux/x64 
 14 | #cgo LDFLAGS: -lUltralightCore -lWebCore -lUltralight -lAppCore
 15 | #include "AppCore/CAPI.h"
 16 | #include 
 17 | #include "cgo_helpers.h"
 18 | */
 19 | import "C"
 20 | 
 21 | const (
 22 | 	// JSC_OBJC_API_ENABLED as defined in JavaScriptCore/JSBase.h:141
 23 | 	JSC_OBJC_API_ENABLED = 0
 24 | )
 25 | 
 26 | // ULWindowFlags as declared in AppCore/CAPI.h:47
 27 | type ULWindowFlags int32
 28 | 
 29 | // ULWindowFlags enumeration from AppCore/CAPI.h:47
 30 | const (
 31 | 	KWindowFlags_Borderless  ULWindowFlags = 1
 32 | 	KWindowFlags_Titled      ULWindowFlags = 2
 33 | 	KWindowFlags_Resizable   ULWindowFlags = 4
 34 | 	KWindowFlags_Maximizable ULWindowFlags = 8
 35 | )
 36 | 
 37 | // ULMessageSource as declared in Ultralight/CAPI.h:73
 38 | type ULMessageSource int32
 39 | 
 40 | // ULMessageSource enumeration from Ultralight/CAPI.h:73
 41 | const (
 42 | 	KMessageSource_XML            ULMessageSource = iota
 43 | 	KMessageSource_JS             ULMessageSource = 1
 44 | 	KMessageSource_Network        ULMessageSource = 2
 45 | 	KMessageSource_ConsoleAPI     ULMessageSource = 3
 46 | 	KMessageSource_Storage        ULMessageSource = 4
 47 | 	KMessageSource_AppCache       ULMessageSource = 5
 48 | 	KMessageSource_Rendering      ULMessageSource = 6
 49 | 	KMessageSource_CSS            ULMessageSource = 7
 50 | 	KMessageSource_Security       ULMessageSource = 8
 51 | 	KMessageSource_ContentBlocker ULMessageSource = 9
 52 | 	KMessageSource_Other          ULMessageSource = 10
 53 | )
 54 | 
 55 | // ULMessageLevel as declared in Ultralight/CAPI.h:81
 56 | type ULMessageLevel int32
 57 | 
 58 | // ULMessageLevel enumeration from Ultralight/CAPI.h:81
 59 | const (
 60 | 	KMessageLevel_Log     ULMessageLevel = 1
 61 | 	KMessageLevel_Warning ULMessageLevel = 2
 62 | 	KMessageLevel_Error   ULMessageLevel = 3
 63 | 	KMessageLevel_Debug   ULMessageLevel = 4
 64 | 	KMessageLevel_Info    ULMessageLevel = 5
 65 | )
 66 | 
 67 | // ULCursor as declared in Ultralight/CAPI.h:128
 68 | type ULCursor int32
 69 | 
 70 | // ULCursor enumeration from Ultralight/CAPI.h:128
 71 | const (
 72 | 	KCursor_Pointer                  ULCursor = iota
 73 | 	KCursor_Cross                    ULCursor = 1
 74 | 	KCursor_Hand                     ULCursor = 2
 75 | 	KCursor_IBeam                    ULCursor = 3
 76 | 	KCursor_Wait                     ULCursor = 4
 77 | 	KCursor_Help                     ULCursor = 5
 78 | 	KCursor_EastResize               ULCursor = 6
 79 | 	KCursor_NorthResize              ULCursor = 7
 80 | 	KCursor_NorthEastResize          ULCursor = 8
 81 | 	KCursor_NorthWestResize          ULCursor = 9
 82 | 	KCursor_SouthResize              ULCursor = 10
 83 | 	KCursor_SouthEastResize          ULCursor = 11
 84 | 	KCursor_SouthWestResize          ULCursor = 12
 85 | 	KCursor_WestResize               ULCursor = 13
 86 | 	KCursor_NorthSouthResize         ULCursor = 14
 87 | 	KCursor_EastWestResize           ULCursor = 15
 88 | 	KCursor_NorthEastSouthWestResize ULCursor = 16
 89 | 	KCursor_NorthWestSouthEastResize ULCursor = 17
 90 | 	KCursor_ColumnResize             ULCursor = 18
 91 | 	KCursor_RowResize                ULCursor = 19
 92 | 	KCursor_MiddlePanning            ULCursor = 20
 93 | 	KCursor_EastPanning              ULCursor = 21
 94 | 	KCursor_NorthPanning             ULCursor = 22
 95 | 	KCursor_NorthEastPanning         ULCursor = 23
 96 | 	KCursor_NorthWestPanning         ULCursor = 24
 97 | 	KCursor_SouthPanning             ULCursor = 25
 98 | 	KCursor_SouthEastPanning         ULCursor = 26
 99 | 	KCursor_SouthWestPanning         ULCursor = 27
100 | 	KCursor_WestPanning              ULCursor = 28
101 | 	KCursor_Move                     ULCursor = 29
102 | 	KCursor_VerticalText             ULCursor = 30
103 | 	KCursor_Cell                     ULCursor = 31
104 | 	KCursor_ContextMenu              ULCursor = 32
105 | 	KCursor_Alias                    ULCursor = 33
106 | 	KCursor_Progress                 ULCursor = 34
107 | 	KCursor_NoDrop                   ULCursor = 35
108 | 	KCursor_Copy                     ULCursor = 36
109 | 	KCursor_None                     ULCursor = 37
110 | 	KCursor_NotAllowed               ULCursor = 38
111 | 	KCursor_ZoomIn                   ULCursor = 39
112 | 	KCursor_ZoomOut                  ULCursor = 40
113 | 	KCursor_Grab                     ULCursor = 41
114 | 	KCursor_Grabbing                 ULCursor = 42
115 | 	KCursor_Custom                   ULCursor = 43
116 | )
117 | 
118 | // ULBitmapFormat as declared in Ultralight/CAPI.h:133
119 | type ULBitmapFormat int32
120 | 
121 | // ULBitmapFormat enumeration from Ultralight/CAPI.h:133
122 | const (
123 | 	KBitmapFormat_A8    ULBitmapFormat = iota
124 | 	KBitmapFormat_RGBA8 ULBitmapFormat = 1
125 | )
126 | 
127 | // ULKeyEventType as declared in Ultralight/CAPI.h:140
128 | type ULKeyEventType int32
129 | 
130 | // ULKeyEventType enumeration from Ultralight/CAPI.h:140
131 | const (
132 | 	KKeyEventType_KeyDown    ULKeyEventType = iota
133 | 	KKeyEventType_KeyUp      ULKeyEventType = 1
134 | 	KKeyEventType_RawKeyDown ULKeyEventType = 2
135 | 	KKeyEventType_Char       ULKeyEventType = 3
136 | )
137 | 
138 | // ULMouseEventType as declared in Ultralight/CAPI.h:146
139 | type ULMouseEventType int32
140 | 
141 | // ULMouseEventType enumeration from Ultralight/CAPI.h:146
142 | const (
143 | 	KMouseEventType_MouseMoved ULMouseEventType = iota
144 | 	KMouseEventType_MouseDown  ULMouseEventType = 1
145 | 	KMouseEventType_MouseUp    ULMouseEventType = 2
146 | )
147 | 
148 | // ULMouseButton as declared in Ultralight/CAPI.h:153
149 | type ULMouseButton int32
150 | 
151 | // ULMouseButton enumeration from Ultralight/CAPI.h:153
152 | const (
153 | 	KMouseButton_None   ULMouseButton = iota
154 | 	KMouseButton_Left   ULMouseButton = 1
155 | 	KMouseButton_Middle ULMouseButton = 2
156 | 	KMouseButton_Right  ULMouseButton = 3
157 | )
158 | 
159 | // ULScrollEventType as declared in Ultralight/CAPI.h:158
160 | type ULScrollEventType int32
161 | 
162 | // ULScrollEventType enumeration from Ultralight/CAPI.h:158
163 | const (
164 | 	KScrollEventType_ScrollByPixel ULScrollEventType = iota
165 | 	KScrollEventType_ScrollByPage  ULScrollEventType = 1
166 | )
167 | 
168 | // JSType as declared in JavaScriptCore/JSValueRef.h:53
169 | type JSType int32
170 | 
171 | // JSType enumeration from JavaScriptCore/JSValueRef.h:53
172 | const (
173 | 	KJSTypeUndefined JSType = iota
174 | 	KJSTypeNull      JSType = 1
175 | 	KJSTypeBoolean   JSType = 2
176 | 	KJSTypeNumber    JSType = 3
177 | 	KJSTypeString    JSType = 4
178 | 	KJSTypeObject    JSType = 5
179 | )
180 | 
181 | // JSTypedArrayType as declared in JavaScriptCore/JSValueRef.h:83
182 | type JSTypedArrayType int32
183 | 
184 | // JSTypedArrayType enumeration from JavaScriptCore/JSValueRef.h:83
185 | const (
186 | 	KJSTypedArrayTypeInt8Array         JSTypedArrayType = iota
187 | 	KJSTypedArrayTypeInt16Array        JSTypedArrayType = 1
188 | 	KJSTypedArrayTypeInt32Array        JSTypedArrayType = 2
189 | 	KJSTypedArrayTypeUint8Array        JSTypedArrayType = 3
190 | 	KJSTypedArrayTypeUint8ClampedArray JSTypedArrayType = 4
191 | 	KJSTypedArrayTypeUint16Array       JSTypedArrayType = 5
192 | 	KJSTypedArrayTypeUint32Array       JSTypedArrayType = 6
193 | 	KJSTypedArrayTypeFloat32Array      JSTypedArrayType = 7
194 | 	KJSTypedArrayTypeFloat64Array      JSTypedArrayType = 8
195 | 	KJSTypedArrayTypeArrayBuffer       JSTypedArrayType = 9
196 | 	KJSTypedArrayTypeNone              JSTypedArrayType = 10
197 | )
198 | 
199 | const (
200 | 	// KJSPropertyAttributeNone as declared in JavaScriptCore/JSObjectRef.h:51
201 | 	KJSPropertyAttributeNone = iota
202 | 	// KJSPropertyAttributeReadOnly as declared in JavaScriptCore/JSObjectRef.h:52
203 | 	KJSPropertyAttributeReadOnly = 2
204 | 	// KJSPropertyAttributeDontEnum as declared in JavaScriptCore/JSObjectRef.h:53
205 | 	KJSPropertyAttributeDontEnum = 4
206 | 	// KJSPropertyAttributeDontDelete as declared in JavaScriptCore/JSObjectRef.h:54
207 | 	KJSPropertyAttributeDontDelete = 8
208 | )
209 | 
210 | const (
211 | 	// KJSClassAttributeNone as declared in JavaScriptCore/JSObjectRef.h:69
212 | 	KJSClassAttributeNone = iota
213 | 	// KJSClassAttributeNoAutomaticPrototype as declared in JavaScriptCore/JSObjectRef.h:70
214 | 	KJSClassAttributeNoAutomaticPrototype = 2
215 | )
216 | 


--------------------------------------------------------------------------------
/ultralight/doc.go:
--------------------------------------------------------------------------------
 1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
 2 | 
 3 | // WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
 4 | // Code generated by https://git.io/c-for-go. DO NOT EDIT.
 5 | 
 6 | /*
 7 | Ultralight bindings for golang
 8 | */
 9 | package ultralight
10 | 


--------------------------------------------------------------------------------
/ultralight/libs/EULA.txt:
--------------------------------------------------------------------------------
 1 | EXHIBIT A
 2 | 
 3 | END USER LICENSE AGREEMENT
 4 | 
 5 | This End User License Agreement ("EULA"), effective today, is made by and between you and Ultralight, Inc., having an address at 15822 Jamie Lee Drive, Houston, Texas 77095 ("Ultralight Inc"), and concerns certain software known as "Ultralight."  The Ultralight software includes a library that makes it easy for developers to embed HTML UI in their applications.  Ultralight software provides developers the ability to embed and manipulate an instance of a web page and render it using a virtual GPU device driver.
 6 | License Grant.  A limited, non-exclusive, nontransferable, and revocable license is granted to you to install, access, and use the Ultralight software solely in conjunction with and through third-party software separately licensed to you (the "Licensed Product") and subject to the terms and conditions of the third-party's license with Ultralight Inc.  By using the Ultralight software (through the Licensed Product), you accept the terms and conditions herein.  You may print and save a copy of this EULA for your records.
 7 | Permitted Use and Restrictions.  You agree to use and access the Ultralight Software solely in conjunction with and through the Licensed Product separately licensed to you.  You agree not to reverse engineer, decompile, disassemble, modify, translate, make any attempt to discover the source code of the Ultralight software, or modify, or otherwise create derivative works of, the Ultralight software.
 8 | 
 9 | Ownership of Intellectual Property.  You acknowledge that Ultralight Inc owns and shall continue to own all intellectual property rights in the Ultralight software, including any documentation.  You agree to use reasonable best efforts to protect the contents of the Ultralight software and to prevent unauthorized copying, disclosure, or use by your agents, officers, employees, and consultants.
10 | 
11 | Copyright Notice.  Ultralight (c) 2018 Ultralight, Inc.  All rights reserved.  Ultralight is a trademark of Ultralight, Inc.
12 | 
13 | Disclaimer of Warranties, "AS IS".  THE ULTRALIGHT SOFTWARE, INCLUDING, WITHOUT LIMITATION, ALL SOFTWARE, DOCUMENTS, FUNCTIONS, MATERIALS, AND INFORMATION, IS PROVIDED "AS IS."  TO THE FULLEST EXTENT PERMISSIBLY BY LAW, Ultralight Inc MAKES NO OTHER REPRESENTATIONS, EXTENDS NO OTHER WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT (INCLUDING ANY OPEN SOURCE VIOLATIONS), AND ASSUMES NO LIABILITY TO YOU OR ANY OTHER PERSON FOR OR ON ACCOUNT OF ANY INJURY, LOSS OR DAMAGE, OF ANY KIND OR NATURE, SUSTAINED BY, OR ANY DAMAGE ASSESSED OR ASSERTED AGAINST, OR ANY OTHER LIABILITY INCURRED BY OR IMPOSED ON YOU OR ANY OTHER PERSON (INCLUDING DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES, NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)), ARISING OUT OF OR IN CONNECTION WITH OR RESULTING FROM THE USE OF THE ULTRALIGHT SOFTWARE OR THIS EULA, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 | 
15 | Exclusive Remedy; Limitation of Liability.  For any breach of warranty, your exclusive remedy shall be to return the Ultralight software to Ultralight Inc.  Under this EULA, Ultralight Inc's maximum liability is further limited to one US Dollar (USD$1.00).
16 | 
17 | Termination.  This EULA is effective until terminated.  Your rights under this EULA will terminate automatically without notice from Ultralight Inc if you fail to comply with any term(s) of this EULA.  You may terminate this EULA by giving written notice of termination to the Ultralight Inc.  Upon termination of this EULA, you shall immediately discontinue all use of the Ultralight Software and destroy the original and all copies, full or partial, including any associated documentation.
18 | 
19 | Export Controls.  The Ultralight software, including any downloading or use of, may be subject to export controls imposed by U.S. export control laws, including the U.S. Export Administration Act and its associated regulations, and may be subject to export or import regulations in other countries.  You agree to comply strictly with all such regulations and acknowledge that you have the responsibility to obtain licenses to export, re-export, or import the Ultralight software.
20 | 
21 | Governing Law and General Provisions.  This EULA shall be governed by the laws of the State of Texas, excluding the application of its conflicts of law rules.  You agree that any dispute regarding or relating to this EULA shall be litigated only in federal or state courts in Harris County, Texas, and hereby waive any objection to the jurisdiction of such courts.  This EULA shall not be governed by the United Nations Convention on Contracts for the International Sale of Goods, the application of which is expressly excluded.  If any provisions of this EULA are held invalid or unenforceable for any reason, the remaining provisions shall remain in full force and effect.  This EULA is binding upon your successors and assigns.  This EULA may be modified only by a non-electronic amendment, signed by each party.  This EULA may not be assigned or transferred to any other person or entity by you without the express consent of Ultralight Inc.  This EULA constitutes the entire agreement between the parties with respect to the use of the Ultralight software licensed hereunder and supersedes all other previous or contemporaneous agreements or understandings between the parties, whether verbal or written, concerning the subject matter.
22 | 
23 | For additional information concerning open-source licensing and required copyright notices, please see the included NOTICES.txt.


--------------------------------------------------------------------------------
/ultralight/libs/LICENSE.txt:
--------------------------------------------------------------------------------
  1 | ULTRALIGHT FREE LICENSE AGREEMENT - V1
  2 | 
  3 | This LICENSE AGREEMENT ("Agreement"), effective as of Effective Date, by and between Ultralight, Inc., having an address at 15822 Jamie Lee Drive, Houston, Texas 77095 ("Ultralight Inc") and Licensee.  Ultralight Inc and Licensee are collectively referred to as the "Parties" and individually referred to as a "Party".  A copy of this Agreement may be printed and saved for Licensee's records.
  4 | RECITALS
  5 |       WHEREAS, Ultralight Inc has developed software, known as the Ultralight software ("Ultralight"), which includes a library that makes it easy for developers to embed HTML UI in their applications.  Ultralight software provides developers the ability to embed and manipulate an instance of a web page and render it using a virtual GPU device driver.
  6 |       WHEREAS, Licensee desires to obtain a non-exclusive, free license to use the Ultralight software to develop, distribute, and display applications licensed to third party users ("End Users") or for public display, using Ultralight software to manipulate and render web pages under the terms and conditions of this Agreement.
  7 |       NOW, THEREFORE, in consideration of the foregoing premises and of the mutual covenants and obligations hereinafter contained, and other good and valuable consideration, the receipt and legal sufficiency of which is hereby acknowledged, the Parties hereto agree as follows:
  8 | ARTICLE 1 
  9 | 
 10 | DEFINITIONS
 11 |       1.1 Definitions.  As used herein, the following terms have the meanings set forth below:
 12 |             1.1.1 "Affiliates" means, with respect to an entity or person, any entity or person that directly or indirectly through one or more intermediaries Controls, is Controlled by, or is under common Control with such entity or person.
 13 |             1.1.2 "Agreement" has the meaning as set forth in the preamble.
 14 |             1.1.3 "Ultralight" has the meaning as set forth in the preamble and includes portions of WebKit software.  The Ultralight software includes a set of C++ header files, static libraries, dynamically-linked libraries, and documentation. For purposes of this Agreement, Ultralight includes the current version of the Ultralight software as of the Effective Date, and any Maintenance Releases during the Support Period, but does not include future releases made after the Support Period.  For purposes of this Agreement, the Ultralight software does NOT include its source code.
 15 |             1.1.4 "Commercial" means for profit or in commerce, including marketing and promotions activities, whether or not profit, revenues, or sales are generated by such purpose.
 16 |             1.1.5 "Commercial Application" has the meaning as set forth in Section 2.2.
 17 |             1.1.6 "Confidential Information" means (a) any information disclosed by either Party to the other Party, either directly or indirectly, in writing, orally or by inspection of tangible objects, including, without limitation, trade secrets, data, know-how, materials, inventions, services, formulas, processes, designs, development, photographs, plans, drawings, models, specifications, samples, reports, pricing information, studies, findings, engineering, finances, financial models, business plans, listings and (concepts to the extent practical, Confidential Information will be disclosed in documentary or tangible form marked "Confidential" (collectively, the "Disclosed Materials")) and (b) any information otherwise obtained, directly or indirectly, by a receiving Party through inspection, review or analysis of the Disclosed Materials.  Confidential Information shall not lose its status merely because it was disclosed orally.  Confidential Information may also include information of a third party that is in the possession of one of the Parties and is disclosed to the other Party under this Agreement.  Confidential Information shall not, however, include any information that (i) was publicly known and made generally available in the public domain prior to the time of disclosure by the disclosing Party; (ii) becomes publicly known and made generally available after disclosure by the disclosing Party to the receiving Party through no action or inaction of the receiving Party; (iii) is already in the possession of the receiving Party at the time of disclosure by the disclosing Party as shown by the receiving Party's files and records immediately prior to the time of disclosure; (iv) is obtained by the receiving Party from a third party lawfully in possession of such information and without a breach of such third party's obligations of confidentiality; or (v) is independently developed by the receiving Party without use of or reference to the disclosing Party's Confidential Information, as shown by documents and other competent evidence in the receiving Party's possession.  The burden of proof shall be on the receiving Party to establish the existence of facts giving rise by clear and convincing evidence that any of the foregoing exceptions to the receiving Party's obligation of confidence apply.
 18 |             1.1.7 "Control" shall mean the possession, directly or indirectly, of the power to direct or cause the direction of the management, activities or policies of any Person, whether through the ownership of voting securities, by contract, employment or otherwise.
 19 |             1.1.8 "Disclosed Material" has the meaning as set forth in Section 1.1.6.
 20 |             1.1.9 "End Users" has the meaning as set forth in the preamble.
 21 |             1.1.10 "Effective Date" has the meaning as set forth in the preamble and is the date the Licensee enters into the Agreement with Ultralight Inc, by the Licensee agreeing to the terms and conditions of the Agreement by signing the Agreement or by otherwise accepting the terms and conditions, e.g., by Licensee clicking on a button on a computer screen, or by Licensee using or installing the Ultralight software.
 22 |             1.1.11 "WebKit" is Open Source software code developed by Apple and licensed under the BSD license and other licenses.  See also https://webkit.org/licensing-webkit/
 23 |             1.1.12 "Improvement" means any enhancement, conception, suggestion, invention or discovery created or otherwise developed by Ultralight Inc or Licensee during the Term, which constitutes an improvement to the Ultralight software.
 24 |             1.1.13 "Indemnified Party" has the meaning as set forth in Section 8.3.
 25 |             1.1.14 "Indemnifying Party" has the meaning as set forth in Section 8.3.
 26 |             1.1.15 "Infringement" has the meaning as set forth in Section 4.6. 
 27 |             1.1.16 "Internal" means solely within Licensee and Licensee's Affiliates.
 28 |             1.1.17 "Ultralight Inc" has the meaning as set forth in the preamble.
 29 |             1.1.18 "Licensed Product" means any application, device, or software developed by the Licensee, the access, copy, distribution, display, manufacture, use, or sale of which would, if not licensed under this Agreement, infringe or misappropriate in any way the Ultralight software.
 30 |             1.1.19  "Licensee" refers to the party to the Agreement to whom Ultralight Inc grants license rights to the Ultralight software as described herein.
 31 |             1.1.20 "Losses" has the meaning as set forth in Section 8.1. 
 32 |             1.1.21 "Maintenance Release" has the meaning as set forth in ARTICLE 5. 
 33 |             1.1.22 "Non-Commercial" has the meaning as set forth in Section 2.2.
 34 |             1.1.23 "Open Source" means software in which source code is generally available for modification and distribution, and which may include specific license requirements for other software that accesses, embeds, or uses the open source software.
 35 |             1.1.24 "Party" or "Parties" has the meaning as set forth in the preamble.
 36 |             1.1.25 "Platform" has the meaning as set forth in Section 2.3.
 37 |             1.1.26 "Support Period" has the meaning as set forth in ARTICLE 5.
 38 |             1.1.27 "Term" has the meaning as set forth in Section 10.1.
 39 |             1.1.28 "Trademarks" means any filed or unfiled, common law, state law and federal law rights, as well as all international trademark rights, Ultralight Inc has in any trademarks for Ultralight software.
 40 |             1.1.29 "Web" means the World Wide Web as set forth in the preamble.
 41 | ARTICLE 2 
 42 | 
 43 | LICENSE GRANT
 44 |       2.1 Development License Grant.  Ultralight Inc hereby grants to Licensee a limited, non-transferable, non-exclusive, revocable, non-sublicensable, world-wide right and license to the Ultralight software solely to develop applications that access, embed, and use the Ultralight software ("Licensed Products"), including to test and evaluate such Licensed Products Internally by Licensee, under the terms and conditions herein.  For purposes of clarity, this development license grant in Section 2.1 does not include any right or license to distribute the Ultralight software or to publically display or publically perform Licensed Products utilizing the Ultralight software.
 45 |       2.2 Non-Commercial Distribution License Grant.  Ultralight Inc hereby grants to Licensee a limited, non-transferable, non-exclusive, revocable, sublicensable as described herein, world-wide right and license to the Ultralight software to copy, develop, display, distribute, export, import, make, publically perform, test, and use a Licensed Product utilizing the Ultralight software, solely for Internal and Non-Commercial purposes, excluding use within Government agencies.  The term "Non-Commercial" as used in this Agreement, means academic or other scholarly research which (a) is not undertaken for profit, or (b) is not intended to produce works, services, or data for Commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged in the Commercial use, application or exploitation of works similar to the software.
 46 |       2.3 Limited Commercial Distribution License Grant. 	Ultralight Inc hereby grants to Licensee a limited, non-transferable, non-exclusive, revocable, sublicensable as described herein, world-wide right and license to the Ultralight software to copy, develop, display, distribute, evaluate, export, import, make, market, publically perform, sell, test, and use a Licensed Product utilizing the Ultralight software for Commercial purposes, excluding use within Government agencies. This provision is NOT valid if Licensee is a company or incorporated entity that had a turnover in excess of US$100,000 in their last fiscal year. In the event Licensee makes a turnover in excess of US$100,000 in any subsequent fiscal year, all commercial distribution provisions of this Agreement will be revoked and Licensee must negotiate a new license with Ultralight Inc to continue commercial distribution.
 47 |       2.4 Trademark License.  In the event that Licensee, at its sole discretion, decides to use Ultralight Inc's Trademarks, Ultralight Inc hereby grants Licensee a non-exclusive, royalty-free right and license to use, including the right to sublicense, the Trademarks in conjunction with Licensee's marketing, advertising, manufacturing information, and product packaging activities.
 48 |             2.4.1 Non-Assignment.  Licensee acknowledges and agrees that the trademark rights granted to Licensee by and obtained by Licensee as a result of or in connection with this Agreement are license rights only, and nothing contained in this Agreement constitutes or shall be construed to be an assignment of any or all of Ultralight Inc's rights in the Trademarks.  All goodwill associated with such activities of Licensee shall inure to the benefit of the Ultralight Inc.
 49 |             2.4.2 Quality of Product.  In the event Licensee decides to use Ultralight Inc's Trademarks, Licensee agrees to maintain a high quality of any Licensed Product provided under the Trademark consistent with the quality of previous versions of Ultralight Inc's products as of the Effective Date and consistent with a standard that ensures the continued protection of the Trademark and the goodwill pertaining to the Trademark.  In such an event, Ultralight Inc reserves the right to receive samples of the mark as used in conjunction with the Licensed Product no more than once per year or as reasonably provided by Licensee, to ensure that the quality meets the foregoing standard.
 50 |             2.4.3 Trademark Format.  Licensee shall only use or display the Trademark in a format approved by Ultralight Inc, such approval not to be unreasonably withheld.
 51 |             2.4.4 Proper Notice and Acknowledgment.  Every use of the Trademark by Licensee shall incorporate in an appropriate manner a "TM" or once it is registered an "R" enclosed by a circle or the phrase "Reg. U.S. Trademark of Ultralight, Inc.".
 52 |             2.4.5 Impairment of Ultralight Inc's Rights.  If Licensee decides to use the Trademark, Licensee shall not at any time, whether during or after the Term of this Agreement, do or cause to be done any act or thing challenging, contesting, impairing, invalidating, or tending to impair or invalidate any of Ultralight Inc's rights in the Trademark or any registrations derived from such rights.
 53 |             2.4.6 Ultralight Inc's Rights and Remedies.  If Licensee decides to use the Trademark, Licensee acknowledges and agrees that Ultralight Inc has, shall retain and may exercise, both during the Term of this Agreement and thereafter, all rights and remedies available to Ultralight Inc, whether derived from this Agreement, from statute, or otherwise, as a result of or in connection with Licensee's breach of the trademark license granted in this Agreement, misuse of the Trademark or any other use of the Trademark by Licensee which is not permitted by this Agreement.
 54 | ARTICLE 3 
 55 | 
 56 | RESTRICTIONS AND IMPROVEMENTS
 57 |       3.1 Restrictions.  All rights not expressly granted in this Agreement are reserved by Ultralight Inc.  Nothing contained in this Agreement shall be interpreted to give Licensee any rights with respect to any copyrights, patents, trademarks, or other intellectual property, including software by Ultralight Inc other than Ultralight software under the terms described herein.
 58 |       3.2 Ownership of Intellectual Property.  As between Ultralight Inc and Licensee, Ultralight Inc owns and shall continue to own all intellectual property rights in the Ultralight software.  Nothing in this agreement shall be construed to grant Ultralight Inc any rights to Licensee's Licensed Products, except as expressly stated herein.
 59 |       3.3 Interest in Improvements.  Ultralight Inc shall own all intellectual property rights and all other property rights in new patent applications and Improvements which Ultralight Inc makes to the Ultralight software, including using information received from Licensee or while performing Ultralight Inc's obligations under the terms of this Agreement.  Licensee hereby assigns, transfers and conveys to Ultralight Inc, and the Ultralight Inc hereby accepts and assumes, free and clear of and from encumbrances, all right, title and interest, together with all rights of priority, in and to such Improvements and the patent(s) that may issue from such Improvements, and including the subject matter of all claims that may be obtained therefrom, any foreign counterparts or equivalents thereto, existing now or in the future, and any and all divisionals, continuations (in whole or in part), reissues, renewals and extensions of any of the foregoing, any substitutions therefore and any patents that may issue from the foregoing, the same to be held and enjoyed by Ultralight Inc for its own use and benefit, and for the use and benefit of its successors or assigns, to the end of the term or terms for which said patents are or may be granted or reissued, as fully and entirely as the same would have been held and enjoyed by the Licensee if this assignment had not been made.  Such assignment includes, without limitation, all income, royalties, damages or payments due or payable after the Effective Date related to any of the foregoing and all claims for damages by reason of past, present or future infringement or other unauthorized use of the foregoing, with the right to sue for and collect the same.  Licensee hereby authorizes and requests the Commissioner of Patents of the United States Patent and Trademark Office, or any equivalent body in any foreign jurisdiction, to record this assignment so as to reflect Ultralight Inc's ownership of the Improvements.  Licensee hereby covenants and agrees that the Licensee will, at any time, upon request, execute and deliver any and all papers and take any and all other reasonable actions that may be necessary or desirable to implement or perfect this assignment, without further compensation but at the expense of the assignee, its successors or assigns with respect to Licensee's reasonable out-of-pocket costs.
 60 |       3.4 Protection of Improvements.  Ultralight Inc shall prepare, file, prosecute, obtain, maintain and enforce any or all intellectual property rights in, to, and under the Improvements.  Notwithstanding the foregoing, Ultralight Inc shall be under no obligation to prosecute or pursue intellectual property protection, in, to or under any Improvements inside or outside of the United States.
 61 | ARTICLE 4 
 62 | 
 63 | CERTAIN LICENSEE OBLIGATIONS
 64 |       4.1 No Reverse Engineering.  Unless otherwise agreed to in writing, Licensee agrees not to reverse engineer, decompile, disassemble, modify, translate, make any attempt to discover the source code of the Ultralight software, or modify, or otherwise create derivative works of, the Ultralight software.
 65 |       4.2 No Static Linking.  Unless otherwise agreed to in writing, Licensee agrees not to access the Ultralight.dll using static-linking tools or other methods that hide or conceal any of the Ultralight software.
 66 |       4.3 Licensing of End Users.  Subject to the license grant in ARTICLE 2, Licensee may distribute to End Users the Ultralight software, as part of and in conjunction with Licensed Products, provided that such distribution to End Users is subject to the End User License Agreement in Exhibit A, or a license by Licensee having substantially the same terms and conditions.
 67 |       4.4 Marking.  Licensee shall ensure that the following legend, or a successor legend as designated by Ultralight Inc from time to time, shall appear in the credit section of any Licensed Product:  
 68 | 
 69 | 			Please see the accompanying NOTICES.txt for full text.
 70 | 
 71 |       4.5 Export Controls.  The Ultralight software, including any downloading or use of, may be subject to export controls imposed by U.S. export control laws, including the U.S. Export Administration Act and its associated regulations, and may be subject to export or import regulations in other countries.  Licensee agrees to comply strictly with all such regulations and acknowledges that Licensee has the responsibility to obtain licenses to export, re-export, or import the Ultralight software.
 72 |       4.6 Infringement.  Licensee agrees to promptly notify Ultralight Inc if it becomes aware of any third party that infringes Ultralight Inc's intellectual property rights, including misappropriation of the Ultralight software or violations of an End User license agreement (an "Infringement").  Ultralight Inc, at its discretion, shall have the right, but not the obligation, to enforce intellectual property rights against any Infringement.  Ultralight Inc shall solely control any such enforcement action.
 73 |       4.7 Update Contact Information.  Licensee shall promptly report to Ultralight Inc any change in mailing address, name or company affiliation during the period of this Agreement, and Licensee also shall promptly report when, and if, Licensee discontinues its development and marketing of the Ultralight software, and/or when Licensee discontinues its efforts to bring the Licensed Products to practical application.
 74 | ARTICLE 5 
 75 | 
 76 | [THIS SECTION INTENTIONALLY RESERVED.]
 77 | ARTICLE 6 
 78 | 
 79 | PAYMENTS AND ROYALTY
 80 |       6.1 Payment.  No payment or royalty is required for this Free License Agreement.  For Commercial purposes or additional license rights, please contact Ultralight Inc:  Ultralight, Inc., 15822 Jamie Lee Drive, Houston, Texas 77095, or through e-mail: sales@ultralig.ht
 81 | ARTICLE 7 
 82 | 
 83 | REPRESENTATIONS AND WARRANTIES
 84 |       7.1 LIMITATION OF WARRANTY; "AS IS".  THE ULTRALIGHT SOFTWARE, INCLUDING, WITHOUT LIMITATION, ALL SOFTWARE, DOCUMENTS, FUNCTIONS, MATERIALS, AND INFORMATION, IS PROVIDED "AS IS."  TO THE FULLEST EXTENT PERMISSIBLY BY LAW, Ultralight Inc MAKES NO OTHER REPRESENTATIONS, EXTENDS NO OTHER WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT (INCLUDING ANY OPEN SOURCE VIOLATIONS), AND ASSUMES NO LIABILITY TO LICENSEE OR ANY OTHER PERSON FOR OR ON ACCOUNT OF ANY INJURY, LOSS OR DAMAGE, OF ANY KIND OR NATURE, SUSTAINED BY, OR ANY DAMAGE ASSESSED OR ASSERTED AGAINST, OR ANY OTHER LIABILITY INCURRED BY OR IMPOSED ON LICENSEE OR ANY OTHER PERSON (INCLUDING DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES, NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)), ARISING OUT OF OR IN CONNECTION WITH OR RESULTING FROM THE USE OF THE ULTRALIGHT SOFTWARE OR THIS AGREEMENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 85 |       7.2 Maximum Liability.  Regardless of the basis on which a claim is made (including fundamental breach, negligence, misrepresentation, or other contract or tort claim), Ultralight Inc's maximum liability under this Agreement is further limited to the lesser of: the amount paid or due Ultralight Inc under this Agreement, or one US Dollar (USD$1.00).  This limitation shall not apply to any claim based on an indemnity in ARTICLE 8 below.
 86 | ARTICLE 8 
 87 | 
 88 | INDEMNIFICATION
 89 |       8.1 Indemnification by Licensee.  Provided that Ultralight Inc provides prompt and reasonable notice to Licensee, then Licensee shall defend and indemnify Ultralight Inc from and against any and all claims for damages, losses, liabilities, costs and expenses (including reasonable legal fees and expenses), deficiencies, including interest and penalties imposed or assessed by any judicial or administrative body, including, all amounts paid in investigation, defense or settlement of the foregoing, (collectively, the "Losses") incurred by Ultralight Inc that arise out of:
 90 |             8.1.1 any breach of Licensee's obligations in ARTICLE 4; or 
 91 |             8.1.2 any breach of the confidentiality obligations under ARTICLE 9 by Licensee, its Affiliates, employees, or contractors; or
 92 |             8.1.3 any third-party claim of infringement or misappropriation that arises out of the Licensed Product due to use of the Ultralight software in combination with Licensee's software or technology.
 93 |       8.2 Indemnification by Ultralight Inc.  Provided that Licensee provides prompt and reasonable notice to Ultralight Inc, then Ultralight Inc shall defend and indemnify Licensee from and against all Losses incurred by Licensee that arise out of: any breach of the confidentiality obligations under ARTICLE 9 by Ultralight Inc, its Affiliates, employees, or contractors.
 94 |       8.3 Party Seeking Indemnification.  (a) If either Party seeks indemnification under the terms of this ARTICLE 8 (the "Indemnified Party") against the other Party (the "Indemnifying Party"), the Indemnified Party shall promptly notify the Indemnifying Party in writing of the third party claim or threatened third party claim it receives notice thereof, shall permit the Indemnifying Party, at the Indemnifying Party's cost and expense, to assume direction and control of the defense of the third party claim, and shall cooperate as requested (at the expense of the Indemnifying Party), in the defense of the claim.
 95 |             8.3.1 The obligations of the Indemnifying Party to indemnify the Indemnified Party pursuant to Section 8.1 and Section 8.2 are conditioned upon the delivery of written notice to the Indemnifying Party of any asserted or threatened third party claim promptly after the Indemnified Party becomes aware of such third party claim; provided, that, the failure of the Indemnified Party to give such notice or any delay thereof shall not offset the Indemnified Party's right to indemnification hereunder, except to the extent that such failure or delay impairs the Indemnifying Party's ability to defend or contest any such third party claim.
 96 | ARTICLE 9 
 97 | 
 98 | CONFIDENTIALITY
 99 |       9.1 Non-use and Non-disclosure.  Each Party agrees not to use any Confidential Information of the other Party for any purpose except for the purposes set forth in this Agreement.  Each Party agrees not to disclose any Confidential Information of the other Party, except that, subject to Section 9.2 below, a receiving Party may disclose the other Party's Confidential Information (except Source Code unless otherwise specified in writing) to those employees of the receiving Party who are required to have the information for the purposes set forth in this Agreement, and relevant consultants, provided that the receiving Party first obtains a signed confidentiality agreement with terms similar to this Agreement from the consultants, such that consultants are under a confidentiality obligation to the receiving Party.  If a receiving Party is required by law to make any disclosure that is prohibited or otherwise constrained by this Agreement, the receiving Party will provide the disclosing Party with prompt written notice of such requirement so that the disclosing Party may seek a protective order or other appropriate relief.  Subject to the foregoing sentence, such receiving Party may furnish that portion (and only that portion) of the Confidential Information that the receiving Party is legally compelled or is otherwise legally required to disclose; provided, however, that the receiving Party provides such reasonable assistance as the disclosing Party may request in obtaining such order or other relief.
100 |       9.2 Maintenance of Confidentiality.  Each Party agrees that it shall take reasonable measures to protect the secrecy of and avoid disclosure and unauthorized use of the Confidential Information of the other Party.  Without limiting the foregoing, each Party shall take at least those measures that it takes to protect its own confidential information of a similar nature, but in no case less than reasonable care (including, without limitation, all precautions the receiving Party employs with respect to its confidential materials).  Prior to any disclosure of Confidential Information to its employees, each Party shall ensure that such employees who have access to the other Party's Confidential Information have signed a non-disclosure agreement in content similar to the provisions of this Agreement or are otherwise legally obligated not to disclose such Confidential Information.  Each Party shall reproduce the other Party's proprietary rights notices on any photo or electronic copies, in the same manner in which such notices were set forth in or on the original.  A Party receiving Confidential Information shall promptly notify the Party disclosing such Confidential Information of any use or disclosure of such Confidential Information in violation of this Agreement of which the receiving Party becomes aware.
101 |       9.3 Source Code.  For purposes of clarity, any Source Code may not be disclosed by a receiving Party to any third party, including consultants under non-disclosure agreements, without the prior written consent of the disclosing Party.
102 |       9.4 Limitation on Copying.  Other than Ultralight Inc's rights in the Improvements, the disclosing Party retains and owns all copyrights, rights in derivative works in the Confidential Information and the receiving Party hereby agrees not to copy the Confidential Information, in whole or in part, except as is necessary to perform its tasks under this Agreement.
103 |       9.5 Return of Materials.  All documents and other tangible objects containing or representing Confidential Information that have been disclosed by either Party to the other Party, shall be and remain the property of the disclosing Party and shall be promptly returned to the disclosing Party upon the disclosing Party's written request.  Notwithstanding the foregoing, one (1) copy of any written or photographic Confidential Information provided by the other Party may be retained by the receiving Party for archival purposes only.
104 |       9.6 Duration.  The confidentiality obligations of each receiving Party under this Agreement shall survive until such time as all Confidential Information of the other Party disclosed hereunder becomes publicly known and made generally available through no action or inaction of the receiving Party.  The obligations to hold information in confidence as required by ARTICLE 9 also shall survive any termination of this Agreement.
105 |       9.7 Duty to Notify of Confidentiality Breach.  Either Party shall immediately provide written notice to the other Party of any breach of this ARTICLE 9, specifying the specific nature of the breach.  The breaching Party shall then have thirty (30) days to reasonably cure the breach.  Should such breach not be reasonably cured within sixty (60) days from receipt of such notice, then the non-breaching Party may terminate this Agreement.
106 |       9.8 Availability of Equitable Relief.  Each Party understands and agrees that its breach or threatened breach of this Agreement will cause irreparable injury to the other Party and that money damages will not provide an adequate remedy for such breach or threatened breach, and both parties hereby agree that, in the event of such a breach or threatened breach, the non-breaching Party will also be entitled, without the requirement of posting a bond or other security, to equitable relief, including injunctive relief and specific performance.  The Parties' rights under this Agreement are cumulative, and a Party's exercise of one right shall not waive the Party's right to assert any other legal remedy.
107 | ARTICLE 10 
108 | 
109 | TERM AND TERMINATION
110 |       10.1 Term.  This Agreement will be for a term beginning on the Effective Date and will continue in effect unless otherwise terminated as provided by under Section 9.7 or as provided for in this ARTICLE 10, including:
111 |            10.1.1 Termination by Licensee.  Licensee may terminate this Agreement by providing Ultralight Inc with thirty (30) days prior written notice intent to terminate.
112 |            10.1.2 Termination by Ultralight Inc.  Ultralight Inc may terminate this Agreement with notification to Licensee of any breach of Licensee's obligations in ARTICLE 4 if such breach is not reasonably cured within thirty (30) days from receipt of such notice.
113 |       10.2 Effect of Termination.  Upon termination or expiration of this Agreement, (1) the licenses granted to Licensee herein shall immediately cease; (2) if Licensee has decided to use the Trademark, Licensee shall immediately cease and desist from using the Trademark in conjunction with any future marketing and advertising activities; and (3) any license fee, consulting fee, or other payment owed by Licensee to Ultralight Inc shall become immediately due and payable.
114 |       10.3 Surviving Provisions.  Notwithstanding any provision herein to the contrary, the rights and obligations of the Parties set forth in Articles 3, 7, 8, 9, 10 and 11, as well as any rights or obligations otherwise accrued hereunder, including any accrued payment obligations, shall survive the expiration or termination of the Term.
115 | ARTICLE 11 
116 | 
117 | GENERAL PROVISIONS
118 |       11.1 Severability.  If any provision(s) of this Agreement are deemed to be unenforceable or are or become invalid, or are ruled illegal by any court of appropriate jurisdiction under then current applicable law from time to time in effect during the Term hereof, it is the intention of the Parties that the remainder of this Agreement shall not be affected thereby provided that a Party's rights under this Agreement are not materially affected.  The Parties hereto covenant and agree to renegotiate any such term, covenant or application thereof in good faith in order to provide a reasonably acceptable alternative to the term, covenant or condition of this Agreement or the application thereof that is invalid, illegal or unenforceable, it being the intent of the Parties that the basic purposes of this Agreement are to be effectuated.
119 |       11.2 Venue and Jurisdiction.  This Agreement shall be governed by and construed in accordance with the internal laws of the State of Texas, without reference to its conflicts of laws and choice of law rules or principles. Any disputes arising hereunder shall be adjudicated in Harris County, Texas, which state or federal courts having appropriate jurisdiction shall have exclusive jurisdiction over such dispute(s) but not including any appeals from decisions therefrom.
120 |       11.3 Notification.  All notices, requests and other communications hereunder shall be in writing, shall be addressed to the receiving Party's address set forth below or as otherwise provided by Licensee to Ultralight Inc, or to such other address as a Party may designate by notice hereunder, and shall be either: (a) delivered by hand; (b) made by facsimile transmission (to be followed with written fax confirmation); (c) sent by private courier service providing evidence of receipt; or (d) sent by registered or certified mail, return receipt requested, postage prepaid.  The addresses and other contact information for the Parties are as follows:
121 | 
122 | If to Ultralight Inc:
123 | Mr. Adam Simmons
124 | 15822 Jamie Lee Drive
125 | Houston, Texas 77095
126 | 
127 | All notices, requests and other communications hereunder shall be deemed to have been given either: (a) if by hand, at the time of the delivery thereof to the receiving Party at the address of such Party set forth above; (b) if made by telecopy or facsimile transmission, at the time that receipt thereof has been acknowledged by the recipient; (c) if sent by private courier, on the day such notice is delivered to the recipient; or (d) if sent by registered or certified mail, on the fifth (5th) business day following the day such mailing is made.
128 |       11.4 Entire Agreement.  This is the entire Agreement between the Parties with respect to the subject matter hereof and supersedes all prior representations, understandings and agreements between the Parties with respect to the subject matter hereof.  No modification shall be effective unless in writing with specific reference to this Agreement and signed by the Parties.
129 |       11.5 Waiver.  The terms or conditions of this Agreement may be waived only by a non-electronic written instrument executed by the Party waiving compliance.  The failure of either Party at any time or times to require performance of any provision hereof shall in no manner affect its rights at a later time to enforce the same.  No waiver by either Party of any condition or term shall be deemed as a continuing waiver of such condition or term or of another condition or term.
130 |       11.6 Headings.  Section and subsection headings are inserted for convenience of reference only and do not form part of this Agreement.
131 |       11.7 Assignment.  Neither this Agreement nor any right or obligation hereunder may be assigned, delegated or otherwise transferred, in whole or part, by either Party without the prior express written consent of the other provided, provided, however, that either Party may, without the prior written consent of the other Party, assign this Agreement and its rights and delegate its obligations hereunder to its Affiliates, and may assign this Agreement in conjunction with an acquisition, merger, sale of substantially all of its assets, or other business combination.  Any permitted assignee shall assume all obligations of its assignor under this Agreement.  Any purported assignment in violation of this Section 11.7 shall be void.  The terms and conditions of this Agreement shall be binding upon and inure to the benefit of the permitted successors and assigns of the Parties.
132 |       11.8 Force Majeure.  Neither Party shall be liable for failure of or delay in performing obligations set forth in this Agreement, and neither shall be deemed in breach of its obligations, if such failure or delay is due to natural disasters, acts of terrorism or any other causes beyond the reasonable control of such Party.  In event of such force majeure, the Party affected thereby shall use reasonable efforts to cure or overcome the same and resume performance of its obligations hereunder.
133 |       11.9 Construction.  The Parties hereto acknowledge and agree that:  (i) each Party and its counsel reviewed and negotiated the terms and provisions of this Agreement and have contributed to its revision; (ii) the rule of construction to the effect that any ambiguities are resolved against the drafting Party shall not be employed in the interpretation of this Agreement; and (iii) the terms and provisions of this Agreement shall be construed fairly as to all Parties hereto and not in favor of or against any Party, regardless of which Party was generally responsible for the preparation of this Agreement.
134 |       11.10 Status.  Nothing in this Agreement is intended or shall be deemed to constitute a partner, agency, employer-employee, or joint venture relationship between the Parties.
135 |       11.11 Further Assurances.  Each Party agrees to execute, acknowledge and deliver such further instructions, and to do all such other acts, as may be reasonably necessary or appropriate in order to carry out the purposes and intent of this Agreement.
136 |       11.12 Counterparts.  This Agreement may be executed simultaneously in one or more counterparts, each of which shall be deemed an original, but all of which together shall constitute one and the same instrument.
137 |       11.13 Negotiation and Mediation.  If an issue arises over the subject matter of this Agreement, before initiating litigation, the Parties hereby agree to attempt in good faith to settle any disputes or issues through mediation, including a direct exchange between chief executives, at least thirty (30) days prior to any filing suit.
138 | 
139 | /end


--------------------------------------------------------------------------------
/ultralight/libs/darwin/x64/libAppCore.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/darwin/x64/libAppCore.dylib


--------------------------------------------------------------------------------
/ultralight/libs/darwin/x64/libUltralight.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/darwin/x64/libUltralight.dylib


--------------------------------------------------------------------------------
/ultralight/libs/darwin/x64/libUltralightCore.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/darwin/x64/libUltralightCore.dylib


--------------------------------------------------------------------------------
/ultralight/libs/darwin/x64/libWebCore.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/darwin/x64/libWebCore.dylib


--------------------------------------------------------------------------------
/ultralight/libs/linux/x64/libAppCore.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/linux/x64/libAppCore.so


--------------------------------------------------------------------------------
/ultralight/libs/linux/x64/libUltralight.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/linux/x64/libUltralight.so


--------------------------------------------------------------------------------
/ultralight/libs/linux/x64/libUltralightCore.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/linux/x64/libUltralightCore.so


--------------------------------------------------------------------------------
/ultralight/libs/linux/x64/libWebCore.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/linux/x64/libWebCore.so


--------------------------------------------------------------------------------
/ultralight/libs/windows/x32/AppCore.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/windows/x32/AppCore.dll


--------------------------------------------------------------------------------
/ultralight/libs/windows/x32/Ultralight.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/windows/x32/Ultralight.dll


--------------------------------------------------------------------------------
/ultralight/libs/windows/x32/UltralightCore.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/windows/x32/UltralightCore.dll


--------------------------------------------------------------------------------
/ultralight/libs/windows/x32/WebCore.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/windows/x32/WebCore.dll


--------------------------------------------------------------------------------
/ultralight/libs/windows/x64/AppCore.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/windows/x64/AppCore.dll


--------------------------------------------------------------------------------
/ultralight/libs/windows/x64/Ultralight.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/windows/x64/Ultralight.dll


--------------------------------------------------------------------------------
/ultralight/libs/windows/x64/UltralightCore.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/windows/x64/UltralightCore.dll


--------------------------------------------------------------------------------
/ultralight/libs/windows/x64/WebCore.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImVexed/muon/63fb5c0bb88207f6a9d76138097354b8bf7b7a69/ultralight/libs/windows/x64/WebCore.dll


--------------------------------------------------------------------------------
/ultralight/types.go:
--------------------------------------------------------------------------------
  1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
  2 | 
  3 | // WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
  4 | // Code generated by https://git.io/c-for-go. DO NOT EDIT.
  5 | 
  6 | package ultralight
  7 | 
  8 | /*
  9 | #cgo CFLAGS: -I../include
 10 | #cgo windows,386 LDFLAGS: -L${SRCDIR}/libs/windows/x32
 11 | #cgo windows,amd64 LDFLAGS: -L${SRCDIR}/libs/windows/x64 
 12 | #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/libs/darwin/x64 
 13 | #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/libs/linux/x64 
 14 | #cgo LDFLAGS: -lUltralightCore -lWebCore -lUltralight -lAppCore
 15 | #include "AppCore/CAPI.h"
 16 | #include 
 17 | #include "cgo_helpers.h"
 18 | */
 19 | import "C"
 20 | import "unsafe"
 21 | 
 22 | // ULSettings as declared in AppCore/CAPI.h:33
 23 | type ULSettings C.ULSettings
 24 | 
 25 | // ULApp as declared in AppCore/CAPI.h:34
 26 | type ULApp C.ULApp
 27 | 
 28 | // ULWindow as declared in AppCore/CAPI.h:35
 29 | type ULWindow C.ULWindow
 30 | 
 31 | // ULMonitor as declared in AppCore/CAPI.h:36
 32 | type ULMonitor C.ULMonitor
 33 | 
 34 | // ULOverlay as declared in AppCore/CAPI.h:37
 35 | type ULOverlay C.ULOverlay
 36 | 
 37 | // ULUpdateCallback type as declared in AppCore/CAPI.h:118
 38 | type ULUpdateCallback func(user_data unsafe.Pointer)
 39 | 
 40 | // ULCloseCallback type as declared in AppCore/CAPI.h:195
 41 | type ULCloseCallback func(user_data unsafe.Pointer)
 42 | 
 43 | // ULResizeCallback type as declared in AppCore/CAPI.h:205
 44 | type ULResizeCallback func(user_data unsafe.Pointer, width uint32, height uint32)
 45 | 
 46 | // ULChar16 type as declared in Ultralight/CAPI.h:43
 47 | type ULChar16 uint16
 48 | 
 49 | // ULConfig as declared in Ultralight/CAPI.h:50
 50 | type ULConfig C.ULConfig
 51 | 
 52 | // ULRenderer as declared in Ultralight/CAPI.h:51
 53 | type ULRenderer C.ULRenderer
 54 | 
 55 | // ULView as declared in Ultralight/CAPI.h:52
 56 | type ULView C.ULView
 57 | 
 58 | // ULBitmap as declared in Ultralight/CAPI.h:53
 59 | type ULBitmap C.ULBitmap
 60 | 
 61 | // ULString as declared in Ultralight/CAPI.h:54
 62 | type ULString C.ULString
 63 | 
 64 | // ULBuffer as declared in Ultralight/CAPI.h:55
 65 | type ULBuffer C.ULBuffer
 66 | 
 67 | // ULRenderTarget as declared in Ultralight/CAPI.h:56
 68 | type ULRenderTarget C.ULRenderTarget
 69 | 
 70 | // ULKeyEvent as declared in Ultralight/CAPI.h:57
 71 | type ULKeyEvent C.ULKeyEvent
 72 | 
 73 | // ULMouseEvent as declared in Ultralight/CAPI.h:58
 74 | type ULMouseEvent C.ULMouseEvent
 75 | 
 76 | // ULScrollEvent as declared in Ultralight/CAPI.h:59
 77 | type ULScrollEvent C.ULScrollEvent
 78 | 
 79 | // ULChangeTitleCallback type as declared in Ultralight/CAPI.h:409
 80 | type ULChangeTitleCallback func(user_data unsafe.Pointer, caller ULView, title ULString)
 81 | 
 82 | // ULChangeURLCallback type as declared in Ultralight/CAPI.h:419
 83 | type ULChangeURLCallback func(user_data unsafe.Pointer, caller ULView, url ULString)
 84 | 
 85 | // ULChangeTooltipCallback type as declared in Ultralight/CAPI.h:429
 86 | type ULChangeTooltipCallback func(user_data unsafe.Pointer, caller ULView, tooltip ULString)
 87 | 
 88 | // ULChangeCursorCallback type as declared in Ultralight/CAPI.h:439
 89 | type ULChangeCursorCallback func(user_data unsafe.Pointer, caller ULView, cursor ULCursor)
 90 | 
 91 | // ULAddConsoleMessageCallback type as declared in Ultralight/CAPI.h:449
 92 | type ULAddConsoleMessageCallback func(user_data unsafe.Pointer, caller ULView, source ULMessageSource, level ULMessageLevel, message ULString, line_number uint32, column_number uint32, source_id ULString)
 93 | 
 94 | // ULBeginLoadingCallback type as declared in Ultralight/CAPI.h:464
 95 | type ULBeginLoadingCallback func(user_data unsafe.Pointer, caller ULView)
 96 | 
 97 | // ULFinishLoadingCallback type as declared in Ultralight/CAPI.h:474
 98 | type ULFinishLoadingCallback func(user_data unsafe.Pointer, caller ULView)
 99 | 
100 | // ULUpdateHistoryCallback type as declared in Ultralight/CAPI.h:484
101 | type ULUpdateHistoryCallback func(user_data unsafe.Pointer, caller ULView)
102 | 
103 | // ULDOMReadyCallback type as declared in Ultralight/CAPI.h:494
104 | type ULDOMReadyCallback func(user_data unsafe.Pointer, caller ULView)
105 | 
106 | // JSContextGroupRef as declared in JavaScriptCore/JSBase.h:40
107 | type JSContextGroupRef C.JSContextGroupRef
108 | 
109 | // JSContextRef as declared in JavaScriptCore/JSBase.h:43
110 | type JSContextRef C.JSContextRef
111 | 
112 | // JSGlobalContextRef as declared in JavaScriptCore/JSBase.h:46
113 | type JSGlobalContextRef C.JSGlobalContextRef
114 | 
115 | // JSStringRef as declared in JavaScriptCore/JSBase.h:49
116 | type JSStringRef C.JSStringRef
117 | 
118 | // JSClassRef as declared in JavaScriptCore/JSBase.h:52
119 | type JSClassRef C.JSClassRef
120 | 
121 | // JSPropertyNameArrayRef as declared in JavaScriptCore/JSBase.h:55
122 | type JSPropertyNameArrayRef C.JSPropertyNameArrayRef
123 | 
124 | // JSPropertyNameAccumulatorRef as declared in JavaScriptCore/JSBase.h:58
125 | type JSPropertyNameAccumulatorRef C.JSPropertyNameAccumulatorRef
126 | 
127 | // JSTypedArrayBytesDeallocator type as declared in JavaScriptCore/JSBase.h:61
128 | type JSTypedArrayBytesDeallocator func(bytes unsafe.Pointer, deallocatorContext unsafe.Pointer)
129 | 
130 | // JSValueRef as declared in JavaScriptCore/JSBase.h:66
131 | type JSValueRef C.JSValueRef
132 | 
133 | // JSObjectRef as declared in JavaScriptCore/JSBase.h:69
134 | type JSObjectRef C.JSObjectRef
135 | 
136 | // JSPropertyAttributes type as declared in JavaScriptCore/JSObjectRef.h:61
137 | type JSPropertyAttributes uint32
138 | 
139 | // JSClassAttributes type as declared in JavaScriptCore/JSObjectRef.h:77
140 | type JSClassAttributes uint32
141 | 
142 | // JSObjectInitializeCallback type as declared in JavaScriptCore/JSObjectRef.h:92
143 | type JSObjectInitializeCallback func(ctx JSContextRef, object JSObjectRef)
144 | 
145 | // JSObjectFinalizeCallback type as declared in JavaScriptCore/JSObjectRef.h:110
146 | type JSObjectFinalizeCallback func(object JSObjectRef)
147 | 
148 | // JSObjectHasPropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:130
149 | type JSObjectHasPropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef) bool
150 | 
151 | // JSObjectGetPropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:147
152 | type JSObjectGetPropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef, exception []JSValueRef) JSValueRef
153 | 
154 | // JSObjectSetPropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:165
155 | type JSObjectSetPropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef, value JSValueRef, exception []JSValueRef) bool
156 | 
157 | // JSObjectDeletePropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:182
158 | type JSObjectDeletePropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef, exception []JSValueRef) bool
159 | 
160 | // JSObjectGetPropertyNamesCallback type as declared in JavaScriptCore/JSObjectRef.h:199
161 | type JSObjectGetPropertyNamesCallback func(ctx JSContextRef, object JSObjectRef, propertyNames JSPropertyNameAccumulatorRef)
162 | 
163 | // JSObjectCallAsFunctionCallback type as declared in JavaScriptCore/JSObjectRef.h:220
164 | type JSObjectCallAsFunctionCallback func(ctx JSContextRef, function JSObjectRef, thisObject JSObjectRef, argumentCount uint, arguments []JSValueRef, exception []JSValueRef) JSValueRef
165 | 
166 | // JSObjectCallAsConstructorCallback type as declared in JavaScriptCore/JSObjectRef.h:240
167 | type JSObjectCallAsConstructorCallback func(ctx JSContextRef, constructor JSObjectRef, argumentCount uint, arguments []JSValueRef, exception []JSValueRef) JSObjectRef
168 | 
169 | // JSObjectHasInstanceCallback type as declared in JavaScriptCore/JSObjectRef.h:261
170 | type JSObjectHasInstanceCallback func(ctx JSContextRef, constructor JSObjectRef, possibleInstance JSValueRef, exception []JSValueRef) bool
171 | 
172 | // JSObjectConvertToTypeCallback type as declared in JavaScriptCore/JSObjectRef.h:280
173 | type JSObjectConvertToTypeCallback func(ctx JSContextRef, object JSObjectRef, _type JSType, exception []JSValueRef) JSValueRef
174 | 
175 | // JSStaticValue as declared in JavaScriptCore/JSObjectRef.h:295
176 | type JSStaticValue struct {
177 | 	Name           string
178 | 	GetProperty    JSObjectGetPropertyCallback
179 | 	SetProperty    JSObjectSetPropertyCallback
180 | 	Attributes     JSPropertyAttributes
181 | 	ref34655956    *C.JSStaticValue
182 | 	allocs34655956 interface{}
183 | }
184 | 
185 | // JSStaticFunction as declared in JavaScriptCore/JSObjectRef.h:308
186 | type JSStaticFunction struct {
187 | 	Name           string
188 | 	CallAsFunction JSObjectCallAsFunctionCallback
189 | 	Attributes     JSPropertyAttributes
190 | 	ref6b5f4953    *C.JSStaticFunction
191 | 	allocs6b5f4953 interface{}
192 | }
193 | 
194 | // JSClassDefinition as declared in JavaScriptCore/JSObjectRef.h:364
195 | type JSClassDefinition struct {
196 | 	Version           int32
197 | 	Attributes        JSClassAttributes
198 | 	ClassName         string
199 | 	ParentClass       JSClassRef
200 | 	StaticValues      []JSStaticValue
201 | 	StaticFunctions   []JSStaticFunction
202 | 	Initialize        JSObjectInitializeCallback
203 | 	Finalize          JSObjectFinalizeCallback
204 | 	HasProperty       JSObjectHasPropertyCallback
205 | 	GetProperty       JSObjectGetPropertyCallback
206 | 	SetProperty       JSObjectSetPropertyCallback
207 | 	DeleteProperty    JSObjectDeletePropertyCallback
208 | 	GetPropertyNames  JSObjectGetPropertyNamesCallback
209 | 	CallAsFunction    JSObjectCallAsFunctionCallback
210 | 	CallAsConstructor JSObjectCallAsConstructorCallback
211 | 	HasInstance       JSObjectHasInstanceCallback
212 | 	ConvertToType     JSObjectConvertToTypeCallback
213 | 	ref192c18d5       *C.JSClassDefinition
214 | 	allocs192c18d5    interface{}
215 | }
216 | 
217 | // JSChar type as declared in JavaScriptCore/JSStringRef.h:49
218 | type JSChar uint16
219 | 


--------------------------------------------------------------------------------