firefly-compiler 0.5.49 → 0.5.51

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 (132) hide show
  1. package/bin/Release.ff +3 -3
  2. package/bin/firefly.mjs +1 -1
  3. package/compiler/Builder.ff +11 -5
  4. package/compiler/Compiler.ff +14 -3
  5. package/compiler/JsEmitter.ff +6 -11
  6. package/compiler/Main.ff +10 -15
  7. package/compiler/ModuleCache.ff +2 -1
  8. package/core/Buffer.ff +26 -4
  9. package/core/BuildSystem.ff +49 -46
  10. package/core/JsValue.ff +5 -0
  11. package/experimental/date/Date.ff +604 -0
  12. package/experimental/date/Main.ff +51 -0
  13. package/experimental/random/AsciiBuffer.ff +15 -0
  14. package/experimental/rhymeapp/Main.ff +2 -3
  15. package/experimental/site/Main.ff +2 -2
  16. package/experimental/site2/Main.ff +2 -2
  17. package/firefly.sh +1 -1
  18. package/fireflysite/CommunityOverview.ff +3 -3
  19. package/fireflysite/CountingButtonDemo.ff +3 -3
  20. package/fireflysite/ExamplesOverview.ff +3 -12
  21. package/fireflysite/FrontPage.ff +3 -3
  22. package/fireflysite/GettingStarted.ff +3 -3
  23. package/fireflysite/Guide.ff +7 -187
  24. package/fireflysite/Html.ff +66 -0
  25. package/fireflysite/Main.ff +13 -77
  26. package/fireflysite/MatchingPasswordsDemo.ff +3 -3
  27. package/fireflysite/Menu.ff +59 -0
  28. package/fireflysite/PackagesOverview.ff +3 -3
  29. package/fireflysite/PostgresqlDemo.ff +3 -3
  30. package/fireflysite/RouteFront.ff +30 -0
  31. package/fireflysite/RouteNonMarkdown.ff +48 -0
  32. package/fireflysite/RouteReference.ff +40 -0
  33. package/fireflysite/Router.ff +33 -0
  34. package/fireflysite/Website.ff +133 -0
  35. package/fireflysite/assets/markdown/reference/{FunctionsAndMethods.md → functions-and-methods.md} +1 -1
  36. package/fireflysite/assets/markdown/reference/{StatementsAndExpressions.md → statements-and-expressions.md} +0 -1
  37. package/fireflysite/assets/markdown/reference/{StructuredConcurrency.md → structured-concurrency.md} +0 -1
  38. package/fireflysite/assets/markdown/reference.md +3 -0
  39. package/graph/.firefly/package.ff +1 -0
  40. package/graph/Graph.ff +79 -0
  41. package/lsp/CompletionHandler.ff +2 -2
  42. package/lux/CssTest.ff +2 -2
  43. package/lux/Main.ff +2 -2
  44. package/lux/Main2.ff +2 -2
  45. package/output/js/ff/compiler/Builder.mjs +44 -12
  46. package/output/js/ff/compiler/Compiler.mjs +28 -10
  47. package/output/js/ff/compiler/Dependencies.mjs +0 -2
  48. package/output/js/ff/compiler/DependencyLock.mjs +0 -2
  49. package/output/js/ff/compiler/Deriver.mjs +0 -2
  50. package/output/js/ff/compiler/Dictionaries.mjs +0 -2
  51. package/output/js/ff/compiler/Environment.mjs +0 -2
  52. package/output/js/ff/compiler/Inference.mjs +0 -2
  53. package/output/js/ff/compiler/JsEmitter.mjs +12 -30
  54. package/output/js/ff/compiler/JsImporter.mjs +0 -2
  55. package/output/js/ff/compiler/LspHook.mjs +0 -2
  56. package/output/js/ff/compiler/Main.mjs +24 -47
  57. package/output/js/ff/compiler/Main.run.mjs +25 -0
  58. package/output/js/ff/compiler/ModuleCache.mjs +4 -6
  59. package/output/js/ff/compiler/Parser.mjs +0 -2
  60. package/output/js/ff/compiler/Patterns.mjs +0 -2
  61. package/output/js/ff/compiler/Resolver.mjs +0 -2
  62. package/output/js/ff/compiler/Substitution.mjs +0 -2
  63. package/output/js/ff/compiler/Syntax.mjs +0 -2
  64. package/output/js/ff/compiler/Token.mjs +0 -2
  65. package/output/js/ff/compiler/Tokenizer.mjs +0 -2
  66. package/output/js/ff/compiler/Unification.mjs +0 -2
  67. package/output/js/ff/compiler/Wildcards.mjs +0 -2
  68. package/output/js/ff/compiler/Workspace.mjs +0 -2
  69. package/output/js/ff/core/Any.mjs +0 -2
  70. package/output/js/ff/core/Array.mjs +0 -2
  71. package/output/js/ff/core/AssetSystem.mjs +0 -2
  72. package/output/js/ff/core/Atomic.mjs +0 -2
  73. package/output/js/ff/core/Bool.mjs +0 -2
  74. package/output/js/ff/core/BrowserSystem.mjs +0 -2
  75. package/output/js/ff/core/Buffer.mjs +50 -10
  76. package/output/js/ff/core/BuildSystem.mjs +92 -72
  77. package/output/js/ff/core/Channel.mjs +0 -2
  78. package/output/js/ff/core/Char.mjs +0 -2
  79. package/output/js/ff/core/Core.mjs +0 -2
  80. package/output/js/ff/core/Crypto.mjs +0 -2
  81. package/output/js/ff/core/Date.mjs +0 -2
  82. package/output/js/ff/core/Duration.mjs +0 -2
  83. package/output/js/ff/core/Equal.mjs +0 -2
  84. package/output/js/ff/core/Error.mjs +0 -2
  85. package/output/js/ff/core/FileHandle.mjs +0 -2
  86. package/output/js/ff/core/Float.mjs +0 -2
  87. package/output/js/ff/core/HttpClient.mjs +0 -2
  88. package/output/js/ff/core/Int.mjs +0 -2
  89. package/output/js/ff/core/IntMap.mjs +0 -2
  90. package/output/js/ff/core/Js.mjs +0 -2
  91. package/output/js/ff/core/JsSystem.mjs +0 -2
  92. package/output/js/ff/core/JsValue.mjs +8 -2
  93. package/output/js/ff/core/Json.mjs +0 -2
  94. package/output/js/ff/core/List.mjs +0 -2
  95. package/output/js/ff/core/Lock.mjs +0 -2
  96. package/output/js/ff/core/Log.mjs +0 -2
  97. package/output/js/ff/core/Map.mjs +0 -2
  98. package/output/js/ff/core/NodeSystem.mjs +0 -2
  99. package/output/js/ff/core/Nothing.mjs +0 -2
  100. package/output/js/ff/core/Option.mjs +0 -2
  101. package/output/js/ff/core/Ordering.mjs +0 -2
  102. package/output/js/ff/core/Pair.mjs +0 -2
  103. package/output/js/ff/core/Path.mjs +0 -2
  104. package/output/js/ff/core/Queue.mjs +0 -2
  105. package/output/js/ff/core/Random.mjs +0 -2
  106. package/output/js/ff/core/RbMap.mjs +0 -2
  107. package/output/js/ff/core/Serializable.mjs +0 -2
  108. package/output/js/ff/core/Set.mjs +0 -2
  109. package/output/js/ff/core/Show.mjs +0 -2
  110. package/output/js/ff/core/SourceLocation.mjs +0 -2
  111. package/output/js/ff/core/Stream.mjs +0 -2
  112. package/output/js/ff/core/String.mjs +0 -2
  113. package/output/js/ff/core/StringMap.mjs +0 -2
  114. package/output/js/ff/core/Task.mjs +0 -2
  115. package/output/js/ff/core/Try.mjs +0 -2
  116. package/output/js/ff/core/Unit.mjs +0 -2
  117. package/package.json +1 -1
  118. package/vscode/client/src/extension.ts +1 -1
  119. package/vscode/package.json +1 -1
  120. package/vscode/snippets.json +2 -2
  121. package/webserver/WebRoute.ff +51 -14
  122. package/fireflysite/ReferenceAll.ff +0 -18
  123. /package/fireflysite/assets/markdown/reference/{BaseTypes.md → base-types.md} +0 -0
  124. /package/fireflysite/assets/markdown/reference/{EmittedJavascript.md → emitted-javascript.md} +0 -0
  125. /package/fireflysite/assets/markdown/reference/{Exceptions.md → exceptions.md} +0 -0
  126. /package/fireflysite/assets/markdown/reference/{JavascriptInterop.md → javascript-interop.md} +0 -0
  127. /package/fireflysite/assets/markdown/reference/{ModulesAndPackages.md → modules-and-packages.md} +0 -0
  128. /package/fireflysite/assets/markdown/reference/{PatternMatching.md → pattern-matching.md} +0 -0
  129. /package/fireflysite/assets/markdown/reference/{TraitsAndInstances.md → traits-and-instances.md} +0 -0
  130. /package/fireflysite/assets/markdown/reference/{UserDefinedTypes.md → user-defined-types.md} +0 -0
  131. /package/fireflysite/assets/markdown/scratch/{ControlFlow.md → control-flow.md} +0 -0
  132. /package/fireflysite/assets/markdown/{reference/OldStructuredConcurrency.md → scratch/old-structured-concurrency.md} +0 -0
