Choosing the Development Environment and Language

Choose your development environment and language before starting development of your web app.

You can use TypeScript or JavaScript with the Thing-IF SDK for JavaScript. This guide explains the following two methods from among various development environments and frameworks available for these languages.

Both the methods require Node.js. Install Node.js and make the npm command executable.

Building TypeScript Code on Node.js

With this method, you implement the web app with TypeScript and build JavaScript files for the web browser on Node.js. Node.js builds and consolidates the Kii Cloud SDK for JavaScript, Thing-IF SDK for JavaScript, and related libraries into JavaScript files.

The code for the web app written in TypeScript is converted to JavaScript code. You can use features that the web browser does not support such as the import statement while you implement the web app. And then, when you build the TypeScript code, you can generate JavaScript files which are executable in the web browser.

Finally, load the JavaScript files generated on Node.js in the web browser by means such as the <script> tag.

Writing JavaScript Code Directly

With this method, you implement the web app code with JavaScript and load it directory in the web browser.

Load JavaScript code of the SDKs and web app in the web browser by means such as the <script> tag. Build JS files from the Thing-IF SDK for JavaScript on Node.js in advance. The Kii Cloud SDK is a single JavaScript file including dependent libraries and the web browser can directly interpret and execute it.

You cannot manage your web app modules with the require() function because the web browser directly interprets and executes the code.

If you need to include any libraries to implement the web app, you can load the libraries in the web browser by means such as the HTML <script> tag.

Writing Rules for the Sample Code

This guide presents sample code in both JavaScript and TypeScript.

Those samples assume the above development methods. Especially, be careful about the following points for the namespace.

  • TypeScript

    Load the Kii SDKs by means such as the import statement and require() function when you use TypeScript.

    The sample code assumes that the namespace of the Kii Cloud SDK is kii and that of the Thing-IF SDK is ThingIF.

    For example, the TypedID class is represented as ThingIF.TypedID in the sample code.

  • JavaScript

    Written source files are directly executed in the web browser together with the built files from the Thing-IF SDK for JavaScript.

    The implementation method and sample code assume that the Kii Cloud SDK uses the global namespace and the Thing-IF SDK uses the ThingIF namespace.

    For example, the TypedID class is represented as ThingIF.TypedID in the sample code.

If you employ any different method, rewrite sample code as required.

For example, you can write source code in JavaScript and generate JavaScript code using Node.js that the web browser can interpret. In this case, you need to load the Kii Cloud SDK classes in a namespace such as kii with the require() function and reference them by adding a prefix such as kii. You need to rewrite the sample code in JavaScript because it uses the global namespace.