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.
Files changed (106) hide show
  1. package/README.md +8 -2
  2. package/dist/cli.js +55 -20
  3. package/dist/lib/core/access.d.ts +10 -0
  4. package/dist/lib/core/access.js +210 -0
  5. package/dist/lib/core/base.d.ts +4 -0
  6. package/dist/lib/core/base.js +50 -0
  7. package/dist/lib/core/bitset.d.ts +9 -0
  8. package/dist/lib/core/bitset.js +75 -0
  9. package/dist/lib/core/boot.d.ts +18 -0
  10. package/dist/lib/core/boot.js +72 -0
  11. package/dist/lib/core/compare.d.ts +9 -0
  12. package/dist/lib/core/compare.js +156 -0
  13. package/dist/lib/core/ctx.d.ts +36 -0
  14. package/dist/lib/core/ctx.js +251 -0
  15. package/dist/lib/core/dec.d.ts +28 -0
  16. package/dist/lib/core/dec.js +158 -0
  17. package/dist/lib/core/errors.d.ts +15 -0
  18. package/dist/lib/core/errors.js +44 -0
  19. package/dist/lib/core/escapes.d.ts +14 -0
  20. package/dist/lib/core/escapes.js +80 -0
  21. package/dist/lib/core/eval.d.ts +220 -0
  22. package/dist/lib/core/eval.js +666 -0
  23. package/dist/lib/core/func.d.ts +64 -0
  24. package/dist/lib/core/func.js +129 -0
  25. package/dist/lib/core/hash.d.ts +5 -0
  26. package/dist/lib/core/hash.js +155 -0
  27. package/dist/lib/core/index.d.ts +18 -0
  28. package/dist/lib/core/index.js +20 -0
  29. package/dist/lib/core/int64.d.ts +22 -0
  30. package/dist/lib/core/int64.js +113 -0
  31. package/dist/lib/core/kinds.d.ts +67 -0
  32. package/dist/lib/core/kinds.js +134 -0
  33. package/dist/lib/core/lexer.d.ts +13 -0
  34. package/dist/lib/core/lexer.js +702 -0
  35. package/dist/lib/core/mezz.d.ts +1 -0
  36. package/dist/lib/core/mezz.js +360 -0
  37. package/dist/lib/core/mold.d.ts +20 -0
  38. package/dist/lib/core/mold.js +434 -0
  39. package/dist/lib/core/natives/control.d.ts +1 -0
  40. package/dist/lib/core/natives/control.js +374 -0
  41. package/dist/lib/core/natives/csv.d.ts +15 -0
  42. package/dist/lib/core/natives/csv.js +315 -0
  43. package/dist/lib/core/natives/data.d.ts +11 -0
  44. package/dist/lib/core/natives/data.js +367 -0
  45. package/dist/lib/core/natives/define.d.ts +17 -0
  46. package/dist/lib/core/natives/define.js +47 -0
  47. package/dist/lib/core/natives/encode.d.ts +3 -0
  48. package/dist/lib/core/natives/encode.js +187 -0
  49. package/dist/lib/core/natives/json.d.ts +5 -0
  50. package/dist/lib/core/natives/json.js +273 -0
  51. package/dist/lib/core/natives/math.d.ts +3 -0
  52. package/dist/lib/core/natives/math.js +500 -0
  53. package/dist/lib/core/natives/parse.d.ts +1 -0
  54. package/dist/lib/core/natives/parse.js +600 -0
  55. package/dist/lib/core/natives/series.d.ts +4 -0
  56. package/dist/lib/core/natives/series.js +509 -0
  57. package/dist/lib/core/natives/text.d.ts +1 -0
  58. package/dist/lib/core/natives/text.js +484 -0
  59. package/dist/lib/core/natives/xml.d.ts +9 -0
  60. package/dist/lib/core/natives/xml.js +242 -0
  61. package/dist/lib/core/series.d.ts +26 -0
  62. package/dist/lib/core/series.js +73 -0
  63. package/dist/lib/core/symbols.d.ts +9 -0
  64. package/dist/lib/core/symbols.js +44 -0
  65. package/dist/lib/core/values.d.ts +206 -0
  66. package/dist/lib/core/values.js +223 -0
  67. package/dist/lib/host/browser.d.ts +4 -0
  68. package/dist/lib/host/browser.js +4081 -0
  69. package/dist/lib/host/chart.d.ts +26 -0
  70. package/dist/lib/host/chart.js +158 -0
  71. package/dist/lib/host/compress.d.ts +1 -0
  72. package/dist/lib/host/compress.js +37 -0
  73. package/dist/lib/host/draw.d.ts +31 -0
  74. package/dist/lib/host/draw.js +348 -0
  75. package/dist/lib/host/icons.d.ts +3 -0
  76. package/dist/lib/host/icons.js +97 -0
  77. package/dist/lib/host/index.d.ts +38 -0
  78. package/dist/lib/host/index.js +190 -0
  79. package/dist/lib/host/locale.d.ts +40 -0
  80. package/dist/lib/host/locale.js +241 -0
  81. package/dist/lib/host/markdown.d.ts +28 -0
  82. package/dist/lib/host/markdown.js +151 -0
  83. package/dist/lib/host/modules.d.ts +10 -0
  84. package/dist/lib/host/modules.js +262 -0
  85. package/dist/lib/host/natives.d.ts +6 -0
  86. package/dist/lib/host/natives.js +98 -0
  87. package/dist/lib/host/net.d.ts +12 -0
  88. package/dist/lib/host/net.js +541 -0
  89. package/dist/lib/host/page.d.ts +9 -0
  90. package/dist/lib/host/page.js +55 -0
  91. package/dist/lib/host/rows.d.ts +15 -0
  92. package/dist/lib/host/rows.js +80 -0
  93. package/dist/lib/host/scheduler.d.ts +45 -0
  94. package/dist/lib/host/scheduler.js +173 -0
  95. package/dist/lib/host/theme.d.ts +58 -0
  96. package/dist/lib/host/theme.js +1462 -0
  97. package/dist/lib/ui/i18n.trb +111 -0
  98. package/dist/lib/ui/ui.trb +1237 -0
  99. package/dist/trebol.js +123 -56
  100. package/package.json +17 -5
  101. package/src/host/browser.ts +274 -33
  102. package/src/host/index.ts +2 -2
  103. package/src/host/modules.ts +8 -1
  104. package/src/host/theme.ts +63 -4
  105. package/src/ui/i18n.trb +4 -0
  106. 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
- columns-of: function [spec [block!]] [
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 [set w word! (label: form w) opt [set label text-rule] (append out reduce [w text-of label])]] [
311
- do make error! "layout: table columns are words, each with an optional label"
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: either f/multiple [append copy any [f/value []] chosen] [copy/part chosen 1]
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
- files: remove at copy f/value index
1041
- f/value: either empty? head files [none] [head files]
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