iobroker.vis-jsontemplate 4.2.0 → 4.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +94 -7
- package/io-package.json +87 -61
- package/package.json +6 -6
- package/widgets/vis-jsontemplate/dist/jsontemplate-dist.js +124 -1
- package/widgets/vis-jsontemplate/dist/jsontemplate-dist.js.map +2 -2
- package/widgets/vis-jsontemplate/js/jsontemplate.js +164 -0
- package/widgets/vis-jsontemplate.html +4 -3
- package/widgets/vis2vis-jsontemplate/assets/{JSONTemplateWidget-B4sSZQuj.js → JSONTemplateWidget-B2k4zKNW.js} +16 -16
- package/widgets/vis2vis-jsontemplate/assets/{createSvgIcon-BD_MBhBd.js → createSvgIcon-Dtnn_Tct.js} +2 -2
- package/widgets/vis2vis-jsontemplate/assets/{defaultTheme-DP1GTDc1.js → defaultTheme-BtHqNVRw.js} +2 -2
- package/widgets/vis2vis-jsontemplate/assets/ext-diff-BOVpk3cr.js +150 -0
- package/widgets/vis2vis-jsontemplate/assets/ext-inline_autocomplete-C5AE1cIa.js +235 -0
- package/widgets/vis2vis-jsontemplate/assets/{ext-prompt-BCF6lmjt.js → ext-prompt-4rVdnI5b.js} +5 -5
- package/widgets/vis2vis-jsontemplate/assets/hostInit-BDi6DR-Y.js +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{index-BISc-5VX.js → index-BqVaGGVp.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{index-BqJ57sae.js → index-CXmiNQUP.js} +27 -27
- package/widgets/vis2vis-jsontemplate/assets/{index-C_tj4ot7.js → index-DA2FLCU0.js} +41 -41
- package/widgets/vis2vis-jsontemplate/assets/{index-DLiw0ycz.js → index-pW2ZedEZ.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{jsx-runtime-5WCSzT7w.js → jsx-runtime-BCIWF1gJ.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{keybinding-emacs-C7PnH1fY.js → keybinding-emacs-Q6X_mukn.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{mode-django-BQkcWdL6.js → mode-django-Bd8S6zSS.js} +3 -3
- package/widgets/vis2vis-jsontemplate/assets/mode-plsql-AgzytsmL.js +1 -0
- package/widgets/vis2vis-jsontemplate/assets/{mode-razor-HQ3WO4ht.js → mode-razor-oJWPILTI.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/mode-vbscript-BuLwesMW.js +4 -0
- package/widgets/vis2vis-jsontemplate/assets/{theme-cloud9_day-DQoca-VF.js → theme-cloud9_day-D98jah6m.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{theme-cloud9_night-DssalqUo.js → theme-cloud9_night-BZh9gIL5.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{theme-cloud9_night_low_color-CmQdrSgm.js → theme-cloud9_night_low_color-CkyOLW5t.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{theme-gruvbox_dark_hard-BcmKgsyJ.js → theme-gruvbox_dark_hard-B0hdbTLh.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{theme-gruvbox_light_hard-DOcAP-lF.js → theme-gruvbox_light_hard-CBPSdLRl.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{useTheme-iMXDunoW.js → useTheme-16T9er0Q.js} +1 -1
- package/widgets/vis2vis-jsontemplate/assets/{virtualExposes-B2YTDh_3.js → virtualExposes-B1yMnjjp.js} +2 -2
- package/widgets/vis2vis-jsontemplate/assets/vis2visjsonTemplateWidgets__loadShare___mf_0_mui_mf_1_icons_mf_2_material__loadShare__-CM4MYcQD.js +1 -0
- package/widgets/vis2vis-jsontemplate/assets/vis2visjsonTemplateWidgets__loadShare__react__loadShare__-B3mgx0MK.js +1 -0
- package/widgets/vis2vis-jsontemplate/assets/vis2visjsonTemplateWidgets__mf_v__runtimeInit__mf_v__-CbZOhenT.js +1 -0
- package/widgets/vis2vis-jsontemplate/customWidgets.js +9 -2
- package/widgets/vis2vis-jsontemplate/assets/ext-diff-CQLhij8i.js +0 -150
- package/widgets/vis2vis-jsontemplate/assets/ext-inline_autocomplete-UmbOYd2M.js +0 -235
- package/widgets/vis2vis-jsontemplate/assets/mode-plsql-DgP7Cdl4.js +0 -1
- package/widgets/vis2vis-jsontemplate/assets/mode-vbscript-BkEqgnMM.js +0 -4
- package/widgets/vis2vis-jsontemplate/assets/vis2visjsonTemplateWidgets__loadShare___mf_0_mui_mf_1_icons_mf_2_material__loadShare__-CO3TTBdF.js +0 -1
- package/widgets/vis2vis-jsontemplate/assets/vis2visjsonTemplateWidgets__loadShare__react__loadShare__-DCWor3BJ.js +0 -1
- package/widgets/vis2vis-jsontemplate/assets/vis2visjsonTemplateWidgets__mf_v__runtimeInit__mf_v__-Dv-bte9P.js +0 -5
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025 oweitman <oweitman@gmx.de>
|
|
3
|
+
Copyright (c) 2025-2026 oweitman <oweitman@gmx.de>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -59,12 +59,16 @@ a combined form of HTML code + JavaScript + CSS + special tags that control
|
|
|
59
59
|
the display of the JSON attributes.
|
|
60
60
|
JSONTemplate now supports async calls with await.
|
|
61
61
|
|
|
62
|
-
| Setting
|
|
63
|
-
|
|
|
64
|
-
| json_template
|
|
65
|
-
| json_oid
|
|
66
|
-
| json_dpCount
|
|
67
|
-
| json_dp
|
|
62
|
+
| Setting | description |
|
|
63
|
+
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
64
|
+
| json_template | The template can be used to determine the appearance of the JSON data. All valid HTML tags (including CSS attributes in style tags) can be used in the template. There are also special tags within which the JSON data is displayed and JavaScript instructions can be executed. |
|
|
65
|
+
| json_oid | Selection of the data point with the corresponding JSON data. |
|
|
66
|
+
| json_dpCount | Number of data points to be made available in the template. |
|
|
67
|
+
| json_dp | Datapoint ID to be made available. |
|
|
68
|
+
| json_scriptCount | Number of JavaScript URLs to be loaded |
|
|
69
|
+
| json_script[] | JavaScript URL to be loaded. See example below. |
|
|
70
|
+
| json_cssCount | Number of CSS URLs to be loaded. |
|
|
71
|
+
| json_css[] | CSS URL to be loaded. |
|
|
68
72
|
|
|
69
73
|
For details on the template system, see chapter Template based on examples
|
|
70
74
|
|
|
@@ -173,6 +177,76 @@ definition of the sendToAsync function
|
|
|
173
177
|
[{"label":"Afghanistan","value":"AF"},{"label":"Åland Islands","value":"AX"},{"label":"Albania","value":"AL"}]
|
|
174
178
|
```
|
|
175
179
|
|
|
180
|
+
#### Use case for loading additional scripts
|
|
181
|
+
|
|
182
|
+
Additional fields allow you to load JavaScript libraries (e.g., from CDNs
|
|
183
|
+
like jsDelivr or cdnjs). The following example demonstrates this
|
|
184
|
+
for the chartJS library.
|
|
185
|
+
|
|
186
|
+
**Step 1:**
|
|
187
|
+
|
|
188
|
+
Create a new Datapoint with type string or json named `0_userdata.0.chartData`
|
|
189
|
+
and the following content
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
[12, 19, 3, 5, 2, 3]
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Step 2:**
|
|
196
|
+
|
|
197
|
+
Enter the following url in the json_script[1] field:
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
https://cdn.jsdelivr.net/npm/chart.js
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Step 3:**
|
|
204
|
+
|
|
205
|
+
Enter the created data point name in the JSON Datapoint field.
|
|
206
|
+
Enter the following template in the JSON Template field.
|
|
207
|
+
|
|
208
|
+
Except for one line, this is standard HTML + JavaScript.
|
|
209
|
+
|
|
210
|
+
```html
|
|
211
|
+
data: <%- JSON.stringify(data) %>,
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
The data read from the data point is available in the JavaScript
|
|
215
|
+
variable `data` and is output within the template instructions <%- ... %>.
|
|
216
|
+
Once the template is compiled and included in the HTML document,
|
|
217
|
+
it is executed by the browser, so that the chart is displayed via JavaScript.
|
|
218
|
+
|
|
219
|
+
```ejs
|
|
220
|
+
<div>
|
|
221
|
+
<canvas id="myChart"></canvas>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<script>
|
|
225
|
+
const ctx = document.getElementById('myChart');
|
|
226
|
+
|
|
227
|
+
new Chart(ctx, {
|
|
228
|
+
type: 'bar',
|
|
229
|
+
data: {
|
|
230
|
+
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
|
|
231
|
+
datasets: [{
|
|
232
|
+
label: '# of Votes',
|
|
233
|
+
data: <%- JSON.stringify(data) %>,
|
|
234
|
+
borderWidth: 1
|
|
235
|
+
}]
|
|
236
|
+
},
|
|
237
|
+
options: {
|
|
238
|
+
scales: {
|
|
239
|
+
y: {
|
|
240
|
+
beginAtZero: true
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
</script>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+

|
|
249
|
+
|
|
176
250
|
#### Use case for a database-supported task list
|
|
177
251
|
|
|
178
252
|
##### **Introduction**
|
|
@@ -558,6 +632,19 @@ Loop over the attributes of an object
|
|
|
558
632
|
Placeholder for the next version (at the beginning of the line):
|
|
559
633
|
### **WORK IN PROGRESS**
|
|
560
634
|
-->
|
|
635
|
+
### 4.3.10 (2026-01-25)
|
|
636
|
+
|
|
637
|
+
- update test and release script
|
|
638
|
+
|
|
639
|
+
### 4.3.1 (2026-01-24)
|
|
640
|
+
|
|
641
|
+
- try again to publish
|
|
642
|
+
|
|
643
|
+
### 4.3.0 (2026-01-24)
|
|
644
|
+
|
|
645
|
+
- The ability to load additional JavaScript and CSS files has been added.
|
|
646
|
+
This is currently only available for vis1 for testing purposes.
|
|
647
|
+
|
|
561
648
|
### 4.2.0 (2025-11-14)
|
|
562
649
|
|
|
563
650
|
- Improve documentation for the object notation in a template
|
|
@@ -592,7 +679,7 @@ Loop over the attributes of an object
|
|
|
592
679
|
|
|
593
680
|
MIT License
|
|
594
681
|
|
|
595
|
-
Copyright (c) 2021-
|
|
682
|
+
Copyright (c) 2021-2026 oweitman <oweitman@gmx.de>
|
|
596
683
|
|
|
597
684
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
598
685
|
of this software and associated documentation files (the "Software"), to deal
|
package/io-package.json
CHANGED
|
@@ -1,72 +1,98 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "vis-jsontemplate",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.10",
|
|
5
5
|
"news": {
|
|
6
|
-
"4.
|
|
7
|
-
"en": "
|
|
8
|
-
"de": "
|
|
9
|
-
"ru": "
|
|
10
|
-
"pt": "
|
|
11
|
-
"nl": "
|
|
12
|
-
"fr": "
|
|
13
|
-
"it": "
|
|
14
|
-
"es": "
|
|
15
|
-
"pl": "
|
|
16
|
-
"uk": "
|
|
17
|
-
"zh-cn": "
|
|
6
|
+
"4.3.10": {
|
|
7
|
+
"en": "update test and release script",
|
|
8
|
+
"de": "update-test und release-skript",
|
|
9
|
+
"ru": "обновить тест и выпустить скрипт",
|
|
10
|
+
"pt": "atualizar script de teste e lançamento",
|
|
11
|
+
"nl": "update test- en releasescript",
|
|
12
|
+
"fr": "mettre à jour le script test et release",
|
|
13
|
+
"it": "test di aggiornamento e script di rilascio",
|
|
14
|
+
"es": "actualización de prueba y script de liberación",
|
|
15
|
+
"pl": "aktualizacja skryptu testowego i wydania",
|
|
16
|
+
"uk": "скрипт тестування і реліз",
|
|
17
|
+
"zh-cn": "更新测试并发布脚本"
|
|
18
18
|
},
|
|
19
|
-
"4.
|
|
20
|
-
"en": "
|
|
21
|
-
"de": "
|
|
22
|
-
"ru": "
|
|
23
|
-
"pt": "
|
|
24
|
-
"nl": "
|
|
25
|
-
"fr": "
|
|
26
|
-
"it": "
|
|
27
|
-
"es": "
|
|
28
|
-
"pl": "
|
|
29
|
-
"uk": "
|
|
30
|
-
"zh-cn": "
|
|
19
|
+
"4.3.9": {
|
|
20
|
+
"en": "update test and release script",
|
|
21
|
+
"de": "update-test und release-skript",
|
|
22
|
+
"ru": "обновить тест и выпустить скрипт",
|
|
23
|
+
"pt": "atualizar script de teste e lançamento",
|
|
24
|
+
"nl": "update test- en releasescript",
|
|
25
|
+
"fr": "mettre à jour le script test et release",
|
|
26
|
+
"it": "test di aggiornamento e script di rilascio",
|
|
27
|
+
"es": "actualización de prueba y script de liberación",
|
|
28
|
+
"pl": "aktualizacja skryptu testowego i wydania",
|
|
29
|
+
"uk": "скрипт тестування і реліз",
|
|
30
|
+
"zh-cn": "更新测试并发布脚本"
|
|
31
31
|
},
|
|
32
|
-
"4.
|
|
33
|
-
"en": "
|
|
34
|
-
"de": "
|
|
35
|
-
"ru": "
|
|
36
|
-
"pt": "
|
|
37
|
-
"nl": "
|
|
38
|
-
"fr": "
|
|
39
|
-
"it": "
|
|
40
|
-
"es": "
|
|
41
|
-
"pl": "
|
|
42
|
-
"uk": "
|
|
43
|
-
"zh-cn": "
|
|
32
|
+
"4.3.8": {
|
|
33
|
+
"en": "update test and release script",
|
|
34
|
+
"de": "update-test und release-skript",
|
|
35
|
+
"ru": "обновить тест и выпустить скрипт",
|
|
36
|
+
"pt": "atualizar script de teste e lançamento",
|
|
37
|
+
"nl": "update test- en releasescript",
|
|
38
|
+
"fr": "mettre à jour le script test et release",
|
|
39
|
+
"it": "test di aggiornamento e script di rilascio",
|
|
40
|
+
"es": "actualización de prueba y script de liberación",
|
|
41
|
+
"pl": "aktualizacja skryptu testowego i wydania",
|
|
42
|
+
"uk": "скрипт тестування і реліз",
|
|
43
|
+
"zh-cn": "更新测试并发布脚本"
|
|
44
44
|
},
|
|
45
|
-
"4.
|
|
46
|
-
"en": "
|
|
47
|
-
"de": "
|
|
48
|
-
"ru": "
|
|
49
|
-
"pt": "
|
|
50
|
-
"nl": "
|
|
51
|
-
"fr": "
|
|
52
|
-
"it": "
|
|
53
|
-
"es": "
|
|
54
|
-
"pl": "
|
|
55
|
-
"uk": "
|
|
56
|
-
"zh-cn": "
|
|
45
|
+
"4.3.7": {
|
|
46
|
+
"en": "update test and release script",
|
|
47
|
+
"de": "update-test und release-skript",
|
|
48
|
+
"ru": "обновить тест и выпустить скрипт",
|
|
49
|
+
"pt": "atualizar script de teste e lançamento",
|
|
50
|
+
"nl": "update test- en releasescript",
|
|
51
|
+
"fr": "mettre à jour le script test et release",
|
|
52
|
+
"it": "test di aggiornamento e script di rilascio",
|
|
53
|
+
"es": "actualización de prueba y script de liberación",
|
|
54
|
+
"pl": "aktualizacja skryptu testowego i wydania",
|
|
55
|
+
"uk": "скрипт тестування і реліз",
|
|
56
|
+
"zh-cn": "更新测试并发布脚本"
|
|
57
57
|
},
|
|
58
|
-
"4.
|
|
59
|
-
"en": "
|
|
60
|
-
"de": "
|
|
61
|
-
"ru": "
|
|
62
|
-
"pt": "
|
|
63
|
-
"nl": "
|
|
64
|
-
"fr": "
|
|
65
|
-
"it": "
|
|
66
|
-
"es": "
|
|
67
|
-
"pl": "
|
|
68
|
-
"uk": "
|
|
69
|
-
"zh-cn": "
|
|
58
|
+
"4.3.6": {
|
|
59
|
+
"en": "update test and release script",
|
|
60
|
+
"de": "update-test und release-skript",
|
|
61
|
+
"ru": "обновить тест и выпустить скрипт",
|
|
62
|
+
"pt": "atualizar script de teste e lançamento",
|
|
63
|
+
"nl": "update test- en releasescript",
|
|
64
|
+
"fr": "mettre à jour le script test et release",
|
|
65
|
+
"it": "test di aggiornamento e script di rilascio",
|
|
66
|
+
"es": "actualización de prueba y script de liberación",
|
|
67
|
+
"pl": "aktualizacja skryptu testowego i wydania",
|
|
68
|
+
"uk": "скрипт тестування і реліз",
|
|
69
|
+
"zh-cn": "更新测试并发布脚本"
|
|
70
|
+
},
|
|
71
|
+
"4.3.5": {
|
|
72
|
+
"en": "update test and release script",
|
|
73
|
+
"de": "update-test und release-skript",
|
|
74
|
+
"ru": "обновить тест и выпустить скрипт",
|
|
75
|
+
"pt": "atualizar script de teste e lançamento",
|
|
76
|
+
"nl": "update test- en releasescript",
|
|
77
|
+
"fr": "mettre à jour le script test et release",
|
|
78
|
+
"it": "test di aggiornamento e script di rilascio",
|
|
79
|
+
"es": "actualización de prueba y script de liberación",
|
|
80
|
+
"pl": "aktualizacja skryptu testowego i wydania",
|
|
81
|
+
"uk": "скрипт тестування і реліз",
|
|
82
|
+
"zh-cn": "更新测试并发布脚本"
|
|
83
|
+
},
|
|
84
|
+
"4.3.4": {
|
|
85
|
+
"en": "update test and release script",
|
|
86
|
+
"de": "update-test und release-skript",
|
|
87
|
+
"ru": "обновить тест и выпустить скрипт",
|
|
88
|
+
"pt": "atualizar script de teste e lançamento",
|
|
89
|
+
"nl": "update test- en releasescript",
|
|
90
|
+
"fr": "mettre à jour le script test et release",
|
|
91
|
+
"it": "test di aggiornamento e script di rilascio",
|
|
92
|
+
"es": "actualización de prueba y script de liberación",
|
|
93
|
+
"pl": "aktualizacja skryptu testowego i wydania",
|
|
94
|
+
"uk": "скрипт тестування і реліз",
|
|
95
|
+
"zh-cn": "更新测试并发布脚本"
|
|
70
96
|
}
|
|
71
97
|
},
|
|
72
98
|
"titleLang": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.vis-jsontemplate",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.10",
|
|
4
4
|
"description": "vis-jsontemplate",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "oweitman",
|
|
@@ -25,14 +25,13 @@
|
|
|
25
25
|
"@alcalzone/release-script-plugin-iobroker": "^4.0.0",
|
|
26
26
|
"@alcalzone/release-script-plugin-license": "^4.0.0",
|
|
27
27
|
"@alcalzone/release-script-plugin-manual-review": "^4.0.0",
|
|
28
|
-
"@iobroker/
|
|
28
|
+
"@iobroker/adapter-dev": "^1.5.0",
|
|
29
29
|
"@iobroker/eslint-config": "^2.2.0",
|
|
30
|
+
"@iobroker/testing": "^5.2.2",
|
|
31
|
+
"@iobroker/build-tools": "^2.0.15",
|
|
30
32
|
"@iobroker/vis-2-widgets-react-dev": "^4.0.4",
|
|
31
33
|
"@iobroker/vis-2-widgets-testing": "^1.0.6",
|
|
32
|
-
"@
|
|
33
|
-
"@iobroker/testing": "^5.2.2",
|
|
34
|
-
"@types/gulp": "^4.0.18",
|
|
35
|
-
"@types/node": "^24.10.0"
|
|
34
|
+
"@types/node": "^24.10.1"
|
|
36
35
|
},
|
|
37
36
|
"main": "widgets/vis2jsontemplate/customWidgets.js",
|
|
38
37
|
"files": [
|
|
@@ -44,6 +43,7 @@
|
|
|
44
43
|
"scripts": {
|
|
45
44
|
"test:package": "mocha test/package --exit",
|
|
46
45
|
"test:widgets": "mocha ./test/*.test.js",
|
|
46
|
+
"test:integration": "mocha test/package --exit",
|
|
47
47
|
"test": "npm run test:package && npm run test:widgets",
|
|
48
48
|
"prepublishOnly": "npm run build-vis1widgets && npm run build-vis2widgets",
|
|
49
49
|
"lint": "npm run lint-adapter && npm run lint-vis1widgets && npm run lint-vis2widgets",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
var version;
|
|
59
59
|
var init_package = __esm({
|
|
60
60
|
"../package.json"() {
|
|
61
|
-
version = "4.
|
|
61
|
+
version = "4.3.10";
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
@@ -73,6 +73,8 @@
|
|
|
73
73
|
}));
|
|
74
74
|
vis.binds["jsontemplate"] = {
|
|
75
75
|
version,
|
|
76
|
+
_assetCache: vis.binds["jsontemplate"] && vis.binds["jsontemplate"]._assetCache || /* @__PURE__ */ new Map(),
|
|
77
|
+
_widgetInit: vis.binds["jsontemplate"] && vis.binds["jsontemplate"]._widgetInit || /* @__PURE__ */ new Map(),
|
|
76
78
|
/**
|
|
77
79
|
* Log the version of jsontemplate and remove it.
|
|
78
80
|
* Should be called from the main thread, as it logs to the console.
|
|
@@ -139,6 +141,20 @@
|
|
|
139
141
|
bound.push(data[`json_dp${i}`]);
|
|
140
142
|
}
|
|
141
143
|
}
|
|
144
|
+
const scriptCount = data.json_scriptCount ? data.json_scriptCount : 1;
|
|
145
|
+
const scripts = [];
|
|
146
|
+
for (let i = 1; i <= scriptCount; i++) {
|
|
147
|
+
if (data[`json_script${i}`]) {
|
|
148
|
+
scripts.push(data[`json_script${i}`]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const cssCount = data.json_cssCount ? data.json_cssCount : 1;
|
|
152
|
+
const css = [];
|
|
153
|
+
for (let i = 1; i <= cssCount; i++) {
|
|
154
|
+
if (data[`json_css${i}`]) {
|
|
155
|
+
css.push(data[`json_css${i}`]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
142
158
|
if (bound) {
|
|
143
159
|
if (!vis.editMode) {
|
|
144
160
|
yield vis.binds["jsontemplate"].bindStatesAsync(
|
|
@@ -153,6 +169,14 @@
|
|
|
153
169
|
);
|
|
154
170
|
}
|
|
155
171
|
}
|
|
172
|
+
try {
|
|
173
|
+
yield vis.binds["jsontemplate"].initWidgetAssetsOnce(widgetID, scripts, css);
|
|
174
|
+
} catch (e) {
|
|
175
|
+
let msg = vis.binds["jsontemplate"].escapeHTML(e.message).replace(/(?:\r\n|\r|\n)/g, "<br>");
|
|
176
|
+
msg = msg.replace(/ /gm, " ");
|
|
177
|
+
$div.html(`<code style="color:red;">${msg}</code>`);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
156
180
|
yield this.render(widgetID, view, data, style);
|
|
157
181
|
});
|
|
158
182
|
},
|
|
@@ -393,6 +417,105 @@
|
|
|
393
417
|
}
|
|
394
418
|
};
|
|
395
419
|
return line;
|
|
420
|
+
},
|
|
421
|
+
loadAsset: function(url, kind) {
|
|
422
|
+
const u = (url || "").trim();
|
|
423
|
+
if (!u) {
|
|
424
|
+
return Promise.resolve();
|
|
425
|
+
}
|
|
426
|
+
const cache = vis.binds["jsontemplate"]._assetCache;
|
|
427
|
+
if (cache.has(u)) {
|
|
428
|
+
return cache.get(u);
|
|
429
|
+
}
|
|
430
|
+
const p = new Promise((resolve, reject) => {
|
|
431
|
+
try {
|
|
432
|
+
const isCss = kind === "css" || u.toLowerCase().endsWith(".css");
|
|
433
|
+
const isJs = kind === "js" || u.toLowerCase().endsWith(".js") || !isCss;
|
|
434
|
+
if (isCss) {
|
|
435
|
+
const existing = document.querySelector(`link[rel="stylesheet"][href="${CSS.escape(u)}"]`);
|
|
436
|
+
if (existing) {
|
|
437
|
+
return resolve();
|
|
438
|
+
}
|
|
439
|
+
const link = document.createElement("link");
|
|
440
|
+
link.rel = "stylesheet";
|
|
441
|
+
link.href = u;
|
|
442
|
+
link.onload = () => resolve();
|
|
443
|
+
link.onerror = () => reject(new Error(`CSS konnte nicht geladen werden: ${u}`));
|
|
444
|
+
document.head.appendChild(link);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (isJs) {
|
|
448
|
+
const existing = document.querySelector(`script[src="${CSS.escape(u)}"]`);
|
|
449
|
+
if (existing) {
|
|
450
|
+
return resolve();
|
|
451
|
+
}
|
|
452
|
+
const s = document.createElement("script");
|
|
453
|
+
s.src = u;
|
|
454
|
+
s.async = false;
|
|
455
|
+
s.defer = false;
|
|
456
|
+
s.onload = () => resolve();
|
|
457
|
+
s.onerror = () => reject(new Error(`Script konnte nicht geladen werden: ${u}`));
|
|
458
|
+
document.head.appendChild(s);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
resolve();
|
|
462
|
+
} catch (err) {
|
|
463
|
+
reject(err);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
cache.set(u, p);
|
|
467
|
+
return p;
|
|
468
|
+
},
|
|
469
|
+
loadAssetsInOrder: function(assets) {
|
|
470
|
+
return __async(this, null, function* () {
|
|
471
|
+
if (!assets || !assets.length) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
for (const a of assets) {
|
|
475
|
+
if (!a) {
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
if (typeof a === "string") {
|
|
479
|
+
yield vis.binds["jsontemplate"].loadAsset(a);
|
|
480
|
+
} else {
|
|
481
|
+
yield vis.binds["jsontemplate"].loadAsset(a.url, a.kind);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
},
|
|
486
|
+
/**
|
|
487
|
+
* Lädt CSS und Scripts (einmalig) in definierter Reihenfolge:
|
|
488
|
+
* 1) CSS (Reihenfolge beibehalten, relevant für Overrides)
|
|
489
|
+
* 2) JS (sequentiell, relevant für Abhängigkeiten)
|
|
490
|
+
*/
|
|
491
|
+
loadScriptsAndCssOnce: function(scripts, css) {
|
|
492
|
+
return __async(this, null, function* () {
|
|
493
|
+
if (Array.isArray(css) && css.length) {
|
|
494
|
+
const cssAssets = css.map((u) => (u || "").trim()).filter(Boolean).map((u) => ({ url: u, kind: "css" }));
|
|
495
|
+
yield vis.binds["jsontemplate"].loadAssetsInOrder(cssAssets);
|
|
496
|
+
}
|
|
497
|
+
if (Array.isArray(scripts) && scripts.length) {
|
|
498
|
+
const scriptAssets = scripts.map((u) => (u || "").trim()).filter(Boolean).map((u) => ({ url: u, kind: "js" }));
|
|
499
|
+
yield vis.binds["jsontemplate"].loadAssetsInOrder(scriptAssets);
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
},
|
|
503
|
+
/**
|
|
504
|
+
* Einmalige Initialisierung pro WidgetID + Asset-Set.
|
|
505
|
+
* Dadurch wird bei render()-Aufrufen (State changes) nicht erneut geladen.
|
|
506
|
+
* Wenn sich Assets in den Properties ändern, erzeugt der Key ein neues Init-Promise.
|
|
507
|
+
*/
|
|
508
|
+
initWidgetAssetsOnce: function(widgetID, scripts, css) {
|
|
509
|
+
const initMap = vis.binds["jsontemplate"]._widgetInit;
|
|
510
|
+
const key = `${widgetID}::css=${(css || []).map((s) => String(s).trim()).filter(Boolean).join("|")}::js=${(scripts || []).map((s) => String(s).trim()).filter(Boolean).join("|")}`;
|
|
511
|
+
if (initMap.has(key)) {
|
|
512
|
+
return initMap.get(key);
|
|
513
|
+
}
|
|
514
|
+
const p = (() => __async(null, null, function* () {
|
|
515
|
+
yield vis.binds["jsontemplate"].loadScriptsAndCssOnce(scripts, css);
|
|
516
|
+
}))();
|
|
517
|
+
initMap.set(key, p);
|
|
518
|
+
return p;
|
|
396
519
|
}
|
|
397
520
|
};
|
|
398
521
|
vis.binds["jsontemplate"].showVersion();
|