{"id":18008463,"url":"https://github.com/gurov/ts-webview-pages","last_synced_at":"2026-04-13T12:02:09.120Z","repository":{"id":86578136,"uuid":"93351845","full_name":"gurov/ts-webview-pages","owner":"gurov","description":"Simple boilerplate typescript code for building webviews. Without frameworks.","archived":false,"fork":false,"pushed_at":"2017-06-06T07:20:04.000Z","size":67,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-28T17:44:36.391Z","etag":null,"topics":["android","typescript","webpack","webview"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gurov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-05T01:07:46.000Z","updated_at":"2017-06-08T02:03:23.000Z","dependencies_parsed_at":"2023-03-13T19:58:09.991Z","dependency_job_id":null,"html_url":"https://github.com/gurov/ts-webview-pages","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gurov/ts-webview-pages","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurov%2Fts-webview-pages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurov%2Fts-webview-pages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurov%2Fts-webview-pages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurov%2Fts-webview-pages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gurov","download_url":"https://codeload.github.com/gurov/ts-webview-pages/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurov%2Fts-webview-pages/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31751705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","typescript","webpack","webview"],"created_at":"2024-10-30T01:18:48.277Z","updated_at":"2026-04-13T12:02:09.090Z","avatar_url":"https://github.com/gurov.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-webview-pages\nSimple boilerplate typescript code for building webviews. Without frameworks. With authorization. Android v5+\n\nExample in iframe [here](https://gurov.github.io/ts-webview-pages/dist/).\n\n## Features\n\n* Typescript (Fewer errors, easier refactoring)\n* No frameworks (Extra small final bandle: **6kB** for [example](https://gurov.github.io/ts-webview-pages/dist/))\n* A simple code (Without: two way bindings, reactive programming, etc.)\n* Auth requests (Just pass authToken from Android)\n\n## Description\n\n**NOTE**: ts-webview-pages intended for small projects!\n(4-5 pages with 2-5 articles)\n\n\n### Structure of templates\n\n* webview1.html\n    * article1\n    * article2\n    * ...\n* webview2.html\n    * article1\n* ...\n\n\nEvery webview has next javascript:\n```javascript\n// set name of webview\nconst CURRENT_WEBVIEW = 'dashboard';\n```\n\n### Structure of typescript code\n\n```\nsrc/\n├── app/\n│   ├── components/\n│   │   └── webview1/\n│   │       └── component1.ts\n│   ├── webview1.router.ts\n│   ├── index.ts\n│   ├── models/\n│   │   └── webview1.ts\n│   └── services/\n│       └── api-service.ts\n└── templates/\n    └── webview1.html\n```\n#### index.ts\n* Set `window.init` function\n* Set auth tokens to `api-service.ts`\n* Load `CURRENT_WEBVIEW` router\n\n#### webview1.router.ts\n* Set `window.onhashchange` function\n* Load components by `location.hash`\n\n#### component1.ts\n* Call `api-service.ts`\n* Push component template to page be html element id\n\n#### api-service.ts\n* API requests\n\n## Webpack\n\nWebpack script build the project to `dist` directory:\n```\ndist/\n├── [hash].bundle.js\n├── [hash].bundle.js.map\n├── [hash].main.css\n├── [hash].main.css.map\n├── webview2.html\n└── webview1.html\n```\n\n## How to use in Android\n\n```java\n@Override\npublic void onCreate(Bundle savedInstanceState) {\n    WebSettings settings = webview.getSettings();\n    settings.setJavaScriptEnabled(true);\n    webview.setWebViewClient(new WebViewClient() {\n        public void onPageFinished(WebView view, String url) {\n            JSONObject authTokens = new JSONObject();\n            authTokens.put(\"authToken\": \"Bearer LKHLK...YUYI\");\n            // pass tokens to js\n            view.evaluateJavascript(\"javascript:init('\" + authTokens + \"')\", null);\n        }\n    });\n    webview.loadUrl(\"https://example.com/webview1.html\");\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgurov%2Fts-webview-pages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgurov%2Fts-webview-pages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgurov%2Fts-webview-pages/lists"}