@lango-project/lango-client 0.2.0 → 0.4.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.
- package/LICENSE +1 -0
- package/NOTICE +5 -1
- package/README.md +571 -855
- package/cli/.lango/localization.mjs +108 -0
- package/{dist/node → cli}/.lango/runtime.mjs +112 -19
- package/cli/.lango/vendor/i18next.LICENSE +21 -0
- package/cli/.lango/vendor/i18next.mjs +2434 -0
- package/cli/create.mjs +62 -0
- package/cli/create.mjs.map +1 -0
- package/dist/.lango/localization.mjs +108 -0
- package/dist/.lango/runtime.mjs +112 -19
- package/dist/.lango/vendor/i18next.LICENSE +21 -0
- package/dist/.lango/vendor/i18next.mjs +2434 -0
- package/dist/accordion.mjs +277 -0
- package/dist/accordion.mjs.map +1 -0
- package/dist/activities.mjs +185 -0
- package/dist/activities.mjs.map +1 -0
- package/dist/app.mjs +636 -0
- package/dist/app.mjs.map +1 -0
- package/dist/boot.mjs +24 -0
- package/dist/boot.mjs.map +1 -0
- package/dist/bootstrap-LICENSE +21 -0
- package/dist/bootstrap.min.css +6 -0
- package/dist/bootstrap.min.css.map +1 -0
- package/dist/button.mjs +77 -0
- package/dist/button.mjs.map +1 -0
- package/dist/chip.mjs +134 -0
- package/dist/chip.mjs.map +1 -0
- package/dist/client.css +95 -0
- package/dist/collections.mjs +77 -0
- package/dist/collections.mjs.map +1 -0
- package/dist/combo_box.mjs +408 -0
- package/dist/combo_box.mjs.map +1 -0
- package/dist/content.mjs +123 -0
- package/dist/content.mjs.map +1 -0
- package/dist/control.mjs +139 -0
- package/dist/control.mjs.map +1 -0
- package/dist/date_input.mjs +242 -0
- package/dist/date_input.mjs.map +1 -0
- package/dist/error_reporter.mjs +136 -0
- package/dist/error_reporter.mjs.map +1 -0
- package/dist/fields.mjs +454 -0
- package/dist/fields.mjs.map +1 -0
- package/dist/file_input.mjs +227 -0
- package/dist/file_input.mjs.map +1 -0
- package/dist/form.mjs +272 -0
- package/dist/form.mjs.map +1 -0
- package/dist/heartbeat.mjs +167 -254
- package/dist/heartbeat.mjs.map +1 -1
- package/dist/index.html +18 -0
- package/dist/indicators.mjs +127 -0
- package/dist/indicators.mjs.map +1 -0
- package/dist/input_changes.mjs +58 -0
- package/dist/input_changes.mjs.map +1 -0
- package/dist/input_group.mjs +38 -0
- package/dist/input_group.mjs.map +1 -0
- package/dist/layouts.mjs +195 -0
- package/dist/layouts.mjs.map +1 -0
- package/dist/library.mjs +130 -775
- package/dist/library.mjs.map +1 -1
- package/dist/longpoll.mjs +254 -0
- package/dist/longpoll.mjs.map +1 -0
- package/dist/main.mjs +138 -0
- package/dist/main.mjs.map +1 -0
- package/dist/markdown.mjs +61 -0
- package/dist/markdown.mjs.map +1 -0
- package/dist/menus.mjs +468 -0
- package/dist/menus.mjs.map +1 -0
- package/dist/navigation.mjs +260 -410
- package/dist/navigation.mjs.map +1 -1
- package/dist/numeric_input.mjs +181 -0
- package/dist/numeric_input.mjs.map +1 -0
- package/dist/otp_input.mjs +113 -0
- package/dist/otp_input.mjs.map +1 -0
- package/dist/presentations.mjs +852 -0
- package/dist/presentations.mjs.map +1 -0
- package/dist/renderer.mjs +293 -0
- package/dist/renderer.mjs.map +1 -0
- package/dist/rich_content.mjs +99 -0
- package/dist/rich_content.mjs.map +1 -0
- package/dist/tables.mjs +369 -0
- package/dist/tables.mjs.map +1 -0
- package/dist/tabs.mjs +205 -0
- package/dist/tabs.mjs.map +1 -0
- package/dist/templates.mjs +46 -0
- package/dist/templates.mjs.map +1 -0
- package/dist/vendor/DOMPurify-LICENSE +202 -0
- package/dist/vendor/dompurify.mjs +2540 -0
- package/dist/vendor/flatpickr-LICENSE.md +21 -0
- package/dist/vendor/flatpickr.min.css +13 -0
- package/dist/vendor/flatpickr.mjs +2340 -0
- package/dist/vendor/flatpickr.mjs.map +7 -0
- package/dist/vendor/marked-LICENSE.md +44 -0
- package/dist/vendor/marked.esm.js.map +7 -0
- package/dist/vendor/marked.mjs +85 -0
- package/dist/vendor/purify.es.mjs.map +1 -0
- package/dist/widgets.mjs +197 -0
- package/dist/widgets.mjs.map +1 -0
- package/docs/implementation.md +42 -0
- package/package.json +26 -40
- package/src/accordion.lango +198 -0
- package/src/activities.lango +132 -0
- package/src/app.lango +508 -0
- package/src/boot.lango +12 -0
- package/src/button.lango +49 -0
- package/src/chip.lango +94 -0
- package/src/collections.lango +46 -0
- package/src/combo_box.lango +298 -0
- package/src/content.lango +75 -0
- package/src/control.lango +100 -0
- package/src/create.lango +42 -0
- package/src/date_input.lango +215 -0
- package/src/error_reporter.lango +95 -0
- package/src/fields.lango +327 -0
- package/src/file_input.lango +175 -0
- package/src/form.lango +195 -0
- package/src/heartbeat.lango +136 -199
- package/src/indicators.lango +94 -0
- package/src/input_changes.lango +33 -0
- package/src/input_group.lango +22 -0
- package/src/layouts.lango +137 -0
- package/src/library.lango +194 -571
- package/src/longpoll.lango +187 -0
- package/src/main.lango +109 -0
- package/src/markdown.lango +48 -0
- package/src/menus.lango +336 -0
- package/src/navigation.lango +209 -299
- package/src/numeric_input.lango +131 -0
- package/src/otp_input.lango +83 -0
- package/src/presentations.lango +617 -0
- package/src/renderer.lango +288 -0
- package/src/rich_content.lango +66 -0
- package/src/tables.lango +271 -0
- package/src/tabs.lango +144 -0
- package/src/templates.lango +29 -0
- package/src/widgets.lango +141 -0
- package/web/client.css +95 -0
- package/web/index.html +18 -0
- package/dist/application.mjs +0 -429
- package/dist/application.mjs.map +0 -1
- package/dist/coordinator.mjs +0 -91
- package/dist/coordinator.mjs.map +0 -1
- package/dist/demo.mjs +0 -110
- package/dist/demo.mjs.map +0 -1
- package/dist/demo_controls.mjs +0 -59
- package/dist/demo_controls.mjs.map +0 -1
- package/dist/errors.mjs +0 -201
- package/dist/errors.mjs.map +0 -1
- package/dist/form_state.mjs +0 -266
- package/dist/form_state.mjs.map +0 -1
- package/dist/inheritance.mjs +0 -240
- package/dist/inheritance.mjs.map +0 -1
- package/dist/input_values.mjs +0 -65
- package/dist/input_values.mjs.map +0 -1
- package/dist/node/.lango/xmldom/conventions.js +0 -429
- package/dist/node/.lango/xmldom/dom-parser.js +0 -591
- package/dist/node/.lango/xmldom/dom.js +0 -3759
- package/dist/node/.lango/xmldom/entities.js +0 -2171
- package/dist/node/.lango/xmldom/errors.js +0 -205
- package/dist/node/.lango/xmldom/grammar.js +0 -559
- package/dist/node/.lango/xmldom/index.js +0 -41
- package/dist/node/.lango/xmldom/package.json +0 -1
- package/dist/node/.lango/xmldom/sax.js +0 -983
- package/dist/node/.lango/xmldom.LICENSE.md +0 -8
- package/dist/node/browser_host.mjs +0 -351
- package/dist/node/browser_host.mjs.map +0 -1
- package/dist/node/create_app.mjs +0 -118
- package/dist/node/create_app.mjs.map +0 -1
- package/dist/presentation.mjs +0 -89
- package/dist/presentation.mjs.map +0 -1
- package/dist/protocol.mjs +0 -706
- package/dist/protocol.mjs.map +0 -1
- package/dist/session.mjs +0 -431
- package/dist/session.mjs.map +0 -1
- package/dist/tokens.mjs +0 -298
- package/dist/tokens.mjs.map +0 -1
- package/examples/contacts.lango +0 -302
- package/examples/contacts_flow.lango +0 -174
- package/examples/contacts_store.lango +0 -109
- package/examples/contacts_store_test.lango +0 -65
- package/examples/demo.css +0 -72
- package/examples/demo_test.lango +0 -356
- package/examples/index.html +0 -28
- package/examples/pages.lango +0 -180
- package/examples/server.lango +0 -189
- package/examples/worker.lango +0 -142
- package/src/application.lango +0 -327
- package/src/browser_host.lango +0 -276
- package/src/coordinator.lango +0 -57
- package/src/demo.lango +0 -110
- package/src/demo_controls.lango +0 -53
- package/src/errors.lango +0 -149
- package/src/errors_test.lango +0 -157
- package/src/form_state.lango +0 -168
- package/src/heartbeat_test.lango +0 -479
- package/src/inheritance.lango +0 -167
- package/src/input_values.lango +0 -37
- package/src/logout_test.lango +0 -564
- package/src/navigation_test.lango +0 -556
- package/src/presentation.lango +0 -55
- package/src/protocol.lango +0 -787
- package/src/renderer_test.lango +0 -1986
- package/src/session.lango +0 -313
- package/src/session_test.lango +0 -455
- package/src/tabs_test.lango +0 -216
- package/src/tokens.lango +0 -215
- package/template/.vscode/extensions.json +0 -3
- package/template/.vscode/settings.json +0 -9
- package/template/README.md +0 -40
- package/template/gitignore +0 -4
- package/template/package.json +0 -22
- package/template/public/app.css +0 -4
- package/template/public/index.html +0 -24
- package/template/src/client.lango +0 -78
- package/template/src/pages.lango +0 -55
- package/template/src/server.lango +0 -24
- package/template/src/worker.lango +0 -77
- package/template/test/app.lango +0 -9
- package/tools/create_app.lango +0 -88
- package/tools/create_app_test.lango +0 -43
- package/tools/starter_test.lango +0 -227
- /package/{dist/node → cli}/.lango/bignumber.mjs +0 -0
- /package/{dist → cli}/.lango/xmldom/conventions.js +0 -0
- /package/{dist → cli}/.lango/xmldom/dom-parser.js +0 -0
- /package/{dist → cli}/.lango/xmldom/dom.js +0 -0
- /package/{dist → cli}/.lango/xmldom/entities.js +0 -0
- /package/{dist → cli}/.lango/xmldom/errors.js +0 -0
- /package/{dist → cli}/.lango/xmldom/grammar.js +0 -0
- /package/{dist → cli}/.lango/xmldom/index.js +0 -0
- /package/{dist → cli}/.lango/xmldom/package.json +0 -0
- /package/{dist → cli}/.lango/xmldom/sax.js +0 -0
- /package/{dist → cli}/.lango/xmldom.LICENSE.md +0 -0
package/src/heartbeat_test.lango
DELETED
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
import js global Promise
|
|
2
|
-
import js global Response
|
|
3
|
-
import js global globalThis as host
|
|
4
|
-
import "./heartbeat"
|
|
5
|
-
class Heartbeat
|
|
6
|
-
import "./session"
|
|
7
|
-
class Session
|
|
8
|
-
import "./tokens"
|
|
9
|
-
class TokenStore
|
|
10
|
-
|
|
11
|
-
export main(args)
|
|
12
|
-
|
|
13
|
-
class Storage
|
|
14
|
-
properties
|
|
15
|
-
writes
|
|
16
|
-
methods
|
|
17
|
-
getItem(key)
|
|
18
|
-
setItem(key, value)
|
|
19
|
-
|
|
20
|
-
Storage()
|
|
21
|
-
@writes = []
|
|
22
|
-
@value = null
|
|
23
|
-
|
|
24
|
-
Storage:getItem(key)
|
|
25
|
-
return @value
|
|
26
|
-
|
|
27
|
-
Storage:setItem(key, value)
|
|
28
|
-
@value = value
|
|
29
|
-
@writes.add(value)
|
|
30
|
-
return null
|
|
31
|
-
|
|
32
|
-
class Root
|
|
33
|
-
properties
|
|
34
|
-
inert
|
|
35
|
-
methods
|
|
36
|
-
setAttribute(name, value)
|
|
37
|
-
|
|
38
|
-
Root()
|
|
39
|
-
@inert = false
|
|
40
|
-
|
|
41
|
-
Root:setAttribute(name, value)
|
|
42
|
-
return null
|
|
43
|
-
|
|
44
|
-
class Clock
|
|
45
|
-
properties
|
|
46
|
-
active
|
|
47
|
-
methods
|
|
48
|
-
now()
|
|
49
|
-
schedule(callback, delay)
|
|
50
|
-
cancel(timer)
|
|
51
|
-
advance(milliseconds)
|
|
52
|
-
|
|
53
|
-
Clock()
|
|
54
|
-
@time = 0
|
|
55
|
-
@active = false
|
|
56
|
-
@id = 0
|
|
57
|
-
|
|
58
|
-
Clock:now()
|
|
59
|
-
return @time
|
|
60
|
-
|
|
61
|
-
Clock:schedule(callback, delay)
|
|
62
|
-
@active = true
|
|
63
|
-
@callback = callback
|
|
64
|
-
@due = @time + delay
|
|
65
|
-
@id++
|
|
66
|
-
return @id
|
|
67
|
-
|
|
68
|
-
Clock:cancel(timer)
|
|
69
|
-
@active = false
|
|
70
|
-
return null
|
|
71
|
-
|
|
72
|
-
Clock:advance(milliseconds)
|
|
73
|
-
@time += milliseconds
|
|
74
|
-
if @active and @time >= @due
|
|
75
|
-
@active = false
|
|
76
|
-
callback = @callback
|
|
77
|
-
callback()
|
|
78
|
-
return null
|
|
79
|
-
|
|
80
|
-
class Transport
|
|
81
|
-
properties
|
|
82
|
-
calls
|
|
83
|
-
hold
|
|
84
|
-
methods
|
|
85
|
-
send(path, input, token = null)
|
|
86
|
-
block(record, resolve, reject)
|
|
87
|
-
wait(count)
|
|
88
|
-
waiting(count, resolve)
|
|
89
|
-
wake()
|
|
90
|
-
release(result = null)
|
|
91
|
-
fail()
|
|
92
|
-
|
|
93
|
-
Transport(kind)
|
|
94
|
-
@kind = kind
|
|
95
|
-
@calls = []
|
|
96
|
-
@pending = []
|
|
97
|
-
@waiters = []
|
|
98
|
-
@hold = true
|
|
99
|
-
|
|
100
|
-
Transport:send(path, input, token = null)
|
|
101
|
-
record = {
|
|
102
|
-
path: path
|
|
103
|
-
input: from_json(to_json(input))
|
|
104
|
-
token: token
|
|
105
|
-
}
|
|
106
|
-
@calls.add(record)
|
|
107
|
-
if @hold
|
|
108
|
-
pending = new Promise((resolve, reject)
|
|
109
|
-
capture record
|
|
110
|
-
block(record, resolve, reject)
|
|
111
|
-
)
|
|
112
|
-
wake()
|
|
113
|
-
return pending
|
|
114
|
-
wake()
|
|
115
|
-
return Promise/resolve(reply(@kind, record))
|
|
116
|
-
|
|
117
|
-
Transport:block(record, resolve, reject)
|
|
118
|
-
@pending.add({
|
|
119
|
-
record: record
|
|
120
|
-
resolve: resolve
|
|
121
|
-
reject: reject
|
|
122
|
-
})
|
|
123
|
-
return null
|
|
124
|
-
|
|
125
|
-
Transport:wait(count)
|
|
126
|
-
if @calls.length >= count
|
|
127
|
-
return Promise/resolve()
|
|
128
|
-
pending = new Promise((resolve, reject)
|
|
129
|
-
capture count
|
|
130
|
-
waiting(count, resolve)
|
|
131
|
-
)
|
|
132
|
-
return pending
|
|
133
|
-
|
|
134
|
-
Transport:waiting(count, resolve)
|
|
135
|
-
@waiters.add({
|
|
136
|
-
count: count
|
|
137
|
-
resolve: resolve
|
|
138
|
-
})
|
|
139
|
-
return null
|
|
140
|
-
|
|
141
|
-
Transport:wake()
|
|
142
|
-
for @waiters as waiter
|
|
143
|
-
if @calls.length >= waiter.count
|
|
144
|
-
waiter.resolve(null)
|
|
145
|
-
return null
|
|
146
|
-
|
|
147
|
-
Transport:release(result = null)
|
|
148
|
-
pending = @pending.shift()
|
|
149
|
-
if result == null
|
|
150
|
-
result = reply(@kind, pending.record)
|
|
151
|
-
pending.resolve(result)
|
|
152
|
-
return null
|
|
153
|
-
|
|
154
|
-
Transport:fail()
|
|
155
|
-
pending = @pending.shift()
|
|
156
|
-
pending.reject("ExpectedNetworkFailure")
|
|
157
|
-
return null
|
|
158
|
-
|
|
159
|
-
reply(kind, record)
|
|
160
|
-
input = record.input
|
|
161
|
-
if kind == "ping"
|
|
162
|
-
forms = []
|
|
163
|
-
for input.forms as form
|
|
164
|
-
forms.add({
|
|
165
|
-
formId: form.formId
|
|
166
|
-
token: "${form.formId}:ping:${form.token}"
|
|
167
|
-
})
|
|
168
|
-
return {
|
|
169
|
-
forms: forms
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
body: {
|
|
173
|
-
formId: input.formId
|
|
174
|
-
seqno: input.seqno
|
|
175
|
-
ui: {
|
|
176
|
-
replace: {
|
|
177
|
-
}
|
|
178
|
-
remove: []
|
|
179
|
-
}
|
|
180
|
-
vals: {
|
|
181
|
-
}
|
|
182
|
-
cmds: []
|
|
183
|
-
}
|
|
184
|
-
token: "${input.formId}:normal:${input.seqno}"
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
fixture(native = false)
|
|
188
|
-
storage = new Storage()
|
|
189
|
-
tokens = new TokenStore(storage)
|
|
190
|
-
tokens.save("seed")
|
|
191
|
-
clock = new Clock()
|
|
192
|
-
normal = new Transport("normal")
|
|
193
|
-
pings = new Transport("ping")
|
|
194
|
-
pingTransport = pings
|
|
195
|
-
if native
|
|
196
|
-
pingTransport = null
|
|
197
|
-
heartbeat = new Heartbeat({
|
|
198
|
-
clock: clock
|
|
199
|
-
transport: pingTransport
|
|
200
|
-
})
|
|
201
|
-
leftRoot = new Root()
|
|
202
|
-
rightRoot = new Root()
|
|
203
|
-
left = session("left", tokens, normal, heartbeat, leftRoot)
|
|
204
|
-
right = session("right", tokens, normal, heartbeat, rightRoot)
|
|
205
|
-
heartbeat.sessions([left, right])
|
|
206
|
-
return {
|
|
207
|
-
storage: storage
|
|
208
|
-
tokens: tokens
|
|
209
|
-
clock: clock
|
|
210
|
-
normal: normal
|
|
211
|
-
pings: pings
|
|
212
|
-
heartbeat: heartbeat
|
|
213
|
-
left: left
|
|
214
|
-
right: right
|
|
215
|
-
leftRoot: leftRoot
|
|
216
|
-
rightRoot: rightRoot
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
session(id, tokens, transport, heartbeat, root)
|
|
220
|
-
return new Session({
|
|
221
|
-
formId: id
|
|
222
|
-
controls: []
|
|
223
|
-
effects: {
|
|
224
|
-
}
|
|
225
|
-
transport: transport
|
|
226
|
-
tokens: tokens
|
|
227
|
-
heartbeat: heartbeat
|
|
228
|
-
root: root
|
|
229
|
-
})
|
|
230
|
-
|
|
231
|
-
dispose(state)
|
|
232
|
-
state.heartbeat.dispose()
|
|
233
|
-
state.left.dispose()
|
|
234
|
-
state.right.dispose()
|
|
235
|
-
return null
|
|
236
|
-
|
|
237
|
-
main(args)
|
|
238
|
-
return checkSerialization().then(()
|
|
239
|
-
return checkInvalidResponse()
|
|
240
|
-
).then(()
|
|
241
|
-
return checkDisposal()
|
|
242
|
-
).then(()
|
|
243
|
-
return checkIdleRetry()
|
|
244
|
-
).then(()
|
|
245
|
-
return checkNativeTransport()
|
|
246
|
-
)
|
|
247
|
-
|
|
248
|
-
checkSerialization()
|
|
249
|
-
state = fixture()
|
|
250
|
-
initial = state.left.send("/save", "click", "save")
|
|
251
|
-
return state.normal.wait(1).then(()
|
|
252
|
-
capture state
|
|
253
|
-
capture initial
|
|
254
|
-
return reserveBatch(state, initial)
|
|
255
|
-
).finally(()
|
|
256
|
-
capture state
|
|
257
|
-
dispose(state)
|
|
258
|
-
)
|
|
259
|
-
|
|
260
|
-
reserveBatch(state, initial)
|
|
261
|
-
ping = state.heartbeat.ping()
|
|
262
|
-
assert ping == state.heartbeat.ping()
|
|
263
|
-
assert !state.rightRoot.inert
|
|
264
|
-
second = state.left.send("/save", "click", "save")
|
|
265
|
-
right = state.right.send("/save", "click", "save")
|
|
266
|
-
state.normal.release()
|
|
267
|
-
return state.pings.wait(1).then(()
|
|
268
|
-
capture state
|
|
269
|
-
capture ping
|
|
270
|
-
capture initial
|
|
271
|
-
capture second
|
|
272
|
-
capture right
|
|
273
|
-
assert state.normal.calls.length == 1
|
|
274
|
-
assertPingTokens(state)
|
|
275
|
-
state.normal.hold = false
|
|
276
|
-
state.pings.release()
|
|
277
|
-
return Promise/all([ping, initial, second, right])
|
|
278
|
-
).then((results)
|
|
279
|
-
capture state
|
|
280
|
-
assertNormalCalls(state)
|
|
281
|
-
println("PASS ping barriers serialize each form, preserve seqno and persist every renewed token")
|
|
282
|
-
)
|
|
283
|
-
|
|
284
|
-
assertPingTokens(state)
|
|
285
|
-
call = state.pings.calls[0]
|
|
286
|
-
input = call.input
|
|
287
|
-
forms = input.forms
|
|
288
|
-
assert forms.length == 2
|
|
289
|
-
assert forms[0].token == "left:normal:1"
|
|
290
|
-
assert forms[1].token == "seed"
|
|
291
|
-
return null
|
|
292
|
-
|
|
293
|
-
assertNormalCalls(state)
|
|
294
|
-
assert state.normal.calls.length == 3
|
|
295
|
-
calls = state.normal.calls
|
|
296
|
-
left = calls[1]
|
|
297
|
-
right = calls[2]
|
|
298
|
-
assert left.input.formId == "left"
|
|
299
|
-
assert left.input.seqno == 2
|
|
300
|
-
assert left.token == "left:ping:left:normal:1"
|
|
301
|
-
assert right.input.formId == "right"
|
|
302
|
-
assert right.input.seqno == 1
|
|
303
|
-
assert right.token == "right:ping:seed"
|
|
304
|
-
assert state.storage.writes.includes("left:ping:left:normal:1")
|
|
305
|
-
assert state.storage.writes.includes("right:ping:seed")
|
|
306
|
-
assert !state.leftRoot.inert
|
|
307
|
-
assert !state.rightRoot.inert
|
|
308
|
-
return null
|
|
309
|
-
|
|
310
|
-
checkInvalidResponse()
|
|
311
|
-
state = fixture()
|
|
312
|
-
state.normal.hold = false
|
|
313
|
-
ping = state.heartbeat.ping()
|
|
314
|
-
queued = state.left.send("/save", "click", "save")
|
|
315
|
-
rejected = ping.catch((error)
|
|
316
|
-
assert error == "UiInvalidPingResponse"
|
|
317
|
-
)
|
|
318
|
-
return state.pings.wait(1).then(()
|
|
319
|
-
capture state
|
|
320
|
-
capture rejected
|
|
321
|
-
capture queued
|
|
322
|
-
releaseInvalid(state)
|
|
323
|
-
return Promise/all([rejected, queued])
|
|
324
|
-
).then((results)
|
|
325
|
-
capture state
|
|
326
|
-
assertRetainedTokens(state)
|
|
327
|
-
println("PASS malformed ping batches keep tokens unchanged and release normal requests")
|
|
328
|
-
).finally(()
|
|
329
|
-
capture state
|
|
330
|
-
dispose(state)
|
|
331
|
-
)
|
|
332
|
-
|
|
333
|
-
releaseInvalid(state)
|
|
334
|
-
state.pings.release({
|
|
335
|
-
forms: [{
|
|
336
|
-
formId: "left"
|
|
337
|
-
token: "must-not-apply"
|
|
338
|
-
}, {
|
|
339
|
-
formId: "unknown"
|
|
340
|
-
token: "wrong-form"
|
|
341
|
-
}]
|
|
342
|
-
})
|
|
343
|
-
return null
|
|
344
|
-
|
|
345
|
-
assertRetainedTokens(state)
|
|
346
|
-
call = state.normal.calls[0]
|
|
347
|
-
assert call.token == "seed"
|
|
348
|
-
assert call.input.seqno == 1
|
|
349
|
-
assert !state.storage.writes.includes("must-not-apply")
|
|
350
|
-
return null
|
|
351
|
-
|
|
352
|
-
checkDisposal()
|
|
353
|
-
state = fixture()
|
|
354
|
-
ping = state.heartbeat.ping()
|
|
355
|
-
queued = state.left.send("/save", "click", "save")
|
|
356
|
-
rejected = queued.catch((error)
|
|
357
|
-
assert error == "UiSessionDisposed"
|
|
358
|
-
)
|
|
359
|
-
return state.pings.wait(1).then(()
|
|
360
|
-
capture state
|
|
361
|
-
capture rejected
|
|
362
|
-
dispose(state)
|
|
363
|
-
return rejected
|
|
364
|
-
).then(()
|
|
365
|
-
capture state
|
|
366
|
-
capture ping
|
|
367
|
-
state.pings.release()
|
|
368
|
-
return ping
|
|
369
|
-
).then(()
|
|
370
|
-
capture state
|
|
371
|
-
assert state.tokens.latest() == "seed"
|
|
372
|
-
assert state.storage.writes.length == 1
|
|
373
|
-
assert state.normal.calls.length == 0
|
|
374
|
-
println("PASS disposal releases queued work and ignores late ping renewals")
|
|
375
|
-
)
|
|
376
|
-
|
|
377
|
-
checkIdleRetry()
|
|
378
|
-
state = fixture()
|
|
379
|
-
state.heartbeat.start()
|
|
380
|
-
state.clock.advance(59000)
|
|
381
|
-
assert state.pings.calls.length == 0
|
|
382
|
-
state.heartbeat.activity()
|
|
383
|
-
state.clock.advance(59999)
|
|
384
|
-
assert state.pings.calls.length == 0
|
|
385
|
-
state.clock.advance(1)
|
|
386
|
-
return state.pings.wait(1).then(()
|
|
387
|
-
capture state
|
|
388
|
-
pending = state.heartbeat.ping()
|
|
389
|
-
state.pings.fail()
|
|
390
|
-
return expectNetworkFailure(pending)
|
|
391
|
-
).then(()
|
|
392
|
-
capture state
|
|
393
|
-
assert state.clock.active
|
|
394
|
-
state.clock.advance(60000)
|
|
395
|
-
return state.pings.wait(2)
|
|
396
|
-
).then(()
|
|
397
|
-
capture state
|
|
398
|
-
pending = state.heartbeat.ping()
|
|
399
|
-
state.pings.release()
|
|
400
|
-
return pending
|
|
401
|
-
).then(()
|
|
402
|
-
capture state
|
|
403
|
-
assert state.tokens.latest() == "right:ping:seed"
|
|
404
|
-
assert state.clock.active
|
|
405
|
-
dispose(state)
|
|
406
|
-
assert !state.clock.active
|
|
407
|
-
state.clock.advance(60000)
|
|
408
|
-
assert state.pings.calls.length == 2
|
|
409
|
-
println("PASS idle ping scheduling resets on activity, retries failures and stops on disposal")
|
|
410
|
-
).finally(()
|
|
411
|
-
capture state
|
|
412
|
-
dispose(state)
|
|
413
|
-
)
|
|
414
|
-
|
|
415
|
-
expectNetworkFailure(pending)
|
|
416
|
-
return pending.catch((error)
|
|
417
|
-
assert error == "ExpectedNetworkFailure"
|
|
418
|
-
)
|
|
419
|
-
|
|
420
|
-
class FetchMock
|
|
421
|
-
properties
|
|
422
|
-
status
|
|
423
|
-
calls
|
|
424
|
-
methods
|
|
425
|
-
send(path, options)
|
|
426
|
-
|
|
427
|
-
FetchMock()
|
|
428
|
-
@status = 200
|
|
429
|
-
@calls = 0
|
|
430
|
-
|
|
431
|
-
FetchMock:send(path, options)
|
|
432
|
-
@calls++
|
|
433
|
-
assert path == "/_lango/ping"
|
|
434
|
-
assert options.method == "POST"
|
|
435
|
-
assert options.cache == "no-store"
|
|
436
|
-
assert options.redirect == "error"
|
|
437
|
-
input = from_json(options.body)
|
|
438
|
-
assert input.forms.length == 2
|
|
439
|
-
result = reply("ping", {
|
|
440
|
-
input: input
|
|
441
|
-
})
|
|
442
|
-
return Promise/resolve(new Response(to_json(result), {
|
|
443
|
-
status: @status
|
|
444
|
-
}))
|
|
445
|
-
|
|
446
|
-
checkNativeTransport()
|
|
447
|
-
original = host.fetch
|
|
448
|
-
mock = new FetchMock()
|
|
449
|
-
stub = (path, options)
|
|
450
|
-
capture mock
|
|
451
|
-
return mock.send(path, options)
|
|
452
|
-
host.fetch = stub
|
|
453
|
-
state = fixture(true)
|
|
454
|
-
return state.heartbeat.ping().then((result)
|
|
455
|
-
capture state
|
|
456
|
-
capture mock
|
|
457
|
-
return checkHttpError(state, mock)
|
|
458
|
-
).then(()
|
|
459
|
-
capture state
|
|
460
|
-
capture mock
|
|
461
|
-
assert mock.calls == 2
|
|
462
|
-
assert state.tokens.latest() == "right:ping:seed"
|
|
463
|
-
println("PASS native ping transport sends one batch, disables caching and rejects HTTP errors")
|
|
464
|
-
).finally(()
|
|
465
|
-
capture state
|
|
466
|
-
capture original
|
|
467
|
-
host.fetch = original
|
|
468
|
-
dispose(state)
|
|
469
|
-
)
|
|
470
|
-
|
|
471
|
-
checkHttpError(state, mock)
|
|
472
|
-
assert state.tokens.latest() == "right:ping:seed"
|
|
473
|
-
mock.status = 401
|
|
474
|
-
return expectHttpFailure(state.heartbeat.ping())
|
|
475
|
-
|
|
476
|
-
expectHttpFailure(pending)
|
|
477
|
-
return pending.catch((error)
|
|
478
|
-
assert error == "UiPingHttpError: 401"
|
|
479
|
-
)
|
package/src/inheritance.lango
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
export normalizeInheritance(spec)
|
|
2
|
-
export inheritedControls(form, parent)
|
|
3
|
-
export inheritanceResources(path, parentPath, spec)
|
|
4
|
-
|
|
5
|
-
validName(name)
|
|
6
|
-
if !is_string(name) or name == "" or name == "__proto__" or name == "constructor" or name == "prototype" or name == "value" or name == "then"
|
|
7
|
-
throw "UiInvalidInheritedName"
|
|
8
|
-
return null
|
|
9
|
-
|
|
10
|
-
normalizeInheritance(spec)
|
|
11
|
-
result = {
|
|
12
|
-
}
|
|
13
|
-
if spec == null
|
|
14
|
-
return result
|
|
15
|
-
if !is_object(spec)
|
|
16
|
-
throw "UiInheritanceMustBeMap"
|
|
17
|
-
for spec as alias: entry
|
|
18
|
-
validName(alias)
|
|
19
|
-
path = entry
|
|
20
|
-
writable = false
|
|
21
|
-
if is_object(entry)
|
|
22
|
-
for entry as name: value
|
|
23
|
-
if name != "path" and name != "writable"
|
|
24
|
-
throw "UiUnknownInheritanceOption"
|
|
25
|
-
path = entry.path
|
|
26
|
-
if entry.writable != null
|
|
27
|
-
if !is_bool(entry.writable)
|
|
28
|
-
throw "UiInheritanceWritableMustBeBoolean"
|
|
29
|
-
writable = entry.writable
|
|
30
|
-
if is_string(path)
|
|
31
|
-
path = [path]
|
|
32
|
-
if !is_array(path) or path.length == 0
|
|
33
|
-
throw "UiInheritanceRequiresPath"
|
|
34
|
-
for path as name
|
|
35
|
-
validName(name)
|
|
36
|
-
result[alias] = {
|
|
37
|
-
path: path.slice()
|
|
38
|
-
writable: writable
|
|
39
|
-
}
|
|
40
|
-
return result
|
|
41
|
-
|
|
42
|
-
inheritedControls(form, parent)
|
|
43
|
-
result = form.controls.slice()
|
|
44
|
-
for form.inherit as alias: entry
|
|
45
|
-
if parent == null
|
|
46
|
-
throw "UiInheritanceRequiresParentForm"
|
|
47
|
-
for form.controls as control
|
|
48
|
-
if control.name == alias
|
|
49
|
-
throw "UiInheritedNameCollision: ${alias}"
|
|
50
|
-
source = findSource(parent.controls, entry.path)
|
|
51
|
-
result.add(new InheritedValue(alias, source, entry.writable))
|
|
52
|
-
return result
|
|
53
|
-
|
|
54
|
-
findSource(controls, path)
|
|
55
|
-
current = controls
|
|
56
|
-
target = null
|
|
57
|
-
for path as index: name
|
|
58
|
-
target = null
|
|
59
|
-
for current as control
|
|
60
|
-
if control.name == name
|
|
61
|
-
target = control
|
|
62
|
-
if target == null
|
|
63
|
-
throw "UiInheritedSourceNotFound: ${name}"
|
|
64
|
-
if target.element.langoFormRoot == true
|
|
65
|
-
throw "UiInheritanceCrossesFormBoundary"
|
|
66
|
-
if index < path.length - 1
|
|
67
|
-
current = target.controls
|
|
68
|
-
if !is_array(current)
|
|
69
|
-
throw "UiInheritedSourceIsNotContainer"
|
|
70
|
-
return target
|
|
71
|
-
|
|
72
|
-
inheritanceResources(path, parentPath, spec)
|
|
73
|
-
reads = []
|
|
74
|
-
writes = [path]
|
|
75
|
-
for spec as alias: entry
|
|
76
|
-
if parentPath == null
|
|
77
|
-
throw "UiInheritanceRequiresParentForm"
|
|
78
|
-
source = parentPath.concat(entry.path)
|
|
79
|
-
reads.add(source)
|
|
80
|
-
if entry.writable
|
|
81
|
-
writes.add(source)
|
|
82
|
-
return {
|
|
83
|
-
reads: reads
|
|
84
|
-
writes: writes
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
class InheritedValue
|
|
88
|
-
properties
|
|
89
|
-
name
|
|
90
|
-
controls
|
|
91
|
-
inherited
|
|
92
|
-
writable
|
|
93
|
-
methods
|
|
94
|
-
getValue()
|
|
95
|
-
setValue(value)
|
|
96
|
-
snapshotState()
|
|
97
|
-
restoreState(snapshot)
|
|
98
|
-
isDirty()
|
|
99
|
-
validate()
|
|
100
|
-
reportValidity()
|
|
101
|
-
reportPendingError()
|
|
102
|
-
applyProperty(name, value)
|
|
103
|
-
|
|
104
|
-
InheritedValue(name, source, writable)
|
|
105
|
-
@name = name
|
|
106
|
-
@source = source
|
|
107
|
-
@inherited = true
|
|
108
|
-
@writable = writable
|
|
109
|
-
@controls = null
|
|
110
|
-
if source.element.langoFormRoot == true
|
|
111
|
-
throw "UiInheritanceCrossesFormBoundary"
|
|
112
|
-
if is_array(source.controls)
|
|
113
|
-
@controls = []
|
|
114
|
-
for source.controls as child
|
|
115
|
-
@controls.add(new InheritedValue(child.name, child, writable))
|
|
116
|
-
|
|
117
|
-
InheritedValue:getValue()
|
|
118
|
-
return from_json(to_json(@source.getValue()))
|
|
119
|
-
|
|
120
|
-
InheritedValue:setValue(value)
|
|
121
|
-
if !@writable
|
|
122
|
-
throw "UiInheritedValueReadOnly"
|
|
123
|
-
@source.setValue(from_json(to_json(value)))
|
|
124
|
-
return null
|
|
125
|
-
|
|
126
|
-
InheritedValue:snapshotState()
|
|
127
|
-
if @source.snapshotState != null
|
|
128
|
-
return {
|
|
129
|
-
custom: true
|
|
130
|
-
value: @source.snapshotState()
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
custom: false
|
|
134
|
-
value: getValue()
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
InheritedValue:restoreState(snapshot)
|
|
138
|
-
if snapshot.custom
|
|
139
|
-
return @source.restoreState(snapshot.value)
|
|
140
|
-
return setValue(snapshot.value)
|
|
141
|
-
|
|
142
|
-
InheritedValue:isDirty()
|
|
143
|
-
if !@writable or @source.isDirty == null
|
|
144
|
-
return false
|
|
145
|
-
return @source.isDirty()
|
|
146
|
-
|
|
147
|
-
InheritedValue:validate()
|
|
148
|
-
if !@writable or @source.validate == null
|
|
149
|
-
return null
|
|
150
|
-
if @source.element.disabled == true or @source.element.hidden == true or @source.element.inert == true
|
|
151
|
-
return null
|
|
152
|
-
return @source.validate()
|
|
153
|
-
|
|
154
|
-
InheritedValue:reportValidity()
|
|
155
|
-
if @source.reportValidity != null
|
|
156
|
-
return @source.reportValidity()
|
|
157
|
-
return true
|
|
158
|
-
|
|
159
|
-
InheritedValue:reportPendingError()
|
|
160
|
-
if !@writable or @source.reportPendingError == null
|
|
161
|
-
return false
|
|
162
|
-
return @source.reportPendingError()
|
|
163
|
-
|
|
164
|
-
InheritedValue:applyProperty(name, value)
|
|
165
|
-
if !@writable or (name != "savedValue" and name != "error") or @source.applyProperty == null
|
|
166
|
-
throw "UiInheritedCommandNotAllowed"
|
|
167
|
-
return @source.applyProperty(name, value)
|
package/src/input_values.lango
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export selectItems(options)
|
|
2
|
-
export selectIndex(items, value)
|
|
3
|
-
|
|
4
|
-
selectItems(options)
|
|
5
|
-
if options == null
|
|
6
|
-
return []
|
|
7
|
-
if !is_array(options)
|
|
8
|
-
throw "UiSelectOptionsMustBeArray"
|
|
9
|
-
items = []
|
|
10
|
-
values = []
|
|
11
|
-
for options as option
|
|
12
|
-
if !is_object(option) or !is_string(option.value) or !is_string(option.text)
|
|
13
|
-
throw "UiSelectOptionRequiresValueAndText"
|
|
14
|
-
if values.includes(option.value)
|
|
15
|
-
throw "UiSelectDuplicateValue"
|
|
16
|
-
disabled = option.disabled
|
|
17
|
-
if disabled == null
|
|
18
|
-
disabled = false
|
|
19
|
-
if !is_bool(disabled)
|
|
20
|
-
throw "UiSelectOptionDisabledMustBeBoolean"
|
|
21
|
-
values.add(option.value)
|
|
22
|
-
items.add({
|
|
23
|
-
value: option.value
|
|
24
|
-
text: option.text
|
|
25
|
-
disabled: disabled
|
|
26
|
-
})
|
|
27
|
-
return items
|
|
28
|
-
|
|
29
|
-
selectIndex(items, value)
|
|
30
|
-
if value == null
|
|
31
|
-
return -1
|
|
32
|
-
if !is_string(value)
|
|
33
|
-
throw "UiSelectValueMustBeStringOrNull"
|
|
34
|
-
for items as index: item
|
|
35
|
-
if item.value == value
|
|
36
|
-
return index
|
|
37
|
-
throw "UiSelectValueNotInOptions"
|