diff --git a/.babelrc b/.babelrc index 27fbea3..56f334b 100644 --- a/.babelrc +++ b/.babelrc @@ -1,17 +1,17 @@ { - "presets": [ - [ - "@babel/preset-env", - { - "useBuiltIns": "usage", - "corejs": 3, - "targets": "> 0.25%, not dead" - } - ] - ], - "plugins": [ - "@babel/plugin-transform-runtime", - "@babel/plugin-syntax-dynamic-import", - ["babel-plugin-transform-remove-console", { "exclude": ["error", "warn"] }] - ] + "presets": [ + [ + "@babel/preset-env", + { + "useBuiltIns": "usage", + "corejs": 3, + "targets": "> 0.25%, not dead" + } + ] + ], + "plugins": [ + "@babel/plugin-transform-runtime", + "@babel/plugin-syntax-dynamic-import", + ["babel-plugin-transform-remove-console", { "exclude": ["error", "warn"] }] + ] } diff --git a/.github/renovate.json b/.github/renovate.json index 900d8b2..aba2e69 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,15 +1,15 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:base"], - "assignees": ["sebastianjnuwu"], - "schedule": ["on the last day of the month"], - "dependencyDashboard": false, - "fetchReleaseNotes": true, - "packageRules": [ - { - "matchPackagePatterns": ["*"], - "labels": ["dependencies"], - "automerge": true - } - ] + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:base"], + "assignees": ["sebastianjnuwu"], + "schedule": ["on the last day of the month"], + "dependencyDashboard": false, + "fetchReleaseNotes": true, + "packageRules": [ + { + "matchPackagePatterns": ["*"], + "labels": ["dependencies"], + "automerge": true + } + ] } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index e26261b..52ca697 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,11 +1,11 @@ { - "recommendations": [ - "bracketpaircolordlw.bracket-pair-color-dlw", - "dracula-theme.theme-dracula", - "editorconfig.editorconfig", - "dbaeumer.vscode-eslint", - "github.vscode-github-actions", - "pkief.material-icon-theme", - "biomejs.biome" - ] + "recommendations": [ + "bracketpaircolordlw.bracket-pair-color-dlw", + "dracula-theme.theme-dracula", + "editorconfig.editorconfig", + "dbaeumer.vscode-eslint", + "github.vscode-github-actions", + "pkief.material-icon-theme", + "biomejs.biome" + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 1e8af0d..525ceaf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,12 @@ { - "editor.tabSize": 4, - "files.exclude": { - "**/.git": true, - "**/.svn": true, - "**/.hg": true, - "**/CVS": true, - "**/.DS_Store": true, - "**/Thumbs.db": true - }, - "java.configuration.updateBuildConfiguration": "disabled" + "editor.tabSize": 4, + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/Thumbs.db": true + }, + "java.configuration.updateBuildConfiguration": "disabled" } diff --git a/.vscode/workspace.code-workspace b/.vscode/workspace.code-workspace index 3b217fa..7a5a969 100644 --- a/.vscode/workspace.code-workspace +++ b/.vscode/workspace.code-workspace @@ -1,4 +1,4 @@ { - "folders": [], - "settings": {} + "folders": [], + "settings": {} } diff --git a/biome.json b/biome.json index a7a6784..25d7e5e 100644 --- a/biome.json +++ b/biome.json @@ -1,31 +1,21 @@ { - "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", - "organizeImports": { - "enabled": true - }, - "linter": { - "enabled": true, - "rules": { - "recommended": false, - "complexity": { - "noStaticOnlyClass": "error", - "noUselessSwitchCase": "error", - "useFlatMap": "error" - }, - "style": { - "noNegationElse": "off", - "useForOf": "error", - "useNodejsImportProtocol": "error", - "useNumberNamespace": "error" - }, - "suspicious": { - "noDoubleEquals": "error", - "noThenProperty": "error", - "useIsArray": "error" - } - } - }, - "files": { - "ignore": ["node_modules", "build", "android"] - } + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 2, + "lineWidth": 80 + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "organizeImports": { + "enabled": true + }, + "files": { + "ignore": ["node_modules", "build", "dist", "android", "ios", "*.log"] + } } diff --git a/capacitor.config.ts b/capacitor.config.ts index 6ece014..ae59316 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -1,18 +1,18 @@ -import { CapacitorConfig } from "@capacitor/cli"; +import type { CapacitorConfig } from "@capacitor/cli"; // https://capacitorjs.com/docs/config const config: CapacitorConfig = { - appId: "uwu.cookie.app", - appName: "Cookie", - webDir: "build", - plugins: { - AdMob: { - androidAppId: "ca-app-pub-6690516270288705~6535066913", - maxAdContentRating: "G", - tagForChildDirectedTreatment: false, - tagForUnderAgeOfConsent: false, - }, - }, + appId: "uwu.cookie.app", + appName: "Cookie", + webDir: "build", + plugins: { + AdMob: { + androidAppId: "ca-app-pub-6690516270288705~6535066913", + maxAdContentRating: "G", + tagForChildDirectedTreatment: false, + tagForUnderAgeOfConsent: false, + }, + }, }; export default config; diff --git a/package.json b/package.json index e0d562b..b3eb9c9 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,55 @@ { - "name": "cookie-app", - "private": true, - "version": "1.0.0", - "type": "module", - "description": "Cookie...", - "author": "Sebastian Jn ", - "scripts": { - "test": "echo \"Test: yes that was a test!\" && exit 1", - "start": "vite", - "build": "vite build", - "lint": "npx @biomejs/biome lint --write", - "format": "npx @biomejs/biome format --write", - "preview": "vite preview", - "copy": "npx cap copy", - "update": "npx cap update", - "sync": "npx cap sync", - "prepare": "husky", - "pre-commit": "cz" - }, - "hooks": { - "prepare-commit-msg": "npx --no -- commitlint --edit $1; exec < /dev/tty && npx cz --hook || true" - }, - "dependencies": { - "@capacitor-community/admob": "^6.1.0", - "@capacitor/android": "^6.2.0", - "@capacitor/core": "^6.2.0", - "@capacitor/push-notifications": "^6.0.3", - "@capacitor/splash-screen": "^6.0.3" - }, - "devDependencies": { - "@babel/core": "^7.26.0", - "@babel/plugin-syntax-dynamic-import": "^7.8.3", - "@babel/plugin-transform-runtime": "^7.25.9", - "@babel/preset-env": "^7.26.0", - "@biomejs/biome": "1.9.4", - "@capacitor/cli": "^6.2.0", - "@commitlint/cli": "^19.6.1", - "@commitlint/config-conventional": "^19.6.0", - "babel-plugin-transform-remove-console": "^6.9.4", - "core-js": "^3.39.0", - "cz-conventional-changelog": "^3.3.0", - "husky": "^9.1.7", - "typescript": "^5.7.2", - "vite": "^5.4.2", - "vite-plugin-babel": "^1.3.0" - }, - "engines": { - "npm": ">=8", - "node": ">=18" - } + "name": "cookie-app", + "private": true, + "version": "1.0.0", + "type": "module", + "description": "Cookie...", + "author": "Sebastian Jn ", + "scripts": { + "test": "echo \"Test: yes that was a test!\" && exit 1", + "start": "vite", + "build": "vite build", + "preview": "vite preview", + "lint": "npx @biomejs/biome lint --write", + "format": "npx @biomejs/biome format --write", + "copy": "npx cap copy", + "update": "npx cap update", + "sync": "npx cap sync", + "prepare": "husky", + "pre-commit": "cz" + }, + "hooks": { + "prepare-commit-msg": "npx --no -- commitlint --edit $1; exec < /dev/tty && npx cz --hook || true" + }, + "dependencies": { + "@capacitor-community/admob": "^6.1.0", + "@capacitor/android": "^6.2.0", + "@capacitor/core": "^6.2.0", + "@capacitor/push-notifications": "^6.0.3", + "@capacitor/splash-screen": "^6.0.3", + "jquery": "^3.7.1" + }, + "devDependencies": { + "@babel/core": "^7.26.0", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-transform-runtime": "^7.25.9", + "@babel/preset-env": "^7.26.0", + "@biomejs/biome": "1.9.4", + "@capacitor/cli": "^6.2.0", + "@commitlint/cli": "^19.6.1", + "@commitlint/config-conventional": "^19.6.0", + "@types/jquery": "^3.5.32", + "babel-plugin-transform-remove-console": "^6.9.4", + "core-js": "^3.39.0", + "cz-conventional-changelog": "^3.3.0", + "husky": "^9.1.7", + "sass-embedded": "^1.83.0", + "typescript": "^5.7.2", + "vite": "^5.4.2", + "vite-plugin-babel": "^1.3.0" + }, + "engines": { + "npm": ">=8", + "node": ">=18" + } } diff --git a/tsconfig.json b/tsconfig.json index 82f0fdd..5d00163 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,19 +1,19 @@ { - "compilerOptions": { - "target": "ESNext", - "outDir": "build", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ESNext", "DOM"], - "moduleResolution": "Node", - "strict": true, - "resolveJsonModule": true, - "isolatedModules": true, - "esModuleInterop": true, - "noEmit": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "skipLibCheck": true - } + "compilerOptions": { + "target": "ESNext", + "outDir": "build", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ESNext", "DOM"], + "moduleResolution": "Node", + "strict": true, + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "noEmit": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "skipLibCheck": true + } } diff --git a/vite.config.ts b/vite.config.ts index a4ce6a4..d38d10f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,17 +2,20 @@ import { defineConfig } from "vite"; import babel from "vite-plugin-babel"; export default defineConfig({ - root: "./www", - build: { - outDir: "../build", - minify: false, - emptyOutDir: false, - }, - plugins: [ - babel({ - babelConfig: { - presets: ["@babel/preset-env"], - }, - }), - ], + root: "./www", + build: { + outDir: "../build", + minify: false, + emptyOutDir: false, + }, + plugins: [ + babel({ + babelConfig: { + presets: ["@babel/preset-env"], + }, + }), + ], + server: { + port: 8080, + }, }); diff --git a/www/index.html b/www/index.html index 51054da..4534ea5 100644 --- a/www/index.html +++ b/www/index.html @@ -4,46 +4,38 @@ Cookie - - - - - - - - - + + + + - - -
- splash-screen -
-
- -
- - - - - - - -
- - - - - - + + +
+ splash-screen +
+
+ +
+ + + + + + + +
+ + + + + \ No newline at end of file diff --git a/www/main.ts b/www/main.ts new file mode 100644 index 0000000..40b9a2a --- /dev/null +++ b/www/main.ts @@ -0,0 +1,3 @@ +import "./res/styles/scss/ui.scss"; +import "./res/plugins/admob.ts"; +import "./res/plugins/push-notifications.ts"; diff --git a/www/res/favicon.ico b/www/res/favicon.ico deleted file mode 100644 index d080f03..0000000 Binary files a/www/res/favicon.ico and /dev/null differ diff --git a/www/res/logo.png b/www/res/logo.png deleted file mode 100644 index d080f03..0000000 Binary files a/www/res/logo.png and /dev/null differ diff --git a/www/res/plugins/admob.ts b/www/res/plugins/admob.ts index 3f4adc7..5c9cc63 100644 --- a/www/res/plugins/admob.ts +++ b/www/res/plugins/admob.ts @@ -3,104 +3,95 @@ import { BannerAdSize, BannerAdPosition, } from "@capacitor-community/admob"; +import $ from "jquery"; -$(document).ready(() => { - // Initialize AdMob plugin - AdMob.initialize() - .then(() => { - console.log("AdMob initialized."); - }) - .catch((err) => { - console.log("Error initializing AdMob: ", err.message); - }); +$(() => { + if (window.Capacitor.getPlatform() !== "android") { + console.log( + `AdMob: Unsupported platform (${window.Capacitor.getPlatform()})`, + ); + return; + } - // Function to show a banner ad - function $show_banner() { - AdMob.showBanner({ - adId: "ca-app-pub-6690516270288705/1043067086", - adSize: BannerAdSize.FULL_BANNER, - position: BannerAdPosition.BOTTOM_CENTER, - margin: 0, - // isTesting: true - // npa: true - }) - .then(() => { - // Log when the banner is displayed successfully - return console.log("Banner displayed."); - }) - .catch((err) => { - // Log error if the banner fails to display - return console.log("Error displaying banner: ", err.message); - }); - } + AdMob.initialize() + .then(() => { + console.log("AdMob initialized."); + }) + .catch((err) => { + console.log("Error initializing AdMob: ", err.message); + }); - // Function to hide the banner ad - function $hide_banner() { - AdMob.hideBanner() - .then(() => { - // Log when the banner is hidden successfully - return console.log("Banner hidden successfully."); - }) - .catch((err) => { - // Log error if hiding the banner fails - return console.log("Error hiding banner: ", err.message); - }); - } + function $show_banner() { + AdMob.showBanner({ + adId: "ca-app-pub-6690516270288705/1043067086", + adSize: BannerAdSize.FULL_BANNER, + position: BannerAdPosition.BOTTOM_CENTER, + margin: 0, + // isTesting: true + // npa: true + }) + .then(() => { + return console.log("Banner displayed."); + }) + .catch((err) => { + return console.log("Error displaying banner: ", err.message); + }); + } - // Function to show a rewarded video ad - function $show_video() { - const adId = "ca-app-pub-6690516270288705/7898187843"; - AdMob.prepareRewardVideoAd({ adId }) - .then(() => { - // Log when the rewarded video ad is prepared - console.log("Rewarded interstitial prepared."); - // Show the prepared rewarded video ad - return AdMob.showRewardVideoAd(); - }) - .then(() => { - // Log when the rewarded video ad is displayed successfully - console.log("Rewarded interstitial displayed successfully."); - }) - .catch((err) => { - // Log error if showing the rewarded video ad fails - console.log("Error displaying rewarded interstitial: ", err.message); - }); - } + function $hide_banner() { + AdMob.hideBanner() + .then(() => { + return console.log("Banner hidden successfully."); + }) + .catch((err) => { + return console.log("Error hiding banner: ", err.message); + }); + } - // Event listener to show the banner when the button is clicked - $("#show_banner").on("click", () => { - return $show_banner(); - }); + function $show_video() { + const adId = "ca-app-pub-6690516270288705/7898187843"; + AdMob.prepareRewardVideoAd({ adId }) + .then(() => { + console.log("Rewarded interstitial prepared."); + return AdMob.showRewardVideoAd(); + }) + .then(() => { + console.log("Rewarded interstitial displayed successfully."); + }) + .catch((err) => { + console.log("Error displaying rewarded interstitial: ", err.message); + }); + } - // Event listener to show the video when the button is clicked - $("#show_video").on("click", () => { - return $show_video(); - }); + function $award() { + AdMob.prepareInterstitial({ + adId: "ca-app-pub-6690516270288705/8937605645", + }) + .then(() => { + console.log("Interstitial prepared."); - // Event listener to hide the banner when the button is clicked - $("#hide_banner").on("click", () => { - return $hide_banner(); - }); + return AdMob.showInterstitial(); + }) + .then(() => { + console.log("Interstitial ad displayed successfully."); + }) + .catch((err) => { + console.log("Error displaying interstitial ad: ", err.message); + }); + } - // Event listener to show an interstitial ad when the button is clicked - $("#award").on("click", () => { - AdMob.prepareInterstitial({ - adId: "ca-app-pub-6690516270288705/8937605645", - autoShow: false, - }) - .then(() => { - // Log when the interstitial ad is prepared - console.log("Interstitial prepared."); - // Show the prepared interstitial ad - return AdMob.showInterstitial(); - }) - .then(() => { - // Log when the interstitial ad is displayed successfully - console.log("Interstitial ad displayed successfully."); - }) - .catch((err) => { - // Log error if showing the interstitial ad fails - console.log("Error displaying interstitial ad: ", err.message); - }); - }); + $("#show_banner").on("click", () => { + return $show_banner(); + }); + $("#show_video").on("click", () => { + return $show_video(); + }); + + $("#hide_banner").on("click", () => { + return $hide_banner(); + }); + + $("#award").on("click", () => { + return $award(); + }); }); diff --git a/www/res/plugins/push-notifications.ts b/www/res/plugins/push-notifications.ts index cdb19aa..7095bad 100644 --- a/www/res/plugins/push-notifications.ts +++ b/www/res/plugins/push-notifications.ts @@ -1,35 +1,42 @@ import { PushNotifications } from "@capacitor/push-notifications"; - -const register = async () => { - let STATUS = await PushNotifications.checkPermissions(); - console.log(STATUS); - - if (STATUS.receive === "prompt") { - STATUS = await PushNotifications.requestPermissions(); - console.log(STATUS); - } - - if (STATUS.receive !== "granted") { - console.log("not permission"); - } - - await PushNotifications.register(); - - PushNotifications.addListener("registration", (token) => { - console.log(token); - }); - - PushNotifications.addListener("registrationError", (error) => { - console.log(error); - }); - - PushNotifications.addListener("pushNotificationReceived", (notification) => { - console.log(notification); - }); - - PushNotifications.addListener("pushNotificationActionPerformed", (action) => { - console.log(action); - }); -}; - -register(); +import $ from "jquery"; + +$(async () => { + if (window.Capacitor.getPlatform() !== "android") { + console.log( + `PushNotifications: Unsupported platform (${window.Capacitor.getPlatform()})`, + ); + return; + } + + let STATUS = await PushNotifications.checkPermissions(); + console.log(STATUS); + + if (STATUS.receive === "prompt") { + STATUS = await PushNotifications.requestPermissions(); + console.log(STATUS); + } + + if (STATUS.receive !== "granted") { + console.log("Not permission"); + return; + } + + await PushNotifications.register(); + + PushNotifications.addListener("registration", (token) => { + console.log(token); + }); + + PushNotifications.addListener("registrationError", (error) => { + console.log(error); + }); + + PushNotifications.addListener("pushNotificationReceived", (notification) => { + console.log(notification); + }); + + PushNotifications.addListener("pushNotificationActionPerformed", (action) => { + console.log(action); + }); +}); diff --git a/www/res/styles/css/ui.css b/www/res/styles/css/ui.css new file mode 100644 index 0000000..b9086fc --- /dev/null +++ b/www/res/styles/css/ui.css @@ -0,0 +1,64 @@ +@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"); +@import url("https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"); + +:root { + --layout: #fffbde; + --text-color: #333; +} + +.ui-cookie { + padding: 0; + margin: 0; + font-family: Arial, sans-serif; + font-size: 14px; + color: var(--text-color); + background-color: var(--layout); +} + +.ui-cookie splash-screen .icon { + width: 25%; + animation: splash-screen 2s infinite ease-in-out; +} + +@keyframes splash-screen { + 0%, + 100% { + transform: translateY(0); + opacity: 1; + } + 25% { + transform: translateY(-8px); + opacity: 0.8; + } + 50% { + transform: translateY(-15px); + opacity: 1; + } + 75% { + transform: translateY(-8px); + opacity: 0.8; + } +} + +.btn-custom { + background-color: transparent; + color: #333; + border: 2px solid #333; + border-radius: 50px; + width: 200px; + height: 50px; + font-size: 16px; + display: flex; + align-items: center; + justify-content: center; + margin: 10px; + transition: all 0.3s ease; +} + +.btn-custom:hover { + border-color: #555; +} + +.btn-custom i { + margin-right: 10px; +} diff --git a/www/res/styles/scss/ui.scss b/www/res/styles/scss/ui.scss new file mode 100644 index 0000000..34090dd --- /dev/null +++ b/www/res/styles/scss/ui.scss @@ -0,0 +1 @@ +// ui.scss diff --git a/www/res/styles/ui.css b/www/res/styles/ui.css deleted file mode 100644 index 225d8a1..0000000 --- a/www/res/styles/ui.css +++ /dev/null @@ -1,84 +0,0 @@ -/* - Author: Sebastian Jn - Email: sebastianjnuwu@gmail.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - This project may contain contributions from multiple authors. - See the AUTHORS file for a full list of contributors. - - You may use, modify, and distribute this code under the terms of the License. - For any questions or clarifications regarding this license, please refer to the official Apache 2.0 documentation. -*/ - -:root { - --layout: #FFFBDE; - --text-color: #333; -} - -.ui-cookie { - padding: 0; - margin: 0; - font-family: Arial, sans-serif; - font-size: 14px; - color: var(--text-color); - background-color: var(--layout); -} - -.ui-cookie splash-screen .icon { - width: 25%; - animation: splash-screen 2s infinite ease-in-out; -} - -@keyframes splash-screen { - 0%, - 100% { - transform: translateY(0); - opacity: 1; - } - 25% { - transform: translateY(-8px); - opacity: 0.8; - } - 50% { - transform: translateY(-15px); - opacity: 1; - } - 75% { - transform: translateY(-8px); - opacity: 0.8; - } -} - -.btn-custom { - background-color: transparent; - color: #333; - border: 2px solid #333; - border-radius: 50px; - width: 200px; - height: 50px; - font-size: 16px; - display: flex; - align-items: center; - justify-content: center; - margin: 10px; - transition: all 0.3s ease; -} - -.btn-custom:hover { - border-color: #555; -} - -.btn-custom i { - margin-right: 10px; -} diff --git a/www/vite-env.d.ts b/www/vite-env.d.ts index 11f02fe..a2c785e 100644 --- a/www/vite-env.d.ts +++ b/www/vite-env.d.ts @@ -1 +1,9 @@ /// + +export {}; + +declare global { + interface Window { + Capacitor: typeof import("@capacitor/core").Capacitor; + } +}