@cocreate/usage 1.2.0 → 1.3.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/workflows/automated.yml +25 -38
- package/CHANGELOG.md +27 -0
- package/docs/index.html +206 -206
- package/package.json +3 -11
- package/release.config.js +12 -4
- package/src/index.js +226 -190
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
name: Automated Workflow
|
|
2
|
+
|
|
2
3
|
on:
|
|
3
4
|
push:
|
|
4
5
|
branches:
|
|
5
6
|
- master
|
|
7
|
+
|
|
6
8
|
jobs:
|
|
7
9
|
about:
|
|
8
10
|
runs-on: ubuntu-latest
|
|
@@ -18,52 +20,37 @@ jobs:
|
|
|
18
20
|
with:
|
|
19
21
|
direction: overwrite-github
|
|
20
22
|
githubToken: "${{ secrets.GITHUB }}"
|
|
23
|
+
|
|
21
24
|
release:
|
|
22
25
|
runs-on: ubuntu-latest
|
|
23
26
|
steps:
|
|
24
27
|
- name: Checkout
|
|
25
|
-
uses: actions/checkout@
|
|
26
|
-
- name: Setup Node.js
|
|
27
|
-
uses: actions/setup-node@v3
|
|
28
|
+
uses: actions/checkout@v4
|
|
28
29
|
with:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
fetch-depth: 0 # Required so semantic-release can trace git tags/history
|
|
31
|
+
|
|
32
|
+
- name: Setup Node.js
|
|
33
|
+
uses: actions/setup-node@v4
|
|
33
34
|
with:
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
node-version: 22
|
|
36
|
+
|
|
37
|
+
- name: Install Semantic Release & Plugins
|
|
38
|
+
# Installs semantic-release and its plugins on the runner
|
|
39
|
+
run: |
|
|
40
|
+
npm install -g semantic-release \
|
|
41
|
+
@semantic-release/changelog \
|
|
42
|
+
@semantic-release/npm \
|
|
43
|
+
@semantic-release/github \
|
|
36
44
|
@semantic-release/git
|
|
37
|
-
|
|
45
|
+
|
|
46
|
+
- name: Run Semantic Release (Native)
|
|
47
|
+
id: semantic
|
|
48
|
+
# This will automatically pick up your export default config file in the repository root
|
|
49
|
+
run: npx semantic-release
|
|
38
50
|
env:
|
|
39
|
-
GITHUB_TOKEN: "${{ secrets.
|
|
51
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
40
52
|
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
53
|
+
|
|
41
54
|
outputs:
|
|
42
55
|
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
|
43
|
-
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
|
44
|
-
upload:
|
|
45
|
-
runs-on: ubuntu-latest
|
|
46
|
-
needs: release
|
|
47
|
-
if: needs.release.outputs.new_release_published == 'true'
|
|
48
|
-
env:
|
|
49
|
-
VERSION: "${{ needs.release.outputs.new_release_version }}"
|
|
50
|
-
steps:
|
|
51
|
-
- name: Checkout
|
|
52
|
-
uses: actions/checkout@v3
|
|
53
|
-
- name: Setup Node.js
|
|
54
|
-
uses: actions/setup-node@v3
|
|
55
|
-
with:
|
|
56
|
-
node-version: 16
|
|
57
|
-
- name: Set npm registry auth
|
|
58
|
-
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
|
|
59
|
-
- name: Install dependencies
|
|
60
|
-
run: yarn install
|
|
61
|
-
|
|
62
|
-
- name: Set Environment Variables
|
|
63
|
-
run: |
|
|
64
|
-
echo "organization_id=${{ secrets.COCREATE_ORGANIZATION_ID }}" >> $GITHUB_ENV
|
|
65
|
-
echo "key=${{ secrets.COCREATE_KEY }}" >> $GITHUB_ENV
|
|
66
|
-
echo "host=${{ secrets.COCREATE_HOST }}" >> $GITHUB_ENV
|
|
67
|
-
- name: CoCreate Upload
|
|
68
|
-
run: coc upload
|
|
69
|
-
|
|
56
|
+
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
# [1.3.0](https://github.com/CoCreate-app/CoCreate-usage/compare/v1.2.2...v1.3.0) (2026-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update automated workflow and release configuration for improved semantic release handling ([47aa8c2](https://github.com/CoCreate-app/CoCreate-usage/commit/47aa8c2941f8393a0ca55cbf6f66ae4df1172dea))
|
|
7
|
+
|
|
8
|
+
## [1.2.2](https://github.com/CoCreate-app/CoCreate-usage/compare/v1.2.1...v1.2.2) (2026-07-14)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove unnecessary console logs in init function for cleaner output ([af5f039](https://github.com/CoCreate-app/CoCreate-usage/commit/af5f03958fa5e84008411e99186bcdea438e7087))
|
|
14
|
+
* removed post install ([933f2b6](https://github.com/CoCreate-app/CoCreate-usage/commit/933f2b6b9a7a551afb7e2723bfd02de9a72f2019))
|
|
15
|
+
* semantic version handling. Reorganize .gitignore for improved clarity and structure ([9d67031](https://github.com/CoCreate-app/CoCreate-usage/commit/9d67031f6144a5b767ff0a2b6d487b14cbbd33aa))
|
|
16
|
+
* update module export to ES6 syntax in release.config.js ([8908cb7](https://github.com/CoCreate-app/CoCreate-usage/commit/8908cb7ea61ceb65d1151909e8706c0a54046903))
|
|
17
|
+
* update organization ID reference and host variable in sendUsageUpdate function ([4f4cc11](https://github.com/CoCreate-app/CoCreate-usage/commit/4f4cc11f9d0757b27c71f180ce83895fb2c436cd))
|
|
18
|
+
* update package.json to use ESM and restructure entry points ([c96c5db](https://github.com/CoCreate-app/CoCreate-usage/commit/c96c5db22a621d2af2a151d2173ffaa265c03f6e))
|
|
19
|
+
|
|
20
|
+
## [1.2.1](https://github.com/CoCreate-app/CoCreate-usage/compare/v1.2.0...v1.2.1) (2025-05-01)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* update [@cocreate](https://github.com/cocreate) dependencies ([945ecb8](https://github.com/CoCreate-app/CoCreate-usage/commit/945ecb85f25dd67a7390f6c68c07721e21e401d5))
|
|
26
|
+
* updated render selector to render-query ([33a8814](https://github.com/CoCreate-app/CoCreate-usage/commit/33a8814e3b724ef87541410df800825bf22fb178))
|
|
27
|
+
|
|
1
28
|
# [1.2.0](https://github.com/CoCreate-app/CoCreate-usage/compare/v1.1.3...v1.2.0) (2024-11-04)
|
|
2
29
|
|
|
3
30
|
|
package/docs/index.html
CHANGED
|
@@ -1,217 +1,217 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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-usage 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
|
+
name="description"
|
|
15
|
+
content="A simple HTML5 and pure javascript component. Easy configuration using data-attributes and highly styleable." />
|
|
16
|
+
<meta
|
|
17
|
+
name="keywords"
|
|
18
|
+
content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
19
|
+
<meta name="robots" content="index,follow" />
|
|
20
|
+
</head>
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
22
|
+
<body>
|
|
23
|
+
<div array="" object="" key="" id="cocreate-usage">
|
|
24
|
+
<div
|
|
25
|
+
class="display:flex flex-wrap:wrap justify-content:space-between margin:10px">
|
|
26
|
+
<div class="display:flex align-items:center">
|
|
27
|
+
<h2>CoCreate-usage</h2>
|
|
28
|
+
</div>
|
|
29
|
+
<div
|
|
30
|
+
class="display:flex align-items:center font-size:20px"
|
|
31
|
+
share-height="600"
|
|
32
|
+
share-width="500"
|
|
33
|
+
share-media="https://via.placeholder.com/300/09f/fff.png">
|
|
34
|
+
<a
|
|
35
|
+
href="https://github.com/CoCreate-app/CoCreate-usage"
|
|
36
|
+
target="_blank"
|
|
37
|
+
class="margin-right:15px"
|
|
38
|
+
><i class="fab fa-github"></i
|
|
39
|
+
></a>
|
|
40
|
+
<a
|
|
41
|
+
class="margin-right:15px share"
|
|
42
|
+
share-network="twitter"
|
|
43
|
+
title="Share on twitter"
|
|
44
|
+
><i class="fab fa-twitter"></i
|
|
45
|
+
></a>
|
|
46
|
+
<a
|
|
47
|
+
class="margin-right:15px share"
|
|
48
|
+
share-network="facebook"
|
|
49
|
+
title="Share on Facebook"
|
|
50
|
+
><i class="fab fa-facebook"></i
|
|
51
|
+
></a>
|
|
52
|
+
<a
|
|
53
|
+
class="margin-right:15px share"
|
|
54
|
+
share-network="instagram"
|
|
55
|
+
title="Share on instagram"
|
|
56
|
+
><i class="fab fa-instagram"></i
|
|
57
|
+
></a>
|
|
58
|
+
<a
|
|
59
|
+
class="margin-right:15px share"
|
|
60
|
+
share-network="share"
|
|
61
|
+
title="Share on share"
|
|
62
|
+
><i class="fas fa-share-alt"></i
|
|
63
|
+
></a>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
<h1 class="max-width:500px margin:20px_10px">
|
|
67
|
+
A simple HTML5, CSS and pure javascript component. Easy
|
|
68
|
+
configuration using data-attributes and highly styleable.
|
|
69
|
+
</h1>
|
|
70
|
+
<div id="usage-section" class="display:flex flex-wrap:wrap">
|
|
71
|
+
<div
|
|
72
|
+
class="flex-grow:1 min-width:300px width:50% padding:20px_10px">
|
|
73
|
+
<h2
|
|
74
|
+
class="border-bottom:1px_solid_lightgrey padding:5px_0px">
|
|
75
|
+
Install
|
|
76
|
+
</h2>
|
|
77
|
+
<pre
|
|
78
|
+
class="margin-top:15px"><code class="language-javascript">npm install cocreate-usage</code></pre>
|
|
79
|
+
<p class="padding:10px_0px">Or you can use cdn link:</p>
|
|
80
|
+
<pre><code class="language-javascript">https://cdn.cocreate.app/js/CoCreate-usage.min.js</code></pre>
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
<h2
|
|
83
|
+
class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
|
|
84
|
+
Usage
|
|
85
|
+
</h2>
|
|
86
|
+
<p class="padding:10px_0px">usage usage content</p>
|
|
87
|
+
<pre><code class="language-html"><div></div></code></pre>
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
<h2
|
|
90
|
+
class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
|
|
91
|
+
Reference
|
|
92
|
+
</h2>
|
|
93
|
+
<p class="padding:10px_0px">
|
|
94
|
+
This is usage reference content
|
|
95
|
+
</p>
|
|
96
|
+
<pre><code class="language-javascript"><div></div></code></pre>
|
|
97
|
+
<p class="padding:10px_0px">
|
|
98
|
+
This is usage reference content
|
|
99
|
+
</p>
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
101
|
+
<h2
|
|
102
|
+
class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
|
|
103
|
+
Attributes
|
|
104
|
+
</h2>
|
|
105
|
+
<ul class="list-style-type:none">
|
|
106
|
+
<li
|
|
107
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
108
|
+
<h4>
|
|
109
|
+
<span>usage</span>
|
|
110
|
+
<span class="cocreate-badge success"
|
|
111
|
+
>string</span
|
|
112
|
+
>
|
|
113
|
+
<span class="cocreate-badge warning"
|
|
114
|
+
>optional</span
|
|
115
|
+
>
|
|
116
|
+
</h4>
|
|
117
|
+
<p>usage-attribute</p>
|
|
118
|
+
</li>
|
|
119
|
+
<li
|
|
120
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
121
|
+
<h4>
|
|
122
|
+
<span>usage</span>
|
|
123
|
+
<span class="cocreate-badge success"
|
|
124
|
+
>string</span
|
|
125
|
+
>
|
|
126
|
+
<span class="cocreate-badge warning"
|
|
127
|
+
>optional</span
|
|
128
|
+
>
|
|
129
|
+
</h4>
|
|
130
|
+
<p>usage-attribute</p>
|
|
131
|
+
</li>
|
|
132
|
+
</ul>
|
|
133
|
+
</div>
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
135
|
+
<div
|
|
136
|
+
class="flex-grow:1 min-width:300px width:50% padding:0px_10px margin:20px_0px border-bottom:1px_solid_lightgrey">
|
|
137
|
+
<!-- SandBox -->
|
|
138
|
+
<div
|
|
139
|
+
class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
|
|
140
|
+
id="playground">
|
|
141
|
+
<div
|
|
142
|
+
id="demo-code"
|
|
143
|
+
resizable
|
|
144
|
+
class="position:relative height:50%">
|
|
145
|
+
<textarea
|
|
146
|
+
type="code"
|
|
147
|
+
lang="html"
|
|
148
|
+
array="demos"
|
|
149
|
+
object=""
|
|
150
|
+
key="demo"
|
|
151
|
+
save="false"
|
|
152
|
+
id="demo"
|
|
153
|
+
class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
154
|
+
<div
|
|
155
|
+
resize="bottom"
|
|
156
|
+
class="background:lightgrey"></div>
|
|
157
|
+
</div>
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
<div
|
|
160
|
+
id="demo-preview"
|
|
161
|
+
class="position:relative overflow:auto background-color:white">
|
|
162
|
+
<div get-value="#demo" class="padding:20px"></div>
|
|
163
|
+
</div>
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
165
|
+
<div
|
|
166
|
+
class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
167
|
+
<a
|
|
168
|
+
class="margin-right:10px"
|
|
169
|
+
id="eye"
|
|
170
|
+
show="#eye-slash"
|
|
171
|
+
hide="#eye, #demo-preview"
|
|
172
|
+
toggle="code-height"
|
|
173
|
+
toggle-query="#demo-code"
|
|
174
|
+
><i class="far fa-eye"></i
|
|
175
|
+
></a>
|
|
176
|
+
<a
|
|
177
|
+
class="margin-right:10px"
|
|
178
|
+
hidden
|
|
179
|
+
id="eye-slash"
|
|
180
|
+
show="#eye, #demo-preview"
|
|
181
|
+
hide="#eye-slash"
|
|
182
|
+
toggle="code-height"
|
|
183
|
+
toggle-query="#demo-code"
|
|
184
|
+
><i class="fas fa-eye-slash"></i
|
|
185
|
+
></a>
|
|
186
|
+
<a
|
|
187
|
+
class="margin-right:10px"
|
|
188
|
+
id="code"
|
|
189
|
+
show="#code-slash"
|
|
190
|
+
hide="#code, #demo-code"
|
|
191
|
+
><i class="fa fa-code"></i
|
|
192
|
+
></a>
|
|
193
|
+
<a
|
|
194
|
+
class="margin-right:10px"
|
|
195
|
+
hidden
|
|
196
|
+
id="code-slash"
|
|
197
|
+
show="#code, #demo-code"
|
|
198
|
+
hide="#code-slash"
|
|
199
|
+
><i class="fas fa-code"></i
|
|
200
|
+
></a>
|
|
201
|
+
<a
|
|
202
|
+
class="margin-right:5px"
|
|
203
|
+
fullscreen
|
|
204
|
+
target="#playground"
|
|
205
|
+
><i class="fas fa-expand"></i
|
|
206
|
+
></a>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
<!-- End SandBox -->
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
<!--CoCreateJS-->
|
|
215
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
216
|
+
</body>
|
|
217
217
|
</html>
|
package/package.json
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/usage",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "CoCreate-usage",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cocreate-usage",
|
|
7
|
-
"cocreate",
|
|
8
|
-
"low-code-framework",
|
|
9
|
-
"no-code-framework",
|
|
10
|
-
"cocreatejs",
|
|
11
|
-
"cocreatejs-component",
|
|
12
|
-
"cocreate-framework",
|
|
13
|
-
"no-code",
|
|
14
7
|
"low-code",
|
|
15
|
-
"collaborative-framework",
|
|
16
8
|
"realtime",
|
|
17
9
|
"realtime-framework",
|
|
18
10
|
"collaboration",
|
|
@@ -20,6 +12,7 @@
|
|
|
20
12
|
"html5-framework",
|
|
21
13
|
"javascript-framework"
|
|
22
14
|
],
|
|
15
|
+
"type": "module",
|
|
23
16
|
"main": "./src/index.js",
|
|
24
17
|
"publishConfig": {
|
|
25
18
|
"access": "public"
|
|
@@ -36,7 +29,6 @@
|
|
|
36
29
|
"homepage": "https://cocreate.app/docs/CoCreate-usage",
|
|
37
30
|
"scripts": {
|
|
38
31
|
"demo": "PORT=5000 node demo/server.js",
|
|
39
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
40
|
-
"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); } }\""
|
|
32
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
41
33
|
}
|
|
42
34
|
}
|
package/release.config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
dryRun: false,
|
|
3
3
|
branches: ["master"],
|
|
4
4
|
plugins: [
|
|
@@ -10,12 +10,20 @@ module.exports = {
|
|
|
10
10
|
changelogFile: "CHANGELOG.md",
|
|
11
11
|
},
|
|
12
12
|
],
|
|
13
|
-
"@semantic-release/npm",
|
|
14
|
-
"@semantic-release/github",
|
|
13
|
+
"@semantic-release/npm",
|
|
15
14
|
[
|
|
16
|
-
"@semantic-release/
|
|
15
|
+
"@semantic-release/github",
|
|
17
16
|
{
|
|
17
|
+
successComment: false,
|
|
18
|
+
failTitle: false,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
"@semantic-release/git",
|
|
23
|
+
{
|
|
24
|
+
// Only stage and commit the changelog and package.json
|
|
18
25
|
assets: ["CHANGELOG.md", "package.json"],
|
|
26
|
+
message: "chore(release): ${nextRelease.version} [skip ci]",
|
|
19
27
|
},
|
|
20
28
|
],
|
|
21
29
|
],
|
package/src/index.js
CHANGED
|
@@ -1,208 +1,244 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2023 CoCreate and Contributors.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
6
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
********************************************************************************/
|
|
18
|
+
|
|
19
|
+
// Commercial Licensing Information:
|
|
20
|
+
// For commercial use of this software without the copyleft provisions of the AGPLv3,
|
|
21
|
+
// you must obtain a commercial license from CoCreate LLC.
|
|
22
|
+
// For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
|
|
23
|
+
|
|
24
|
+
import server from '@cocreate/server';
|
|
25
|
+
|
|
26
|
+
// ==========================================
|
|
27
|
+
// Module-Level Sandbox State (ESM Singleton Container)
|
|
28
|
+
// ==========================================
|
|
29
|
+
const organizations = new Map();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Normalizes input data types and calculates payload sizing in bytes.
|
|
33
|
+
*/
|
|
34
|
+
function getBytes(data) {
|
|
35
|
+
if (typeof data === 'number')
|
|
36
|
+
return data;
|
|
37
|
+
else if (data instanceof Buffer)
|
|
38
|
+
return data.byteLength || 0;
|
|
39
|
+
else if (data instanceof String || typeof data === 'string')
|
|
40
|
+
return Buffer.byteLength(data, 'utf8') || 0;
|
|
41
|
+
else if (typeof data === 'object' && data !== null)
|
|
42
|
+
return Buffer.byteLength(JSON.stringify(data), 'utf8') || 0;
|
|
43
|
+
else return 0;
|
|
44
|
+
}
|
|
14
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Determines pricing tier rates based on aggregate historical usage indicators.
|
|
48
|
+
*/
|
|
49
|
+
function getRate(totalUsage = 0) {
|
|
50
|
+
const tiers = [
|
|
51
|
+
{ limit: 1, rate: 10 },
|
|
52
|
+
{ limit: 10, rate: 5 },
|
|
53
|
+
{ limit: 100, rate: 2.5 },
|
|
54
|
+
{ limit: 1000, rate: 1.125 },
|
|
55
|
+
{ limit: 10000, rate: 0.562 },
|
|
56
|
+
{ limit: 100000, rate: 0.281 },
|
|
57
|
+
{ limit: 1000000, rate: 0.145 }
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
const matchingTier = tiers.find(tier => totalUsage < tier.limit);
|
|
61
|
+
return matchingTier ? matchingTier.rate : 0.12;
|
|
62
|
+
}
|
|
15
63
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
console.log('Usage error', error)
|
|
64
|
+
/**
|
|
65
|
+
* Calculates and writes final bandwidth depletion transactions to the platform database.
|
|
66
|
+
*/
|
|
67
|
+
async function sendUsageUpdate(org, organization_id, host) {
|
|
68
|
+
if (!server || !server.crud) return;
|
|
69
|
+
delete org.debounce;
|
|
70
|
+
|
|
71
|
+
org.dataTransferedOut += 250;
|
|
72
|
+
org.dataTransferedOutCount++;
|
|
73
|
+
|
|
74
|
+
const platformOrganization = server.organization_id;
|
|
75
|
+
let organization = await server.crud.send({
|
|
76
|
+
method: 'object.read',
|
|
77
|
+
// host: server.host,
|
|
78
|
+
array: 'organizations',
|
|
79
|
+
object: { _id: organization_id },
|
|
80
|
+
organization_id: platformOrganization
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
org.dataTransferedIn += getBytes(platformOrganization);
|
|
84
|
+
org.dataTransferedInCount++;
|
|
85
|
+
|
|
86
|
+
if (organization && organization.object && organization.object[0]) {
|
|
87
|
+
organization = organization.object[0];
|
|
88
|
+
} else return;
|
|
89
|
+
|
|
90
|
+
if (server.wsManager && server.wsManager.organizations.has(organization_id)) {
|
|
91
|
+
const socketOrg = server.wsManager.organizations.get(organization_id);
|
|
92
|
+
if (organization.balance <= 0) {
|
|
93
|
+
socketOrg.status = false;
|
|
94
|
+
socketOrg.organizationBalance = false;
|
|
95
|
+
socketOrg.error = 'Your balance has fallen below 0';
|
|
96
|
+
} else {
|
|
97
|
+
socketOrg.status = true;
|
|
98
|
+
socketOrg.organizationBalance = true;
|
|
99
|
+
socketOrg.error = '';
|
|
53
100
|
}
|
|
54
101
|
}
|
|
55
102
|
|
|
103
|
+
let timeStamp = new Date(new Date().toISOString());
|
|
104
|
+
let isExpired = false;
|
|
105
|
+
if (organization.lastDeposit) {
|
|
106
|
+
let lastDeposit = new Date(organization.lastDeposit);
|
|
107
|
+
isExpired = lastDeposit <= timeStamp.setFullYear(timeStamp.getFullYear() - 1);
|
|
108
|
+
}
|
|
56
109
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
organization = organization.object[0]
|
|
77
|
-
} else return
|
|
78
|
-
|
|
79
|
-
//TODO: if (organization.transactionInterval) // set in global map to use with timeout 1 sec intervals to 3600 sec
|
|
80
|
-
if (this.wsManager.organizations.has(organization_id)) {
|
|
81
|
-
if (organization.balance <= 0) {
|
|
82
|
-
this.wsManager.organizations.get(organization_id).status = false
|
|
83
|
-
this.wsManager.organizations.get(organization_id).organizationBalance = false
|
|
84
|
-
this.wsManager.organizations.get(organization_id).error = 'Your balance has fallen bellow 0'
|
|
85
|
-
|
|
86
|
-
} else {
|
|
87
|
-
this.wsManager.organizations.get(organization_id).status = true
|
|
88
|
-
this.wsManager.organizations.get(organization_id).organizationBalance = true
|
|
89
|
-
this.wsManager.organizations.get(organization_id).error = ''
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
let timeStamp = new Date(new Date().toISOString());
|
|
94
|
-
let isExpired = false
|
|
95
|
-
if (organization.lastDeposit) {
|
|
96
|
-
let lastDeposit = new Date(organization.lastDeposit)
|
|
97
|
-
isExpired = lastDeposit <= timeStamp.setFullYear(timeStamp.getFullYear() - 1)
|
|
110
|
+
let isResetDataTransfer = false;
|
|
111
|
+
if (organization.modified && organization.modified.on) {
|
|
112
|
+
let previousTimeStamp = new Date(organization.modified.on);
|
|
113
|
+
if (previousTimeStamp.getMonth() !== timeStamp.getMonth()) {
|
|
114
|
+
isResetDataTransfer = true;
|
|
115
|
+
server.crud.send({
|
|
116
|
+
method: 'object.create',
|
|
117
|
+
// host: server.host,
|
|
118
|
+
array: 'transactions',
|
|
119
|
+
object: {
|
|
120
|
+
organization_id,
|
|
121
|
+
type: "withdrawal",
|
|
122
|
+
dataTransfered: organization.dataTransfered,
|
|
123
|
+
previousTimeStamp
|
|
124
|
+
},
|
|
125
|
+
organization_id: platformOrganization,
|
|
126
|
+
timeStamp
|
|
127
|
+
});
|
|
128
|
+
organization.dataTransfered = 0;
|
|
98
129
|
}
|
|
130
|
+
}
|
|
99
131
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
132
|
+
let dataTransfered = org.dataTransferedIn + org.dataTransferedOut;
|
|
133
|
+
dataTransfered = dataTransfered / 1073741824;
|
|
134
|
+
dataTransfered = dataTransfered.toFixed(32);
|
|
135
|
+
dataTransfered = parseFloat(dataTransfered);
|
|
136
|
+
|
|
137
|
+
let rate = getRate(organization.dataTransfered);
|
|
138
|
+
let amount = dataTransfered * rate;
|
|
139
|
+
amount = -amount;
|
|
140
|
+
amount = amount.toFixed(32);
|
|
141
|
+
amount = parseFloat(amount);
|
|
142
|
+
|
|
143
|
+
let balanceUpdate = {
|
|
144
|
+
method: 'object.update',
|
|
145
|
+
// host: server.host,
|
|
146
|
+
array: 'organizations',
|
|
147
|
+
object: { _id: organization_id },
|
|
148
|
+
organization_id: platformOrganization,
|
|
149
|
+
timeStamp
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
if (isExpired)
|
|
153
|
+
balanceUpdate.object['balance'] = 0;
|
|
154
|
+
else
|
|
155
|
+
balanceUpdate.object.$inc = { balance: amount };
|
|
156
|
+
|
|
157
|
+
if (isResetDataTransfer)
|
|
158
|
+
balanceUpdate.object['dataTransfered'] = 0;
|
|
159
|
+
else if (!balanceUpdate.object.$inc)
|
|
160
|
+
balanceUpdate.object.$inc = { dataTransfered };
|
|
161
|
+
else
|
|
162
|
+
balanceUpdate.object.$inc.dataTransfered = dataTransfered;
|
|
163
|
+
|
|
164
|
+
server.crud.send(balanceUpdate);
|
|
165
|
+
|
|
166
|
+
let transaction = {
|
|
167
|
+
method: 'object.create',
|
|
168
|
+
host,
|
|
169
|
+
array: 'transactions',
|
|
170
|
+
object: {
|
|
171
|
+
organization_id,
|
|
172
|
+
type: "withdrawal",
|
|
173
|
+
amount,
|
|
174
|
+
rate,
|
|
175
|
+
dataTransfered,
|
|
176
|
+
...org
|
|
177
|
+
},
|
|
178
|
+
organization_id,
|
|
179
|
+
timeStamp
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
server.crud.send(transaction);
|
|
183
|
+
}
|
|
121
184
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
let
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Event-driven handler that accumulates payload footprints and manages write debouncing.
|
|
187
|
+
*/
|
|
188
|
+
async function setBandwidth({ type, data, organization_id }) {
|
|
189
|
+
try {
|
|
190
|
+
let dataTransfered = getBytes(data);
|
|
191
|
+
|
|
192
|
+
if (!dataTransfered || !organization_id)
|
|
193
|
+
return;
|
|
194
|
+
|
|
195
|
+
let org = organizations.get(organization_id);
|
|
196
|
+
if (!org) {
|
|
197
|
+
org = {};
|
|
198
|
+
org.debounce = setTimeout(() => {
|
|
199
|
+
sendUsageUpdate(org, organization_id, data.host);
|
|
200
|
+
organizations.delete(organization_id);
|
|
201
|
+
}, 60000);
|
|
202
|
+
|
|
203
|
+
org.dataTransferedIn = 0;
|
|
204
|
+
org.dataTransferedInCount = 0;
|
|
205
|
+
org.dataTransferedOut = 0;
|
|
206
|
+
org.dataTransferedOutCount = 0;
|
|
207
|
+
|
|
208
|
+
organizations.set(organization_id, org);
|
|
140
209
|
}
|
|
141
210
|
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
balanceUpdate.object.$inc = { dataTransfered }
|
|
151
|
-
else
|
|
152
|
-
balanceUpdate.object.$inc.dataTransfered = dataTransfered
|
|
153
|
-
|
|
154
|
-
// console.log('balanceUpdate: ', balanceUpdate)
|
|
155
|
-
|
|
156
|
-
this.crud.send(balanceUpdate)
|
|
157
|
-
|
|
158
|
-
let transaction = {
|
|
159
|
-
method: 'object.create',
|
|
160
|
-
host,
|
|
161
|
-
array: 'transactions',
|
|
162
|
-
object: {
|
|
163
|
-
organization_id,
|
|
164
|
-
type: "withdrawal", // deposit, credit, withdrawal, debit
|
|
165
|
-
amount,
|
|
166
|
-
rate,
|
|
167
|
-
dataTransfered,
|
|
168
|
-
...org
|
|
169
|
-
},
|
|
170
|
-
organization_id,
|
|
171
|
-
timeStamp
|
|
211
|
+
if (type === 'in') {
|
|
212
|
+
org.dataTransferedIn = dataTransfered;
|
|
213
|
+
org.dataTransferedInCount++;
|
|
214
|
+
} else if (type === 'out') {
|
|
215
|
+
org.dataTransferedOut = dataTransfered;
|
|
216
|
+
org.dataTransferedOutCount++;
|
|
217
|
+
} else {
|
|
218
|
+
console.log('else');
|
|
172
219
|
}
|
|
173
220
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
getBytes(data) {
|
|
179
|
-
if (typeof data === 'number')
|
|
180
|
-
return data;
|
|
181
|
-
else if (data instanceof Buffer)
|
|
182
|
-
return data.byteLength || 0;
|
|
183
|
-
else if (data instanceof String || typeof data === 'string')
|
|
184
|
-
return Buffer.byteLength(data, 'utf8') || 0;
|
|
185
|
-
else if (typeof data === 'object')
|
|
186
|
-
return Buffer.byteLength(JSON.stringify(data), 'utf8') || 0;
|
|
187
|
-
else return 0
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.log('Usage error', error);
|
|
188
223
|
}
|
|
224
|
+
}
|
|
189
225
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return matchingTier ? matchingTier.rate : 0.12;
|
|
226
|
+
/**
|
|
227
|
+
* Auto-initialization loop.
|
|
228
|
+
* Silently polls to verify that the unified server orchestrator is fully loaded,
|
|
229
|
+
* and that both the database (crud) and socket manager (wsManager) have completed
|
|
230
|
+
* their initial handshakes, then attaches active bandwidth monitoring triggers.
|
|
231
|
+
*/
|
|
232
|
+
function init() {
|
|
233
|
+
if (server && server.isInitialized && server.crud && server.wsManager) {
|
|
234
|
+
server.wsManager.on('setBandwidth', (data) => setBandwidth(data));
|
|
235
|
+
} else {
|
|
236
|
+
// If the server and WebSocket managers are not yet ready, retry in 500ms
|
|
237
|
+
setTimeout(init, 500);
|
|
204
238
|
}
|
|
205
|
-
|
|
206
239
|
}
|
|
207
240
|
|
|
208
|
-
module
|
|
241
|
+
// Auto-execute initialization upon module load
|
|
242
|
+
init();
|
|
243
|
+
|
|
244
|
+
export default init;
|