zuzu-js 0.1.0

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 (167) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +113 -0
  3. package/bin/zuzu +17 -0
  4. package/bin/zuzu-build-browser-bundle +57 -0
  5. package/bin/zuzu-generate-browser-stdlib +584 -0
  6. package/bin/zuzu-js +23 -0
  7. package/bin/zuzu-js-compile +152 -0
  8. package/bin/zuzu-js-electron +19 -0
  9. package/dist/zuzu-browser-worker.js +45574 -0
  10. package/dist/zuzu-browser.js +45362 -0
  11. package/lib/browser-bundle-entry.js +160 -0
  12. package/lib/browser-gui-renderer.js +387 -0
  13. package/lib/browser-runtime.js +167 -0
  14. package/lib/browser-worker-entry.js +413 -0
  15. package/lib/browser-ztests/runner.html +103 -0
  16. package/lib/browser-ztests/runner.js +369 -0
  17. package/lib/cli.js +350 -0
  18. package/lib/collections.js +367 -0
  19. package/lib/compiler.js +303 -0
  20. package/lib/electron/launcher.js +70 -0
  21. package/lib/electron/main.js +956 -0
  22. package/lib/electron/preload.js +80 -0
  23. package/lib/electron/renderer.html +122 -0
  24. package/lib/electron/renderer.js +24 -0
  25. package/lib/execution-metadata.js +18 -0
  26. package/lib/gui/dom-renderer.js +778 -0
  27. package/lib/host/browser-host.js +278 -0
  28. package/lib/host/capabilities.js +47 -0
  29. package/lib/host/electron-host.js +15 -0
  30. package/lib/host/node-host.js +74 -0
  31. package/lib/paths.js +150 -0
  32. package/lib/runtime-entrypoints.js +60 -0
  33. package/lib/runtime-helpers.js +886 -0
  34. package/lib/runtime.js +3529 -0
  35. package/lib/tap.js +37 -0
  36. package/lib/transpiler-new/ast.js +23 -0
  37. package/lib/transpiler-new/codegen.js +2455 -0
  38. package/lib/transpiler-new/errors.js +28 -0
  39. package/lib/transpiler-new/index.js +26 -0
  40. package/lib/transpiler-new/lexer.js +834 -0
  41. package/lib/transpiler-new/parser.js +2332 -0
  42. package/lib/transpiler-new/validate-bindings.js +326 -0
  43. package/lib/transpiler-utils.js +95 -0
  44. package/lib/transpiler.js +33 -0
  45. package/lib/zuzu.js +53 -0
  46. package/modules/javascript.js +193 -0
  47. package/modules/std/archive.js +603 -0
  48. package/modules/std/clib.js +338 -0
  49. package/modules/std/data/csv.js +1331 -0
  50. package/modules/std/data/json.js +531 -0
  51. package/modules/std/data/xml.js +441 -0
  52. package/modules/std/data/yaml.js +256 -0
  53. package/modules/std/db-worker.js +250 -0
  54. package/modules/std/db.js +664 -0
  55. package/modules/std/digest/_hash.js +443 -0
  56. package/modules/std/digest/md5.js +26 -0
  57. package/modules/std/digest/sha.js +72 -0
  58. package/modules/std/eval.js +10 -0
  59. package/modules/std/gui/objects.js +1519 -0
  60. package/modules/std/internals.js +571 -0
  61. package/modules/std/io/socks-worker.js +318 -0
  62. package/modules/std/io/socks.js +186 -0
  63. package/modules/std/io.js +475 -0
  64. package/modules/std/marshal/cbor.js +463 -0
  65. package/modules/std/marshal/graph.js +1624 -0
  66. package/modules/std/marshal.js +87 -0
  67. package/modules/std/math/bignum.js +91 -0
  68. package/modules/std/math.js +79 -0
  69. package/modules/std/net/dns.js +306 -0
  70. package/modules/std/net/http.js +820 -0
  71. package/modules/std/net/smtp.js +943 -0
  72. package/modules/std/net/url.js +109 -0
  73. package/modules/std/proc.js +602 -0
  74. package/modules/std/secure.js +3724 -0
  75. package/modules/std/string/base64.js +138 -0
  76. package/modules/std/string.js +299 -0
  77. package/modules/std/task.js +914 -0
  78. package/modules/std/time.js +579 -0
  79. package/modules/std/tui.js +188 -0
  80. package/modules/std/worker-thread.js +246 -0
  81. package/modules/std/worker.js +790 -0
  82. package/package.json +67 -0
  83. package/stdlib/modules/javascript.zzm +99 -0
  84. package/stdlib/modules/perl.zzm +105 -0
  85. package/stdlib/modules/std/archive.zzm +132 -0
  86. package/stdlib/modules/std/cache/lru.zzm +174 -0
  87. package/stdlib/modules/std/clib.zzm +112 -0
  88. package/stdlib/modules/std/colour.zzm +220 -0
  89. package/stdlib/modules/std/config.zzm +818 -0
  90. package/stdlib/modules/std/data/cbor.zzm +497 -0
  91. package/stdlib/modules/std/data/csv.zzm +285 -0
  92. package/stdlib/modules/std/data/ini.zzm +472 -0
  93. package/stdlib/modules/std/data/json/schema/core.zzm +573 -0
  94. package/stdlib/modules/std/data/json/schema/format.zzm +581 -0
  95. package/stdlib/modules/std/data/json/schema/model.zzm +255 -0
  96. package/stdlib/modules/std/data/json/schema/output.zzm +272 -0
  97. package/stdlib/modules/std/data/json/schema/relative_pointer.zzm +299 -0
  98. package/stdlib/modules/std/data/json/schema/validation.zzm +1503 -0
  99. package/stdlib/modules/std/data/json/schema.zzm +306 -0
  100. package/stdlib/modules/std/data/json.zzm +102 -0
  101. package/stdlib/modules/std/data/kdl/json.zzm +460 -0
  102. package/stdlib/modules/std/data/kdl/xml.zzm +387 -0
  103. package/stdlib/modules/std/data/kdl.zzm +1631 -0
  104. package/stdlib/modules/std/data/toml.zzm +756 -0
  105. package/stdlib/modules/std/data/toon.zzm +1017 -0
  106. package/stdlib/modules/std/data/xml/escape.zzm +156 -0
  107. package/stdlib/modules/std/data/xml.zzm +276 -0
  108. package/stdlib/modules/std/data/yaml.zzm +94 -0
  109. package/stdlib/modules/std/db.zzm +173 -0
  110. package/stdlib/modules/std/defer.zzm +75 -0
  111. package/stdlib/modules/std/digest/crc32.zzm +196 -0
  112. package/stdlib/modules/std/digest/md5.zzm +54 -0
  113. package/stdlib/modules/std/digest/sha.zzm +83 -0
  114. package/stdlib/modules/std/dump.zzm +317 -0
  115. package/stdlib/modules/std/eval.zzm +63 -0
  116. package/stdlib/modules/std/getopt.zzm +432 -0
  117. package/stdlib/modules/std/gui/dialogue.zzm +592 -0
  118. package/stdlib/modules/std/gui/objects.zzm +123 -0
  119. package/stdlib/modules/std/gui.zzm +1914 -0
  120. package/stdlib/modules/std/internals.zzm +139 -0
  121. package/stdlib/modules/std/io/socks.zzm +139 -0
  122. package/stdlib/modules/std/io.zzm +157 -0
  123. package/stdlib/modules/std/lingua/en.zzm +347 -0
  124. package/stdlib/modules/std/log.zzm +169 -0
  125. package/stdlib/modules/std/mail.zzm +2726 -0
  126. package/stdlib/modules/std/marshal.zzm +138 -0
  127. package/stdlib/modules/std/math/bignum.zzm +98 -0
  128. package/stdlib/modules/std/math/range.zzm +116 -0
  129. package/stdlib/modules/std/math/roman.zzm +156 -0
  130. package/stdlib/modules/std/math.zzm +141 -0
  131. package/stdlib/modules/std/net/dns.zzm +93 -0
  132. package/stdlib/modules/std/net/http.zzm +278 -0
  133. package/stdlib/modules/std/net/smtp.zzm +257 -0
  134. package/stdlib/modules/std/net/url.zzm +69 -0
  135. package/stdlib/modules/std/path/jsonpointer.zzm +526 -0
  136. package/stdlib/modules/std/path/kdl.zzm +1003 -0
  137. package/stdlib/modules/std/path/simple.zzm +520 -0
  138. package/stdlib/modules/std/path/z/context.zzm +147 -0
  139. package/stdlib/modules/std/path/z/evaluate.zzm +549 -0
  140. package/stdlib/modules/std/path/z/functions.zzm +874 -0
  141. package/stdlib/modules/std/path/z/lexer.zzm +490 -0
  142. package/stdlib/modules/std/path/z/node.zzm +1455 -0
  143. package/stdlib/modules/std/path/z/operators.zzm +445 -0
  144. package/stdlib/modules/std/path/z/parser.zzm +359 -0
  145. package/stdlib/modules/std/path/z.zzm +403 -0
  146. package/stdlib/modules/std/path/zz/functions.zzm +828 -0
  147. package/stdlib/modules/std/path/zz/operators.zzm +1036 -0
  148. package/stdlib/modules/std/path/zz.zzm +100 -0
  149. package/stdlib/modules/std/proc.zzm +155 -0
  150. package/stdlib/modules/std/result.zzm +149 -0
  151. package/stdlib/modules/std/secure.zzm +606 -0
  152. package/stdlib/modules/std/string/base64.zzm +66 -0
  153. package/stdlib/modules/std/string/quoted_printable.zzm +485 -0
  154. package/stdlib/modules/std/string.zzm +179 -0
  155. package/stdlib/modules/std/task.zzm +221 -0
  156. package/stdlib/modules/std/template/z.zzm +531 -0
  157. package/stdlib/modules/std/template/zz.zzm +62 -0
  158. package/stdlib/modules/std/time.zzm +188 -0
  159. package/stdlib/modules/std/tui.zzm +89 -0
  160. package/stdlib/modules/std/uuid.zzm +223 -0
  161. package/stdlib/modules/std/web/session.zzm +388 -0
  162. package/stdlib/modules/std/web/static.zzm +329 -0
  163. package/stdlib/modules/std/web.zzm +1942 -0
  164. package/stdlib/modules/std/worker.zzm +202 -0
  165. package/stdlib/modules/std/zuzuzoo.zzm +3960 -0
  166. package/stdlib/modules/test/more.zzm +528 -0
  167. package/stdlib/modules/test/parser.zzm +209 -0
