@lango-project/lango-client 0.0.0-stage → 0.2.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 +200 -0
- package/NOTICE +2 -0
- package/README.md +877 -2
- package/dist/.lango/bignumber.mjs +3119 -0
- package/dist/.lango/runtime.mjs +607 -0
- package/dist/.lango/xmldom/conventions.js +429 -0
- package/dist/.lango/xmldom/dom-parser.js +591 -0
- package/dist/.lango/xmldom/dom.js +3759 -0
- package/dist/.lango/xmldom/entities.js +2171 -0
- package/dist/.lango/xmldom/errors.js +205 -0
- package/dist/.lango/xmldom/grammar.js +559 -0
- package/dist/.lango/xmldom/index.js +41 -0
- package/dist/.lango/xmldom/package.json +1 -0
- package/dist/.lango/xmldom/sax.js +983 -0
- package/dist/.lango/xmldom.LICENSE.md +8 -0
- package/dist/application.mjs +429 -0
- package/dist/application.mjs.map +1 -0
- package/dist/coordinator.mjs +91 -0
- package/dist/coordinator.mjs.map +1 -0
- package/dist/demo.mjs +110 -0
- package/dist/demo.mjs.map +1 -0
- package/dist/demo_controls.mjs +59 -0
- package/dist/demo_controls.mjs.map +1 -0
- package/dist/errors.mjs +201 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/form_state.mjs +266 -0
- package/dist/form_state.mjs.map +1 -0
- package/dist/heartbeat.mjs +330 -0
- package/dist/heartbeat.mjs.map +1 -0
- package/dist/inheritance.mjs +240 -0
- package/dist/inheritance.mjs.map +1 -0
- package/dist/input_values.mjs +65 -0
- package/dist/input_values.mjs.map +1 -0
- package/dist/library.mjs +792 -0
- package/dist/library.mjs.map +1 -0
- package/dist/navigation.mjs +466 -0
- package/dist/navigation.mjs.map +1 -0
- package/dist/node/.lango/bignumber.mjs +3119 -0
- package/dist/node/.lango/runtime.mjs +609 -0
- package/dist/node/.lango/xmldom/conventions.js +429 -0
- package/dist/node/.lango/xmldom/dom-parser.js +591 -0
- package/dist/node/.lango/xmldom/dom.js +3759 -0
- package/dist/node/.lango/xmldom/entities.js +2171 -0
- package/dist/node/.lango/xmldom/errors.js +205 -0
- package/dist/node/.lango/xmldom/grammar.js +559 -0
- package/dist/node/.lango/xmldom/index.js +41 -0
- package/dist/node/.lango/xmldom/package.json +1 -0
- package/dist/node/.lango/xmldom/sax.js +983 -0
- package/dist/node/.lango/xmldom.LICENSE.md +8 -0
- package/dist/node/browser_host.mjs +351 -0
- package/dist/node/browser_host.mjs.map +1 -0
- package/dist/node/create_app.mjs +118 -0
- package/dist/node/create_app.mjs.map +1 -0
- package/dist/presentation.mjs +89 -0
- package/dist/presentation.mjs.map +1 -0
- package/dist/protocol.mjs +706 -0
- package/dist/protocol.mjs.map +1 -0
- package/dist/session.mjs +431 -0
- package/dist/session.mjs.map +1 -0
- package/dist/tokens.mjs +298 -0
- package/dist/tokens.mjs.map +1 -0
- package/examples/contacts.lango +302 -0
- package/examples/contacts_flow.lango +174 -0
- package/examples/contacts_store.lango +109 -0
- package/examples/contacts_store_test.lango +65 -0
- package/examples/demo.css +72 -0
- package/examples/demo_test.lango +356 -0
- package/examples/index.html +28 -0
- package/examples/pages.lango +180 -0
- package/examples/server.lango +189 -0
- package/examples/worker.lango +142 -0
- package/package.json +64 -4
- package/src/application.lango +327 -0
- package/src/browser_host.lango +276 -0
- package/src/coordinator.lango +57 -0
- package/src/demo.lango +110 -0
- package/src/demo_controls.lango +53 -0
- package/src/errors.lango +149 -0
- package/src/errors_test.lango +157 -0
- package/src/form_state.lango +168 -0
- package/src/heartbeat.lango +230 -0
- package/src/heartbeat_test.lango +479 -0
- package/src/inheritance.lango +167 -0
- package/src/input_values.lango +37 -0
- package/src/library.lango +571 -0
- package/src/logout_test.lango +564 -0
- package/src/navigation.lango +309 -0
- package/src/navigation_test.lango +556 -0
- package/src/presentation.lango +55 -0
- package/src/protocol.lango +787 -0
- package/src/renderer_test.lango +1986 -0
- package/src/session.lango +313 -0
- package/src/session_test.lango +455 -0
- package/src/tabs_test.lango +216 -0
- package/src/tokens.lango +215 -0
- package/template/.vscode/extensions.json +3 -0
- package/template/.vscode/settings.json +9 -0
- package/template/README.md +40 -0
- package/template/gitignore +4 -0
- package/template/package.json +22 -0
- package/template/public/app.css +4 -0
- package/template/public/index.html +24 -0
- package/template/src/client.lango +78 -0
- package/template/src/pages.lango +55 -0
- package/template/src/server.lango +24 -0
- package/template/src/worker.lango +77 -0
- package/template/test/app.lango +9 -0
- package/tools/create_app.lango +88 -0
- package/tools/create_app_test.lango +43 -0
- package/tools/starter_test.lango +227 -0
|
@@ -0,0 +1,167 @@
|
|
|
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)
|
|
@@ -0,0 +1,37 @@
|
|
|
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"
|