Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ typings/
.next

# Omit compiled files
build/
build/

.idea
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"scripts": {
"babel": "babel src/Ubidots.js -o build/ubidots-html-canvas.js",
"build": "webpack",
"dev": "webpack --watch --mode=development",
"serve": "webpack serve --mode=development --open",
"unit:all": "mocha --require @babel/register -r jsdom-global/register --recursive './tests/*.js'",
"unit": "mocha --require @babel/register -r jsdom-global/register ",
"format": "prettier --config .prettierrc --write src/**/*",
Expand Down Expand Up @@ -33,7 +35,8 @@
"prettier": "3.0.3",
"sinon": "16.0.0",
"webpack": "5.88.2",
"webpack-cli": "5.1.4"
"webpack-cli": "5.1.4",
"webpack-dev-server": "^4.15.2"
},
"dependencies": {
"@ubidots/ubidots-javascript-library": "^1.1.1"
Expand Down
78 changes: 78 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ubidots HTML Canvas Dev Server</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
line-height: 1.6;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 5px;
}
h1 {
color: #333;
}
pre {
background-color: #f5f5f5;
padding: 10px;
border-radius: 5px;
overflow: auto;
}
.example {
margin-top: 20px;
padding: 15px;
background-color: #f9f9f9;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container">
<h1>Ubidots HTML Canvas Development Server</h1>
<p>This is a development server for the Ubidots HTML Canvas library. You can use this to test your widgets during development.</p>

<h2>How to Use</h2>
<p>Include the library in your HTML:</p>
<pre>&lt;script src="http://localhost:9000/ubidots-html-canvas.js"&gt;&lt;/script&gt;</pre>

<div class="example">
<h3>Example Widget</h3>
<div id="widget-container"></div>
<script>
// This will be populated when the library is loaded
document.addEventListener('DOMContentLoaded', () => {
const container = document.getElementById('widget-container');
container.innerHTML = '<p>Library loaded successfully!</p>';

// Check if Ubidots is available
if (typeof Ubidots !== 'undefined') {
container.innerHTML += '<p>Ubidots class is available.</p>';

try {
// Create an instance
const ubidots = new Ubidots();
container.innerHTML += '<p>Ubidots instance created successfully.</p>';
} catch (error) {
container.innerHTML += `<p>Error creating Ubidots instance: ${error.message}</p>`;
}
} else {
container.innerHTML += '<p>Ubidots class is not available. Make sure the library is loaded correctly.</p>';
}
});
</script>
</div>
</div>

<!-- Load the library -->
<script src="/ubidots-html-canvas.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,27 @@ module.exports = {
colors: true,
},
devtool: "source-map",
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 300,
poll: 1000,
},
devServer: {
static: [
{
directory: path.join(__dirname, 'build'),
},
{
directory: path.join(__dirname, 'public'),
}
],
compress: true,
port: 9100,
hot: true,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
},
},
};
Loading