@cocreate/notification 1.0.0
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/.github/FUNDING.yml +3 -0
- package/.github/workflows/automated.yml +44 -0
- package/.github/workflows/manual.yml +44 -0
- package/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +96 -0
- package/CoCreate.config.js +24 -0
- package/LICENSE +683 -0
- package/README.md +85 -0
- package/demo/index.html +20 -0
- package/docs/index.html +378 -0
- package/package.json +63 -0
- package/release.config.js +22 -0
- package/src/client.js +79 -0
- package/src/index.js +38 -0
- package/src/server.js +173 -0
- package/webpack.config.js +90 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# CoCreate-notification
|
|
2
|
+
|
|
3
|
+
Simple HTML5 & JavaScript component add, update & remove values in element's notification from input, select or js api. Easily configured using HTML5 notification and/or JavaScript API. Take it for a spin in our [playground!](https://cocreate.app/docs/notification)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
## [Docs & Demo](https://cocreate.app/docs/notification)
|
|
15
|
+
|
|
16
|
+
For a complete guide and working demo refer to the [doumentation](https://cocreate.app/docs/notification)
|
|
17
|
+
|
|
18
|
+
## CDN
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script src="https://cdn.cocreate.app/notification/latest/CoCreate-notification.min.js"></script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<script src="https://cdn.cocreate.app/notification/latest/CoCreate-notification.min.css"></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## NPM
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
$ npm i @cocreate/notification
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## yarn
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
$ yarn install @cocreate/notification
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# Table of Contents
|
|
41
|
+
|
|
42
|
+
- [Table of Contents](#table-of-contents)
|
|
43
|
+
- [Announcements](#announcements)
|
|
44
|
+
- [Roadmap](#roadmap)
|
|
45
|
+
- [How to Contribute](#how-to-contribute)
|
|
46
|
+
- [About](#about)
|
|
47
|
+
- [License](#license)
|
|
48
|
+
|
|
49
|
+
<a name="announcements"></a>
|
|
50
|
+
|
|
51
|
+
# Announcements
|
|
52
|
+
|
|
53
|
+
All updates to this library are documented in our [CHANGELOG](https://github.com/CoCreate-app/CoCreate-notification/blob/master/CHANGELOG.md) and [releases](https://github.com/CoCreate-app/CoCreate-notification/releases). You may also subscribe to email for releases and breaking changes.
|
|
54
|
+
|
|
55
|
+
<a name="roadmap"></a>
|
|
56
|
+
|
|
57
|
+
# Roadmap
|
|
58
|
+
|
|
59
|
+
If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/CoCreate-app/CoCreate-notification/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-notification/pulls). We would love to hear your feedback.
|
|
60
|
+
|
|
61
|
+
<a name="about"></a>
|
|
62
|
+
|
|
63
|
+
# About
|
|
64
|
+
|
|
65
|
+
CoCreate-notification is guided and supported by the CoCreate Developer Experience Team.
|
|
66
|
+
|
|
67
|
+
Please Email the Developer Experience Team [here](mailto:develop@cocreate.app) in case of any queries.
|
|
68
|
+
|
|
69
|
+
CoCreate-notification is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
|
|
70
|
+
|
|
71
|
+
<a name="contribute"></a>
|
|
72
|
+
|
|
73
|
+
# How to Contribute
|
|
74
|
+
|
|
75
|
+
We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/CoCreate-app/CoCreate-notification/blob/master/CONTRIBUTING.md) guide for details.
|
|
76
|
+
|
|
77
|
+
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/CoCreate-app/CoCreate-notification/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-notification/pulls) or merely upvote or comment on existing issues or pull requests.
|
|
78
|
+
|
|
79
|
+
We appreciate your continued support, thank you!
|
|
80
|
+
|
|
81
|
+
<a name="license"></a>
|
|
82
|
+
|
|
83
|
+
# License
|
|
84
|
+
|
|
85
|
+
[The MIT License (MIT)](https://github.com/CoCreate-app/CoCreate-notification/blob/master/LICENSE)
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<title>notification | CoCreateJS</title>
|
|
5
|
+
<!-- CoCreate Favicon -->
|
|
6
|
+
<link
|
|
7
|
+
rel="icon"
|
|
8
|
+
href="https://cdn.cocreate.app/favicon.ico"
|
|
9
|
+
type="image/ico"
|
|
10
|
+
sizes="16x16" />
|
|
11
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body>
|
|
15
|
+
<button actions="notification.subscribe">click</button>
|
|
16
|
+
|
|
17
|
+
<!--<script src="../dist/CoCreate-notification.js"></script>-->
|
|
18
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<title>CoCreate-notification Documentation | CoCreateJS</title>
|
|
8
|
+
<link
|
|
9
|
+
rel="icon"
|
|
10
|
+
type="image/png"
|
|
11
|
+
sizes="32x32"
|
|
12
|
+
href="https://cocreate.app/images/favicon.ico" />
|
|
13
|
+
<meta
|
|
14
|
+
key="description"
|
|
15
|
+
content="A JavaScript component target,update & remove values in element's notification from an input,select or js api.Configurable using class, style or any custom attribute" />
|
|
16
|
+
<meta name="robots" content="index,follow" />
|
|
17
|
+
<meta
|
|
18
|
+
property="og:image"
|
|
19
|
+
content="https://cdn.cocreate.app/docs/notification.png" />
|
|
20
|
+
|
|
21
|
+
<!-- CoCreate CSS -->
|
|
22
|
+
<link
|
|
23
|
+
rel="stylesheet"
|
|
24
|
+
href="https://cdn.cocreate.app/latest/CoCreate.min.css"
|
|
25
|
+
type="text/css" />
|
|
26
|
+
<link
|
|
27
|
+
rel="stylesheet"
|
|
28
|
+
href="/docs/index.css"
|
|
29
|
+
array="files"
|
|
30
|
+
object="60888216117c640e7596303f"
|
|
31
|
+
key="src"
|
|
32
|
+
type="text/css"
|
|
33
|
+
save="true" />
|
|
34
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
35
|
+
</head>
|
|
36
|
+
|
|
37
|
+
<body>
|
|
38
|
+
<nav
|
|
39
|
+
class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px"
|
|
40
|
+
content_id="content"
|
|
41
|
+
scroll="sticky-nav,hide-nav"
|
|
42
|
+
scroll-up="10"
|
|
43
|
+
scroll-down="10"
|
|
44
|
+
array="files"
|
|
45
|
+
object="60395ef42b3ac232657040fd"
|
|
46
|
+
key="src"></nav>
|
|
47
|
+
<sidenav
|
|
48
|
+
id="menuL"
|
|
49
|
+
class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
|
|
50
|
+
resizable
|
|
51
|
+
resize-selector="[content_id='content']"
|
|
52
|
+
resize-property="margin-left"
|
|
53
|
+
resize-value="width">
|
|
54
|
+
<menu
|
|
55
|
+
array="files"
|
|
56
|
+
object="603717b07de7fb350ae9fec8"
|
|
57
|
+
key="src"></menu>
|
|
58
|
+
<div resize="right"></div>
|
|
59
|
+
</sidenav>
|
|
60
|
+
<main
|
|
61
|
+
class="padding-top:15px padding:15px@lg@xl"
|
|
62
|
+
content_id="content"
|
|
63
|
+
id="cocreate-domEditorPanel">
|
|
64
|
+
<div
|
|
65
|
+
class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px">
|
|
66
|
+
<div class="display:flex align-items:center">
|
|
67
|
+
<h2>CoCreate-domEditorPanel</h2>
|
|
68
|
+
</div>
|
|
69
|
+
<div
|
|
70
|
+
class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white">
|
|
71
|
+
<div
|
|
72
|
+
class="display:flex align-items:center transition:0.3s padding-left:10px"
|
|
73
|
+
share-network="true"
|
|
74
|
+
share-text="A JavaScript component target,update & remove values in element's notification from an input,select or js api.Configurable using class,style or any custom attribute"
|
|
75
|
+
share-title="CoCreate notification"
|
|
76
|
+
share-height="600"
|
|
77
|
+
share-width="700"
|
|
78
|
+
share-media="https://cdn.cocreate.app/docs/notification.png"
|
|
79
|
+
hover="display:block!important"
|
|
80
|
+
hover-selector=".social-networks">
|
|
81
|
+
<div class="display:none social-networks">
|
|
82
|
+
<a
|
|
83
|
+
class="margin-right:15px"
|
|
84
|
+
share-network="twitter"
|
|
85
|
+
title="Share on twitter"
|
|
86
|
+
><i
|
|
87
|
+
class="height:20px fill:#505050"
|
|
88
|
+
src="/assets/svg/twitter.svg"></i
|
|
89
|
+
></a>
|
|
90
|
+
<a
|
|
91
|
+
class="margin-right:15px"
|
|
92
|
+
share-network="facebook"
|
|
93
|
+
title="Share on Facebook"
|
|
94
|
+
><i
|
|
95
|
+
class="height:20px fill:#505050"
|
|
96
|
+
src="/assets/svg/facebook.svg"></i
|
|
97
|
+
></a>
|
|
98
|
+
<a
|
|
99
|
+
class="margin-right:15px"
|
|
100
|
+
share-network="instagram"
|
|
101
|
+
title="Share on instagram"
|
|
102
|
+
><i
|
|
103
|
+
class="height:20px fill:#505050"
|
|
104
|
+
src="/assets/svg/instagram.svg"></i
|
|
105
|
+
></a>
|
|
106
|
+
</div>
|
|
107
|
+
<a
|
|
108
|
+
class="margin-right:15px"
|
|
109
|
+
share-network="share"
|
|
110
|
+
title="Share on share"
|
|
111
|
+
><i
|
|
112
|
+
class="height:20px fill:#505050"
|
|
113
|
+
src="/assets/svg/share-alt.svg"></i
|
|
114
|
+
></a>
|
|
115
|
+
</div>
|
|
116
|
+
<a
|
|
117
|
+
class="margin-right:15px"
|
|
118
|
+
share-network="share"
|
|
119
|
+
title="Share on share"
|
|
120
|
+
><i
|
|
121
|
+
class="height:20px fill:#505050"
|
|
122
|
+
src="/assets/svg/share-alt.svg"></i
|
|
123
|
+
></a>
|
|
124
|
+
</div>
|
|
125
|
+
<a
|
|
126
|
+
href="https://github.com/CoCreate-app/CoCreate-domEditorPanel"
|
|
127
|
+
target="_blank"
|
|
128
|
+
class="margin-right:15px"
|
|
129
|
+
><i
|
|
130
|
+
class="height:20px fill:#505050"
|
|
131
|
+
src="/assets/svg/github.svg"></i
|
|
132
|
+
></a>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<h1
|
|
136
|
+
class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100">
|
|
137
|
+
Simple HTML5 & JavaScript component operate add, update
|
|
138
|
+
& remove values in element's notification from input, select
|
|
139
|
+
or js api. Easy configuration using class, style or any custom
|
|
140
|
+
attribute. Highly customizable and styleable.
|
|
141
|
+
</h1>
|
|
142
|
+
<div
|
|
143
|
+
id="domEditorPanel-section"
|
|
144
|
+
class="display:flex flex-wrap:wrap">
|
|
145
|
+
<div
|
|
146
|
+
class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
|
|
147
|
+
<div
|
|
148
|
+
id="notification-install"
|
|
149
|
+
class="border-bottom:1px_solid_lightgrey"
|
|
150
|
+
scroll
|
|
151
|
+
scroll-intersect="color:dodgerblue"
|
|
152
|
+
scroll-selector="#notification-install-section">
|
|
153
|
+
<span
|
|
154
|
+
class="display:flex align-items:center width:fit-content"
|
|
155
|
+
hover="display:block!important"
|
|
156
|
+
hover-selector="[href='#notification-install']">
|
|
157
|
+
<h2 class="padding:5px_0px">Install</h2>
|
|
158
|
+
<a
|
|
159
|
+
class="margin-left:10px display:none"
|
|
160
|
+
href="#notification-install"
|
|
161
|
+
><i
|
|
162
|
+
class="height:20px fill:#505050"
|
|
163
|
+
src="/assets/svg/link.svg"></i
|
|
164
|
+
></a>
|
|
165
|
+
</span>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<pre><code class="language-bash">npm i @cocreate/action</code></pre>
|
|
169
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
170
|
+
Or you can use cdn link:
|
|
171
|
+
</p>
|
|
172
|
+
<pre><code class="language-html"><script>https://cdn.cocreate.app/notification/latest/CoCreate-notification.min.js</script></code></pre>
|
|
173
|
+
|
|
174
|
+
<div
|
|
175
|
+
id="notification-usage"
|
|
176
|
+
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
177
|
+
scroll
|
|
178
|
+
scroll-intersect="color:dodgerblue"
|
|
179
|
+
scroll-selector="#notification-usage-section">
|
|
180
|
+
<span
|
|
181
|
+
class="display:flex align-items:center width:fit-content"
|
|
182
|
+
hover="display:block!important"
|
|
183
|
+
hover-selector="[href='#notification-usage']">
|
|
184
|
+
<h2 class="padding:5px_0px">Usage</h2>
|
|
185
|
+
<a
|
|
186
|
+
class="margin-left:10px display:none"
|
|
187
|
+
href="#notification-usage"
|
|
188
|
+
><i
|
|
189
|
+
class="height:20px fill:#505050"
|
|
190
|
+
src="/assets/svg/link.svg"></i
|
|
191
|
+
></a>
|
|
192
|
+
</span>
|
|
193
|
+
</div>
|
|
194
|
+
<div class="">
|
|
195
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
196
|
+
This is domEditorPanel usage
|
|
197
|
+
</p>
|
|
198
|
+
|
|
199
|
+
<div class="flex-grow:1 min-width:300px width:100%">
|
|
200
|
+
<pre><code class="language-html"><div></div></code></pre>
|
|
201
|
+
</div>
|
|
202
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
203
|
+
This is domEditorPanel usage
|
|
204
|
+
</p>
|
|
205
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
206
|
+
This is domEditorPanel usage
|
|
207
|
+
</p>
|
|
208
|
+
</div>
|
|
209
|
+
<div
|
|
210
|
+
id="notification-notification"
|
|
211
|
+
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
212
|
+
scroll
|
|
213
|
+
scroll-intersect="color:dodgerblue"
|
|
214
|
+
scroll-selector="#notification-notification-section">
|
|
215
|
+
<span
|
|
216
|
+
class="display:flex align-items:center width:fit-content"
|
|
217
|
+
hover="display:block!important"
|
|
218
|
+
hover-selector="[href='#notification-notification']">
|
|
219
|
+
<h2 class="padding:5px_0px">notification</h2>
|
|
220
|
+
<a
|
|
221
|
+
class="margin-left:10px display:none"
|
|
222
|
+
href="#notification-notification"
|
|
223
|
+
><i
|
|
224
|
+
class="height:20px fill:#505050"
|
|
225
|
+
src="/assets/svg/link.svg"></i
|
|
226
|
+
></a>
|
|
227
|
+
</span>
|
|
228
|
+
</div>
|
|
229
|
+
<ul class="list-style-type:none">
|
|
230
|
+
<li
|
|
231
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
232
|
+
<h4>
|
|
233
|
+
<span>domEditorPanel</span>
|
|
234
|
+
<span class="cocreate-badge success"
|
|
235
|
+
>string</span
|
|
236
|
+
>
|
|
237
|
+
<span class="cocreate-badge warning"
|
|
238
|
+
>optional</span
|
|
239
|
+
>
|
|
240
|
+
</h4>
|
|
241
|
+
<p>domEditorPanel-attribute</p>
|
|
242
|
+
</li>
|
|
243
|
+
<li
|
|
244
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
245
|
+
<h4>
|
|
246
|
+
<span>domEditorPanel</span>
|
|
247
|
+
<span class="cocreate-badge success"
|
|
248
|
+
>string</span
|
|
249
|
+
>
|
|
250
|
+
<span class="cocreate-badge warning"
|
|
251
|
+
>optional</span
|
|
252
|
+
>
|
|
253
|
+
</h4>
|
|
254
|
+
<p>domEditorPanel-attribute</p>
|
|
255
|
+
</li>
|
|
256
|
+
</ul>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<div
|
|
260
|
+
class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
|
|
261
|
+
<!-- SandBox -->
|
|
262
|
+
<div
|
|
263
|
+
id="notification-demo"
|
|
264
|
+
class="border-bottom:1px_solid_lightgrey"
|
|
265
|
+
scroll
|
|
266
|
+
scroll-intersect="color:dodgerblue"
|
|
267
|
+
scroll-selector="#notification-demo-section">
|
|
268
|
+
<span
|
|
269
|
+
class="display:flex align-items:center width:fit-content"
|
|
270
|
+
hover="display:block!important"
|
|
271
|
+
hover-selector="[href='#notification-demo']">
|
|
272
|
+
<h2 class="padding:5px_0px">Demo</h2>
|
|
273
|
+
<a
|
|
274
|
+
class="margin-left:10px display:none"
|
|
275
|
+
href="#notification-demo"
|
|
276
|
+
><i
|
|
277
|
+
class="height:20px fill:#505050"
|
|
278
|
+
src="/assets/svg/link.svg"></i
|
|
279
|
+
></a>
|
|
280
|
+
</span>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<div
|
|
284
|
+
class="position:sticky top:0 padding:15px_0px height:100vh">
|
|
285
|
+
<!-- SandBox -->
|
|
286
|
+
<div
|
|
287
|
+
class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
|
|
288
|
+
id="playground">
|
|
289
|
+
<div
|
|
290
|
+
id="demo-code"
|
|
291
|
+
resizable
|
|
292
|
+
class="position:relative height:50%">
|
|
293
|
+
<textarea
|
|
294
|
+
type="code"
|
|
295
|
+
lang="html"
|
|
296
|
+
array="demos"
|
|
297
|
+
object=""
|
|
298
|
+
key="demo"
|
|
299
|
+
save="false"
|
|
300
|
+
id="demo"
|
|
301
|
+
class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
302
|
+
<div
|
|
303
|
+
resize="bottom"
|
|
304
|
+
class="background:lightgrey"></div>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
<div
|
|
308
|
+
id="demo-preview"
|
|
309
|
+
class="position:relative overflow:auto background-color:white">
|
|
310
|
+
<div class="demopreview padding:20px"></div>
|
|
311
|
+
</div>
|
|
312
|
+
|
|
313
|
+
<div
|
|
314
|
+
class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
315
|
+
<a
|
|
316
|
+
class="margin-right:10px"
|
|
317
|
+
id="eye"
|
|
318
|
+
show="#eye-slash"
|
|
319
|
+
hide="#eye, #demo-preview"
|
|
320
|
+
toggle="code-height"
|
|
321
|
+
toggle-selector="#demo-code"
|
|
322
|
+
><i
|
|
323
|
+
class="height:18px fill:#505050"
|
|
324
|
+
src="/assets/svg/eye.svg"></i
|
|
325
|
+
></a>
|
|
326
|
+
<a
|
|
327
|
+
class="margin-right:10px"
|
|
328
|
+
hidden
|
|
329
|
+
id="eye-slash"
|
|
330
|
+
show="#eye, #demo-preview"
|
|
331
|
+
hide="#eye-slash"
|
|
332
|
+
toggle="code-height"
|
|
333
|
+
toggle-selector="#demo-code"
|
|
334
|
+
><i
|
|
335
|
+
class="height:20px fill:#505050"
|
|
336
|
+
src="/assets/svg/eye-slash.svg"></i
|
|
337
|
+
></a>
|
|
338
|
+
<a
|
|
339
|
+
class="margin-right:10px"
|
|
340
|
+
id="code"
|
|
341
|
+
show="#code-slash"
|
|
342
|
+
hide="#code, #demo-code"
|
|
343
|
+
><i
|
|
344
|
+
class="height:20px fill:#505050"
|
|
345
|
+
src="/assets/svg/code.svg"></i
|
|
346
|
+
></a>
|
|
347
|
+
<a
|
|
348
|
+
class="margin-right:10px"
|
|
349
|
+
hidden
|
|
350
|
+
id="code-slash"
|
|
351
|
+
show="#code, #demo-code"
|
|
352
|
+
hide="#code-slash"
|
|
353
|
+
><i
|
|
354
|
+
class="display:flex height:18px fill:#505050"
|
|
355
|
+
src="/assets/svg/code.svg"></i
|
|
356
|
+
></a>
|
|
357
|
+
<a
|
|
358
|
+
class="margin-right:5px"
|
|
359
|
+
fullscreen
|
|
360
|
+
fullscreen-selector="#playground"></a>
|
|
361
|
+
</div>
|
|
362
|
+
</div>
|
|
363
|
+
<!-- End SandBox -->
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
</div>
|
|
367
|
+
<button
|
|
368
|
+
href="https://github.com/CoCreate-app/CoCreate-notification/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
|
|
369
|
+
target="_blank"
|
|
370
|
+
class="position:fixed bottom:15px right:15px padding:15px background:dodgerblue color:#fff font-size:1.5rem grow-hover border-radius:50% border-width:0 box-shadow:0px_2px_10px_0px_rgba(0,_0,_0,_0.4)">
|
|
371
|
+
<i
|
|
372
|
+
class="height:20px fill:#505050"
|
|
373
|
+
src="/assets/svg/pencil-alt.svg"></i>
|
|
374
|
+
</button>
|
|
375
|
+
</main>
|
|
376
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
377
|
+
</body>
|
|
378
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cocreate/notification",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Simple HTML5 & JavaScript component add, update & remove values in element's notification from input, select or js api. Easily configured using HTML5 notification and/or JavaScript API.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cocreate",
|
|
7
|
+
"no-code-framework",
|
|
8
|
+
"cocreatejs",
|
|
9
|
+
"cocreatejs-component",
|
|
10
|
+
"cocreate-framework",
|
|
11
|
+
"no-code",
|
|
12
|
+
"low-code",
|
|
13
|
+
"collaborative-framework",
|
|
14
|
+
"realtime",
|
|
15
|
+
"realtime-framework",
|
|
16
|
+
"collaboration",
|
|
17
|
+
"shared-editing",
|
|
18
|
+
"html5-framework",
|
|
19
|
+
"javascript-framework"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"start": "npx webpack --config webpack.config.js",
|
|
26
|
+
"build": "npx webpack --mode=production --config webpack.config.js",
|
|
27
|
+
"dev": "npx webpack --config webpack.config.js --watch",
|
|
28
|
+
"postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/CoCreate-app/CoCreate-notification.git"
|
|
33
|
+
},
|
|
34
|
+
"author": "CoCreate LLC",
|
|
35
|
+
"license": "AGPL-3.0",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/CoCreate-app/CoCreate-notification/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://cocreate.app/docs/notification",
|
|
40
|
+
"funding": {
|
|
41
|
+
"type": "GitHub Sponsors ❤",
|
|
42
|
+
"url": "https://github.com/sponsors/CoCreate-app"
|
|
43
|
+
},
|
|
44
|
+
"main": "./src/index.js",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@babel/core": "^7.9.6",
|
|
47
|
+
"@babel/preset-env": "^7.9.6",
|
|
48
|
+
"babel-loader": "^8.1.0",
|
|
49
|
+
"clean-webpack-plugin": "^3.0.0",
|
|
50
|
+
"file-loader": "^6.2.0",
|
|
51
|
+
"html-webpack-plugin": "^5.3.1",
|
|
52
|
+
"mini-css-extract-plugin": "^1.4.0",
|
|
53
|
+
"style-loader": "^3.3.1",
|
|
54
|
+
"terser-webpack-plugin": "^5.1.1",
|
|
55
|
+
"webpack": "^5.24.4",
|
|
56
|
+
"webpack-cli": "^4.5.0",
|
|
57
|
+
"webpack-log": "^3.0.1"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@cocreate/actions": "^1.11.2",
|
|
61
|
+
"@cocreate/socket-client": "^1.28.0"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dryRun: false,
|
|
3
|
+
branches: ["master"],
|
|
4
|
+
plugins: [
|
|
5
|
+
"@semantic-release/commit-analyzer",
|
|
6
|
+
"@semantic-release/release-notes-generator",
|
|
7
|
+
[
|
|
8
|
+
"@semantic-release/changelog",
|
|
9
|
+
{
|
|
10
|
+
changelogFile: "CHANGELOG.md",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
"@semantic-release/npm",
|
|
14
|
+
"@semantic-release/github",
|
|
15
|
+
[
|
|
16
|
+
"@semantic-release/git",
|
|
17
|
+
{
|
|
18
|
+
assets: ["CHANGELOG.md", "package.json"],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
],
|
|
22
|
+
};
|
package/src/client.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import socket from '@cocreate/socket-client'
|
|
2
|
+
// import actions from '@cocreate/actions'
|
|
3
|
+
|
|
4
|
+
// Request push notification permission
|
|
5
|
+
const permission = await Notification.requestPermission();
|
|
6
|
+
if (permission === 'granted') {
|
|
7
|
+
// User granted push notification permission, handle it here
|
|
8
|
+
subscribeToPushNotifications();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
async function handlePushPermission() {
|
|
13
|
+
// Request push notification permission
|
|
14
|
+
const permission = await Notification.requestPermission();
|
|
15
|
+
|
|
16
|
+
if (permission === 'granted') {
|
|
17
|
+
// Permission granted, create or update the subscription
|
|
18
|
+
const registration = await navigator.serviceWorker.ready;
|
|
19
|
+
try {
|
|
20
|
+
// Create a new subscription or retrieve the existing one
|
|
21
|
+
const existingSubscription = await registration.pushManager.getSubscription();
|
|
22
|
+
|
|
23
|
+
if (existingSubscription) {
|
|
24
|
+
// Update the existing subscription if needed
|
|
25
|
+
// This might involve generating a new public key or other changes
|
|
26
|
+
// For this example, we'll assume no updates are needed
|
|
27
|
+
console.log('Subscription already exists:', existingSubscription);
|
|
28
|
+
} else {
|
|
29
|
+
//TODO: getPublicKey
|
|
30
|
+
let response = await socket.send({
|
|
31
|
+
method: 'notification.publicKey',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
if (!response.publicKey)
|
|
35
|
+
return
|
|
36
|
+
|
|
37
|
+
// Create a new subscription
|
|
38
|
+
const newSubscription = await registration.pushManager.subscribe({
|
|
39
|
+
userVisibleOnly: true,
|
|
40
|
+
applicationServerKey: response.publicKey,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await socket.send({
|
|
44
|
+
method: 'notification.subscription',
|
|
45
|
+
subscription: newSubscription
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
console.log('New subscription created:', newSubscription);
|
|
49
|
+
|
|
50
|
+
navigator.serviceWorker.addEventListener('pushsubscriptionchange', (event) => {
|
|
51
|
+
// Handle the subscription change here
|
|
52
|
+
const newSubscription = event.newSubscription;
|
|
53
|
+
const oldSubscription = event.oldSubscription;
|
|
54
|
+
|
|
55
|
+
socket.send({
|
|
56
|
+
method: 'notification.subscription',
|
|
57
|
+
subscription: newSubscription
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Error handling push subscription:', error);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
// Permission denied, handle accordingly
|
|
68
|
+
console.warn('Push notification permission denied.');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Call the function when the user interacts with a relevant UI element (e.g., a button)
|
|
73
|
+
document.querySelector('[actions*="notification.subscribe"]').addEventListener('click', handlePushPermission);
|
|
74
|
+
|
|
75
|
+
// actions.init({
|
|
76
|
+
// name: "notification",
|
|
77
|
+
// endEvent: "notification",
|
|
78
|
+
// callback: (action) => handlePushPermission
|
|
79
|
+
// });
|