diff --git a/examples/quickstart/presence-sensor.js b/examples/quickstart/presence-sensor.js index 72670855f..0bd977216 100644 --- a/examples/quickstart/presence-sensor.js +++ b/examples/quickstart/presence-sensor.js @@ -13,6 +13,7 @@ * * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 ********************************************************************************/ +Object.defineProperty(exports, "__esModule", { value: true }); // This is an example Thing script which is a simple presence detector // It fires an event when it detects a person (mocked as every 5 second) const core_1 = require("@node-wot/core"); diff --git a/examples/quickstart/simple-coffee-machine.js b/examples/quickstart/simple-coffee-machine.js index 136e3ee1f..6d012a3d4 100644 --- a/examples/quickstart/simple-coffee-machine.js +++ b/examples/quickstart/simple-coffee-machine.js @@ -13,6 +13,7 @@ * * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 ********************************************************************************/ +Object.defineProperty(exports, "__esModule", { value: true }); // This is an example Thing script which is a simple coffee machine. // You can order coffee and see the status of the resources const core_1 = require("@node-wot/core"); diff --git a/examples/quickstart/smart-clock.js b/examples/quickstart/smart-clock.js index b235c4356..22f24617d 100644 --- a/examples/quickstart/smart-clock.js +++ b/examples/quickstart/smart-clock.js @@ -13,12 +13,13 @@ * * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 ********************************************************************************/ +Object.defineProperty(exports, "__esModule", { value: true }); // This is an example Thing which is a smart clock that runs 60 times faster than real time, where 1 hour happens in 1 minute. const core_1 = require("@node-wot/core"); const binding_coap_1 = require("@node-wot/binding-coap"); // create Servient add CoAP binding with port configuration const servient = new core_1.Servient(); -servient.addServer(new binding_coap_1.CoapServer(5686)); +servient.addServer(new binding_coap_1.CoapServer({ port: 5686 })); core_1.Helpers.setStaticAddress("plugfest.thingweb.io"); // comment this out if you are testing locally let minuteCounter = 0; let hourCounter = 0; diff --git a/examples/scripts/countdown.js b/examples/scripts/countdown.js index 3d99d1ee2..9aa8bb9ac 100644 --- a/examples/scripts/countdown.js +++ b/examples/scripts/countdown.js @@ -1,5 +1,6 @@ +"use strict"; /******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2021 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -12,7 +13,6 @@ * * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 ********************************************************************************/ - function uuidv4() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { const r = (Math.random() * 16) | 0; diff --git a/examples/scripts/counter-client.js b/examples/scripts/counter-client.js index 6b28dd5c9..6cd614d26 100644 --- a/examples/scripts/counter-client.js +++ b/examples/scripts/counter-client.js @@ -1,3 +1,4 @@ +"use strict"; /******************************************************************************** * Copyright (c) 2020 Contributors to the Eclipse Foundation * @@ -12,7 +13,6 @@ * * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 ********************************************************************************/ - function getFormIndexForDecrementWithCoAP(thing) { const forms = thing.getThingDescription().actions?.decrement.forms; if (forms !== undefined) { diff --git a/examples/scripts/counter.js b/examples/scripts/counter.js index 19939def7..21d873a80 100644 --- a/examples/scripts/counter.js +++ b/examples/scripts/counter.js @@ -1,5 +1,6 @@ +"use strict"; /******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2020 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -12,7 +13,6 @@ * * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 ********************************************************************************/ - // This is an example Thing script. // It has a count property that can be incremented or decremented via actions and its changes are reported via events. // It also has two properties that return an image. The SVG property is also influenced by the increment and decrement actions. diff --git a/examples/scripts/smart-coffee-machine-client.js b/examples/scripts/smart-coffee-machine-client.js index 9dd42c843..3539ca6b0 100644 --- a/examples/scripts/smart-coffee-machine-client.js +++ b/examples/scripts/smart-coffee-machine-client.js @@ -1,5 +1,6 @@ +"use strict"; /******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2020 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/examples/scripts/smart-coffee-machine.js b/examples/scripts/smart-coffee-machine.js index 6c89b9e15..50b37a968 100644 --- a/examples/scripts/smart-coffee-machine.js +++ b/examples/scripts/smart-coffee-machine.js @@ -1,5 +1,6 @@ +"use strict"; /******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2020 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/examples/security/oauth/consumer.js b/examples/security/oauth/consumer.js index 08e508fa3..1435a8a97 100644 --- a/examples/security/oauth/consumer.js +++ b/examples/security/oauth/consumer.js @@ -1,5 +1,6 @@ +"use strict"; /******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2018 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/examples/security/oauth/exposer.js b/examples/security/oauth/exposer.js index be99e211a..980858098 100644 --- a/examples/security/oauth/exposer.js +++ b/examples/security/oauth/exposer.js @@ -1,5 +1,6 @@ +"use strict"; /******************************************************************************** - * Copyright (c) 2018 - 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2018 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -12,6 +13,7 @@ * * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 ********************************************************************************/ +Object.defineProperty(exports, "__esModule", { value: true }); const td = { "@context": "https://www.w3.org/2019/wot/td/v1", title: "OAuth", diff --git a/examples/testthing/testclient.js b/examples/testthing/testclient.js index 772a2368e..ee89e0cee 100644 --- a/examples/testthing/testclient.js +++ b/examples/testthing/testclient.js @@ -1,5 +1,6 @@ +"use strict"; /******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2020 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -12,7 +13,6 @@ * * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 ********************************************************************************/ - console.log = () => { /* empty */ }; diff --git a/examples/testthing/testthing.js b/examples/testthing/testthing.js index c2886c22b..b47ecdf76 100644 --- a/examples/testthing/testthing.js +++ b/examples/testthing/testthing.js @@ -1,5 +1,6 @@ +"use strict"; /******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2020 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/packages/examples/README.md b/packages/examples/README.md index 6f0bc04b0..9056c574f 100644 --- a/packages/examples/README.md +++ b/packages/examples/README.md @@ -1,33 +1,25 @@ # node-wot Examples -## Script Examples +## Examples -Script examples are located in +Examples are located in -- `src\scripts` -- `src\testthing` +- `src\scripts` +- `src\testthing` +- ... The idea of these folders is to use TypeScript to work on the examples which offers support in being up-to-date with the current API. see https://github.com/eclipse-thingweb/node-wot/issues/171. -### Workflow +## Workflow for generating JS examples 1. Run `npm run build` -2. Remove the following 3/4 lines in JS files of folder `dist/` -``` -Object.defineProperty(exports, "__esModule", { value: true }); -require("wot-typescript-definitions"); -let WoT; -let WoTHelpers; -``` +2. Copy the according JS file(s) from `/packages/examples/dist` to -3. Copy the according JS file(s) to +- `/examples/scripts` +- `/examples/testthing` +- ... -- `/examples/scripts` -- `/examples/testthing` - -## Test Thing - -Test thing and client is located in `src\testthing`. +3. Run `npm run format`