@lango-project/lango-client 0.0.0-stage → 0.2.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 (112) hide show
  1. package/LICENSE +200 -0
  2. package/NOTICE +2 -0
  3. package/README.md +929 -2
  4. package/dist/.lango/bignumber.mjs +3119 -0
  5. package/dist/.lango/runtime.mjs +607 -0
  6. package/dist/.lango/xmldom/conventions.js +429 -0
  7. package/dist/.lango/xmldom/dom-parser.js +591 -0
  8. package/dist/.lango/xmldom/dom.js +3759 -0
  9. package/dist/.lango/xmldom/entities.js +2171 -0
  10. package/dist/.lango/xmldom/errors.js +205 -0
  11. package/dist/.lango/xmldom/grammar.js +559 -0
  12. package/dist/.lango/xmldom/index.js +41 -0
  13. package/dist/.lango/xmldom/package.json +1 -0
  14. package/dist/.lango/xmldom/sax.js +983 -0
  15. package/dist/.lango/xmldom.LICENSE.md +8 -0
  16. package/dist/application.mjs +429 -0
  17. package/dist/application.mjs.map +1 -0
  18. package/dist/coordinator.mjs +91 -0
  19. package/dist/coordinator.mjs.map +1 -0
  20. package/dist/demo.mjs +110 -0
  21. package/dist/demo.mjs.map +1 -0
  22. package/dist/demo_controls.mjs +59 -0
  23. package/dist/demo_controls.mjs.map +1 -0
  24. package/dist/errors.mjs +201 -0
  25. package/dist/errors.mjs.map +1 -0
  26. package/dist/form_state.mjs +266 -0
  27. package/dist/form_state.mjs.map +1 -0
  28. package/dist/heartbeat.mjs +330 -0
  29. package/dist/heartbeat.mjs.map +1 -0
  30. package/dist/inheritance.mjs +240 -0
  31. package/dist/inheritance.mjs.map +1 -0
  32. package/dist/input_values.mjs +65 -0
  33. package/dist/input_values.mjs.map +1 -0
  34. package/dist/library.mjs +824 -0
  35. package/dist/library.mjs.map +1 -0
  36. package/dist/navigation.mjs +466 -0
  37. package/dist/navigation.mjs.map +1 -0
  38. package/dist/node/.lango/bignumber.mjs +3119 -0
  39. package/dist/node/.lango/runtime.mjs +609 -0
  40. package/dist/node/.lango/xmldom/conventions.js +429 -0
  41. package/dist/node/.lango/xmldom/dom-parser.js +591 -0
  42. package/dist/node/.lango/xmldom/dom.js +3759 -0
  43. package/dist/node/.lango/xmldom/entities.js +2171 -0
  44. package/dist/node/.lango/xmldom/errors.js +205 -0
  45. package/dist/node/.lango/xmldom/grammar.js +559 -0
  46. package/dist/node/.lango/xmldom/index.js +41 -0
  47. package/dist/node/.lango/xmldom/package.json +1 -0
  48. package/dist/node/.lango/xmldom/sax.js +983 -0
  49. package/dist/node/.lango/xmldom.LICENSE.md +8 -0
  50. package/dist/node/browser_host.mjs +351 -0
  51. package/dist/node/browser_host.mjs.map +1 -0
  52. package/dist/node/create_app.mjs +118 -0
  53. package/dist/node/create_app.mjs.map +1 -0
  54. package/dist/presentation.mjs +89 -0
  55. package/dist/presentation.mjs.map +1 -0
  56. package/dist/protocol.mjs +706 -0
  57. package/dist/protocol.mjs.map +1 -0
  58. package/dist/session.mjs +471 -0
  59. package/dist/session.mjs.map +1 -0
  60. package/dist/tokens.mjs +298 -0
  61. package/dist/tokens.mjs.map +1 -0
  62. package/examples/contacts.lango +293 -0
  63. package/examples/contacts_flow.lango +174 -0
  64. package/examples/contacts_store.lango +109 -0
  65. package/examples/contacts_store_test.lango +65 -0
  66. package/examples/demo.css +87 -0
  67. package/examples/demo_test.lango +356 -0
  68. package/examples/index.html +32 -0
  69. package/examples/pages.lango +174 -0
  70. package/examples/server.lango +189 -0
  71. package/examples/worker.lango +142 -0
  72. package/package.json +68 -4
  73. package/src/application.lango +327 -0
  74. package/src/browser_host.lango +276 -0
  75. package/src/coordinator.lango +57 -0
  76. package/src/demo.lango +110 -0
  77. package/src/demo_controls.lango +53 -0
  78. package/src/errors.lango +149 -0
  79. package/src/errors_test.lango +157 -0
  80. package/src/form_state.lango +168 -0
  81. package/src/heartbeat.lango +230 -0
  82. package/src/heartbeat_test.lango +479 -0
  83. package/src/inheritance.lango +167 -0
  84. package/src/input_values.lango +37 -0
  85. package/src/library.lango +599 -0
  86. package/src/logout_test.lango +564 -0
  87. package/src/navigation.lango +309 -0
  88. package/src/navigation_test.lango +556 -0
  89. package/src/presentation.lango +55 -0
  90. package/src/protocol.lango +787 -0
  91. package/src/renderer_test.lango +2047 -0
  92. package/src/session.lango +343 -0
  93. package/src/session_test.lango +455 -0
  94. package/src/tabs_test.lango +216 -0
  95. package/src/tokens.lango +215 -0
  96. package/template/.vscode/extensions.json +3 -0
  97. package/template/.vscode/settings.json +9 -0
  98. package/template/README.md +44 -0
  99. package/template/gitignore +4 -0
  100. package/template/package.json +22 -0
  101. package/template/public/app.css +10 -0
  102. package/template/public/index.html +24 -0
  103. package/template/src/client.lango +78 -0
  104. package/template/src/pages.lango +55 -0
  105. package/template/src/server.lango +24 -0
  106. package/template/src/worker.lango +77 -0
  107. package/template/test/app.lango +9 -0
  108. package/tools/browser_runner.lango +32 -0
  109. package/tools/browser_test.lango +343 -0
  110. package/tools/create_app.lango +88 -0
  111. package/tools/create_app_test.lango +43 -0
  112. 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"