Skip to content

Commit

Permalink
add td-utils bundle to plugin resources
Browse files Browse the repository at this point in the history
Signed-off-by: Hasan Eroglu <[email protected]>
  • Loading branch information
hasanheroglu committed Jul 29, 2024
1 parent 2a80e97 commit 0a34468
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion node-red-node-wot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"build": "npm run copy:src2dist && tsc && npm run build:plugin",
"copy:src2dist": "node -e \"require('fs-extra').copySync('./src', './dist')\"",
"build:plugin": "npm run copy:plugin-resources-src2resources && tsc --project ./tsconfig-for-plugin.json",
"copy:plugin-resources-src2resources": "node -e \"require('fs-extra').copySync('./plugin-resources-src', './resources')\"",
"copy:plugin-resources-src2resources": "node -e \"require('fs-extra').copySync('./plugin-resources-src', './resources')\" && node -e \"require('fs-extra').copySync('./node_modules/@thingweb/td-utils/dist/web-bundle.min.js', './resources/@thingweb/td-utils/dist/web-bundle.min.js')\"",
"publish": "npm publish --access=public",
"publish:beta": "npm publish --access=public --tag=beta",
"test": "mocha --require ts-node/register --extension ts --exit"
Expand Down
6 changes: 3 additions & 3 deletions node-red-node-wot/plugin-resources-src/node-wot-plugin-lib.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { detectProtocolSchemes } from "@thingweb/td-utils/build";

const PROTOCOLS = ["http", "ws", "coap", "mqtt", "opcua", "modbus"]
const DATATYPES = {
string: {
Expand Down Expand Up @@ -316,6 +314,8 @@ function generateId() {
return bytes.join("")
}

const detectProtocolSchemes = (window as any).tdUtils?.detectProtocolSchemes;

function checkBinding(tdStr: string, binding: string) {
// In case of OPC UA we look for opc.tcp in href not opcua
binding = binding === "opcua" ? "opc.tcp" : binding
Expand All @@ -324,7 +324,7 @@ function checkBinding(tdStr: string, binding: string) {

const bindings = Object.keys(detectProtocolSchemes(tdStr))

return bindings.includes(binding)
return bindings.some(b => b === binding || b === binding + 's');
}

const THING_COMMON_TEMP = `[
Expand Down
1 change: 1 addition & 0 deletions node-red-node-wot/plugin/node-wot-plugin.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<script type="module" src="resources/@thingweb/node-red-node-wot/@thingweb/td-utils/dist/web-bundle.min.js"></script>
<script type="module" src="/resources/@thingweb/node-red-node-wot/node-wot-plugin-lib.js" ></script>
<script type="module">
import {createClientFlowUsingDashboard} from "/resources/@thingweb/node-red-node-wot/node-wot-plugin-lib.js"
Expand Down

0 comments on commit 0a34468

Please sign in to comment.