flash-notifications 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +5 -0
- package/README.md +18 -53
- package/android/build.gradle +43 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/flashnotifications/FlashNotificationsModule.kt +50 -0
- package/android/src/main/java/expo/modules/flashnotifications/FlashNotificationsView.kt +30 -0
- package/build/container/index.d.ts +3 -0
- package/build/container/index.d.ts.map +1 -0
- package/build/container/index.js +42 -0
- package/build/container/index.js.map +1 -0
- package/build/container/notification.d.ts +3 -0
- package/build/container/notification.d.ts.map +1 -0
- package/build/container/notification.js +48 -0
- package/build/container/notification.js.map +1 -0
- package/build/flash-notifications.d.ts +8 -0
- package/build/flash-notifications.d.ts.map +1 -0
- package/build/flash-notifications.js +66 -0
- package/build/flash-notifications.js.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +4 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +17 -0
- package/ios/FlashNotifications.podspec +29 -0
- package/ios/FlashNotificationsModule.swift +48 -0
- package/ios/FlashNotificationsView.swift +38 -0
- package/package.json +39 -38
- package/src/index.js +7 -0
- package/tsconfig.json +10 -0
- package/.github/dependabot.yml +0 -9
- package/index.js +0 -7
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/src/reportWebVitals.js +0 -13
- package/src/setupTests.js +0 -5
package/.eslintrc.js
ADDED
package/README.md
CHANGED
|
@@ -1,70 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# flash-notifications
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
My new module
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# API documentation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/flash-notifications/)
|
|
8
|
+
- [Documentation for the main branch](https://docs.expo.dev/versions/unversioned/sdk/flash-notifications/)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
# Installation in managed Expo projects
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
|
12
|
+
For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
You will also see any lint errors in the console.
|
|
14
|
+
# Installation in bare React Native projects
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
18
|
+
### Add the package to your npm dependencies
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
```
|
|
21
|
+
npm install flash-notifications
|
|
22
|
+
```
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
24
|
+
### Configure for Android
|
|
26
25
|
|
|
27
|
-
The build is minified and the filenames include the hashes.\
|
|
28
|
-
Your app is ready to be deployed!
|
|
29
26
|
|
|
30
|
-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
31
27
|
|
|
32
|
-
### `yarn eject`
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
### Configure for iOS
|
|
35
30
|
|
|
36
|
-
|
|
31
|
+
Run `npx pod-install` after installing the npm package.
|
|
37
32
|
|
|
38
|
-
|
|
33
|
+
# Contributing
|
|
39
34
|
|
|
40
|
-
|
|
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
|
-
### `yarn 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)
|
|
35
|
+
Contributions are very welcome! Please refer to guidelines described in the [contributing guide]( https://github.com/expo/expo#contributing).
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
group = 'expo.modules.flashnotifications'
|
|
4
|
+
version = '0.1.0'
|
|
5
|
+
|
|
6
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
|
+
apply from: expoModulesCorePlugin
|
|
8
|
+
applyKotlinExpoModulesCorePlugin()
|
|
9
|
+
useCoreDependencies()
|
|
10
|
+
useExpoPublishing()
|
|
11
|
+
|
|
12
|
+
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
|
|
13
|
+
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
|
|
14
|
+
// Most of the time, you may like to manage the Android SDK versions yourself.
|
|
15
|
+
def useManagedAndroidSdkVersions = false
|
|
16
|
+
if (useManagedAndroidSdkVersions) {
|
|
17
|
+
useDefaultAndroidSdkVersions()
|
|
18
|
+
} else {
|
|
19
|
+
buildscript {
|
|
20
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
21
|
+
ext.safeExtGet = { prop, fallback ->
|
|
22
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
project.android {
|
|
26
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 34)
|
|
27
|
+
defaultConfig {
|
|
28
|
+
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
29
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
android {
|
|
35
|
+
namespace "expo.modules.flashnotifications"
|
|
36
|
+
defaultConfig {
|
|
37
|
+
versionCode 1
|
|
38
|
+
versionName "0.1.0"
|
|
39
|
+
}
|
|
40
|
+
lintOptions {
|
|
41
|
+
abortOnError false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package expo.modules.flashnotifications
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
import java.net.URL
|
|
6
|
+
|
|
7
|
+
class FlashNotificationsModule : Module() {
|
|
8
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
9
|
+
// that describes the module's functionality and behavior.
|
|
10
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
11
|
+
override fun definition() = ModuleDefinition {
|
|
12
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
13
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
14
|
+
// The module will be accessible from `requireNativeModule('FlashNotifications')` in JavaScript.
|
|
15
|
+
Name("FlashNotifications")
|
|
16
|
+
|
|
17
|
+
// Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
|
|
18
|
+
Constants(
|
|
19
|
+
"PI" to Math.PI
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
// Defines event names that the module can send to JavaScript.
|
|
23
|
+
Events("onChange")
|
|
24
|
+
|
|
25
|
+
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
26
|
+
Function("hello") {
|
|
27
|
+
"Hello world! 👋"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Defines a JavaScript function that always returns a Promise and whose native code
|
|
31
|
+
// is by default dispatched on the different thread than the JavaScript runtime runs on.
|
|
32
|
+
AsyncFunction("setValueAsync") { value: String ->
|
|
33
|
+
// Send an event to JavaScript.
|
|
34
|
+
sendEvent("onChange", mapOf(
|
|
35
|
+
"value" to value
|
|
36
|
+
))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Enables the module to be used as a native view. Definition components that are accepted as part of
|
|
40
|
+
// the view definition: Prop, Events.
|
|
41
|
+
View(FlashNotificationsView::class) {
|
|
42
|
+
// Defines a setter for the `url` prop.
|
|
43
|
+
Prop("url") { view: FlashNotificationsView, url: URL ->
|
|
44
|
+
view.webView.loadUrl(url.toString())
|
|
45
|
+
}
|
|
46
|
+
// Defines an event that the view can send to JavaScript.
|
|
47
|
+
Events("onLoad")
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package expo.modules.flashnotifications
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.webkit.WebView
|
|
5
|
+
import android.webkit.WebViewClient
|
|
6
|
+
import expo.modules.kotlin.AppContext
|
|
7
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
8
|
+
import expo.modules.kotlin.views.ExpoView
|
|
9
|
+
|
|
10
|
+
class FlashNotificationsView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
11
|
+
// Creates and initializes an event dispatcher for the `onLoad` event.
|
|
12
|
+
// The name of the event is inferred from the value and needs to match the event name defined in the module.
|
|
13
|
+
private val onLoad by EventDispatcher()
|
|
14
|
+
|
|
15
|
+
// Defines a WebView that will be used as the root subview.
|
|
16
|
+
internal val webView = WebView(context).apply {
|
|
17
|
+
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
18
|
+
webViewClient = object : WebViewClient() {
|
|
19
|
+
override fun onPageFinished(view: WebView, url: String) {
|
|
20
|
+
// Sends an event to JavaScript. Triggers a callback defined on the view component in JavaScript.
|
|
21
|
+
onLoad(mapOf("url" to url))
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
init {
|
|
27
|
+
// Adds the WebView to the view hierarchy.
|
|
28
|
+
addView(webView)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/container/index.jsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
import { digg } from "diggerize";
|
|
3
|
+
import Notification from "./notification";
|
|
4
|
+
import { shapeComponent, ShapeComponent } from "set-state-compare/src/shape-component.js";
|
|
5
|
+
import useEventListener from "@kaspernj/api-maker/src/use-event-listener";
|
|
6
|
+
import { View } from "react-native";
|
|
7
|
+
export default memo(shapeComponent(class FlashNotificationsContainer extends ShapeComponent {
|
|
8
|
+
setup() {
|
|
9
|
+
this.useStates({
|
|
10
|
+
count: 0,
|
|
11
|
+
notifications: []
|
|
12
|
+
});
|
|
13
|
+
useEventListener(window, "pushNotification", this.onPushNotification);
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
return (React.createElement(View, { dataSet: { class: "flash-notifications-container" }, style: {
|
|
17
|
+
position: "fixed",
|
|
18
|
+
zIndex: 99999,
|
|
19
|
+
top: 20,
|
|
20
|
+
right: 20
|
|
21
|
+
} }, this.state.notifications.map((notification) => React.createElement(Notification, { key: `notification-${notification.count}`, message: notification.message, notification: notification, onRemovedClicked: this.onRemovedClicked, title: notification.title, type: notification.type }))));
|
|
22
|
+
}
|
|
23
|
+
onPushNotification = (event) => {
|
|
24
|
+
const detail = digg(event, "detail");
|
|
25
|
+
const count = this.state.count + 1;
|
|
26
|
+
setTimeout(() => this.removeNotification(count), 4000);
|
|
27
|
+
const notification = {
|
|
28
|
+
count,
|
|
29
|
+
message: digg(detail, "message"),
|
|
30
|
+
title: digg(detail, "title"),
|
|
31
|
+
type: digg(detail, "type")
|
|
32
|
+
};
|
|
33
|
+
this.setState({ count, notifications: this.state.notifications.concat([notification]) });
|
|
34
|
+
};
|
|
35
|
+
onRemovedClicked = (notification) => this.removeNotification(digg(notification, "count"));
|
|
36
|
+
removeNotification = (count) => {
|
|
37
|
+
this.setState({
|
|
38
|
+
notifications: this.state.notifications.filter((notification) => notification.count != count)
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
}));
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/container/index.jsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAA;AAC1B,OAAO,EAAC,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,CAAA;QAElC,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;QAEtD,MAAM,YAAY,GAAG;YACnB,KAAK;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC;YAChC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;YAC5B,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;SAC3B,CAAA;QAED,IAAI,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,EAAC,CAAC,CAAA;IACxF,CAAC,CAAA;IAED,gBAAgB,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAA;IAEzF,kBAAkB,GAAG,CAAC,KAAK,EAAE,EAAE;QAC7B,IAAI,CAAC,QAAQ,CAAC;YACZ,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,IAAI,KAAK,CAAC;SAC9F,CAAC,CAAA;IACJ,CAAC,CAAA;CACF,CAAC,CAAC,CAAA","sourcesContent":["import {memo} from \"react\"\nimport {digg} from \"diggerize\"\nimport Notification from \"./notification\"\nimport {shapeComponent, ShapeComponent} from \"set-state-compare/src/shape-component.js\"\nimport useEventListener from \"@kaspernj/api-maker/src/use-event-listener\"\nimport {View} from \"react-native\"\n\nexport default memo(shapeComponent(class FlashNotificationsContainer extends ShapeComponent {\n setup() {\n this.useStates({\n count: 0,\n notifications: []\n })\n\n useEventListener(window, \"pushNotification\", this.onPushNotification)\n }\n\n render() {\n return (\n <View\n dataSet={{class: \"flash-notifications-container\"}}\n style={{\n position: \"fixed\",\n zIndex: 99999,\n top: 20,\n right: 20\n }}\n >\n {this.state.notifications.map((notification) =>\n <Notification\n key={`notification-${notification.count}`}\n message={notification.message}\n notification={notification}\n onRemovedClicked={this.onRemovedClicked}\n title={notification.title}\n type={notification.type}\n />\n )}\n </View>\n )\n }\n\n onPushNotification = (event) => {\n const detail = digg(event, \"detail\")\n const count = this.state.count + 1\n\n setTimeout(() => this.removeNotification(count), 4000)\n\n const notification = {\n count,\n message: digg(detail, \"message\"),\n title: digg(detail, \"title\"),\n type: digg(detail, \"type\")\n }\n\n this.setState({count, notifications: this.state.notifications.concat([notification])})\n }\n\n onRemovedClicked = (notification) => this.removeNotification(digg(notification, \"count\"))\n\n removeNotification = (count) => {\n this.setState({\n notifications: this.state.notifications.filter((notification) => notification.count != count)\n })\n }\n}))\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../src/container/notification.jsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Pressable, Text, View } from "react-native";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import PropTypesExact from "prop-types-exact";
|
|
5
|
+
import { shapeComponent, ShapeComponent } from "set-state-compare/src/shape-component.js";
|
|
6
|
+
export default memo(shapeComponent(class NotificationsNotification extends ShapeComponent {
|
|
7
|
+
static propTypes = PropTypesExact({
|
|
8
|
+
className: PropTypes.string,
|
|
9
|
+
message: PropTypes.string.isRequired,
|
|
10
|
+
notification: PropTypes.object.isRequired,
|
|
11
|
+
onRemovedClicked: PropTypes.func.isRequired,
|
|
12
|
+
title: PropTypes.string.isRequired,
|
|
13
|
+
type: PropTypes.string.isRequired
|
|
14
|
+
});
|
|
15
|
+
render() {
|
|
16
|
+
const { className, message, title, type } = this.props;
|
|
17
|
+
const style = {
|
|
18
|
+
width: 300,
|
|
19
|
+
maxWidth: "100%",
|
|
20
|
+
marginBottom: 15,
|
|
21
|
+
padding: 15,
|
|
22
|
+
borderRadius: 11,
|
|
23
|
+
cursor: "pointer"
|
|
24
|
+
};
|
|
25
|
+
if (type == "error") {
|
|
26
|
+
style.border = "1px solid rgba(161 34 32 / 95%)";
|
|
27
|
+
style.background = "rgba(161 34 32 / 87%)";
|
|
28
|
+
}
|
|
29
|
+
if (type == "success") {
|
|
30
|
+
style.border = "1px solid rgba(0 0 0 / 95%)";
|
|
31
|
+
style.background = "rgba(0 0 0 / 87%)";
|
|
32
|
+
}
|
|
33
|
+
if (type == "alert") {
|
|
34
|
+
style.border = "1px solid rgba(204 51 0 / 95%)";
|
|
35
|
+
style.background = "rgba(204 51 0 / 87%)";
|
|
36
|
+
}
|
|
37
|
+
return (React.createElement(Pressable, { dataSet: { class: classNames("flash-notifications-notification", className), type }, onPress: this.onRemovedClicked },
|
|
38
|
+
React.createElement(View, { style: style },
|
|
39
|
+
React.createElement(View, { dataSet: { class: "notification-title" }, style: { marginBottom: 5 } },
|
|
40
|
+
React.createElement(Text, { style: { color: "#fff", fontWeight: "bold" } }, title)),
|
|
41
|
+
React.createElement(View, { dataSet: { class: "notification-message" } },
|
|
42
|
+
React.createElement(Text, { style: { color: "#fff" } }, message)))));
|
|
43
|
+
}
|
|
44
|
+
onRemovedClicked = () => {
|
|
45
|
+
this.props.onRemovedClicked(this.props.notification);
|
|
46
|
+
};
|
|
47
|
+
}));
|
|
48
|
+
//# sourceMappingURL=notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../src/container/notification.jsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,cAAc,CAAA;AAClD,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAA;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAC,cAAc,E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AU,CAAC,kCAAkC,EAAE,SAAS,CAAC,EAAE,IAAI,EAAC,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB;YAC1H,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK;gBAChB,oBAAC,IAAI,IAAC,OAAO,EAAE,EAAC,KAAK,EAAE,oBAAoB,EAAC,EAAE,KAAK,EAAE,EAAC,YAAY,EAAE,CAAC,EAAC;oBACpE,oBAAC,IAAI,IAAC,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAC,IAC7C,KAAK,CACD,CACF;gBACP,oBAAC,IAAI,IAAC,OAAO,EAAE,EAAC,KAAK,EAAE,sBAAsB,EAAC;oBAC5C,oBAAC,IAAI,IAAC,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAC,IACzB,OAAO,CACH,CACF,CACF,CACG,CACb,CAAA;IACH,CAAC;IAED,gBAAgB,GAAG,GAAG,EAAE;QACtB,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IACtD,CAAC,CAAA;CACF,CAAC,CAAC,CAAA","sourcesContent":["import {Pressable, Text, View} from \"react-native\"\nimport {memo} from \"react\"\nimport PropTypes from \"prop-types\"\nimport PropTypesExact from \"prop-types-exact\"\nimport {shapeComponent, ShapeComponent} from \"set-state-compare/src/shape-component.js\"\n\nexport default memo(shapeComponent(class NotificationsNotification extends ShapeComponent {\n static propTypes = PropTypesExact({\n className: PropTypes.string,\n message: PropTypes.string.isRequired,\n notification: PropTypes.object.isRequired,\n onRemovedClicked: PropTypes.func.isRequired,\n title: PropTypes.string.isRequired,\n type: PropTypes.string.isRequired\n })\n\n render() {\n const {className, message, title, type} = this.props\n\n const style = {\n width: 300,\n maxWidth: \"100%\",\n marginBottom: 15,\n padding: 15,\n borderRadius: 11,\n cursor: \"pointer\"\n }\n\n if (type == \"error\") {\n style.border = \"1px solid rgba(161 34 32 / 95%)\"\n style.background = \"rgba(161 34 32 / 87%)\"\n }\n\n if (type == \"success\") {\n style.border = \"1px solid rgba(0 0 0 / 95%)\"\n style.background = \"rgba(0 0 0 / 87%)\"\n }\n\n\n if (type == \"alert\") {\n style.border = \"1px solid rgba(204 51 0 / 95%)\"\n style.background = \"rgba(204 51 0 / 87%)\"\n }\n\n return (\n <Pressable dataSet={{class: classNames(\"flash-notifications-notification\", className), type}} onPress={this.onRemovedClicked}>\n <View style={style}>\n <View dataSet={{class: \"notification-title\"}} style={{marginBottom: 5}}>\n <Text style={{color: \"#fff\", fontWeight: \"bold\"}}>\n {title}\n </Text>\n </View>\n <View dataSet={{class: \"notification-message\"}}>\n <Text style={{color: \"#fff\"}}>\n {message}\n </Text>\n </View>\n </View>\n </Pressable>\n )\n }\n\n onRemovedClicked = () => {\n this.props.onRemovedClicked(this.props.notification)\n }\n}))\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default class FlashMessage {
|
|
2
|
+
static alert(message: any): void;
|
|
3
|
+
static error(error: any): void;
|
|
4
|
+
static errorResponse(error: any): void;
|
|
5
|
+
static success(message: any): void;
|
|
6
|
+
static show(args: any): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=flash-notifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flash-notifications.d.ts","sourceRoot":"","sources":["../src/flash-notifications.js"],"names":[],"mappings":"AAGA;IACE,iCAEC;IAED,+BA0BC;IAED,uCAEC;IAED,mCAEC;IAED,6BAsBC;CACF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import BaseError from "@kaspernj/api-maker/src/base-error";
|
|
2
|
+
import ValidationError from "@kaspernj/api-maker/src/validation-error";
|
|
3
|
+
export default class FlashMessage {
|
|
4
|
+
static alert(message) {
|
|
5
|
+
FlashMessage.show({ type: "alert", text: message });
|
|
6
|
+
}
|
|
7
|
+
static error(error) {
|
|
8
|
+
if (error instanceof BaseError) {
|
|
9
|
+
if (error.args.response && error.args.response.errors) {
|
|
10
|
+
const errors = digg(error, "args", "response", "errors");
|
|
11
|
+
const errorMessages = errors.map((error) => {
|
|
12
|
+
if (typeof error == "string") {
|
|
13
|
+
return error;
|
|
14
|
+
}
|
|
15
|
+
return digg(error, "message");
|
|
16
|
+
});
|
|
17
|
+
FlashMessage.alert(errorMessages.join(". "));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if (error instanceof ValidationError) {
|
|
24
|
+
if (error.hasUnhandledErrors()) {
|
|
25
|
+
FlashMessage.alert(error.message);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
FlashMessage.alert(I18n.t("js.notification.couldnt_submit_because_of_validation_errors"));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.error("Didnt know what to do with that error", error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
static errorResponse(error) {
|
|
37
|
+
this.error(error);
|
|
38
|
+
}
|
|
39
|
+
static success(message) {
|
|
40
|
+
FlashMessage.show({ type: "success", text: message });
|
|
41
|
+
}
|
|
42
|
+
static show(args) {
|
|
43
|
+
let title;
|
|
44
|
+
if (args.type == "alert") {
|
|
45
|
+
title = I18n.t("js.shared.alert");
|
|
46
|
+
}
|
|
47
|
+
else if (args.type == "error") {
|
|
48
|
+
title = I18n.t("js.shared.error");
|
|
49
|
+
}
|
|
50
|
+
else if (args.type == "success") {
|
|
51
|
+
title = I18n.t("js.shared.success");
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
title = I18n.t("js.shared.notification");
|
|
55
|
+
}
|
|
56
|
+
const event = new CustomEvent("pushNotification", {
|
|
57
|
+
detail: {
|
|
58
|
+
message: args.text,
|
|
59
|
+
title,
|
|
60
|
+
type: args.type
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
window.dispatchEvent(event);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=flash-notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flash-notifications.js","sourceRoot":"","sources":["../src/flash-notifications.js"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oCAAoC,CAAA;AAC1D,OAAO,eAAe,MAAM,0CAA0C,CAAA;AAEtE,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,MAAM,CAAC,KAAK,CAAC,OAAO;QAClB,YAAY,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;IACnD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK;QAChB,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;YAC/B,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBACtD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAA;gBACxD,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;oBACzC,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;wBAC7B,OAAO,KAAK,CAAA;oBACd,CAAC;oBAED,OAAO,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;gBAC/B,CAAC,CAAC,CAAA;gBAEF,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC9C,CAAC;iBAAM,CAAC;gBACN,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;YAC5C,IAAI,KAAK,CAAC,kBAAkB,EAAE,EAAE,CAAC;gBAC/B,YAAY,CAAC,KAAK,CAAC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AEF,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAC7B,CAAC;CACF","sourcesContent":["import BaseError from \"@kaspernj/api-maker/src/base-error\"\nimport ValidationError from \"@kaspernj/api-maker/src/validation-error\"\n\nexport default class FlashMessage {\n static alert(message) {\n FlashMessage.show({type: \"alert\", text: message})\n }\n\n static error(error) {\n if (error instanceof BaseError) {\n if (error.args.response && error.args.response.errors) {\n const errors = digg(error, \"args\", \"response\", \"errors\")\n const errorMessages = errors.map((error) => {\n if (typeof error == \"string\") {\n return error\n }\n\n return digg(error, \"message\")\n })\n\n FlashMessage.alert(errorMessages.join(\". \"))\n } else {\n throw error\n }\n } else if (error instanceof ValidationError) {\n if (error.hasUnhandledErrors()) {\n FlashMessage.alert(error.message)\n } else {\n FlashMessage.alert(I18n.t(\"js.notification.couldnt_submit_because_of_validation_errors\"))\n }\n } else {\n console.error(\"Didnt know what to do with that error\", error)\n throw error\n }\n }\n\n static errorResponse(error) {\n this.error(error)\n }\n\n static success(message) {\n FlashMessage.show({type: \"success\", text: message})\n }\n\n static show(args) {\n let title\n\n if (args.type == \"alert\") {\n title = I18n.t(\"js.shared.alert\")\n } else if (args.type == \"error\") {\n title = I18n.t(\"js.shared.error\")\n } else if (args.type == \"success\") {\n title = I18n.t(\"js.shared.success\")\n } else {\n title = I18n.t(\"js.shared.notification\")\n }\n\n const event = new CustomEvent(\"pushNotification\", {\n detail: {\n message: args.text,\n title,\n type: args.type\n }\n })\n\n window.dispatchEvent(event)\n }\n}\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"sBAAsB,aAAa;+BACJ,uBAAuB"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,kBAAkB,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EACL,SAAS,EACT,kBAAkB,EACnB,CAAA","sourcesContent":["import Container from \"./container\"\nimport FlashNotifications from \"./flash-notifications\"\n\nexport {\n Container,\n FlashNotifications\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'FlashNotifications'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.description = package['description']
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.homepage = package['homepage']
|
|
13
|
+
s.platforms = {
|
|
14
|
+
:ios => '15.1',
|
|
15
|
+
:tvos => '15.1'
|
|
16
|
+
}
|
|
17
|
+
s.swift_version = '5.4'
|
|
18
|
+
s.source = { git: 'https://github.com/kaspernj/flash-notifications' }
|
|
19
|
+
s.static_framework = true
|
|
20
|
+
|
|
21
|
+
s.dependency 'ExpoModulesCore'
|
|
22
|
+
|
|
23
|
+
# Swift/Objective-C compatibility
|
|
24
|
+
s.pod_target_xcconfig = {
|
|
25
|
+
'DEFINES_MODULE' => 'YES',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
|
|
29
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
public class FlashNotificationsModule: Module {
|
|
4
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
5
|
+
// that describes the module's functionality and behavior.
|
|
6
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
7
|
+
public func definition() -> ModuleDefinition {
|
|
8
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
9
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
10
|
+
// The module will be accessible from `requireNativeModule('FlashNotifications')` in JavaScript.
|
|
11
|
+
Name("FlashNotifications")
|
|
12
|
+
|
|
13
|
+
// Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
|
|
14
|
+
Constants([
|
|
15
|
+
"PI": Double.pi
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
// Defines event names that the module can send to JavaScript.
|
|
19
|
+
Events("onChange")
|
|
20
|
+
|
|
21
|
+
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
22
|
+
Function("hello") {
|
|
23
|
+
return "Hello world! 👋"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Defines a JavaScript function that always returns a Promise and whose native code
|
|
27
|
+
// is by default dispatched on the different thread than the JavaScript runtime runs on.
|
|
28
|
+
AsyncFunction("setValueAsync") { (value: String) in
|
|
29
|
+
// Send an event to JavaScript.
|
|
30
|
+
self.sendEvent("onChange", [
|
|
31
|
+
"value": value
|
|
32
|
+
])
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Enables the module to be used as a native view. Definition components that are accepted as part of the
|
|
36
|
+
// view definition: Prop, Events.
|
|
37
|
+
View(FlashNotificationsView.self) {
|
|
38
|
+
// Defines a setter for the `url` prop.
|
|
39
|
+
Prop("url") { (view: FlashNotificationsView, url: URL) in
|
|
40
|
+
if view.webView.url != url {
|
|
41
|
+
view.webView.load(URLRequest(url: url))
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Events("onLoad")
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import WebKit
|
|
3
|
+
|
|
4
|
+
// This view will be used as a native component. Make sure to inherit from `ExpoView`
|
|
5
|
+
// to apply the proper styling (e.g. border radius and shadows).
|
|
6
|
+
class FlashNotificationsView: ExpoView {
|
|
7
|
+
let webView = WKWebView()
|
|
8
|
+
let onLoad = EventDispatcher()
|
|
9
|
+
var delegate: WebViewDelegate?
|
|
10
|
+
|
|
11
|
+
required init(appContext: AppContext? = nil) {
|
|
12
|
+
super.init(appContext: appContext)
|
|
13
|
+
clipsToBounds = true
|
|
14
|
+
delegate = WebViewDelegate { url in
|
|
15
|
+
self.onLoad(["url": url])
|
|
16
|
+
}
|
|
17
|
+
webView.navigationDelegate = delegate
|
|
18
|
+
addSubview(webView)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override func layoutSubviews() {
|
|
22
|
+
webView.frame = bounds
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class WebViewDelegate: NSObject, WKNavigationDelegate {
|
|
27
|
+
let onUrlChange: (String) -> Void
|
|
28
|
+
|
|
29
|
+
init(onUrlChange: @escaping (String) -> Void) {
|
|
30
|
+
self.onUrlChange = onUrlChange
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation) {
|
|
34
|
+
if let url = webView.url {
|
|
35
|
+
onUrlChange(url.absoluteString)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
"main": "index.js",
|
|
3
2
|
"name": "flash-notifications",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
3
|
+
"version": "0.0.12",
|
|
4
|
+
"description": "My new module",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "expo-module build",
|
|
9
|
+
"clean": "expo-module clean",
|
|
10
|
+
"lint": "expo-module lint",
|
|
11
|
+
"test": "expo-module test",
|
|
12
|
+
"prepare": "expo-module prepare",
|
|
13
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
14
|
+
"expo-module": "expo-module",
|
|
15
|
+
"open:ios": "xed example/ios",
|
|
16
|
+
"open:android": "open -a \"Android Studio\" example/android"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
19
|
-
"react"
|
|
20
|
-
"
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-native",
|
|
20
|
+
"expo",
|
|
21
|
+
"flash-notifications",
|
|
22
|
+
"FlashNotifications"
|
|
23
|
+
],
|
|
24
|
+
"repository": "https://github.com/kaspernj/flash-notifications",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/kaspernj/flash-notifications/issues"
|
|
21
27
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
28
|
+
"author": "kaspernj <kasper@diestoeckels.de> (https://github.com/kaspernj)",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/kaspernj/flash-notifications#readme",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"diggerize": "*",
|
|
33
|
+
"prop-types-exact": "*",
|
|
34
|
+
"set-state-compare": "*"
|
|
27
35
|
},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/react": "~18.3.12",
|
|
38
|
+
"expo-module-scripts": "^4.0.2",
|
|
39
|
+
"expo": "~52.0.0",
|
|
40
|
+
"react-native": "0.76.0"
|
|
33
41
|
},
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"not op_mini all"
|
|
39
|
-
],
|
|
40
|
-
"development": [
|
|
41
|
-
"last 1 chrome version",
|
|
42
|
-
"last 1 firefox version",
|
|
43
|
-
"last 1 safari version"
|
|
44
|
-
]
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"expo": "*",
|
|
44
|
+
"react": "*",
|
|
45
|
+
"react-native": "*"
|
|
45
46
|
}
|
|
46
47
|
}
|
package/src/index.js
ADDED
package/tsconfig.json
ADDED
package/.github/dependabot.yml
DELETED
package/index.js
DELETED
package/public/favicon.ico
DELETED
|
Binary file
|
package/public/index.html
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
<meta name="theme-color" content="#000000" />
|
|
8
|
-
<meta
|
|
9
|
-
name="description"
|
|
10
|
-
content="Web site created using create-react-app"
|
|
11
|
-
/>
|
|
12
|
-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
|
-
<!--
|
|
14
|
-
manifest.json provides metadata used when your web app is installed on a
|
|
15
|
-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
16
|
-
-->
|
|
17
|
-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
18
|
-
<!--
|
|
19
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
20
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
21
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
22
|
-
|
|
23
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
24
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
25
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
26
|
-
-->
|
|
27
|
-
<title>React App</title>
|
|
28
|
-
</head>
|
|
29
|
-
<body>
|
|
30
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
31
|
-
<div id="root"></div>
|
|
32
|
-
<!--
|
|
33
|
-
This HTML file is a template.
|
|
34
|
-
If you open it directly in the browser, you will see an empty page.
|
|
35
|
-
|
|
36
|
-
You can add webfonts, meta tags, or analytics to this file.
|
|
37
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
38
|
-
|
|
39
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
40
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
41
|
-
-->
|
|
42
|
-
</body>
|
|
43
|
-
</html>
|
package/public/logo192.png
DELETED
|
Binary file
|
package/public/logo512.png
DELETED
|
Binary file
|
package/public/manifest.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|
package/public/robots.txt
DELETED
package/src/reportWebVitals.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
package/src/setupTests.js
DELETED