@cocreate/url-uploader 1.1.2 → 1.2.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 +18 -0
- package/package.json +3 -11
- package/release.config.js +12 -4
- package/src/index.js +88 -51
|
@@ -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,21 @@
|
|
|
1
|
+
# [1.2.0](https://github.com/CoCreate-app/CoCreate-url-uploader/compare/v1.1.3...v1.2.0) (2026-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update automated workflow and release configuration for improved semantic release handling ([cbba9cd](https://github.com/CoCreate-app/CoCreate-url-uploader/commit/cbba9cdfee2bd4a524308397d91c7da5e1a0947b))
|
|
7
|
+
|
|
8
|
+
## [1.1.3](https://github.com/CoCreate-app/CoCreate-url-uploader/compare/v1.1.2...v1.1.3) (2026-07-14)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove unnecessary console logs in init function for cleaner output ([816740d](https://github.com/CoCreate-app/CoCreate-url-uploader/commit/816740df97ea0582e1b55c4d8d1b29fa77770a2f))
|
|
14
|
+
* removed post install ([5a25d82](https://github.com/CoCreate-app/CoCreate-url-uploader/commit/5a25d8261d25aeb51cd32ccdb4301eaa0f1ac652))
|
|
15
|
+
* semantic version handling. Reorganize .gitignore for improved clarity and structure ([ba5c0de](https://github.com/CoCreate-app/CoCreate-url-uploader/commit/ba5c0de22dae1e670ab5c5862fac52111f160cc5))
|
|
16
|
+
* update .gitignore to include package-lock.json and pnpm-lock.yaml ([a677fea](https://github.com/CoCreate-app/CoCreate-url-uploader/commit/a677fea7b4e8236145c5a97e520b02b045ef999b))
|
|
17
|
+
* update module export to ES6 syntax in release.config.js ([99052d8](https://github.com/CoCreate-app/CoCreate-url-uploader/commit/99052d8b5a7c3233890c3850ecef28392ce5dc04))
|
|
18
|
+
|
|
1
19
|
## [1.1.2](https://github.com/CoCreate-app/CoCreate-url-uploader/compare/v1.1.1...v1.1.2) (2025-05-01)
|
|
2
20
|
|
|
3
21
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/url-uploader",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A simple url-uploader component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"url-uploader",
|
|
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",
|
|
@@ -26,8 +18,7 @@
|
|
|
26
18
|
"scripts": {
|
|
27
19
|
"start": "npx webpack --config webpack.config.js",
|
|
28
20
|
"build": "npx webpack --mode=production --config webpack.config.js",
|
|
29
|
-
"dev": "npx webpack --config webpack.config.js --watch"
|
|
30
|
-
"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); } }\""
|
|
21
|
+
"dev": "npx webpack --config webpack.config.js --watch"
|
|
31
22
|
},
|
|
32
23
|
"repository": {
|
|
33
24
|
"type": "git",
|
|
@@ -43,6 +34,7 @@
|
|
|
43
34
|
"type": "GitHub Sponsors ❤",
|
|
44
35
|
"url": "https://github.com/sponsors/CoCreate-app"
|
|
45
36
|
},
|
|
37
|
+
"type": "module",
|
|
46
38
|
"main": "./src/index.js",
|
|
47
39
|
"dependencies": {
|
|
48
40
|
"node-fetch": "^3.3.2"
|
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
|
@@ -20,65 +20,102 @@
|
|
|
20
20
|
// you must obtain a commercial license from CoCreate LLC.
|
|
21
21
|
// For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
import { URL } from "url";
|
|
24
|
+
import fetch from "node-fetch";
|
|
25
|
+
import server from "@cocreate/server";
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Converts a raw binary ArrayBuffer payload cleanly to a Base64 string.
|
|
29
|
+
* @param {ArrayBuffer} buffer - The downloaded file raw binary buffer
|
|
30
|
+
* @returns {string} Base64 formatted string
|
|
31
|
+
*/
|
|
32
|
+
function arrayBufferToBase64(buffer) {
|
|
33
|
+
let binary = "";
|
|
34
|
+
const bytes = new Uint8Array(buffer);
|
|
35
|
+
const len = bytes.byteLength;
|
|
36
|
+
for (let i = 0; i < len; i++) {
|
|
37
|
+
binary += String.fromCharCode(bytes[i]);
|
|
38
|
+
}
|
|
39
|
+
return Buffer.from(binary, "binary").toString("base64");
|
|
40
|
+
}
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Fetches the binary asset from a remote URL, updates the file parameters,
|
|
44
|
+
* converts the raw output to Base64, and sends the updated payload back to the client socket.
|
|
45
|
+
* @param {Object} data - Socket event payload
|
|
46
|
+
*/
|
|
47
|
+
async function fetchFileFromURL(data) {
|
|
48
|
+
try {
|
|
49
|
+
const file = data.file;
|
|
50
|
+
if (!file || !file.src) {
|
|
51
|
+
data.error = "Missing file object or file source URL.";
|
|
52
|
+
if (data.socket && server && server.wsManager) {
|
|
53
|
+
return server.wsManager.send(data);
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
40
57
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
58
|
+
// Store original URL before file.src gets overwritten with Base64 content
|
|
59
|
+
const originalUrl = file.src;
|
|
60
|
+
const response = await fetch(originalUrl);
|
|
45
61
|
|
|
46
|
-
|
|
47
|
-
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
data.error = "Failed to fetch file: " + response.statusText;
|
|
64
|
+
if (data.socket && server && server.wsManager) {
|
|
65
|
+
return server.wsManager.send(data);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
48
69
|
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
71
|
+
file.src = arrayBufferToBase64(arrayBuffer);
|
|
72
|
+
file.size = arrayBuffer.byteLength;
|
|
73
|
+
file["content-type"] = response.headers.get("content-type");
|
|
51
74
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
if (!file.name) {
|
|
76
|
+
const parsedUrl = new URL(originalUrl);
|
|
77
|
+
file.name = parsedUrl.pathname.split("/").pop() || "downloaded_file";
|
|
78
|
+
}
|
|
56
79
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
if (!file.directory) file.directory = "/";
|
|
81
|
+
if (!file.path) file.path = file.directory;
|
|
82
|
+
|
|
83
|
+
if (!file.pathname) {
|
|
84
|
+
if (file.path.endsWith("/")) {
|
|
85
|
+
file.pathname = file.path + file.name;
|
|
86
|
+
} else {
|
|
87
|
+
file.pathname = file.path + "/" + file.name;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
65
90
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
91
|
+
if (data.socket && server && server.wsManager) {
|
|
92
|
+
server.wsManager.send(data);
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error("Error fetching file:", error);
|
|
96
|
+
data.error = "Internal uploader error while retrieving resource.";
|
|
97
|
+
if (data.socket && server && server.wsManager) {
|
|
98
|
+
server.wsManager.send(data);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
72
102
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Auto-initialization loop.
|
|
105
|
+
* Silently polls to verify that the unified server orchestrator is fully loaded,
|
|
106
|
+
* and that the socket manager (wsManager) has completed its initial handshakes,
|
|
107
|
+
* then maps active URL importing event triggers.
|
|
108
|
+
*/
|
|
109
|
+
function init() {
|
|
110
|
+
if (server && server.isInitialized && server.wsManager) {
|
|
111
|
+
server.wsManager.on("importUrl", (data) => fetchFileFromURL(data));
|
|
112
|
+
} else {
|
|
113
|
+
// Retry in 500ms if the shared socket server instance has not yet mounted
|
|
114
|
+
setTimeout(init, 500);
|
|
115
|
+
}
|
|
82
116
|
}
|
|
83
117
|
|
|
84
|
-
module
|
|
118
|
+
// Auto-execute initialization upon module compilation
|
|
119
|
+
init();
|
|
120
|
+
|
|
121
|
+
export default init;
|