-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from ThaUnknown/monorepo
feat: monorepo
- Loading branch information
Showing
118 changed files
with
6,971 additions
and
2,637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/node_modules/ | ||
android/* | ||
!android/app | ||
android/app/* | ||
!android/app/src | ||
android/app/src/* | ||
!android/app/src/main | ||
android/app/src/main/* | ||
!android/app/src/main/AndroidManifest.xml | ||
!android/app/src/main/java | ||
android/app/src/main/java/* | ||
!android/app/src/main/java/watch | ||
android/app/src/main/java/watch/* | ||
!android/app/src/main/java/watch/miru | ||
android/app/src/main/java/watch/miru/* | ||
!android/app/src/main/java/watch/miru/MainActivity.java | ||
ios/ | ||
|
||
package-lock.json | ||
.env | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 t. Macleod Sawyer | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" | ||
android:name=".MainActivity" | ||
android:label="@string/title_activity_main" | ||
android:theme="@style/AppTheme.NoActionBarLaunch" | ||
android:launchMode="singleTask" | ||
android:exported="true"> | ||
<intent-filter> | ||
<!-- added scheme rest is generated --> | ||
<data android:scheme="miru" /> | ||
|
||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<provider | ||
android:name="androidx.core.content.FileProvider" | ||
android:authorities="${applicationId}.fileprovider" | ||
android:exported="false" | ||
android:grantUriPermissions="true"> | ||
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> | ||
</provider> | ||
</application> | ||
|
||
<!-- Permissions --> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
30 changes: 30 additions & 0 deletions
30
capacitor/android/app/src/main/java/watch/miru/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package watch.miru; | ||
import android.os.Bundle; | ||
import android.webkit.ServiceWorkerClient; | ||
import android.webkit.ServiceWorkerController; | ||
import android.webkit.WebResourceRequest; | ||
import android.webkit.WebResourceResponse; | ||
|
||
import com.getcapacitor.BridgeActivity; | ||
public class MainActivity extends BridgeActivity { | ||
// this isn't generated! required patch to be able to register service workers | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { | ||
ServiceWorkerController swController = null; | ||
swController = ServiceWorkerController.getInstance(); | ||
|
||
swController.setServiceWorkerClient(new ServiceWorkerClient() { | ||
@Override | ||
public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) { | ||
if (request.getUrl().toString().contains("index.html")) { | ||
request.getRequestHeaders().put("Accept", "text/html"); | ||
} | ||
return bridge.getLocalServer().shouldInterceptRequest(request); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const mode = process.env.NODE_ENV?.trim() || 'development' | ||
|
||
const config = { | ||
appId: 'watch.miru', | ||
appName: 'Miru', | ||
webDir: 'build', | ||
bundledWebRuntime: false, | ||
android: { | ||
buildOptions: { | ||
keystorePath: './watch.miru', | ||
keystorePassword: '', | ||
keystoreAlias: 'watch.miru' | ||
} | ||
}, | ||
plugins: { | ||
SplashScreen: { launchShowDuration: 0 }, | ||
CapacitorHttp: { enabled: false } | ||
} | ||
} | ||
|
||
if (mode === 'development') { | ||
config.server = { | ||
url: 'http://localhost:5001/index.html', | ||
cleartext: true | ||
} | ||
} | ||
module.exports = config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "capacitor", | ||
"private": true, | ||
"scripts": { | ||
"build:app": "cross-env NODE_ENV=production run-s build:web build:assets build:android", | ||
"build:web": "webpack build", | ||
"build:android": "cap build android", | ||
"build:ios": "cap build ios", | ||
"build:assets": "capacitor-assets generate --iconBackgroundColor #17191c --iconBackgroundColorDark #17191c --splashBackgroundColor #17191c --splashBackgroundColorDark #17191c --android", | ||
"dev:adb-port": "adb reverse tcp:5001 tcp:5001", | ||
"dev:ios": "run-p dev:start cap-run:ios", | ||
"dev:android": "cap run android", | ||
"dev:android-port": "run-s dev:android dev:adb-port", | ||
"dev:preview": "vite preview", | ||
"dev:start": "run-p dev:webpack dev:android-port", | ||
"dev:webpack": "webpack serve", | ||
"test:e2e": "cross-env NODE_ENV=production run-s build:web dev:android" | ||
}, | ||
"devDependencies": { | ||
"@capacitor/assets": "^3.0.1", | ||
"assert": "^2.1.0", | ||
"buffer": "^6.0.3", | ||
"chrome-dgram": "^3.0.6", | ||
"chrome-net": "^3.3.4", | ||
"cordova-res": "^0.15.4", | ||
"crypto-browserify": "^3.12.0", | ||
"hybrid-chunk-store": "^1.2.2", | ||
"npm-run-all": "^4.1.5", | ||
"path-esm": "^1.0.0", | ||
"querystring": "^0.2.1", | ||
"stream-browserify": "^3.0.0", | ||
"stream-http": "^3.2.0", | ||
"timers-browserify": "^2.0.12", | ||
"util": "^0.12.5", | ||
"webpack-cli": "^5.1.4" | ||
}, | ||
"dependencies": { | ||
"@capacitor/android": "^5.5.1", | ||
"@capacitor/app": "^5.0.6", | ||
"@capacitor/browser": "^5.1.0", | ||
"@capacitor/cli": "^5.5.1", | ||
"@capacitor/core": "^5.5.1", | ||
"@capacitor/ios": "^5.5.1", | ||
"@capacitor/status-bar": "^5.0.6", | ||
"@superfrogbe/cordova-plugin-chrome-apps-sockets-udp": "github:superfrogbe/cordova-plugin-chrome-apps-sockets-udp", | ||
"capacitor-plugin-safe-area": "^2.0.5", | ||
"common": "workspace:*", | ||
"cordova-plugin-chrome-apps-common": "^1.0.7", | ||
"cordova-plugin-chrome-apps-sockets-tcp": "github:KoenLav/cordova-plugin-chrome-apps-sockets-tcp", | ||
"cordova-plugin-navigationbar": "^1.0.31", | ||
"cordova-plugin-screen-orientation": "^3.0.4", | ||
"es6-promise-plugin": "^4.2.2", | ||
"webpack-merge": "^5.10.0" | ||
} | ||
} |
File renamed without changes
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* globals navigationbar */ | ||
import { StatusBar, Style } from '@capacitor/status-bar' | ||
import { SafeArea } from 'capacitor-plugin-safe-area' | ||
import { App } from '@capacitor/app' | ||
import { Browser } from '@capacitor/browser' | ||
import { ipcRendererUI, main } from './ipc.js' | ||
|
||
main.on('open', url => Browser.open({ url })) | ||
|
||
App.addListener('appUrlOpen', ({ url }) => handleProtocol(url)) | ||
|
||
// schema: miru://key/value | ||
const protocolMap = { | ||
auth: token => sendToken(token), | ||
anime: id => ipcRendererUI.emit('open-anime', id), | ||
w2g: link => ipcRendererUI.emit('w2glink', link), | ||
schedule: () => ipcRendererUI.emit('schedule'), | ||
donate: () => Browser.open({ url: 'https://github.com/sponsors/ThaUnknown/' }) | ||
} | ||
|
||
const protocolRx = /miru:\/\/([a-z0-9]+)\/(.*)/i | ||
|
||
function handleProtocol (text) { | ||
const match = text.match(protocolRx) | ||
if (match) protocolMap[match[1]]?.(match[2]) | ||
} | ||
|
||
function sendToken (line) { | ||
let token = line.split('access_token=')[1].split('&token_type')[0] | ||
if (token) { | ||
if (token.endsWith('/')) token = token.slice(0, -1) | ||
ipcRendererUI.emit('altoken', token) | ||
} | ||
} | ||
|
||
App.getLaunchUrl().then(res => { | ||
if (res) handleProtocol(res.url) | ||
}) | ||
|
||
SafeArea.addListener('safeAreaChanged', updateInsets) | ||
screen.orientation.addEventListener('change', updateInsets) | ||
|
||
async function updateInsets () { | ||
const { insets } = await SafeArea.getSafeAreaInsets() | ||
for (const [key, value] of Object.entries(insets)) { | ||
document.documentElement.style.setProperty(`--safe-area-${key}`, `${value}px`) | ||
} | ||
} | ||
updateInsets() | ||
|
||
StatusBar.hide() | ||
StatusBar.setStyle({ style: Style.Dark }) | ||
StatusBar.setOverlaysWebView({ overlay: true }) | ||
|
||
navigationbar.setUp(true) | ||
|
||
// cordova screen orientation plugin is also used, and it patches global screen.orientation.lock |
Oops, something went wrong.