Skip to content

Commit 441b812

Browse files
Openblocks-docsgitbook-bot
Openblocks-docs
authored andcommitted
GitBook: [#59] No subject
1 parent b9e3673 commit 441b812

23 files changed

+91
-1
lines changed
116 KB
Loading
116 KB
Loading
116 KB
Loading
97.3 KB
Loading

docs/.gitbook/assets/image (1).png

-92.7 KB
Loading
81.3 KB
Loading
81.3 KB
Loading
81.3 KB
Loading
148 KB
Loading
148 KB
Loading
148 KB
Loading
Loading
Loading
92.8 KB
Loading

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* [Create a new app](build-apps/create-a-new-app.md)
2222
* [App editor](build-apps/app-editor.md)
2323
* [Event handlers](build-apps/event-handlers.md)
24+
* [Use third-party libraries](build-apps/use-third-party-libraries.md)
2425
* [Version and release management](build-apps/version-and-release-management.md)
2526

2627
## Workspace management
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Use third-party libraries
2+
3+
Every developer learns one of the most important principles of software engineering early in their career: DRY (Don’t Repeat Yourself). Using third-party libraries can save your time as you do not need to develop the functionality that the library provides. Openblocks provides some built-in third-party libraries for common uses, and you can manually import other libraries on demand.
4+
5+
### Built-in third-party libraries
6+
7+
Openblocks provides some JavaScript built-in libraries for use:
8+
9+
| Library | Docs | Version |
10+
| --------- | -------------------------------------------------------------------- | -------------------------- |
11+
| lodash | [https://lodash.com/docs/](https://lodash.com/docs/) | 4.17.21 |
12+
| moment | [https://momentjs.com/docs/](https://momentjs.com/docs/) | 2.29.3 |
13+
| uuid | [https://github.com/uuidjs/uuid](https://github.com/uuidjs/uuid) | 8.3.2(Support v1/v3/v4/v5) |
14+
| numbro | [https://numbrojs.com/format.html](https://numbrojs.com/format.html) | 2.3.6 |
15+
| papaparse | [https://www.papaparse.com/docs](https://www.papaparse.com/docs) | 5.3.2 |
16+
17+
### Manually import third-party libraries
18+
19+
Openblocks supports setting up preloaded JavaScript and libraries which can be **app-level** or **workspace-level**.
20+
21+
* **App-level** JavaScript **** gets loaded only in the app where defined. Plus, app A cannot use libraries that are set up for app B.
22+
* **Workspace-level** JavaScript **** will be loaded when you open any application in your workspace. All the apps can access those libraries. There can be a certain impact on app performance, especially when you have complex JavaScript functions that aren't being used in every app.
23+
24+
{% hint style="info" %}
25+
**Tips you should know before setting up libraries:**
26+
27+
* External libraries are loaded and run in the browser.
28+
* NodeJS-only libraries are not supported now.
29+
* URLs of external libraries need to support cross-domain.
30+
* The export of the library must be set directly on the window object, global variables like (var xxx = xxx) do not take effect.
31+
* The external libraries run in a restricted sandbox environment and the following global variables are not available:
32+
33+
<mark style="background-color:yellow;">`parent`</mark>
34+
35+
<mark style="background-color:yellow;">`document`</mark>
36+
37+
<mark style="background-color:yellow;">`location`</mark>
38+
39+
<mark style="background-color:yellow;">`chrome`</mark>
40+
41+
<mark style="background-color:yellow;">`setTimeout`</mark>
42+
43+
<mark style="background-color:yellow;">`fetch`</mark>
44+
45+
<mark style="background-color:yellow;">`setInterval`</mark>
46+
47+
<mark style="background-color:yellow;">`clearInterval`</mark>
48+
49+
<mark style="background-color:yellow;">`setImmediate`</mark>
50+
51+
<mark style="background-color:yellow;">`XMLHttpRequest`</mark>
52+
53+
<mark style="background-color:yellow;">`importScripts`</mark>
54+
55+
<mark style="background-color:yellow;">`Navigator`</mark>
56+
57+
<mark style="background-color:yellow;">`MutationObserver`</mark>
58+
{% endhint %}
59+
60+
\
61+
Now let's take **cowsay** as an example and import it on app-level and workspace-level.
62+
63+
* GitHub page: [https://github.com/piuccio/cowsay](https://github.com/piuccio/cowsay)
64+
* Library link: [https://unpkg.com/cowsay@1.5.0/build/cowsay.umd.js](https://unpkg.com/cowsay@1.5.0/build/cowsay.umd.js)
65+
66+
#### Import on App-level
67+
68+
Navigate to the left sidebar, click <img src="../.gitbook/assets/image (1).png" alt="" data-size="line"> > **Other** > **Scripts and style** > **Add a library**. Then paste the **cowsay** link here.
69+
70+
<figure><img src="../.gitbook/assets/Add a library (2).png" alt=""><figcaption></figcaption></figure>
71+
72+
Now you can write code in **JS query** to test its usage with `cowsay.say`:
73+
74+
<figure><img src="../.gitbook/assets/write code in JS query (2).png" alt=""><figcaption></figcaption></figure>
75+
76+
or in **Properties** to use:
77+
78+
<figure><img src="../.gitbook/assets/or in Properties (2).png" alt=""><figcaption></figcaption></figure>
79+
80+
And since you have set up cowsay just for **Openblocks's new application 1,** you can not use cowsay in another app.
81+
82+
<figure><img src="../.gitbook/assets/in another app (1).png" alt=""><figcaption></figcaption></figure>
83+
84+
#### Import on Workspace-level libraries
85+
86+
Navigate to **Workspace settings** > **Advanced** > **JavaScript library** > **Add a library**. Then paste the **cowsay** link here and click **Save**. Now you can use **cowsay** library **** in any app of your workspace.\
87+
![](<../.gitbook/assets/Import on Workspace-level libraries (1).png>)
88+
89+
<figure><img src="../.gitbook/assets/Import on Workspace-level libraries-advanced.png" alt=""><figcaption></figcaption></figure>

docs/data-sources/data-source-basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Data source basics
22

3-
Data source is where you manage credentials and make connections to various popular databases such as PostgreSQL, MongoDB, Elasticsearch and all kinds of internal or third party APIs.&#x20;
3+
Data source is where you manage credentials and make connections to various popular databases such as PostgreSQL, MongoDB, Elasticsearch and all kinds of internal or third-party APIs.&#x20;
44

55
Openblocks stores your credentials securely and does not store any data from your requests or responses. It only serves as a proxy between client side and your data sources.
66

0 commit comments

Comments
 (0)