@@ -0,0 +1,604 @@
1
+ // Temporal.ZonedDateTime but with consistent equals/compare
2
+ newtype Date(jsValue: JsValue)
3
+
4
+ data DateGap(
5
+ years: Int = 0
6
+ months: Int = 0
7
+ weeks: Int = 0
8
+ days: Int = 0
9
+ hours: Int = 0
10
+ minutes: Int = 0
11
+ seconds: Int = 0
12
+ milliseconds: Int = 0
13
+ microseconds: Int = 0
14
+ nanoseconds: Int = 0
15
+ )
16
+
17
+ new(
18
+ timeZoneId: String
19
+ year: Int
20
+ month: Int
21
+ day: Int
22
+ hour: Int = 0
23
+ minute: Int = 0
24
+ second: Int = 0
25
+ millisecond: Int = 0
26
+ microsecond: Int = 0
27
+ nanosecond: Int = 0
28
+ calendarId: String = "iso8601"
29
+ offset: Option[String] = None
30
+ earlier: Bool = True
31
+ later: Bool = True
32
+ ): Date {
33
+ Date(Js->Temporal->ZonedDateTime->from(Js->(
34
+ timeZone = timeZoneId
35
+ year = year
36
+ month = month
37
+ day = day
38
+ hour = hour
39
+ minute = minute
40
+ second = second
41
+ millisecond = millisecond
42
+ microsecond = microsecond
43
+ nanosecond = nanosecond
44
+ calendar = calendarId
45
+ offset = offset.map {_!}.else {Js.undefined()}
46
+ ), internalDisambiguation(earlier, later)))
47
+ }
48
+
49
+ newEra(
50
+ calendarId: String
51
+ timeZoneId: String
52
+ era: String
53
+ eraYear: Int
54
+ month: Int
55
+ day: Int
56
+ hour: Int = 0
57
+ minute: Int = 0
58
+ second: Int = 0
59
+ millisecond: Int = 0
60
+ microsecond: Int = 0
61
+ nanosecond: Int = 0
62
+ offset: Option[String] = None
63
+ earlier: Bool = True
64
+ later: Bool = True
65
+ ): Date {
66
+ Date(Js->Temporal->ZonedDateTime->from(Js->(
67
+ timeZone = timeZoneId
68
+ era = era
69
+ eraYear = eraYear
70
+ month = month
71
+ day = day
72
+ hour = hour
73
+ minute = minute
74
+ second = second
75
+ millisecond = millisecond
76
+ microsecond = microsecond
77
+ nanosecond = nanosecond
78
+ calendar = calendarId
79
+ offset = offset.map {_!}.else {Js.undefined()}
80
+ ), internalDisambiguation(earlier, later)))
81
+ }
82
+
83
+ newEpochMilliseconds(timeZoneId: String, epochMilliseconds: Int, calendarId: String = "iso8601"): Date {
84
+ let zoned = Js->Temporal->Instant->fromEpochMilliseconds(epochMilliseconds)->toZonedDateTimeISO(timeZoneId)
85
+ if(calendarId != "iso8601") {Date(zoned->withCalendar(calendarId))} else {Date(zoned)}
86
+ }
87
+
88
+ newRfc9557(rfc9557: String): Date {
89
+ Date(Js->Temporal->ZonedDateTime->from(rfc9557))
90
+ }
91
+
92
+ gap(iso8601: String): DateGap {
93
+ let duration = Js->Temporal->Duration->from(iso8601)
94
+ DateGap(
95
+ years = duration->years?
96
+ months = duration->months?
97
+ weeks = duration->weeks?
98
+ days = duration->days?
99
+ hours = duration->hours?
100
+ minutes = duration->minutes?
101
+ seconds = duration->seconds?
102
+ milliseconds = duration->milliseconds?
103
+ microseconds = duration->microseconds?
104
+ nanoseconds = duration->nanoseconds?
105
+ )
106
+ }
107
+
108
+ instance Date: Equal {
109
+ equals(x: Date, y: Date): Bool {
110
+ x.jsValue->equals(y.jsValue)?
111
+ }
112
+ }
113
+
114
+ instance Date: Order {
115
+ compare(x: Date, y: Date): Ordering {
116
+ let instant: Int = Js->Temporal->ZonedDateTime->compare(x.jsValue, y.jsValue)?
117
+ if(instant != 0) {Ordering.fromInt(instant)} else:
118
+ let timeZone = Ordering.compare(x.timeZoneId(), y.timeZoneId())
119
+ if(timeZone != OrderingSame) {timeZone} else:
120
+ Ordering.compare(x.calendarId(), y.calendarId())
121
+ }
122
+ }
123
+
124
+ instance Date: HasAnyTag {
125
+ anyTag(): AnyTag[Date] {
126
+ Any.internalAnyTag("ff:core/Date.Date[]")
127
+ }
128
+ }
129
+
130
+ instance Date: Show {
131
+ show(value: Date): String {
132
+ value.toRfc9557()
133
+ }
134
+ }
135
+
136
+ instance Date: Serializable {
137
+
138
+ serializeUsing(serialization: Serialization, value: Date): Unit {
139
+ Serializable.serializeUsing(serialization, value.toRfc9557())
140
+ }
141
+
142
+ deserializeUsing(serialization: Serialization): Date {
143
+ newRfc9557(Serializable.deserializeUsing(serialization))
144
+ }
145
+
146
+ }
147
+
148
+ extend self: Date {
149
+
150
+ timeZoneId(): String {
151
+ self.jsValue->timeZoneId?
152
+ }
153
+
154
+ calendarId(): String {
155
+ self.jsValue->calendarId?
156
+ }
157
+
158
+ day(): Int {
159
+ self.jsValue->day?
160
+ }
161
+
162
+ dayOfWeek(): Int {
163
+ self.jsValue->dayOfWeek?
164
+ }
165
+
166
+ dayOfYear(): Int {
167
+ self.jsValue->dayOfYear?
168
+ }
169
+
170
+ daysInWeek(): Int {
171
+ self.jsValue->daysInWeek?
172
+ }
173
+
174
+ daysInMonth(): Int {
175
+ self.jsValue->daysInMonth?
176
+ }
177
+
178
+ daysInYear(): Int {
179
+ self.jsValue->daysInYear?
180
+ }
181
+
182
+ epochMilliseconds(): Int {
183
+ self.jsValue->epochMilliseconds?
184
+ }
185
+
186
+ era(): Option[String] {
187
+ let era = self.jsValue->era
188
+ if(!era.isNullOrUndefined()) {era?}
189
+ }
190
+
191
+ eraYear(): Option[Int] {
192
+ let eraYear = self.jsValue->eraYear
193
+ if(!eraYear.isNullOrUndefined()) {eraYear?}
194
+ }
195
+
196
+ hour(): Int {
197
+ self.jsValue->hour?
198
+ }
199
+
200
+ hoursInDay(): Int {
201
+ self.jsValue->hoursInDay?
202
+ }
203
+
204
+ inLeapYear(): Bool {
205
+ self.jsValue->inLeapYear?
206
+ }
207
+
208
+ microsecond(): Int {
209
+ self.jsValue->microsecond?
210
+ }
211
+
212
+ millisecond(): Int {
213
+ self.jsValue->millisecond?
214
+ }
215
+
216
+ minute(): Int {
217
+ self.jsValue->minute?
218
+ }
219
+
220
+ month(): Int {
221
+ self.jsValue->month?
222
+ }
223
+
224
+ monthCode(): String {
225
+ self.jsValue->monthCode?
226
+ }
227
+
228
+ monthsInYear(): Int {
229
+ self.jsValue->monthsInYear?
230
+ }
231
+
232
+ nanosecond(): Int {
233
+ self.jsValue->nanosecond?
234
+ }
235
+
236
+ offset(): String {
237
+ self.jsValue->offset?
238
+ }
239
+
240
+ offsetNanoseconds(): Int {
241
+ self.jsValue->offsetNanoseconds?
242
+ }
243
+
244
+ second(): Int {
245
+ self.jsValue->second?
246
+ }
247
+
248
+ weekOfYear(): Int {
249
+ self.jsValue->weekOfYear?
250
+ }
251
+
252
+ year(): Int {
253
+ self.jsValue->year?
254
+ }
255
+
256
+ yearOfWeek(): Int {
257
+ self.jsValue->yearOfWeek?
258
+ }
259
+
260
+ nextTimeZoneTransition(): Date {
261
+ Date(self.jsValue->getTimeZoneTransition("next"))
262
+ }
263
+
264
+ previousTimeZoneTransition(): Date {
265
+ Date(self.jsValue->getTimeZoneTransition("previous"))
266
+ }
267
+
268
+ startOfYear(): Date {
269
+ Date(self.jsValue->with(Js->(year = self.year(), month = 1, day = 1))->startOfDay())
270
+ }
271
+
272
+ startOfMonth(): Date {
273
+ Date(self.jsValue->with(Js->(year = self.year(), month = self.month(), day = 1))->startOfDay())
274
+ }
275
+
276
+ startOfWeek(firstDayOfWeek: Int = 1): Date {
277
+ let offset = ((self.dayOfWeek() - firstDayOfWeek) + self.daysInWeek()) % self.daysInWeek()
278
+ Date(self.jsValue->subtract(Js->(day = offset))->startOfDay())
279
+ }
280
+
281
+ startOfDay(): Date {
282
+ Date(self.jsValue->startOfDay())
283
+ }
284
+
285
+ startOfHour(): Date {
286
+ Date(self.jsValue->round(Js->(smallestUnit = "hour", roundingMode = "floor")))
287
+ }
288
+
289
+ startOfMinute(): Date {
290
+ Date(self.jsValue->round(Js->(smallestUnit = "minute", roundingMode = "floor")))
291
+ }
292
+
293
+ startOfSecond(): Date {
294
+ Date(self.jsValue->round(Js->(smallestUnit = "second", roundingMode = "floor")))
295
+ }
296
+
297
+ startOfMillisecond(): Date {
298
+ Date(self.jsValue->round(Js->(smallestUnit = "millisecond", roundingMode = "floor")))
299
+ }
300
+
301
+ startOfMicrosecond(): Date {
302
+ Date(self.jsValue->round(Js->(smallestUnit = "microsecond", roundingMode = "floor")))
303
+ }
304
+
305
+ toRfc9557(
306
+ smallestUnit: Option[String] = None
307
+ fractionalSecondDigits: Option[Int] = None
308
+ roundingMode: String = "trunc"
309
+ timeZoneName: String = "auto"
310
+ offset: String = "auto"
311
+ calendarName: String = "auto"
312
+ ): String {
313
+ self.jsValue->toString(Js->(
314
+ calendarName = calendarName
315
+ fractionalSecondDigits = fractionalSecondDigits.map {_!}.else {"auto"!}
316
+ roundingMode = roundingMode
317
+ smallestUnit = smallestUnit.map {_!}.else {Js.undefined()}
318
+ timeZoneName = timeZoneName
319
+ offset = offset
320
+ ))?
321
+ }
322
+
323
+ withCalendar(calendarId: String): Date {
324
+ Date(self.jsValue->withCalendar(calendarId))
325
+ }
326
+
327
+ withTimeZone(timeZoneId: String): Date {
328
+ Date(self.jsValue->withTimeZone(timeZoneId))
329
+ }
330
+
331
+ withEra(era: String, eraYear: Int, earlier: Bool = True, later: Bool = True): Date {
332
+ Date(self.jsValue->with(Js->(era = era, eraYear = eraYear), internalDisambiguation(earlier, later)))
333
+ }
334
+
335
+ with(
336
+ year: Option[Int] = None
337
+ month: Option[Int] = None
338
+ week: Option[Int] = None
339
+ day: Option[Int] = None
340
+ hour: Option[Int] = None
341
+ minute: Option[Int] = None
342
+ second: Option[Int] = None
343
+ millisecond: Option[Int] = None
344
+ microsecond: Option[Int] = None
345
+ nanosecond: Option[Int] = None
346
+ offset: Option[String] = None
347
+ earlier: Bool = True
348
+ later: Bool = True
349
+ ): Date {
350
+ Date(self.jsValue->with(Js->(
351
+ year = year.map {_!}.else {Js.undefined()}
352
+ month = month.map {_!}.else {Js.undefined()}
353
+ week = week.map {_!}.else {Js.undefined()}
354
+ day = day.map {_!}.else {Js.undefined()}
355
+ hour = hour.map {_!}.else {Js.undefined()}
356
+ minute = minute.map {_!}.else {Js.undefined()}
357
+ second = second.map {_!}.else {Js.undefined()}
358
+ millisecond = millisecond.map {_!}.else {Js.undefined()}
359
+ microsecond = microsecond.map {_!}.else {Js.undefined()}
360
+ nanosecond = nanosecond.map {_!}.else {Js.undefined()}
361
+ offset = offset.map {_!}.else {Js.undefined()}
362
+ ), internalDisambiguation(earlier, later)))
363
+ }
364
+
365
+ add(
366
+ years: Int = 0
367
+ months: Int = 0
368
+ weeks: Int = 0
369
+ days: Int = 0
370
+ hours: Int = 0
371
+ minutes: Int = 0
372
+ seconds: Int = 0
373
+ milliseconds: Int = 0
374
+ microseconds: Int = 0
375
+ nanoseconds: Int = 0
376
+ ): Date {
377
+ Date(self.jsValue->add(Js->(
378
+ years = years
379
+ months = months
380
+ weeks = weeks
381
+ days = days
382
+ hours = hours
383
+ minutes = minutes
384
+ seconds = seconds
385
+ milliseconds = milliseconds
386
+ microseconds = microseconds
387
+ nanoseconds = nanoseconds
388
+ )))
389
+ }
390
+
391
+ subtract(
392
+ years: Int = 0
393
+ months: Int = 0
394
+ weeks: Int = 0
395
+ days: Int = 0
396
+ hours: Int = 0
397
+ minutes: Int = 0
398
+ seconds: Int = 0
399
+ milliseconds: Int = 0
400
+ microseconds: Int = 0
401
+ nanoseconds: Int = 0
402
+ ): Date {
403
+ Date(self.jsValue->subtract(Js->(
404
+ years = years
405
+ months = months
406
+ weeks = weeks
407
+ days = days
408
+ hours = hours
409
+ minutes = minutes
410
+ seconds = seconds
411
+ milliseconds = milliseconds
412
+ microseconds = microseconds
413
+ nanoseconds = nanoseconds
414
+ )))
415
+ }
416
+
417
+ addGap(gap: DateGap): Date {
418
+ Date(self.jsValue->add(Js->(
419
+ years = gap.years
420
+ months = gap.months
421
+ weeks = gap.weeks
422
+ days = gap.days
423
+ hours = gap.hours
424
+ minutes = gap.minutes
425
+ seconds = gap.seconds
426
+ milliseconds = gap.milliseconds
427
+ microseconds = gap.microseconds
428
+ nanoseconds = gap.nanoseconds
429
+ )))
430
+ }
431
+
432
+ subtractGap(gap: DateGap): Date {
433
+ Date(self.jsValue->add(Js->(
434
+ years = gap.years
435
+ months = gap.months
436
+ weeks = gap.weeks
437
+ days = gap.days
438
+ hours = gap.hours
439
+ minutes = gap.minutes
440
+ seconds = gap.seconds
441
+ milliseconds = gap.milliseconds
442
+ microseconds = gap.microseconds
443
+ nanoseconds = gap.nanoseconds
444
+ )))
445
+ }
446
+
447
+ since(that: Date): DateGap {
448
+ let duration = self.jsValue->since(that.jsValue)
449
+ DateGap(
450
+ years = duration->years?
451
+ months = duration->months?
452
+ weeks = duration->weeks?
453
+ days = duration->days?
454
+ hours = duration->hours?
455
+ minutes = duration->minutes?
456
+ seconds = duration->seconds?
457
+ milliseconds = duration->milliseconds?
458
+ microseconds = duration->microseconds?
459
+ nanoseconds = duration->nanoseconds?
460
+ )
461
+ }
462
+
463
+ until(that: Date): DateGap {
464
+ let duration = self.jsValue->until(that.jsValue)
465
+ DateGap(
466
+ years = duration->years?
467
+ months = duration->months?
468
+ weeks = duration->weeks?
469
+ days = duration->days?
470
+ hours = duration->hours?
471
+ minutes = duration->minutes?
472
+ seconds = duration->seconds?
473
+ milliseconds = duration->milliseconds?
474
+ microseconds = duration->microseconds?
475
+ nanoseconds = duration->nanoseconds?
476
+ )
477
+ }
478
+
479
+ yearsSince(that: Date): Float {
480
+ let duration = self.jsValue->since(that.jsValue)
481
+ duration->total(Js->(unit = "years", relativeTo = that.jsValue))?
482
+ }
483
+
484
+ monthsSince(that: Date): Float {
485
+ let duration = self.jsValue->since(that.jsValue)
486
+ duration->total(Js->(unit = "months", relativeTo = that.jsValue))?
487
+ }
488
+
489
+ weeksSince(that: Date): Float {
490
+ let duration = self.jsValue->since(that.jsValue)
491
+ duration->total(Js->(unit = "weeks", relativeTo = that.jsValue))?
492
+ }
493
+
494
+ daysSince(that: Date): Float {
495
+ let duration = self.jsValue->since(that.jsValue)
496
+ duration->total(Js->(unit = "days", relativeTo = that.jsValue))?
497
+ }
498
+
499
+ hoursSince(that: Date): Float {
500
+ let duration = self.jsValue->since(that.jsValue)
501
+ duration->total(Js->(unit = "hours", relativeTo = that.jsValue))?
502
+ }
503
+
504
+ minutesSince(that: Date): Float {
505
+ let duration = self.jsValue->since(that.jsValue)
506
+ duration->total(Js->(unit = "minutes", relativeTo = that.jsValue))?
507
+ }
508
+
509
+ secondsSince(that: Date): Float {
510
+ let duration = self.jsValue->since(that.jsValue)
511
+ duration->total(Js->(unit = "seconds", relativeTo = that.jsValue))?
512
+ }
513
+
514
+ millisecondsSince(that: Date): Float {
515
+ let duration = self.jsValue->since(that.jsValue)
516
+ duration->total(Js->(unit = "milliseconds", relativeTo = that.jsValue))?
517
+ }
518
+
519
+ microsecondsSince(that: Date): Float {
520
+ let duration = self.jsValue->since(that.jsValue)
521
+ duration->total(Js->(unit = "microseconds", relativeTo = that.jsValue))?
522
+ }
523
+
524
+ nanosecondsSince(that: Date): Float {
525
+ let duration = self.jsValue->since(that.jsValue)
526
+ duration->total(Js->(unit = "nanoseconds", relativeTo = that.jsValue))?
527
+ }
528
+
529
+ toStream(next: Date => Date): Stream[Date] {
530
+ mutable date = self
531
+ Stream.new {
532
+ let current = date
533
+ date = next(date)
534
+ Some(current)
535
+ }
536
+ }
537
+
538
+ }
539
+
540
+ extend self: DateGap {
541
+
542
+ toIso8601(
543
+ smallestUnit: Option[String] = None
544
+ fractionalSecondDigits: Option[Int] = None
545
+ roundingMode: String = "trunc"
546
+ ): String {
547
+ let duration = Js->Temporal->Duration->from(Js->(
548
+ years = self.years
549
+ months = self.months
550
+ weeks = self.weeks
551
+ days = self.days
552
+ hours = self.hours
553
+ minutes = self.minutes
554
+ seconds = self.seconds
555
+ milliseconds = self.milliseconds
556
+ microseconds = self.microseconds
557
+ nanoseconds = self.nanoseconds
558
+ ))
559
+ duration->toString(Js->(
560
+ smallestUnit = smallestUnit.map {_!}.else {Js.undefined()}
561
+ fractionalSecondDigits = fractionalSecondDigits.map {_!}.else {"auto"!}
562
+ roundingMode = roundingMode
563
+ ))?
564
+ }
565
+
566
+ }
567
+
568
+ utcTimeZoneId: String = "UTC"
569
+ isoCalendarId: String = "iso8601"
570
+
571
+ monday: Int = 1
572
+ tuesday: Int = 2
573
+ wednesday: Int = 3
574
+ thursday: Int = 4
575
+ friday: Int = 5
576
+ saturday: Int = 6
577
+ sunday: Int = 7
578
+
579
+ january: Int = 1
580
+ february: Int = 2
581
+ march: Int = 3
582
+ april: Int = 4
583
+ may: Int = 5
584
+ june: Int = 6
585
+ july: Int = 7
586
+ august: Int = 8
587
+ september: Int = 9
588
+ october: Int = 10
589
+ november: Int = 11
590
+ december: Int = 12
591
+
592
+ internalDisambiguation(earlier: Bool, later: Bool): JsValue {
593
+ Js->(
594
+ disambiguation = if(earlier && later) {
595
+ "compatible"
596
+ } elseIf {earlier} {
597
+ "earlier"
598
+ } elseIf {later} {
599
+ "later"
600
+ } else {
601
+ "reject"
602
+ }
603
+ )
604
+ }
@@ -0,0 +1,51 @@
1
+ dependency ff:webserver:0.0.0
2
+ import WebServer from ff:webserver
3
+ import Date
4
+
5
+ browserMain(system: BrowserSystem) {
6
+ let now = Date.new("Europe/Copenhagen", 2025, 2, 1, 18, 0, 0)
7
+ let firstTuesday = now.toStream {_.add(days = 1)}.find {_.dayOfWeek() == Date.tuesday}
8
+ let tuesdays = firstTuesday.grab().toStream {_.add(weeks = 1)}
9
+ let meetups = tuesdays.filter {d => d.add(weeks = 1).month() > d.month()}
10
+ meetups.takeWhile {_.year() == 2025}.each {meetup =>
11
+ Log.debug("Meetup: " + meetup.toRfc9557())
12
+ }
13
+ }
14
+
15
+ buildMain(system: BuildSystem) {
16
+ let jsAssets = system.compileForBrowser(["Main.ff"])
17
+ Log.debug(jsAssets.list("/").join(" "))
18
+ let assets = AssetSystem.create().addAssets("/js", jsAssets)
19
+ Log.debug(assets.files.keys().toList().join(" "))
20
+ system.setAssets(assets)
21
+ }
22
+
23
+ nodeMain(system: NodeSystem) {
24
+ let host = system.arguments().grab(0)
25
+ let port = system.arguments().grab(1).grabInt()
26
+ WebServer.new(system, host, port).listen {request =>
27
+ let path = request.readPath()
28
+ let segments = path.split('/').filter {s => s != "" && s != "." && s != ".."}
29
+ segments.{
30
+ | ["js", ...] =>
31
+ request.writeHeader("Content-Type", "text/javascript; charset=UTF-8")
32
+ request.writeStream(system.assets().readStream(path))
33
+ | [] =>
34
+ request.writeHeader("Content-Type", "text/html; charset=UTF-8")
35
+ request.writeText("<!doctype html>")
36
+ request.writeText("<html lang='en' style='background-color: #ffffff; color: #333333; width: 100%; height: 100%; color-scheme: light;'>")
37
+ request.writeText("<head>")
38
+ request.writeText("<title>Date</title>")
39
+ request.writeText("<meta name='viewport' content='width=device-width, initial-scale=1.0'>")
40
+ request.writeText("<meta name='theme-color' content='#ecc45e'>")
41
+ request.writeText("<script src='https://cdn.jsdelivr.net/npm/temporal-polyfill@0.2.5/global.min.js'></script>")
42
+ request.writeText("<script type='module' src='" + "/js/script/script/Main.mjs" + "'></script>")
43
+ request.writeText("</head>")
44
+ request.writeText("<body style='margin: 0; padding: 0; width: 100%; height: 100%; touch-action: manipulation;'>")
45
+ request.writeText("</body>")
46
+ request.writeText("</html>")
47
+ | _ =>
48
+ request.writeStatus("404 Not Found")
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,15 @@
1
+ nodeMain(system: NodeSystem) {
2
+ let random = Random.newFromInt(42)
3
+ let buffer = Buffer.new(10000)
4
+ random.nextBytes(buffer, 0, buffer.size())
5
+ //0.until(buffer.size()).each {i => buffer.setUint8(i, buffer.grabUint8(i).bitAnd(0x1f))}
6
+ Log.debug(Buffer.fromByteList(buffer.toByteList().sort()).toLetter16())
7
+ let x = Buffer.fromByteList([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100, 101, 102, 103, 104, 105])
8
+ let a = x.toLetter16()
9
+ let b = Buffer.fromLetter16(a.upper())
10
+ Log.debug(x.toByteList().map {Show.show(_)}.join(" "))
11
+ Log.debug(a)
12
+ Log.debug(b.toByteList().map {Show.show(_)}.join(" "))
13
+ Log.debug(Show.show((16.bitAnd(0x0f) + 0x68)))
14
+ Log.debug(Show.show((16.bitRightUnsigned(4).bitAnd(0x0f) + 0x68).bitLeft(8)))
15
+ }
@@ -52,11 +52,10 @@ nodeMain(system: NodeSystem): Unit {
52
52
  }
53
53
 
54
54
  buildMain(system: BuildSystem) {
55
- let browser: BrowserCode = system.compileForBrowser("Main.ff")
56
55
  let browserAssets = if(system.buildMode()) {
57
- browser.bundle().assets()
56
+ system.bundleForBrowser(["Main.ff"])
58
57
  } else {
59
- browser.assets()
58
+ system.compileForBrowser(["Main.ff"])
60
59
  }
61
60
  let indexAssets = if(system.buildMode()) {
62
61
  let html = system.packageAssets().readText("/index.html")
@@ -33,8 +33,8 @@ nodeMain(system: NodeSystem): Unit {
33
33
  buildMain(system: BuildSystem) {
34
34
  mutable assets = AssetSystem.create()
35
35
  Routes.routes.each {route =>
36
- let browser = system.compileForBrowser(route.page + ".ff") // .bundle()
37
- assets = assets.addAssets("/js/", browser.assets())
36
+ let browser = system.compileForBrowser([route.page + ".ff"])
37
+ assets = assets.addAssets("/js/", browser)
38
38
  }
39
39
  system.setAssets(assets)
40
40
  }
@@ -30,8 +30,8 @@ nodeMain(system: NodeSystem): Unit {
30
30
  buildMain(system: BuildSystem) {
31
31
  mutable assets = AssetSystem.create()
32
32
  Router.modulesWithBrowserMain.each {moduleName =>
33
- let browser = system.compileForBrowser(moduleName + ".ff") // .bundle()
34
- assets = assets.addAssets("/js/", browser.assets())
33
+ let browser = system.compileForBrowser([moduleName + ".ff"])
34
+ assets = assets.addAssets("/js/", browser)
35
35
  }
36
36
  system.setAssets(assets)
37
37
  }