trebol 0.1.0 → 0.1.1
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/README.md +8 -2
- package/dist/cli.js +55 -20
- package/dist/lib/core/access.d.ts +10 -0
- package/dist/lib/core/access.js +210 -0
- package/dist/lib/core/base.d.ts +4 -0
- package/dist/lib/core/base.js +50 -0
- package/dist/lib/core/bitset.d.ts +9 -0
- package/dist/lib/core/bitset.js +75 -0
- package/dist/lib/core/boot.d.ts +18 -0
- package/dist/lib/core/boot.js +72 -0
- package/dist/lib/core/compare.d.ts +9 -0
- package/dist/lib/core/compare.js +156 -0
- package/dist/lib/core/ctx.d.ts +36 -0
- package/dist/lib/core/ctx.js +251 -0
- package/dist/lib/core/dec.d.ts +28 -0
- package/dist/lib/core/dec.js +158 -0
- package/dist/lib/core/errors.d.ts +15 -0
- package/dist/lib/core/errors.js +44 -0
- package/dist/lib/core/escapes.d.ts +14 -0
- package/dist/lib/core/escapes.js +80 -0
- package/dist/lib/core/eval.d.ts +220 -0
- package/dist/lib/core/eval.js +666 -0
- package/dist/lib/core/func.d.ts +64 -0
- package/dist/lib/core/func.js +129 -0
- package/dist/lib/core/hash.d.ts +5 -0
- package/dist/lib/core/hash.js +155 -0
- package/dist/lib/core/index.d.ts +18 -0
- package/dist/lib/core/index.js +20 -0
- package/dist/lib/core/int64.d.ts +22 -0
- package/dist/lib/core/int64.js +113 -0
- package/dist/lib/core/kinds.d.ts +67 -0
- package/dist/lib/core/kinds.js +134 -0
- package/dist/lib/core/lexer.d.ts +13 -0
- package/dist/lib/core/lexer.js +702 -0
- package/dist/lib/core/mezz.d.ts +1 -0
- package/dist/lib/core/mezz.js +360 -0
- package/dist/lib/core/mold.d.ts +20 -0
- package/dist/lib/core/mold.js +434 -0
- package/dist/lib/core/natives/control.d.ts +1 -0
- package/dist/lib/core/natives/control.js +374 -0
- package/dist/lib/core/natives/csv.d.ts +15 -0
- package/dist/lib/core/natives/csv.js +315 -0
- package/dist/lib/core/natives/data.d.ts +11 -0
- package/dist/lib/core/natives/data.js +367 -0
- package/dist/lib/core/natives/define.d.ts +17 -0
- package/dist/lib/core/natives/define.js +47 -0
- package/dist/lib/core/natives/encode.d.ts +3 -0
- package/dist/lib/core/natives/encode.js +187 -0
- package/dist/lib/core/natives/json.d.ts +5 -0
- package/dist/lib/core/natives/json.js +273 -0
- package/dist/lib/core/natives/math.d.ts +3 -0
- package/dist/lib/core/natives/math.js +500 -0
- package/dist/lib/core/natives/parse.d.ts +1 -0
- package/dist/lib/core/natives/parse.js +600 -0
- package/dist/lib/core/natives/series.d.ts +4 -0
- package/dist/lib/core/natives/series.js +509 -0
- package/dist/lib/core/natives/text.d.ts +1 -0
- package/dist/lib/core/natives/text.js +484 -0
- package/dist/lib/core/natives/xml.d.ts +9 -0
- package/dist/lib/core/natives/xml.js +242 -0
- package/dist/lib/core/series.d.ts +26 -0
- package/dist/lib/core/series.js +73 -0
- package/dist/lib/core/symbols.d.ts +9 -0
- package/dist/lib/core/symbols.js +44 -0
- package/dist/lib/core/values.d.ts +206 -0
- package/dist/lib/core/values.js +223 -0
- package/dist/lib/host/browser.d.ts +4 -0
- package/dist/lib/host/browser.js +4081 -0
- package/dist/lib/host/chart.d.ts +26 -0
- package/dist/lib/host/chart.js +158 -0
- package/dist/lib/host/compress.d.ts +1 -0
- package/dist/lib/host/compress.js +37 -0
- package/dist/lib/host/draw.d.ts +31 -0
- package/dist/lib/host/draw.js +348 -0
- package/dist/lib/host/icons.d.ts +3 -0
- package/dist/lib/host/icons.js +97 -0
- package/dist/lib/host/index.d.ts +38 -0
- package/dist/lib/host/index.js +190 -0
- package/dist/lib/host/locale.d.ts +40 -0
- package/dist/lib/host/locale.js +241 -0
- package/dist/lib/host/markdown.d.ts +28 -0
- package/dist/lib/host/markdown.js +151 -0
- package/dist/lib/host/modules.d.ts +10 -0
- package/dist/lib/host/modules.js +262 -0
- package/dist/lib/host/natives.d.ts +6 -0
- package/dist/lib/host/natives.js +98 -0
- package/dist/lib/host/net.d.ts +12 -0
- package/dist/lib/host/net.js +541 -0
- package/dist/lib/host/page.d.ts +9 -0
- package/dist/lib/host/page.js +55 -0
- package/dist/lib/host/rows.d.ts +15 -0
- package/dist/lib/host/rows.js +80 -0
- package/dist/lib/host/scheduler.d.ts +45 -0
- package/dist/lib/host/scheduler.js +173 -0
- package/dist/lib/host/theme.d.ts +58 -0
- package/dist/lib/host/theme.js +1462 -0
- package/dist/lib/ui/i18n.trb +111 -0
- package/dist/lib/ui/ui.trb +1237 -0
- package/dist/trebol.js +123 -56
- package/package.json +17 -5
- package/src/host/browser.ts +274 -33
- package/src/host/index.ts +2 -2
- package/src/host/modules.ts +8 -1
- package/src/host/theme.ts +63 -4
- package/src/ui/i18n.trb +4 -0
- package/src/ui/ui.trb +48 -15
package/src/ui/ui.trb
CHANGED
|
@@ -36,6 +36,12 @@ face: make object! [
|
|
|
36
36
|
readonly: false ; shown and sent, but the user cannot change it, and no rule applies
|
|
37
37
|
inert: false ; shown as it is, but neither it nor its children can be used
|
|
38
38
|
linked: false ; a tile that stands for something kept elsewhere: marked with an arrow
|
|
39
|
+
round: false ; an image: cut to a circle, as for a person's photo
|
|
40
|
+
poster: none ; a video: the image shown before it plays
|
|
41
|
+
captions: none ; a video: its captions, a .vtt file, or a block of one per language [en %a.vtt es %b.vtt]
|
|
42
|
+
looping: false ; a video or a sound starts again when it ends (loop in the dialect)
|
|
43
|
+
silent: false ; a video or a sound plays without its sound (muted in the dialect)
|
|
44
|
+
autoplay: false ; a video or a sound plays on its own, always silent, as browsers allow
|
|
39
45
|
drag: false ; can be dragged: carries its value, or the row in a table, list or tree
|
|
40
46
|
drop: false ; accepts drops (on-drop)
|
|
41
47
|
reorder: false ; its children or rows can be moved around (on-reorder)
|
|
@@ -43,7 +49,7 @@ face: make object! [
|
|
|
43
49
|
error: none ; current message, shown once the face is touched
|
|
44
50
|
touched: false
|
|
45
51
|
pending: false ; an asynchronous check is running
|
|
46
|
-
sent: none ; an upload: how far its files went up, 0-1; none hides the bar
|
|
52
|
+
sent: none ; an upload or photo: how far its files went up, 0-1; none hides the bar
|
|
47
53
|
async-error: none ; result of the last asynchronous check
|
|
48
54
|
action: none ; the block after the face: click, change
|
|
49
55
|
events: none ; [on-change [...] on-select [...]]
|
|
@@ -59,11 +65,11 @@ face: make object! [
|
|
|
59
65
|
built: none ; rows: what its rows were last made from
|
|
60
66
|
owner: none ; a row of rows: the rows face it belongs to
|
|
61
67
|
typed: none ; what the user typed in a number, money or date field when it is not one;
|
|
62
|
-
; in an upload, the names of the files it refused
|
|
68
|
+
; in an upload or photo, the names of the files it refused
|
|
63
69
|
multiple: false ; an upload or a lookup takes more than one
|
|
64
|
-
accept: none ; the files an upload takes: ["pdf" "image/*"]
|
|
70
|
+
accept: none ; the files an upload takes: ["pdf" "image/*"]; a photo, images unless told
|
|
65
71
|
pane: none
|
|
66
|
-
columns: none ; table, list and tree: [field "Label" ...]
|
|
72
|
+
columns: none ; table, list and tree: [field "Label" ...]; a column of images, [field ["Label" image round]]
|
|
67
73
|
data: none ; table, list and tree: a block of map! or object! rows (a tree's
|
|
68
74
|
; have their own in `children`); breadcrumb: its items
|
|
69
75
|
key: 'id ; the row field that identifies a row
|
|
@@ -84,14 +90,15 @@ face: make object! [
|
|
|
84
90
|
styles: make map! []
|
|
85
91
|
|
|
86
92
|
container-styles: [view column row form panel grid dialog scroll split toolbar desktop]
|
|
87
|
-
input-styles: [field password number money date area rich check toggle choice radio upload lookup rows]
|
|
93
|
+
input-styles: [field password number money date area rich check toggle choice radio upload photo lookup rows]
|
|
88
94
|
data-styles: [table list tree chart]
|
|
89
95
|
|
|
90
96
|
foreach [name base] [
|
|
91
97
|
view column column column row row form form panel panel grid grid scroll scroll desktop desktop
|
|
92
98
|
title title heading heading text text divider divider
|
|
93
99
|
field field password password number number money money date date area area rich rich check check choice choice
|
|
94
|
-
toggle toggle radio radio upload upload lookup lookup progress progress image image icon icon
|
|
100
|
+
toggle toggle radio radio upload upload photo photo lookup lookup progress progress image image backdrop backdrop icon icon
|
|
101
|
+
video video audio audio
|
|
95
102
|
button button link link tile tile table table list list tabs tabs tab tab
|
|
96
103
|
toolbar toolbar breadcrumb breadcrumb tree tree screens screens screen screen rows rows entry entry
|
|
97
104
|
canvas canvas chart chart
|
|
@@ -126,11 +133,13 @@ roles: [primary accent danger success warning muted]
|
|
|
126
133
|
sizes: [small medium large]
|
|
127
134
|
aligns: [left center right spread]
|
|
128
135
|
valigns: [top middle bottom]
|
|
129
|
-
flags: [fill fit hidden disabled readonly inert narrow-only wide-only linked drag drop reorder multiple sortable stacked]
|
|
136
|
+
flags: [fill fit hidden disabled readonly inert narrow-only wide-only linked round drag drop reorder multiple sortable stacked]
|
|
130
137
|
chart-kinds: [bar line area pie]
|
|
131
138
|
simple-rules: [required email url integer]
|
|
132
139
|
letter: charset [#"a" - #"z" #"A" - #"Z"]
|
|
133
|
-
rule-words: [min max length pattern match check check-async calc width pad gap menu accept known links sorted]
|
|
140
|
+
rule-words: [min max length pattern match check check-async calc width pad gap menu accept known links sorted poster captions]
|
|
141
|
+
media-styles: [video audio]
|
|
142
|
+
media-flags: [loop muted autoplay] ; of a video or a sound
|
|
134
143
|
|
|
135
144
|
; Words that never name a field. email, url and integer are rules too,
|
|
136
145
|
; but also common field names, so the first word after an input style names it.
|
|
@@ -252,6 +261,12 @@ build-faces: function [
|
|
|
252
261
|
| 'length set a integer! set n integer! (add-rule f reduce ['length a n])
|
|
253
262
|
| 'pattern set b block! (add-rule f reduce ['pattern b])
|
|
254
263
|
| 'accept set b block! (f/accept: b)
|
|
264
|
+
| 'poster set v [file! | url!] (f/poster: v)
|
|
265
|
+
| 'captions set v [file! | url! | block!] (f/captions: v)
|
|
266
|
+
; muted names a role elsewhere, and loop a function, so a video keeps them in fields of its own
|
|
267
|
+
| set w word! if (all [find media-flags w find media-styles f/style]) (
|
|
268
|
+
poke f select [muted silent loop looping autoplay autoplay] w true
|
|
269
|
+
)
|
|
255
270
|
| 'known set v map! (f/known: v)
|
|
256
271
|
| 'links set v map! (f/links: v)
|
|
257
272
|
| 'match set w word! (add-rule f reduce ['match w])
|
|
@@ -305,10 +320,19 @@ spacing: func [n [integer!]] [
|
|
|
305
320
|
]
|
|
306
321
|
|
|
307
322
|
; [name "Name" email] -> [name "Name" email "email"]
|
|
308
|
-
|
|
323
|
+
; A column of images keeps what it is with its label: [photo "" image round] -> [photo ["" image round]]
|
|
324
|
+
columns-of: function [spec [block!] /local w label kind] [
|
|
309
325
|
out: copy []
|
|
310
|
-
unless parse spec [any [
|
|
311
|
-
|
|
326
|
+
unless parse spec [any [
|
|
327
|
+
set w word! (label: form w kind: none) opt [set label text-rule]
|
|
328
|
+
opt ['image (kind: copy [image]) opt ['round (append kind 'round)]]
|
|
329
|
+
(
|
|
330
|
+
label: text-of label
|
|
331
|
+
append out w
|
|
332
|
+
append/only out either kind [head insert/only kind label] [label]
|
|
333
|
+
)
|
|
334
|
+
]] [
|
|
335
|
+
do make error! "layout: table columns are words, each with an optional label, then image or image round"
|
|
312
336
|
]
|
|
313
337
|
out
|
|
314
338
|
]
|
|
@@ -877,6 +901,7 @@ validate-face: function [
|
|
|
877
901
|
]
|
|
878
902
|
if f/typed [
|
|
879
903
|
if f/style = 'upload [return message 'accept reduce [list-of f/accept]]
|
|
904
|
+
if f/style = 'photo [return either f/accept [message 'accept reduce [list-of f/accept]] [message 'images []]]
|
|
880
905
|
return message select [number number money amount date date] f/style []
|
|
881
906
|
]
|
|
882
907
|
if blank? :v [
|
|
@@ -1018,6 +1043,7 @@ changed: function [f] [
|
|
|
1018
1043
|
|
|
1019
1044
|
; An upload's value is none or a block of objects [name size type file];
|
|
1020
1045
|
; file is a handle the host keeps, read with read-file or sent with multipart.
|
|
1046
|
+
; A photo's is none, the object of the image chosen, or the address of one kept elsewhere.
|
|
1021
1047
|
ui-files: function [
|
|
1022
1048
|
"Called by the host when the user chooses or drops files: name size type file for each, and the names it refused."
|
|
1023
1049
|
f files [block!] refused [block!]
|
|
@@ -1026,7 +1052,11 @@ ui-files: function [
|
|
|
1026
1052
|
foreach [n s t h] files [keep make object! [name: n size: s type: t file: h]]
|
|
1027
1053
|
]
|
|
1028
1054
|
unless empty? chosen [
|
|
1029
|
-
f/value:
|
|
1055
|
+
f/value: case [
|
|
1056
|
+
f/style = 'photo [first chosen]
|
|
1057
|
+
f/multiple [append copy any [f/value []] chosen]
|
|
1058
|
+
true [copy/part chosen 1]
|
|
1059
|
+
]
|
|
1030
1060
|
]
|
|
1031
1061
|
f/typed: either empty? refused [none] [refused]
|
|
1032
1062
|
f/touched: true
|
|
@@ -1034,12 +1064,15 @@ ui-files: function [
|
|
|
1034
1064
|
]
|
|
1035
1065
|
|
|
1036
1066
|
ui-remove-file: function [
|
|
1037
|
-
"Called by the host when the user removes the file at a position of an upload."
|
|
1067
|
+
"Called by the host when the user removes the file at a position of an upload, or a photo's."
|
|
1038
1068
|
f index [integer!]
|
|
1039
1069
|
] [
|
|
1040
|
-
|
|
1041
|
-
|
|
1070
|
+
f/value: either f/style = 'photo [none] [
|
|
1071
|
+
files: remove at copy f/value index
|
|
1072
|
+
either empty? head files [none] [head files]
|
|
1073
|
+
]
|
|
1042
1074
|
f/typed: none
|
|
1075
|
+
f/touched: true
|
|
1043
1076
|
changed f
|
|
1044
1077
|
]
|
|
1045
1078
|
|