Skip to content

Commit

Permalink
Changes for browser use
Browse files Browse the repository at this point in the history
  • Loading branch information
deleterium committed May 20, 2022
1 parent 3222e24 commit 81a6c8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ try {
```

## Browser
Your javascript file must be imported as module in the html.
```ts
import { SmartC } from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/smartc.min.js';
Import the minified javascript file. SmartC will be imported as global.
```html
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/smartc.min.js"></script>
```

Then in your javascript file, just use it:
```js
// Example: Simple compilation test
try {
const startUpTest = new SmartC({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "smartc-signum-compiler",
"version": "1.0.2",
"version": "1.0.3",
"description": "C Compiler for smart contracts on Signum network",
"main": "dist/smartc.js",
"types": "dist/smartc.d.ts",
Expand Down
5 changes: 5 additions & 0 deletions src/smartc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,8 @@ export class SmartC {
return this.Program.Config.compilerVersion
}
}

if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {
// @ts-ignore: Browser only
window.SmartC = SmartC
}

0 comments on commit 81a6c8f

Please sign in to comment.