@@ -0,0 +1,220 @@
1
+ =encoding utf8
2
+
3
+ =head1 NAME
4
+
5
+ std/colour - Colour parsing helpers.
6
+
7
+ =head1 SYNOPSIS
8
+
9
+ from std/colour import parse_colour;
10
+
11
+ say( parse_colour("red") ); # #ff0000
12
+ say( parse_colour("#abc") ); # #aabbcc
13
+
14
+ =head1 IMPLEMENTATION SUPPORT
15
+
16
+ This module is supported by all implementations of ZuzuScript.
17
+
18
+ =head1 DESCRIPTION
19
+
20
+ C<parse_colour> accepts three- and six-digit hexadecimal colours and the
21
+ CSS3 extended colour keywords. It returns a lowercase six-digit
22
+ hexadecimal colour string.
23
+
24
+ =head1 EXPORTS
25
+
26
+ =head2 Functions
27
+
28
+ =over
29
+
30
+ =item C<< parse_colour(String x) >>
31
+
32
+ Parameters: C<x> is a CSS colour keyword or a three- or six-digit
33
+ hexadecimal colour string. Returns: C<String>. Returns the normalized
34
+ lowercase C<#rrggbb> colour string, or throws if C<x> is not recognised.
35
+
36
+ =back
37
+
38
+ =head1 COPYRIGHT AND LICENCE
39
+
40
+ B<< std/colour >> is copyright Toby Inkster.
41
+
42
+ It is free software; you may redistribute it and/or modify it under
43
+ the terms of either the Artistic License 1.0 or the GNU General Public
44
+ License version 2.
45
+
46
+ =cut
47
+
48
+ from std/string import trim;
49
+
50
+ const _COLOUR_KEYWORDS := {
51
+ aliceblue: "#f0f8ff",
52
+ antiquewhite: "#faebd7",
53
+ aqua: "#00ffff",
54
+ aquamarine: "#7fffd4",
55
+ azure: "#f0ffff",
56
+ beige: "#f5f5dc",
57
+ bisque: "#ffe4c4",
58
+ black: "#000000",
59
+ blanchedalmond: "#ffebcd",
60
+ blue: "#0000ff",
61
+ blueviolet: "#8a2be2",
62
+ brown: "#a52a2a",
63
+ burlywood: "#deb887",
64
+ cadetblue: "#5f9ea0",
65
+ chartreuse: "#7fff00",
66
+ chocolate: "#d2691e",
67
+ coral: "#ff7f50",
68
+ cornflowerblue: "#6495ed",
69
+ cornsilk: "#fff8dc",
70
+ crimson: "#dc143c",
71
+ cyan: "#00ffff",
72
+ darkblue: "#00008b",
73
+ darkcyan: "#008b8b",
74
+ darkgoldenrod: "#b8860b",
75
+ darkgray: "#a9a9a9",
76
+ darkgreen: "#006400",
77
+ darkgrey: "#a9a9a9",
78
+ darkkhaki: "#bdb76b",
79
+ darkmagenta: "#8b008b",
80
+ darkolivegreen: "#556b2f",
81
+ darkorange: "#ff8c00",
82
+ darkorchid: "#9932cc",
83
+ darkred: "#8b0000",
84
+ darksalmon: "#e9967a",
85
+ darkseagreen: "#8fbc8f",
86
+ darkslateblue: "#483d8b",
87
+ darkslategray: "#2f4f4f",
88
+ darkslategrey: "#2f4f4f",
89
+ darkturquoise: "#00ced1",
90
+ darkviolet: "#9400d3",
91
+ deeppink: "#ff1493",
92
+ deepskyblue: "#00bfff",
93
+ dimgray: "#696969",
94
+ dimgrey: "#696969",
95
+ dodgerblue: "#1e90ff",
96
+ firebrick: "#b22222",
97
+ floralwhite: "#fffaf0",
98
+ forestgreen: "#228b22",
99
+ fuchsia: "#ff00ff",
100
+ gainsboro: "#dcdcdc",
101
+ ghostwhite: "#f8f8ff",
102
+ gold: "#ffd700",
103
+ goldenrod: "#daa520",
104
+ gray: "#808080",
105
+ green: "#008000",
106
+ greenyellow: "#adff2f",
107
+ grey: "#808080",
108
+ honeydew: "#f0fff0",
109
+ hotpink: "#ff69b4",
110
+ indianred: "#cd5c5c",
111
+ indigo: "#4b0082",
112
+ ivory: "#fffff0",
113
+ khaki: "#f0e68c",
114
+ lavender: "#e6e6fa",
115
+ lavenderblush: "#fff0f5",
116
+ lawngreen: "#7cfc00",
117
+ lemonchiffon: "#fffacd",
118
+ lightblue: "#add8e6",
119
+ lightcoral: "#f08080",
120
+ lightcyan: "#e0ffff",
121
+ lightgoldenrodyellow: "#fafad2",
122
+ lightgray: "#d3d3d3",
123
+ lightgreen: "#90ee90",
124
+ lightgrey: "#d3d3d3",
125
+ lightpink: "#ffb6c1",
126
+ lightsalmon: "#ffa07a",
127
+ lightseagreen: "#20b2aa",
128
+ lightskyblue: "#87cefa",
129
+ lightslategray: "#778899",
130
+ lightslategrey: "#778899",
131
+ lightsteelblue: "#b0c4de",
132
+ lightyellow: "#ffffe0",
133
+ lime: "#00ff00",
134
+ limegreen: "#32cd32",
135
+ linen: "#faf0e6",
136
+ magenta: "#ff00ff",
137
+ maroon: "#800000",
138
+ mediumaquamarine: "#66cdaa",
139
+ mediumblue: "#0000cd",
140
+ mediumorchid: "#ba55d3",
141
+ mediumpurple: "#9370db",
142
+ mediumseagreen: "#3cb371",
143
+ mediumslateblue: "#7b68ee",
144
+ mediumspringgreen: "#00fa9a",
145
+ mediumturquoise: "#48d1cc",
146
+ mediumvioletred: "#c71585",
147
+ midnightblue: "#191970",
148
+ mintcream: "#f5fffa",
149
+ mistyrose: "#ffe4e1",
150
+ moccasin: "#ffe4b5",
151
+ navajowhite: "#ffdead",
152
+ navy: "#000080",
153
+ oldlace: "#fdf5e6",
154
+ olive: "#808000",
155
+ olivedrab: "#6b8e23",
156
+ orange: "#ffa500",
157
+ orangered: "#ff4500",
158
+ orchid: "#da70d6",
159
+ palegoldenrod: "#eee8aa",
160
+ palegreen: "#98fb98",
161
+ paleturquoise: "#afeeee",
162
+ palevioletred: "#db7093",
163
+ papayawhip: "#ffefd5",
164
+ peachpuff: "#ffdab9",
165
+ peru: "#cd853f",
166
+ pink: "#ffc0cb",
167
+ plum: "#dda0dd",
168
+ powderblue: "#b0e0e6",
169
+ purple: "#800080",
170
+ red: "#ff0000",
171
+ rosybrown: "#bc8f8f",
172
+ royalblue: "#4169e1",
173
+ saddlebrown: "#8b4513",
174
+ salmon: "#fa8072",
175
+ sandybrown: "#f4a460",
176
+ seagreen: "#2e8b57",
177
+ seashell: "#fff5ee",
178
+ sienna: "#a0522d",
179
+ silver: "#c0c0c0",
180
+ skyblue: "#87ceeb",
181
+ slateblue: "#6a5acd",
182
+ slategray: "#708090",
183
+ slategrey: "#708090",
184
+ snow: "#fffafa",
185
+ springgreen: "#00ff7f",
186
+ steelblue: "#4682b4",
187
+ tan: "#d2b48c",
188
+ teal: "#008080",
189
+ thistle: "#d8bfd8",
190
+ tomato: "#ff6347",
191
+ turquoise: "#40e0d0",
192
+ violet: "#ee82ee",
193
+ wheat: "#f5deb3",
194
+ white: "#ffffff",
195
+ whitesmoke: "#f5f5f5",
196
+ yellow: "#ffff00",
197
+ yellowgreen: "#9acd32",
198
+ };
199
+
200
+ function parse_colour ( String x ) {
201
+ let text := lc( trim(x) );
202
+
203
+ if ( text ~ /^#[0-9a-f]{6}$/ ) {
204
+ return text;
205
+ }
206
+
207
+ let short := text ~ /^#([0-9a-f])([0-9a-f])([0-9a-f])$/;
208
+ if ( short ) {
209
+ return "#"
210
+ _ short[1] _ short[1]
211
+ _ short[2] _ short[2]
212
+ _ short[3] _ short[3];
213
+ }
214
+
215
+ if ( _COLOUR_KEYWORDS.exists(text) ) {
216
+ return _COLOUR_KEYWORDS.get(text);
217
+ }
218
+
219
+ die `Invalid colour: ${x}`;
220
+ }