Christian Fraß commited on 2021-03-12 22:01:27
Zeige 22 geänderte Dateien mit 517 Einfügungen und 6161 Löschungen.
... | ... |
@@ -1,394 +0,0 @@ |
1 |
-declare module lib_call { |
|
2 |
- /** |
|
3 |
- * @desc hacked class for postfix function application |
|
4 |
- * @author fenris |
|
5 |
- */ |
|
6 |
- class class_valuewrapper<type_value> { |
|
7 |
- /** |
|
8 |
- * @author fenris |
|
9 |
- */ |
|
10 |
- protected value: type_value; |
|
11 |
- /** |
|
12 |
- * @desc [constructor] |
|
13 |
- * @author fenris |
|
14 |
- */ |
|
15 |
- constructor(value: type_value); |
|
16 |
- /** |
|
17 |
- * @desc [accessor] applies a function and returns a new valuewrapper |
|
18 |
- * @author fenris |
|
19 |
- */ |
|
20 |
- pass<type_value_>(function_: (value: type_value) => type_value_): class_valuewrapper<type_value_>; |
|
21 |
- /** |
|
22 |
- * @desc [accessor] gives the wrapped value |
|
23 |
- * @author fenris |
|
24 |
- */ |
|
25 |
- extract(): type_value; |
|
26 |
- } |
|
27 |
- /** |
|
28 |
- * @desc shortcut for constructing a valuewrapper-object |
|
29 |
- * @author fenris |
|
30 |
- */ |
|
31 |
- function vw<type_value>(value: type_value): class_valuewrapper<type_value>; |
|
32 |
- /** |
|
33 |
- * @author fenris |
|
34 |
- */ |
|
35 |
- function use<type_input, type_output>(input: type_input, function_: (input: type_input) => type_output): type_output; |
|
36 |
- /** |
|
37 |
- * @desc just the identity; useful for some callbacks etc. |
|
38 |
- * @author fenris |
|
39 |
- */ |
|
40 |
- function id<type_value>(x: type_value): type_value; |
|
41 |
- /** |
|
42 |
- * @desc composes two functions (i.e. returns a function that return the result of the successive execution of both input-functions) |
|
43 |
- * @param {function} function_f |
|
44 |
- * @param {function} function_g |
|
45 |
- * @author fenris |
|
46 |
- */ |
|
47 |
- function compose<type_x, type_y, type_z>(function_f: (type_x: any) => type_y, function_g: (type_y: any) => type_z): (value: type_x) => type_z; |
|
48 |
- /** |
|
49 |
- * @desc transforms a function with sequential input into a function with leveled input; example: add(2,3) = curryfy(add)(2)(3) |
|
50 |
- * @param {function} f |
|
51 |
- * @param {int} n (don't set manually) |
|
52 |
- * @return {function} the currified version of the in put function |
|
53 |
- * @author fenris |
|
54 |
- */ |
|
55 |
- function curryfy(f: Function, n?: int): Function; |
|
56 |
-} |
|
57 |
-declare module lib_call { |
|
58 |
- /** |
|
59 |
- * @author fenris |
|
60 |
- */ |
|
61 |
- type type_executor<type_result, type_reason> = ((resolve: (result?: type_result) => any, reject?: (reason?: type_reason) => void) => void); |
|
62 |
- /** |
|
63 |
- * @author fenris |
|
64 |
- */ |
|
65 |
- function executor_resolve<type_result, type_reason>(result: type_result): type_executor<type_result, type_reason>; |
|
66 |
- /** |
|
67 |
- * @author fenris |
|
68 |
- */ |
|
69 |
- function executor_reject<type_result, type_reason>(reason: type_reason): type_executor<type_result, type_reason>; |
|
70 |
- /** |
|
71 |
- * @author fenris |
|
72 |
- */ |
|
73 |
- function executor_transform<type_result_from, type_error_from, type_result_to, type_error_to>(executor: type_executor<type_result_from, type_error_from>, transform_result: (result_from: type_result_from) => type_result_to, transform_reason: (error_from: type_error_from) => type_error_to): type_executor<type_result_to, type_error_to>; |
|
74 |
- /** |
|
75 |
- * @author fenris |
|
76 |
- */ |
|
77 |
- function executor_transform_default<type_result_from, type_result_to>(executor: type_executor<type_result_from, Error>, transform_result: (result_from: type_result_from) => type_result_to, wrap_string?: string): type_executor<type_result_to, Error>; |
|
78 |
- /** |
|
79 |
- * @author fenris |
|
80 |
- */ |
|
81 |
- function executor_compose_sequential<type_result_first, type_result_second, type_reason>(first: type_executor<type_result_first, type_reason>, second: (result: type_result_first) => type_executor<type_result_second, type_reason>): type_executor<type_result_second, type_reason>; |
|
82 |
- /** |
|
83 |
- * @author fenris |
|
84 |
- */ |
|
85 |
- function executor_chain<type_state, type_error>(state: type_state, executors: Array<(state: type_state) => type_executor<type_state, type_error>>): type_executor<type_state, type_error>; |
|
86 |
- /** |
|
87 |
- * @author fenris |
|
88 |
- */ |
|
89 |
- function executor_first<type_result, type_reason>(executors: Array<type_executor<type_result, type_reason>>): type_executor<type_result, Array<type_reason>>; |
|
90 |
- /** |
|
91 |
- * @author fenris |
|
92 |
- */ |
|
93 |
- function executor_condense<type_element>(executors: Array<type_executor<type_element, Error>>): type_executor<Array<type_element>, Error>; |
|
94 |
- /** |
|
95 |
- * @author fenris |
|
96 |
- * @deprecated use condense |
|
97 |
- */ |
|
98 |
- function executor_filter<type_element>(executors: Array<type_executor<type_element, Error>>, predicate: (element: type_element) => boolean): type_executor<Array<type_element>, Error>; |
|
99 |
- /** |
|
100 |
- * @author fenris |
|
101 |
- * @deprecated use condense |
|
102 |
- */ |
|
103 |
- function executor_map<type_element1, type_element2>(executors: Array<type_executor<type_element1, Error>>, transformator: (element1: type_element1) => type_element2): type_executor<Array<type_element2>, Error>; |
|
104 |
- /** |
|
105 |
- * @author fenris |
|
106 |
- * @deprecated use condense |
|
107 |
- */ |
|
108 |
- function executor_reduce<type_element, type_result>(executors: Array<type_executor<type_element, Error>>, initial: type_result, accumulator: (result: type_result, element: type_element) => type_result): type_executor<type_result, Error>; |
|
109 |
-} |
|
110 |
-declare module lib_call { |
|
111 |
- /** |
|
112 |
- * @author fenris |
|
113 |
- */ |
|
114 |
- type type_promise<type_result, type_reason> = Promise<type_result>; |
|
115 |
- /** |
|
116 |
- * @author fenris |
|
117 |
- */ |
|
118 |
- function promise_reject<type_result, type_reason>(reason: type_reason): type_promise<type_result, type_reason>; |
|
119 |
- /** |
|
120 |
- * @author fenris |
|
121 |
- */ |
|
122 |
- function promise_resolve<type_result, type_reason>(result: type_result): type_promise<type_result, type_reason>; |
|
123 |
- /** |
|
124 |
- * @author fenris |
|
125 |
- */ |
|
126 |
- function promise_make<type_result, type_reason>(executor: (resolve: (result?: type_result) => void, reject: (reason?: type_reason) => void) => void): type_promise<type_result, type_reason>; |
|
127 |
- /** |
|
128 |
- * @author fenris |
|
129 |
- */ |
|
130 |
- function promise_then_close<type_result, type_reason>(promise: type_promise<type_result, type_reason>, resolver: (result: type_result) => void, rejector: (reason: type_reason) => void): void; |
|
131 |
- /** |
|
132 |
- * @author fenris |
|
133 |
- */ |
|
134 |
- function promise_then_append<type_result, type_reason, type_result_>(promise: type_promise<type_result, type_reason>, resolver: (result: type_result) => type_promise<type_result_, type_reason>, rejector?: (reason: type_reason) => type_promise<type_result_, type_reason>): type_promise<type_result_, type_result>; |
|
135 |
- /** |
|
136 |
- * @author fenris |
|
137 |
- */ |
|
138 |
- function promise_all<type_result, type_reason>(promises: Array<type_promise<type_result, type_reason>>): type_promise<Array<type_result>, type_reason>; |
|
139 |
- /** |
|
140 |
- * @author fenris |
|
141 |
- */ |
|
142 |
- function promise_chain<type_result, type_reason>(promises: Array<(input: type_result) => type_promise<type_result, type_reason>>, start?: type_result): type_promise<type_result, type_reason>; |
|
143 |
- /** |
|
144 |
- * @author fenris |
|
145 |
- */ |
|
146 |
- function promise_condense<type_element, type_reason>(promises: Array<() => type_promise<type_element, type_reason>>): type_promise<Array<type_element>, type_reason>; |
|
147 |
- /** |
|
148 |
- * @author fenris |
|
149 |
- */ |
|
150 |
- function promise_group<type_reason>(promises: { |
|
151 |
- [name: string]: () => type_promise<any, type_reason>; |
|
152 |
- }, serial?: boolean): type_promise<{ |
|
153 |
- [name: string]: any; |
|
154 |
- }, type_reason>; |
|
155 |
- /** |
|
156 |
- * @author fenris |
|
157 |
- */ |
|
158 |
- function promise_wrap<type_result_inner, type_result_outer, type_reason>(promise: type_promise<type_result_inner, type_reason>, transformator_result: (reason: type_result_inner) => type_result_outer, transformator_reason?: (reason: type_reason) => type_reason): type_promise<type_result_outer, type_reason>; |
|
159 |
- /** |
|
160 |
- * @author fenris |
|
161 |
- */ |
|
162 |
- function promise_show<type_result, type_reason>(label: string): (result: type_result) => type_promise<type_result, type_reason>; |
|
163 |
- /** |
|
164 |
- * @author fenris |
|
165 |
- */ |
|
166 |
- function promise_log<type_result, type_reason>(result: type_result): (result: type_result) => type_promise<type_result, type_reason>; |
|
167 |
- /** |
|
168 |
- * @author fenris |
|
169 |
- */ |
|
170 |
- function promise_attach<type_reason>(state: { |
|
171 |
- [name: string]: any; |
|
172 |
- }, promise: type_promise<any, type_reason>, name: string): type_promise<{ |
|
173 |
- [name: string]: any; |
|
174 |
- }, type_reason>; |
|
175 |
- /** |
|
176 |
- * @author fenris |
|
177 |
- */ |
|
178 |
- function promise_delay<type_result, type_reason>(promise: type_promise<type_result, type_reason>, delay: int): type_promise<type_result, type_reason>; |
|
179 |
- /** |
|
180 |
- * @author fenris |
|
181 |
- */ |
|
182 |
- function promise_to_executor<type_result, type_reason>(promise: type_promise<type_result, type_reason>): type_executor<type_result, type_reason>; |
|
183 |
-} |
|
184 |
-declare module lib_call { |
|
185 |
- /** |
|
186 |
- * @author fenris |
|
187 |
- */ |
|
188 |
- type type_initializer_state = int; |
|
189 |
- const initializer_state_initial: type_initializer_state; |
|
190 |
- const initializer_state_waiting: type_initializer_state; |
|
191 |
- const initializer_state_successful: type_initializer_state; |
|
192 |
- const initializer_state_failed: type_initializer_state; |
|
193 |
- /** |
|
194 |
- * @author fenris |
|
195 |
- */ |
|
196 |
- type type_initializer<type_result, type_reason> = { |
|
197 |
- fetcher: () => type_promise<type_result, type_reason>; |
|
198 |
- state?: type_initializer_state; |
|
199 |
- queue: Array<{ |
|
200 |
- resolve: (result?: type_result) => void; |
|
201 |
- reject: (reason?: type_reason) => void; |
|
202 |
- }>; |
|
203 |
- result?: type_result; |
|
204 |
- reason?: type_reason; |
|
205 |
- }; |
|
206 |
- /** |
|
207 |
- * @author fenris |
|
208 |
- */ |
|
209 |
- function initializer_make<type_result, type_reason>(fetcher: () => type_promise<type_result, type_reason>): type_initializer<type_result, type_reason>; |
|
210 |
- /** |
|
211 |
- * @author fenris |
|
212 |
- */ |
|
213 |
- function initializer_reset<type_result, type_reason>(subject: type_initializer<type_result, type_reason>): void; |
|
214 |
- /** |
|
215 |
- * @author fenris |
|
216 |
- */ |
|
217 |
- function initializer_state<type_result, type_reason>(subject: type_initializer<type_result, type_reason>): type_initializer_state; |
|
218 |
- /** |
|
219 |
- * @author fenris |
|
220 |
- */ |
|
221 |
- function initializer_get<type_result, type_reason>(subject: type_initializer<type_result, type_reason>): type_promise<type_result, type_reason>; |
|
222 |
-} |
|
223 |
-declare module lib_call { |
|
224 |
- /** |
|
225 |
- * @author fenris |
|
226 |
- */ |
|
227 |
- type type_deferral<type_input, type_output> = { |
|
228 |
- representation: (input: type_input) => Promise<type_output>; |
|
229 |
- }; |
|
230 |
- /** |
|
231 |
- * @author fenris |
|
232 |
- * @desc activates the deferral and handles its output according to a given procedure |
|
233 |
- * @param {(value : type_value)=>void} procedure a function which receives the output of the deferral as argument |
|
234 |
- */ |
|
235 |
- function deferral_use<type_input, type_output>(deferral: type_deferral<type_input, type_output>, input: type_input, procedure: (output: type_output) => void): void; |
|
236 |
- /** |
|
237 |
- * @author fenris |
|
238 |
- * @desc creates a deferral-subject (similar to "new Promise", where "convey" reflects "resolve"/"reject") |
|
239 |
- */ |
|
240 |
- function deferral_make<type_input, type_output>(handler: (input: type_input, convey: (output: type_output) => void) => void): type_deferral<type_input, type_output>; |
|
241 |
- /** |
|
242 |
- * @author fenris |
|
243 |
- * @desc wraps a simple function into a deferral (similar to "Promise.resolve"/"Promise.reject") |
|
244 |
- */ |
|
245 |
- function deferral_wrap<type_input, type_output>(function_: (input: type_input) => type_output): type_deferral<type_input, type_output>; |
|
246 |
- /** |
|
247 |
- * @author fenris |
|
248 |
- */ |
|
249 |
- function deferral_id<type_value>(): type_deferral<type_value, type_value>; |
|
250 |
- /** |
|
251 |
- * @author fenris |
|
252 |
- */ |
|
253 |
- function deferral_const<type_value>(value: type_value): type_deferral<type_value, type_value>; |
|
254 |
- /** |
|
255 |
- * @author fenris |
|
256 |
- */ |
|
257 |
- function deferral_delay<type_output>(output: type_output, delay: int): type_deferral<any, type_output>; |
|
258 |
- /** |
|
259 |
- * @author fenris |
|
260 |
- * @desc connects two deferrals to form a new one; the output of the first is taken as input for the second |
|
261 |
- * (similar to "Promise.then" when passing a function which returns a new promise) |
|
262 |
- * @param {type_deferral<type_value1>} first a simple deferral |
|
263 |
- * @param {(value1 : type_value1)=>type_deferral<type_value2>} second a function depending from a value returning a deferral |
|
264 |
- */ |
|
265 |
- function deferral_compose_serial<type_input, type_between, type_output>(first: type_deferral<type_input, type_between>, second: type_deferral<type_between, type_output>): type_deferral<type_input, type_output>; |
|
266 |
- /** |
|
267 |
- * @author fenris |
|
268 |
- */ |
|
269 |
- function deferral_compose_parallel<type_input, type_output_left, type_output_right>({ "left": deferral_left, "right": deferral_right, }: { |
|
270 |
- left: type_deferral<type_input, type_output_left>; |
|
271 |
- right: type_deferral<type_input, type_output_right>; |
|
272 |
- }): type_deferral<type_input, { |
|
273 |
- left: type_output_left; |
|
274 |
- right: type_output_right; |
|
275 |
- }>; |
|
276 |
- /** |
|
277 |
- * @author fenris |
|
278 |
- * @desc repeatedly applied serial composition |
|
279 |
- */ |
|
280 |
- function deferral_chain<type_value>(members: Array<type_deferral<type_value, type_value>>): type_deferral<type_value, type_value>; |
|
281 |
- /** |
|
282 |
- * @author fenris |
|
283 |
- */ |
|
284 |
-} |
|
285 |
-declare module lib_call { |
|
286 |
- /** |
|
287 |
- * @author fenris |
|
288 |
- */ |
|
289 |
- class class_deferral<type_input, type_output> { |
|
290 |
- /** |
|
291 |
- * @author fenris |
|
292 |
- */ |
|
293 |
- private subject; |
|
294 |
- /** |
|
295 |
- * @author fenris |
|
296 |
- */ |
|
297 |
- private constructor(); |
|
298 |
- /** |
|
299 |
- * @author fenris |
|
300 |
- */ |
|
301 |
- private static _cram; |
|
302 |
- /** |
|
303 |
- * @author fenris |
|
304 |
- */ |
|
305 |
- private static _tear; |
|
306 |
- /** |
|
307 |
- * @author fenris |
|
308 |
- */ |
|
309 |
- static make<type_input, type_output>(handler: (input: type_input, convey: (value: type_output) => void) => void): class_deferral<type_input, type_output>; |
|
310 |
- /** |
|
311 |
- * @author fenris |
|
312 |
- */ |
|
313 |
- use(input: type_input, procedure: (value: type_output) => void): void; |
|
314 |
- /** |
|
315 |
- * @author fenris |
|
316 |
- */ |
|
317 |
- compose_serial<type_output_>(second: class_deferral<type_output, type_output_>): class_deferral<type_input, type_output_>; |
|
318 |
- /** |
|
319 |
- * @author fenris |
|
320 |
- */ |
|
321 |
- static chain<type_value>(members: Array<class_deferral<type_value, type_value>>): class_deferral<type_value, type_value>; |
|
322 |
- /** |
|
323 |
- * @author fenris |
|
324 |
- */ |
|
325 |
- static wrap<type_input, type_output>(function_: (input: type_input) => type_output): class_deferral<type_input, type_output>; |
|
326 |
- /** |
|
327 |
- * @author fenris |
|
328 |
- */ |
|
329 |
- static const_<type_value>(value: type_value): class_deferral<type_value, type_value>; |
|
330 |
- /** |
|
331 |
- * @author fenris |
|
332 |
- */ |
|
333 |
- static delay<type_output>(output: type_output, delay: int): class_deferral<any, type_output>; |
|
334 |
- } |
|
335 |
-} |
|
336 |
-declare module lib_call { |
|
337 |
- /** |
|
338 |
- * @author fenris |
|
339 |
- */ |
|
340 |
- function timeout(function_: () => void, delay: int): int; |
|
341 |
- /** |
|
342 |
- * @desc a definition for a value being "defined" |
|
343 |
- * @author neuc |
|
344 |
- */ |
|
345 |
- function is_def<type_value>(obj: type_value, null_is_valid?: boolean): boolean; |
|
346 |
- /** |
|
347 |
- * @desc returns the value if set and, when a type is specified, if the type is correct, if not return default_value |
|
348 |
- * @author neuc |
|
349 |
- */ |
|
350 |
- function def_val(value: any, default_value: any, type?: string, null_is_valid?: boolean): any; |
|
351 |
- /** |
|
352 |
- * @desc just the empty function; useful for some callbacks etc. |
|
353 |
- * @author fenris |
|
354 |
- */ |
|
355 |
- function nothing(): void; |
|
356 |
- /** |
|
357 |
- * @desc outputs |
|
358 |
- * @author fenris |
|
359 |
- */ |
|
360 |
- function output(...args: Array<any>): void; |
|
361 |
- /** |
|
362 |
- * @desc converts the "arguments"-map into an array |
|
363 |
- * @param {Object} args |
|
364 |
- * @author fenris |
|
365 |
- */ |
|
366 |
- function args2list(args: any): Array<any>; |
|
367 |
- /** |
|
368 |
- * @desc provides the call for an attribute of a class as a regular function |
|
369 |
- * @param {string} name the name of the attribute |
|
370 |
- * @return {*} |
|
371 |
- * @author fenris |
|
372 |
- */ |
|
373 |
- function attribute<type_object, type_attribute>(name: string): (object: type_object) => type_attribute; |
|
374 |
- /** |
|
375 |
- * @desc provides a method of a class as a regular function |
|
376 |
- * @param {string} name the name of the method |
|
377 |
- * @return {function} |
|
378 |
- * @author fenris |
|
379 |
- */ |
|
380 |
- function method<type_object, type_output>(name: string): (object: type_object) => type_output; |
|
381 |
- /** |
|
382 |
- * @author fenris |
|
383 |
- */ |
|
384 |
- type type_unival = { |
|
385 |
- kind: string; |
|
386 |
- data?: any; |
|
387 |
- }; |
|
388 |
- /** |
|
389 |
- * @author fenris |
|
390 |
- */ |
|
391 |
- function distinguish(unival: type_unival, handlers: { |
|
392 |
- [kind: string]: (data?: any) => any; |
|
393 |
- }, fallback?: (unival?: type_unival) => any): any; |
|
394 |
-} |
... | ... |
@@ -1,992 +0,0 @@ |
1 |
-/* |
|
2 |
-This file is part of »bacterio-plankton:call«. |
|
3 |
- |
|
4 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
5 |
-<info@greenscale.de> |
|
6 |
- |
|
7 |
-»bacterio-plankton:call« is free software: you can redistribute it and/or modify |
|
8 |
-it under the terms of the GNU Lesser General Public License as published by |
|
9 |
-the Free Software Foundation, either version 3 of the License, or |
|
10 |
-(at your option) any later version. |
|
11 |
- |
|
12 |
-»bacterio-plankton:call« is distributed in the hope that it will be useful, |
|
13 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
-GNU Lesser General Public License for more details. |
|
16 |
- |
|
17 |
-You should have received a copy of the GNU Lesser General Public License |
|
18 |
-along with »bacterio-plankton:call«. If not, see <http://www.gnu.org/licenses/>. |
|
19 |
- */ |
|
20 |
-"use strict"; |
|
21 |
-/* |
|
22 |
-This file is part of »bacterio-plankton:call«. |
|
23 |
- |
|
24 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
25 |
-<info@greenscale.de> |
|
26 |
- |
|
27 |
-»bacterio-plankton:call« is free software: you can redistribute it and/or modify |
|
28 |
-it under the terms of the GNU Lesser General Public License as published by |
|
29 |
-the Free Software Foundation, either version 3 of the License, or |
|
30 |
-(at your option) any later version. |
|
31 |
- |
|
32 |
-»bacterio-plankton:call« is distributed in the hope that it will be useful, |
|
33 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
34 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
35 |
-GNU Lesser General Public License for more details. |
|
36 |
- |
|
37 |
-You should have received a copy of the GNU Lesser General Public License |
|
38 |
-along with »bacterio-plankton:call«. If not, see <http://www.gnu.org/licenses/>. |
|
39 |
- */ |
|
40 |
-var lib_call; |
|
41 |
-(function (lib_call) { |
|
42 |
- /** |
|
43 |
- * @desc hacked class for postfix function application |
|
44 |
- * @author fenris |
|
45 |
- */ |
|
46 |
- class class_valuewrapper { |
|
47 |
- /** |
|
48 |
- * @desc [constructor] |
|
49 |
- * @author fenris |
|
50 |
- */ |
|
51 |
- constructor(value) { |
|
52 |
- this.value = value; |
|
53 |
- } |
|
54 |
- /** |
|
55 |
- * @desc [accessor] applies a function and returns a new valuewrapper |
|
56 |
- * @author fenris |
|
57 |
- */ |
|
58 |
- pass(function_) { |
|
59 |
- return (new class_valuewrapper(function_(this.value))); |
|
60 |
- } |
|
61 |
- /** |
|
62 |
- * @desc [accessor] gives the wrapped value |
|
63 |
- * @author fenris |
|
64 |
- */ |
|
65 |
- extract() { |
|
66 |
- return this.value; |
|
67 |
- } |
|
68 |
- } |
|
69 |
- lib_call.class_valuewrapper = class_valuewrapper; |
|
70 |
- /** |
|
71 |
- * @desc shortcut for constructing a valuewrapper-object |
|
72 |
- * @author fenris |
|
73 |
- */ |
|
74 |
- function vw(value) { |
|
75 |
- return (new class_valuewrapper(value)); |
|
76 |
- } |
|
77 |
- lib_call.vw = vw; |
|
78 |
- /** |
|
79 |
- * @author fenris |
|
80 |
- */ |
|
81 |
- function use(input, function_) { |
|
82 |
- return function_(input); |
|
83 |
- } |
|
84 |
- lib_call.use = use; |
|
85 |
- /** |
|
86 |
- * @desc just the identity; useful for some callbacks etc. |
|
87 |
- * @author fenris |
|
88 |
- */ |
|
89 |
- function id(x) { |
|
90 |
- return x; |
|
91 |
- } |
|
92 |
- lib_call.id = id; |
|
93 |
- /** |
|
94 |
- * @desc composes two functions (i.e. returns a function that return the result of the successive execution of both input-functions) |
|
95 |
- * @param {function} function_f |
|
96 |
- * @param {function} function_g |
|
97 |
- * @author fenris |
|
98 |
- */ |
|
99 |
- function compose(function_f, function_g) { |
|
100 |
- return (function (x) { |
|
101 |
- // return function_g(function_f(x)); |
|
102 |
- return function_g(function_f.apply(function_f, lib_call.args2list(arguments))); |
|
103 |
- }); |
|
104 |
- } |
|
105 |
- lib_call.compose = compose; |
|
106 |
- /** |
|
107 |
- * @desc transforms a function with sequential input into a function with leveled input; example: add(2,3) = curryfy(add)(2)(3) |
|
108 |
- * @param {function} f |
|
109 |
- * @param {int} n (don't set manually) |
|
110 |
- * @return {function} the currified version of the in put function |
|
111 |
- * @author fenris |
|
112 |
- */ |
|
113 |
- function curryfy(f, n = f.length) { |
|
114 |
- switch (n) { |
|
115 |
- case 0: { |
|
116 |
- throw (new Error("[curryfy] impossible")); |
|
117 |
- // break; |
|
118 |
- } |
|
119 |
- case 1: { |
|
120 |
- return f; |
|
121 |
- // break; |
|
122 |
- } |
|
123 |
- default: { |
|
124 |
- return (function (x) { |
|
125 |
- return (curryfy(function () { return f.apply(f, [x].concat(lib_call.args2list(arguments))); }, n - 1)); |
|
126 |
- }); |
|
127 |
- // break; |
|
128 |
- } |
|
129 |
- } |
|
130 |
- } |
|
131 |
- lib_call.curryfy = curryfy; |
|
132 |
-})(lib_call || (lib_call = {})); |
|
133 |
-var lib_call; |
|
134 |
-(function (lib_call) { |
|
135 |
- /** |
|
136 |
- * @author fenris |
|
137 |
- */ |
|
138 |
- function executor_resolve(result) { |
|
139 |
- return ((resolve, reject) => resolve(result)); |
|
140 |
- } |
|
141 |
- lib_call.executor_resolve = executor_resolve; |
|
142 |
- /** |
|
143 |
- * @author fenris |
|
144 |
- */ |
|
145 |
- function executor_reject(reason) { |
|
146 |
- return ((resolve, reject) => reject(reason)); |
|
147 |
- } |
|
148 |
- lib_call.executor_reject = executor_reject; |
|
149 |
- /** |
|
150 |
- * @author fenris |
|
151 |
- */ |
|
152 |
- function executor_transform(executor, transform_result, transform_reason) { |
|
153 |
- return ((resolve, reject) => { |
|
154 |
- executor(result => resolve(transform_result(result)), reason => reject(transform_reason(reason))); |
|
155 |
- }); |
|
156 |
- } |
|
157 |
- lib_call.executor_transform = executor_transform; |
|
158 |
- /** |
|
159 |
- * @author fenris |
|
160 |
- */ |
|
161 |
- function executor_transform_default(executor, transform_result, wrap_string = null) { |
|
162 |
- let transform_reason = (error => ((wrap_string == null) ? error : new class_error(wrap_string, [error]))); |
|
163 |
- return (executor_transform(executor, transform_result, transform_reason)); |
|
164 |
- } |
|
165 |
- lib_call.executor_transform_default = executor_transform_default; |
|
166 |
- /** |
|
167 |
- * @author fenris |
|
168 |
- */ |
|
169 |
- function executor_compose_sequential(first, second) { |
|
170 |
- return ((resolve, reject) => { |
|
171 |
- first(result => { |
|
172 |
- second(result)(resolve, reject); |
|
173 |
- }, reason => { |
|
174 |
- reject(reason); |
|
175 |
- }); |
|
176 |
- }); |
|
177 |
- } |
|
178 |
- lib_call.executor_compose_sequential = executor_compose_sequential; |
|
179 |
- /** |
|
180 |
- * @author fenris |
|
181 |
- */ |
|
182 |
- function executor_chain(state, executors) { |
|
183 |
- return ((resolve, reject) => { |
|
184 |
- if (executors.length == 0) { |
|
185 |
- return resolve(state); |
|
186 |
- } |
|
187 |
- else { |
|
188 |
- return executors[0](state)(result => { |
|
189 |
- executor_chain(result, executors.slice(1))(resolve, reject); |
|
190 |
- }, reject); |
|
191 |
- } |
|
192 |
- }); |
|
193 |
- /* |
|
194 |
- */ |
|
195 |
- /* |
|
196 |
- if (executors.length == 0) { |
|
197 |
- return executor_resolve<type_state, type_error>(state); |
|
198 |
- } |
|
199 |
- else if (executors.length == 1) { |
|
200 |
- return executors[0](state); |
|
201 |
- } |
|
202 |
- else { |
|
203 |
- return ( |
|
204 |
- executor_chain<type_state, type_error>( |
|
205 |
- state, |
|
206 |
- [ |
|
207 |
- state => (resolve, reject) => executors[0](state)(result => executors[1](result)(resolve, reject), reject) |
|
208 |
- ].concat(executors.slice(2)) |
|
209 |
- ) |
|
210 |
- ); |
|
211 |
- } |
|
212 |
- */ |
|
213 |
- /* |
|
214 |
- return ( |
|
215 |
- executors.reduce( |
|
216 |
- (chain, current) => executor_compose_sequential<type_state, type_state, type_error>(chain, current, deferred), |
|
217 |
- executor_resolve<type_state, type_error>(state) |
|
218 |
- ) |
|
219 |
- ); |
|
220 |
- */ |
|
221 |
- } |
|
222 |
- lib_call.executor_chain = executor_chain; |
|
223 |
- /** |
|
224 |
- * @author fenris |
|
225 |
- */ |
|
226 |
- function executor_first(executors) { |
|
227 |
- /* |
|
228 |
- return ( |
|
229 |
- (resolve, reject) => { |
|
230 |
- if (executors.length == 0) { |
|
231 |
- reject(new Error("all failed")); |
|
232 |
- } |
|
233 |
- else { |
|
234 |
- executors[0]( |
|
235 |
- result => { |
|
236 |
- resolve(result); |
|
237 |
- }, |
|
238 |
- reason => { |
|
239 |
- executor_first<type_result, type_reason>(executors.slice(1))(resolve, reject); |
|
240 |
- } |
|
241 |
- ) |
|
242 |
- } |
|
243 |
- } |
|
244 |
- ); |
|
245 |
- */ |
|
246 |
- return ((resolve, reject) => { |
|
247 |
- executor_chain([], executors.map(executor => reasons => (resolve_, reject_) => { |
|
248 |
- executor(result => reject_(result), reason => resolve_(reasons.concat([reason]))); |
|
249 |
- }))(errors => reject(errors), result => resolve(result)); |
|
250 |
- }); |
|
251 |
- } |
|
252 |
- lib_call.executor_first = executor_first; |
|
253 |
- /** |
|
254 |
- * @author fenris |
|
255 |
- */ |
|
256 |
- function executor_condense(executors) { |
|
257 |
- return (executor_chain([], executors.map(executor => result => (resolve, reject) => { |
|
258 |
- executor(element => resolve(result.concat([element])), reject); |
|
259 |
- }))); |
|
260 |
- } |
|
261 |
- lib_call.executor_condense = executor_condense; |
|
262 |
- /** |
|
263 |
- * @author fenris |
|
264 |
- * @deprecated use condense |
|
265 |
- */ |
|
266 |
- function executor_filter(executors, predicate) { |
|
267 |
- return (executor_chain([], executors.map(executor => result => (resolve, reject) => { |
|
268 |
- executor(element => resolve(predicate(element) ? result.concat([element]) : result), reject); |
|
269 |
- }))); |
|
270 |
- } |
|
271 |
- lib_call.executor_filter = executor_filter; |
|
272 |
- /** |
|
273 |
- * @author fenris |
|
274 |
- * @deprecated use condense |
|
275 |
- */ |
|
276 |
- function executor_map(executors, transformator) { |
|
277 |
- return (executor_chain([], executors.map(executor => result => (resolve, reject) => { |
|
278 |
- executor(element1 => resolve(result.concat([transformator(element1)])), reject); |
|
279 |
- }))); |
|
280 |
- } |
|
281 |
- lib_call.executor_map = executor_map; |
|
282 |
- /** |
|
283 |
- * @author fenris |
|
284 |
- * @deprecated use condense |
|
285 |
- */ |
|
286 |
- function executor_reduce(executors, initial, accumulator) { |
|
287 |
- return (executor_chain(initial, executors.map(executor => result => (resolve, reject) => { |
|
288 |
- executor(element => resolve(accumulator(result, element)), reject); |
|
289 |
- }))); |
|
290 |
- } |
|
291 |
- lib_call.executor_reduce = executor_reduce; |
|
292 |
-})(lib_call || (lib_call = {})); |
|
293 |
-/* |
|
294 |
-This file is part of »bacterio-plankton:call«. |
|
295 |
- |
|
296 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
297 |
-<info@greenscale.de> |
|
298 |
- |
|
299 |
-»bacterio-plankton:call« is free software: you can redistribute it and/or modify |
|
300 |
-it under the terms of the GNU Lesser General Public License as published by |
|
301 |
-the Free Software Foundation, either version 3 of the License, or |
|
302 |
-(at your option) any later version. |
|
303 |
- |
|
304 |
-»bacterio-plankton:call« is distributed in the hope that it will be useful, |
|
305 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
306 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
307 |
-GNU Lesser General Public License for more details. |
|
308 |
- |
|
309 |
-You should have received a copy of the GNU Lesser General Public License |
|
310 |
-along with »bacterio-plankton:call«. If not, see <http://www.gnu.org/licenses/>. |
|
311 |
- */ |
|
312 |
-var lib_call; |
|
313 |
-(function (lib_call) { |
|
314 |
- /** |
|
315 |
- * @author fenris |
|
316 |
- */ |
|
317 |
- function promise_reject(reason) { |
|
318 |
- return Promise.reject(reason); |
|
319 |
- } |
|
320 |
- lib_call.promise_reject = promise_reject; |
|
321 |
- /** |
|
322 |
- * @author fenris |
|
323 |
- */ |
|
324 |
- function promise_resolve(result) { |
|
325 |
- return Promise.resolve(result); |
|
326 |
- } |
|
327 |
- lib_call.promise_resolve = promise_resolve; |
|
328 |
- /** |
|
329 |
- * @author fenris |
|
330 |
- */ |
|
331 |
- function promise_make(executor) { |
|
332 |
- return (new Promise(executor)); |
|
333 |
- } |
|
334 |
- lib_call.promise_make = promise_make; |
|
335 |
- /** |
|
336 |
- * @author fenris |
|
337 |
- */ |
|
338 |
- function promise_then_close(promise, resolver, rejector) { |
|
339 |
- promise.then(resolver, rejector); |
|
340 |
- } |
|
341 |
- lib_call.promise_then_close = promise_then_close; |
|
342 |
- /** |
|
343 |
- * @author fenris |
|
344 |
- */ |
|
345 |
- function promise_then_append(promise, resolver, rejector = null) { |
|
346 |
- if (rejector == null) { |
|
347 |
- rejector = (reason) => promise_reject(reason); |
|
348 |
- } |
|
349 |
- return (promise.then(resolver, rejector)); |
|
350 |
- } |
|
351 |
- lib_call.promise_then_append = promise_then_append; |
|
352 |
- /** |
|
353 |
- * @author fenris |
|
354 |
- */ |
|
355 |
- function promise_all(promises) { |
|
356 |
- return Promise.all(promises); |
|
357 |
- } |
|
358 |
- lib_call.promise_all = promise_all; |
|
359 |
- /** |
|
360 |
- * @author fenris |
|
361 |
- */ |
|
362 |
- function promise_chain(promises, start = undefined) { |
|
363 |
- return (promises.reduce((chain, promise) => promise_then_append(chain, promise), promise_resolve(start))); |
|
364 |
- } |
|
365 |
- lib_call.promise_chain = promise_chain; |
|
366 |
- /** |
|
367 |
- * @author fenris |
|
368 |
- */ |
|
369 |
- function promise_condense(promises) { |
|
370 |
- return (promise_chain(promises.map(promise => result => promise_then_append(promise(), element => promise_resolve(result.concat([element])))), [])); |
|
371 |
- } |
|
372 |
- lib_call.promise_condense = promise_condense; |
|
373 |
- /** |
|
374 |
- * @author fenris |
|
375 |
- */ |
|
376 |
- function promise_group(promises, serial = false) { |
|
377 |
- const decorate = function (promise, name) { |
|
378 |
- return (() => promise_then_append(promise(), value => promise_resolve({ "key": name, "value": value }))); |
|
379 |
- }; |
|
380 |
- const convert = function (array) { |
|
381 |
- let object = {}; |
|
382 |
- array.forEach(({ "key": key, "value": value }) => { object[key] = value; }); |
|
383 |
- return object; |
|
384 |
- }; |
|
385 |
- if (serial) { |
|
386 |
- return (promise_then_append(promise_condense(Object.keys(promises) |
|
387 |
- .map(name => decorate(promises[name], name))), list => promise_resolve(convert(list)))); |
|
388 |
- } |
|
389 |
- else { |
|
390 |
- return (promise_then_append(promise_all(Object.keys(promises) |
|
391 |
- .map(name => decorate(promises[name], name)) |
|
392 |
- .map(promise => promise())), list => promise_resolve(convert(list)))); |
|
393 |
- } |
|
394 |
- } |
|
395 |
- lib_call.promise_group = promise_group; |
|
396 |
- /** |
|
397 |
- * @author fenris |
|
398 |
- */ |
|
399 |
- function promise_wrap(promise, transformator_result, transformator_reason = lib_call.id) { |
|
400 |
- return (promise_make((resolve, reject) => { |
|
401 |
- promise_then_close(promise, result => resolve(transformator_result(result)), reason => reject(transformator_reason(reason))); |
|
402 |
- })); |
|
403 |
- } |
|
404 |
- lib_call.promise_wrap = promise_wrap; |
|
405 |
- /** |
|
406 |
- * @author fenris |
|
407 |
- */ |
|
408 |
- function promise_show(label) { |
|
409 |
- return (result => promise_make((resolve, reject) => { |
|
410 |
- lib_log.info(label + ": " + instance_show(result)); |
|
411 |
- resolve(result); |
|
412 |
- })); |
|
413 |
- } |
|
414 |
- lib_call.promise_show = promise_show; |
|
415 |
- /** |
|
416 |
- * @author fenris |
|
417 |
- */ |
|
418 |
- function promise_log(result) { |
|
419 |
- return promise_show("log"); |
|
420 |
- } |
|
421 |
- lib_call.promise_log = promise_log; |
|
422 |
- /** |
|
423 |
- * @author fenris |
|
424 |
- */ |
|
425 |
- function promise_attach(state, promise, name) { |
|
426 |
- return (promise_wrap(promise, result => { |
|
427 |
- state[name] = result; |
|
428 |
- return state; |
|
429 |
- })); |
|
430 |
- } |
|
431 |
- lib_call.promise_attach = promise_attach; |
|
432 |
- /** |
|
433 |
- * @author fenris |
|
434 |
- */ |
|
435 |
- function promise_delay(promise, delay) { |
|
436 |
- return promise_make((resolve, reject) => { |
|
437 |
- lib_call.timeout(() => { |
|
438 |
- promise_then_close(promise, resolve, reject); |
|
439 |
- return null; |
|
440 |
- }, delay); |
|
441 |
- }); |
|
442 |
- } |
|
443 |
- lib_call.promise_delay = promise_delay; |
|
444 |
- /** |
|
445 |
- * @author fenris |
|
446 |
- */ |
|
447 |
- function promise_to_executor(promise) { |
|
448 |
- return ((resolve, reject) => promise.then(resolve, reject)); |
|
449 |
- } |
|
450 |
- lib_call.promise_to_executor = promise_to_executor; |
|
451 |
-})(lib_call || (lib_call = {})); |
|
452 |
-/* |
|
453 |
-This file is part of »bacterio-plankton:call«. |
|
454 |
- |
|
455 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
456 |
-<info@greenscale.de> |
|
457 |
- |
|
458 |
-»bacterio-plankton:call« is free software: you can redistribute it and/or modify |
|
459 |
-it under the terms of the GNU Lesser General Public License as published by |
|
460 |
-the Free Software Foundation, either version 3 of the License, or |
|
461 |
-(at your option) any later version. |
|
462 |
- |
|
463 |
-»bacterio-plankton:call« is distributed in the hope that it will be useful, |
|
464 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
465 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
466 |
-GNU Lesser General Public License for more details. |
|
467 |
- |
|
468 |
-You should have received a copy of the GNU Lesser General Public License |
|
469 |
-along with »bacterio-plankton:call«. If not, see <http://www.gnu.org/licenses/>. |
|
470 |
- */ |
|
471 |
-var lib_call; |
|
472 |
-(function (lib_call) { |
|
473 |
- lib_call.initializer_state_initial = 0; |
|
474 |
- lib_call.initializer_state_waiting = 1; |
|
475 |
- lib_call.initializer_state_successful = 2; |
|
476 |
- lib_call.initializer_state_failed = 3; |
|
477 |
- /** |
|
478 |
- * @author fenris |
|
479 |
- */ |
|
480 |
- function initializer_make(fetcher) { |
|
481 |
- let subject = { |
|
482 |
- "fetcher": fetcher, |
|
483 |
- "state": lib_call.initializer_state_initial, |
|
484 |
- "queue": [], |
|
485 |
- "result": undefined, |
|
486 |
- "reason": undefined, |
|
487 |
- }; |
|
488 |
- return subject; |
|
489 |
- } |
|
490 |
- lib_call.initializer_make = initializer_make; |
|
491 |
- /** |
|
492 |
- * @author fenris |
|
493 |
- */ |
|
494 |
- function initializer_actuate(subject) { |
|
495 |
- switch (subject.state) { |
|
496 |
- case lib_call.initializer_state_successful: { |
|
497 |
- subject.queue.forEach(entry => entry.resolve(subject.result)); |
|
498 |
- break; |
|
499 |
- } |
|
500 |
- case lib_call.initializer_state_failed: { |
|
501 |
- subject.queue.forEach(entry => entry.reject(subject.reason)); |
|
502 |
- break; |
|
503 |
- } |
|
504 |
- default: { |
|
505 |
- let message = `unhandled state ${subject.state}`; |
|
506 |
- throw (new Error(message)); |
|
507 |
- break; |
|
508 |
- } |
|
509 |
- } |
|
510 |
- } |
|
511 |
- /** |
|
512 |
- * @author fenris |
|
513 |
- */ |
|
514 |
- function initializer_reset(subject) { |
|
515 |
- subject.state = lib_call.initializer_state_initial; |
|
516 |
- subject.queue = []; |
|
517 |
- } |
|
518 |
- lib_call.initializer_reset = initializer_reset; |
|
519 |
- /** |
|
520 |
- * @author fenris |
|
521 |
- */ |
|
522 |
- function initializer_state(subject) { |
|
523 |
- return subject.state; |
|
524 |
- } |
|
525 |
- lib_call.initializer_state = initializer_state; |
|
526 |
- /** |
|
527 |
- * @author fenris |
|
528 |
- */ |
|
529 |
- function initializer_get(subject) { |
|
530 |
- switch (subject.state) { |
|
531 |
- case lib_call.initializer_state_initial: { |
|
532 |
- subject.state = lib_call.initializer_state_waiting; |
|
533 |
- return (lib_call.promise_make((resolve, reject) => { |
|
534 |
- subject.queue.push({ "resolve": resolve, "reject": reject }); |
|
535 |
- subject.fetcher().then(result => { |
|
536 |
- subject.state = lib_call.initializer_state_successful; |
|
537 |
- subject.result = result; |
|
538 |
- initializer_actuate(subject); |
|
539 |
- }, reason => { |
|
540 |
- subject.state = lib_call.initializer_state_failed; |
|
541 |
- subject.reason = reason; |
|
542 |
- initializer_actuate(subject); |
|
543 |
- }); |
|
544 |
- })); |
|
545 |
- break; |
|
546 |
- } |
|
547 |
- case lib_call.initializer_state_waiting: { |
|
548 |
- return (lib_call.promise_make((resolve, reject) => { |
|
549 |
- subject.queue.push({ "resolve": resolve, "reject": reject }); |
|
550 |
- })); |
|
551 |
- break; |
|
552 |
- } |
|
553 |
- case lib_call.initializer_state_successful: { |
|
554 |
- return (lib_call.promise_resolve(subject.result)); |
|
555 |
- break; |
|
556 |
- } |
|
557 |
- case lib_call.initializer_state_failed: { |
|
558 |
- return (lib_call.promise_reject(subject.reason)); |
|
559 |
- break; |
|
560 |
- } |
|
561 |
- default: { |
|
562 |
- let message = `unhandled state ${subject.state}`; |
|
563 |
- throw (new Error(message)); |
|
564 |
- break; |
|
565 |
- } |
|
566 |
- } |
|
567 |
- } |
|
568 |
- lib_call.initializer_get = initializer_get; |
|
569 |
- /** |
|
570 |
- * @author fenris |
|
571 |
- */ |
|
572 |
- function initializer_get_sync(subject) { |
|
573 |
- switch (subject.state) { |
|
574 |
- case lib_call.initializer_state_successful: { |
|
575 |
- return subject.result; |
|
576 |
- break; |
|
577 |
- } |
|
578 |
- case lib_call.initializer_state_failed: { |
|
579 |
- throw subject.reason; |
|
580 |
- break; |
|
581 |
- } |
|
582 |
- default: { |
|
583 |
- let message = `unhandled state ${subject.state}`; |
|
584 |
- throw (new Error(message)); |
|
585 |
- break; |
|
586 |
- } |
|
587 |
- } |
|
588 |
- } |
|
589 |
- /** |
|
590 |
- * @author fenris |
|
591 |
- */ |
|
592 |
- function initializer_set_sync(subject, result) { |
|
593 |
- switch (subject.state) { |
|
594 |
- case lib_call.initializer_state_successful: { |
|
595 |
- subject.result = result; |
|
596 |
- break; |
|
597 |
- } |
|
598 |
- case lib_call.initializer_state_failed: { |
|
599 |
- subject.state = lib_call.initializer_state_successful; |
|
600 |
- subject.result = result; |
|
601 |
- break; |
|
602 |
- } |
|
603 |
- default: { |
|
604 |
- let message = `unhandled state ${subject.state}`; |
|
605 |
- throw (new Error(message)); |
|
606 |
- break; |
|
607 |
- } |
|
608 |
- } |
|
609 |
- } |
|
610 |
-})(lib_call || (lib_call = {})); |
|
611 |
-/* |
|
612 |
-This file is part of »bacterio-plankton:call«. |
|
613 |
- |
|
614 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
615 |
-<info@greenscale.de> |
|
616 |
- |
|
617 |
-»bacterio-plankton:call« is free software: you can redistribute it and/or modify |
|
618 |
-it under the terms of the GNU Lesser General Public License as published by |
|
619 |
-the Free Software Foundation, either version 3 of the License, or |
|
620 |
-(at your option) any later version. |
|
621 |
- |
|
622 |
-»bacterio-plankton:call« is distributed in the hope that it will be useful, |
|
623 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
624 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
625 |
-GNU Lesser General Public License for more details. |
|
626 |
- |
|
627 |
-You should have received a copy of the GNU Lesser General Public License |
|
628 |
-along with »bacterio-plankton:call«. If not, see <http://www.gnu.org/licenses/>. |
|
629 |
- */ |
|
630 |
-var lib_call; |
|
631 |
-(function (lib_call) { |
|
632 |
- /* |
|
633 |
- The core idea of this library is to provide means for asynchronous program flow. The old-school way to do is, |
|
634 |
- is to use callbacks. While this approach is simple and easy to understand, it has some disadvantages. As an |
|
635 |
- attempt to relief and improve this, the promise-system was introduced. In principle it solves most of the |
|
636 |
- problems found in the callback-approach; however it has some downsides as well: |
|
637 |
- |
|
638 |
- - Convolution of multiple principles |
|
639 |
- Promises unite the ideas of asynchronous program flow and error handling. |
|
640 |
- |
|
641 |
- - Instant execution |
|
642 |
- Creating a promise results in the instant execution of the given executor prodecure. While this might be |
|
643 |
- convenient in some cases, it can be quite disturbing and counter-intuitive in others. |
|
644 |
- |
|
645 |
- - Broken typing |
|
646 |
- The Promise system doesn't distinguish between an appending "then" (i.e. passing a function, which returns a |
|
647 |
- new promise) and a closing "then" (i.e. passing a function, which has no return value). On top of that it |
|
648 |
- allows returning simple values in an appending "then", which results in an implicit call of the executors |
|
649 |
- "resolve"-function. The price for these "pragmatic" features is that the whole system can't be typed well. |
|
650 |
- And even though JavaScript is not a strictly typed language, it was a quite questionable decision to design |
|
651 |
- the promise system in a way, which breaks typing from the start. |
|
652 |
- |
|
653 |
- The deferral-system forseeks to solve these issues while retaining the advantages of the promise-system. |
|
654 |
- */ |
|
655 |
- /** |
|
656 |
- * @author fenris |
|
657 |
- * @desc activates the deferral and handles its output according to a given procedure |
|
658 |
- * @param {(value : type_value)=>void} procedure a function which receives the output of the deferral as argument |
|
659 |
- */ |
|
660 |
- function deferral_use(deferral, input, procedure) { |
|
661 |
- deferral.representation(input).then(value => { |
|
662 |
- procedure(value); |
|
663 |
- }, reason => { |
|
664 |
- throw reason; |
|
665 |
- }); |
|
666 |
- } |
|
667 |
- lib_call.deferral_use = deferral_use; |
|
668 |
- /** |
|
669 |
- * @author fenris |
|
670 |
- * @desc creates a deferral-subject (similar to "new Promise", where "convey" reflects "resolve"/"reject") |
|
671 |
- */ |
|
672 |
- function deferral_make(handler) { |
|
673 |
- return ({ |
|
674 |
- "representation": ((input) => (new Promise((resolve, reject) => { |
|
675 |
- handler(input, resolve); |
|
676 |
- }))) |
|
677 |
- }); |
|
678 |
- } |
|
679 |
- lib_call.deferral_make = deferral_make; |
|
680 |
- /** |
|
681 |
- * @author fenris |
|
682 |
- * @desc wraps a simple function into a deferral (similar to "Promise.resolve"/"Promise.reject") |
|
683 |
- */ |
|
684 |
- function deferral_wrap(function_) { |
|
685 |
- return (deferral_make((input, convey) => convey(function_(input)))); |
|
686 |
- } |
|
687 |
- lib_call.deferral_wrap = deferral_wrap; |
|
688 |
- /** |
|
689 |
- * @author fenris |
|
690 |
- */ |
|
691 |
- function deferral_id() { |
|
692 |
- return (deferral_make((input, convey) => convey(input))); |
|
693 |
- } |
|
694 |
- lib_call.deferral_id = deferral_id; |
|
695 |
- /** |
|
696 |
- * @author fenris |
|
697 |
- */ |
|
698 |
- function deferral_const(value) { |
|
699 |
- return (deferral_make((input, convey) => convey(value))); |
|
700 |
- } |
|
701 |
- lib_call.deferral_const = deferral_const; |
|
702 |
- /** |
|
703 |
- * @author fenris |
|
704 |
- */ |
|
705 |
- function deferral_delay(output, delay) { |
|
706 |
- return (deferral_make((input, convey) => { |
|
707 |
- setTimeout(() => convey(output), delay); |
|
708 |
- })); |
|
709 |
- } |
|
710 |
- lib_call.deferral_delay = deferral_delay; |
|
711 |
- /** |
|
712 |
- * @author fenris |
|
713 |
- * @desc connects two deferrals to form a new one; the output of the first is taken as input for the second |
|
714 |
- * (similar to "Promise.then" when passing a function which returns a new promise) |
|
715 |
- * @param {type_deferral<type_value1>} first a simple deferral |
|
716 |
- * @param {(value1 : type_value1)=>type_deferral<type_value2>} second a function depending from a value returning a deferral |
|
717 |
- */ |
|
718 |
- function deferral_compose_serial(first, second) { |
|
719 |
- return { |
|
720 |
- "representation": ((input) => first.representation(input).then((between) => second.representation(between))) |
|
721 |
- }; |
|
722 |
- } |
|
723 |
- lib_call.deferral_compose_serial = deferral_compose_serial; |
|
724 |
- /** |
|
725 |
- * @author fenris |
|
726 |
- */ |
|
727 |
- function deferral_compose_parallel({ "left": deferral_left, "right": deferral_right, }) { |
|
728 |
- return (deferral_make((input, convey) => { |
|
729 |
- let object = { |
|
730 |
- "left": lib_maybe.make_nothing(), |
|
731 |
- "right": lib_maybe.make_nothing(), |
|
732 |
- }; |
|
733 |
- let finish = function () { |
|
734 |
- if (lib_maybe.is_just(object.left) |
|
735 |
- && |
|
736 |
- lib_maybe.is_just(object.right)) { |
|
737 |
- let result = { |
|
738 |
- "left": lib_maybe.cull(object.left), |
|
739 |
- "right": lib_maybe.cull(object.right), |
|
740 |
- }; |
|
741 |
- convey(result); |
|
742 |
- } |
|
743 |
- else { |
|
744 |
- // do nothing |
|
745 |
- } |
|
746 |
- }; |
|
747 |
- deferral_use(deferral_left, input, output_left => { |
|
748 |
- object.left = lib_maybe.make_just(output_left); |
|
749 |
- finish(); |
|
750 |
- }); |
|
751 |
- deferral_use(deferral_right, input, output_right => { |
|
752 |
- object.right = lib_maybe.make_just(output_right); |
|
753 |
- finish(); |
|
754 |
- }); |
|
755 |
- })); |
|
756 |
- } |
|
757 |
- lib_call.deferral_compose_parallel = deferral_compose_parallel; |
|
758 |
- /** |
|
759 |
- * @author fenris |
|
760 |
- * @desc repeatedly applied serial composition |
|
761 |
- */ |
|
762 |
- function deferral_chain(members) { |
|
763 |
- return (members.reduce( |
|
764 |
- // (result, current) => deferral_compose_serial<type_value, type_value, type_value>(result, current), |
|
765 |
- deferral_compose_serial, deferral_id())); |
|
766 |
- } |
|
767 |
- lib_call.deferral_chain = deferral_chain; |
|
768 |
- /** |
|
769 |
- * @author fenris |
|
770 |
- */ |
|
771 |
- /* |
|
772 |
- export function deferral_bunch<type_input, type_output>( |
|
773 |
- members : {[name : string] : type_deferral<type_input, type_output>} |
|
774 |
- ) : type_deferral<type_input, {[name : string] : type_output}> { |
|
775 |
- |
|
776 |
- } |
|
777 |
- */ |
|
778 |
-})(lib_call || (lib_call = {})); |
|
779 |
-/* |
|
780 |
-This file is part of »bacterio-plankton:call«. |
|
781 |
- |
|
782 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
783 |
-<info@greenscale.de> |
|
784 |
- |
|
785 |
-»bacterio-plankton:call« is free software: you can redistribute it and/or modify |
|
786 |
-it under the terms of the GNU Lesser General Public License as published by |
|
787 |
-the Free Software Foundation, either version 3 of the License, or |
|
788 |
-(at your option) any later version. |
|
789 |
- |
|
790 |
-»bacterio-plankton:call« is distributed in the hope that it will be useful, |
|
791 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
792 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
793 |
-GNU Lesser General Public License for more details. |
|
794 |
- |
|
795 |
-You should have received a copy of the GNU Lesser General Public License |
|
796 |
-along with »bacterio-plankton:call«. If not, see <http://www.gnu.org/licenses/>. |
|
797 |
- */ |
|
798 |
-var lib_call; |
|
799 |
-(function (lib_call) { |
|
800 |
- /** |
|
801 |
- * @author fenris |
|
802 |
- */ |
|
803 |
- class class_deferral { |
|
804 |
- /** |
|
805 |
- * @author fenris |
|
806 |
- */ |
|
807 |
- constructor(subject) { |
|
808 |
- this.subject = subject; |
|
809 |
- } |
|
810 |
- /** |
|
811 |
- * @author fenris |
|
812 |
- */ |
|
813 |
- static _cram(subject) { |
|
814 |
- return (new class_deferral(subject)); |
|
815 |
- } |
|
816 |
- /** |
|
817 |
- * @author fenris |
|
818 |
- */ |
|
819 |
- static _tear(instance) { |
|
820 |
- return instance.subject; |
|
821 |
- } |
|
822 |
- /** |
|
823 |
- * @author fenris |
|
824 |
- */ |
|
825 |
- static make(handler) { |
|
826 |
- return (class_deferral._cram(lib_call.deferral_make(handler))); |
|
827 |
- } |
|
828 |
- /** |
|
829 |
- * @author fenris |
|
830 |
- */ |
|
831 |
- use(input, procedure) { |
|
832 |
- return (lib_call.deferral_use(class_deferral._tear(this), input, procedure)); |
|
833 |
- } |
|
834 |
- /** |
|
835 |
- * @author fenris |
|
836 |
- */ |
|
837 |
- compose_serial(second) { |
|
838 |
- return (class_deferral._cram(lib_call.deferral_compose_serial(class_deferral._tear(this), class_deferral._tear(second)))); |
|
839 |
- } |
|
840 |
- /** |
|
841 |
- * @author fenris |
|
842 |
- */ |
|
843 |
- static chain(members) { |
|
844 |
- return (class_deferral._cram(lib_call.deferral_chain(members.map(member => class_deferral._tear(member))))); |
|
845 |
- } |
|
846 |
- /** |
|
847 |
- * @author fenris |
|
848 |
- */ |
|
849 |
- static wrap(function_) { |
|
850 |
- return (class_deferral._cram(lib_call.deferral_wrap(function_))); |
|
851 |
- } |
|
852 |
- /** |
|
853 |
- * @author fenris |
|
854 |
- */ |
|
855 |
- static const_(value) { |
|
856 |
- return (class_deferral._cram(lib_call.deferral_const(value))); |
|
857 |
- } |
|
858 |
- /** |
|
859 |
- * @author fenris |
|
860 |
- */ |
|
861 |
- static delay(output, delay) { |
|
862 |
- return (class_deferral._cram(lib_call.deferral_delay(output, delay))); |
|
863 |
- } |
|
864 |
- } |
|
865 |
- lib_call.class_deferral = class_deferral; |
|
866 |
-})(lib_call || (lib_call = {})); |
|
867 |
-/* |
|
868 |
-This file is part of »bacterio-plankton:call«. |
|
869 |
- |
|
870 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
871 |
-<info@greenscale.de> |
|
872 |
- |
|
873 |
-»bacterio-plankton:call« is free software: you can redistribute it and/or modify |
|
874 |
-it under the terms of the GNU Lesser General Public License as published by |
|
875 |
-the Free Software Foundation, either version 3 of the License, or |
|
876 |
-(at your option) any later version. |
|
877 |
- |
|
878 |
-»bacterio-plankton:call« is distributed in the hope that it will be useful, |
|
879 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
880 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
881 |
-GNU Lesser General Public License for more details. |
|
882 |
- |
|
883 |
-You should have received a copy of the GNU Lesser General Public License |
|
884 |
-along with »bacterio-plankton:call«. If not, see <http://www.gnu.org/licenses/>. |
|
885 |
- */ |
|
886 |
-var lib_call; |
|
887 |
-(function (lib_call) { |
|
888 |
- /** |
|
889 |
- * @author fenris |
|
890 |
- */ |
|
891 |
- function timeout(function_, delay) { |
|
892 |
- return ( |
|
893 |
- /*window.*/ setTimeout(function_, delay)); |
|
894 |
- } |
|
895 |
- lib_call.timeout = timeout; |
|
896 |
- /** |
|
897 |
- * @desc a definition for a value being "defined" |
|
898 |
- * @author neuc |
|
899 |
- */ |
|
900 |
- function is_def(obj, null_is_valid = false) { |
|
901 |
- return (!((typeof (obj) === "undefined") |
|
902 |
- || |
|
903 |
- (!null_is_valid && (obj === null)))); |
|
904 |
- } |
|
905 |
- lib_call.is_def = is_def; |
|
906 |
- /** |
|
907 |
- * @desc returns the value if set and, when a type is specified, if the type is correct, if not return default_value |
|
908 |
- * @author neuc |
|
909 |
- */ |
|
910 |
- function def_val(value, default_value, type = null, null_is_valid = false) { |
|
911 |
- if (is_def(value, null_is_valid) |
|
912 |
- && |
|
913 |
- (is_def(type) |
|
914 |
- ? ((typeof value === type) |
|
915 |
- || |
|
916 |
- ((value === null) |
|
917 |
- && |
|
918 |
- null_is_valid)) |
|
919 |
- : true)) { |
|
920 |
- return value; |
|
921 |
- } |
|
922 |
- else { |
|
923 |
- return default_value; |
|
924 |
- } |
|
925 |
- } |
|
926 |
- lib_call.def_val = def_val; |
|
927 |
- ; |
|
928 |
- /** |
|
929 |
- * @desc just the empty function; useful for some callbacks etc. |
|
930 |
- * @author fenris |
|
931 |
- */ |
|
932 |
- function nothing() { |
|
933 |
- } |
|
934 |
- lib_call.nothing = nothing; |
|
935 |
- /** |
|
936 |
- * @desc outputs |
|
937 |
- * @author fenris |
|
938 |
- */ |
|
939 |
- function output(...args) { |
|
940 |
- lib_log.info.apply(lib_log, args); |
|
941 |
- } |
|
942 |
- lib_call.output = output; |
|
943 |
- /** |
|
944 |
- * @desc converts the "arguments"-map into an array |
|
945 |
- * @param {Object} args |
|
946 |
- * @author fenris |
|
947 |
- */ |
|
948 |
- function args2list(args) { |
|
949 |
- return Object.keys(args).map(key => args[key]); |
|
950 |
- } |
|
951 |
- lib_call.args2list = args2list; |
|
952 |
- /** |
|
953 |
- * @desc provides the call for an attribute of a class as a regular function |
|
954 |
- * @param {string} name the name of the attribute |
|
955 |
- * @return {*} |
|
956 |
- * @author fenris |
|
957 |
- */ |
|
958 |
- function attribute(name) { |
|
959 |
- return ((object) => object[name]); |
|
960 |
- } |
|
961 |
- lib_call.attribute = attribute; |
|
962 |
- /** |
|
963 |
- * @desc provides a method of a class as a regular function |
|
964 |
- * @param {string} name the name of the method |
|
965 |
- * @return {function} |
|
966 |
- * @author fenris |
|
967 |
- */ |
|
968 |
- function method(name) { |
|
969 |
- return (function (object) { return object[name].apply(object, args2list(arguments).slice(1)); }); |
|
970 |
- } |
|
971 |
- lib_call.method = method; |
|
972 |
- /** |
|
973 |
- * @author fenris |
|
974 |
- */ |
|
975 |
- function distinguish(unival, handlers, fallback = null) { |
|
976 |
- if (unival.kind in handlers) { |
|
977 |
- let handler = handlers[unival.kind]; |
|
978 |
- return handler(unival.data); |
|
979 |
- } |
|
980 |
- else { |
|
981 |
- let message = ("unhandled kind '" + unival.kind + "'"); |
|
982 |
- if (fallback !== null) { |
|
983 |
- console.warn(message); |
|
984 |
- return fallback(unival); |
|
985 |
- } |
|
986 |
- else { |
|
987 |
- throw (new Error(message)); |
|
988 |
- } |
|
989 |
- } |
|
990 |
- } |
|
991 |
- lib_call.distinguish = distinguish; |
|
992 |
-})(lib_call || (lib_call = {})); |
... | ... |
@@ -244,39 +244,6 @@ declare module lib_code { |
244 | 244 |
decode(x: string): Date; |
245 | 245 |
} |
246 | 246 |
} |
247 |
-declare module lib_code { |
|
248 |
- /** |
|
249 |
- * @author fenris |
|
250 |
- */ |
|
251 |
- function json_encode(x: any, formatted?: boolean): string; |
|
252 |
- /** |
|
253 |
- * @author fenris |
|
254 |
- */ |
|
255 |
- function json_decode(x: string): any; |
|
256 |
-} |
|
257 |
-declare module lib_code { |
|
258 |
-} |
|
259 |
-declare module lib_code { |
|
260 |
- /** |
|
261 |
- * @author fenris |
|
262 |
- */ |
|
263 |
- class class_code_json implements interface_code<any, string> { |
|
264 |
- /** |
|
265 |
- * @author fenris |
|
266 |
- */ |
|
267 |
- constructor(); |
|
268 |
- /** |
|
269 |
- * @implementation |
|
270 |
- * @author fenris |
|
271 |
- */ |
|
272 |
- encode(x: any): string; |
|
273 |
- /** |
|
274 |
- * @implementation |
|
275 |
- * @author fenris |
|
276 |
- */ |
|
277 |
- decode(x: string): any; |
|
278 |
- } |
|
279 |
-} |
|
280 | 247 |
declare module lib_code { |
281 | 248 |
/** |
282 | 249 |
* @author Christian Fraß <frass@greenscale.de> |
... | ... |
@@ -323,69 +290,3 @@ declare module lib_code { |
323 | 290 |
decode(x: string): type_csv_from; |
324 | 291 |
} |
325 | 292 |
} |
326 |
-declare module lib_code { |
|
327 |
- /** |
|
328 |
- * @author fenris |
|
329 |
- */ |
|
330 |
- function uri_encode(x: string): string; |
|
331 |
- /** |
|
332 |
- * @author fenris |
|
333 |
- */ |
|
334 |
- function uri_decode(x: string): string; |
|
335 |
-} |
|
336 |
-declare module lib_code { |
|
337 |
-} |
|
338 |
-declare module lib_code { |
|
339 |
- /** |
|
340 |
- * @author fenris |
|
341 |
- */ |
|
342 |
- class class_code_uri implements interface_code<string, string> { |
|
343 |
- /** |
|
344 |
- * @author fenris |
|
345 |
- */ |
|
346 |
- constructor(); |
|
347 |
- /** |
|
348 |
- * @implementation |
|
349 |
- * @author fenris |
|
350 |
- */ |
|
351 |
- encode(x: string): string; |
|
352 |
- /** |
|
353 |
- * @implementation |
|
354 |
- * @author fenris |
|
355 |
- */ |
|
356 |
- decode(x: string): string; |
|
357 |
- } |
|
358 |
-} |
|
359 |
-declare module lib_code { |
|
360 |
- /** |
|
361 |
- * @author fenris |
|
362 |
- */ |
|
363 |
- function base64_encode(x: string): string; |
|
364 |
- /** |
|
365 |
- * @author fenris |
|
366 |
- */ |
|
367 |
- function base64_decode(x: string): string; |
|
368 |
-} |
|
369 |
-declare module lib_code { |
|
370 |
-} |
|
371 |
-declare module lib_code { |
|
372 |
- /** |
|
373 |
- * @author fenris |
|
374 |
- */ |
|
375 |
- class class_code_base64 implements interface_code<string, string> { |
|
376 |
- /** |
|
377 |
- * @author fenris |
|
378 |
- */ |
|
379 |
- constructor(); |
|
380 |
- /** |
|
381 |
- * @implementation |
|
382 |
- * @author fenris |
|
383 |
- */ |
|
384 |
- encode(x: string): string; |
|
385 |
- /** |
|
386 |
- * @implementation |
|
387 |
- * @author fenris |
|
388 |
- */ |
|
389 |
- decode(x: string): string; |
|
390 |
- } |
|
391 |
-} |
... | ... |
@@ -781,129 +781,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of |
781 | 781 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
782 | 782 |
GNU Lesser General Public License for more details. |
783 | 783 |
|
784 |
-You should have received a copy of the GNU Lesser General Public License |
|
785 |
-along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
|
786 |
- */ |
|
787 |
-var lib_code; |
|
788 |
-(function (lib_code) { |
|
789 |
- /** |
|
790 |
- * @author fenris |
|
791 |
- */ |
|
792 |
- function json_encode(x, formatted = false) { |
|
793 |
- return JSON.stringify(x, undefined, formatted ? "\t" : undefined); |
|
794 |
- } |
|
795 |
- lib_code.json_encode = json_encode; |
|
796 |
- /** |
|
797 |
- * @author fenris |
|
798 |
- */ |
|
799 |
- function json_decode(x) { |
|
800 |
- return JSON.parse(x); |
|
801 |
- } |
|
802 |
- lib_code.json_decode = json_decode; |
|
803 |
-})(lib_code || (lib_code = {})); |
|
804 |
-/* |
|
805 |
-This file is part of »bacterio-plankton:code«. |
|
806 |
- |
|
807 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
808 |
-<info@greenscale.de> |
|
809 |
- |
|
810 |
-»bacterio-plankton:code« is free software: you can redistribute it and/or modify |
|
811 |
-it under the terms of the GNU Lesser General Public License as published by |
|
812 |
-the Free Software Foundation, either version 3 of the License, or |
|
813 |
-(at your option) any later version. |
|
814 |
- |
|
815 |
-»bacterio-plankton:code« is distributed in the hope that it will be useful, |
|
816 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
817 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
818 |
-GNU Lesser General Public License for more details. |
|
819 |
- |
|
820 |
-You should have received a copy of the GNU Lesser General Public License |
|
821 |
-along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
|
822 |
- */ |
|
823 |
-var lib_code; |
|
824 |
-(function (lib_code) { |
|
825 |
- /** |
|
826 |
- * @author fenris |
|
827 |
- */ |
|
828 |
- lib_trait.attend("code", "json", { |
|
829 |
- "from": { |
|
830 |
- "name": "any" |
|
831 |
- }, |
|
832 |
- "to": { |
|
833 |
- "name": "string" |
|
834 |
- } |
|
835 |
- }, { |
|
836 |
- "encode": () => (x) => { |
|
837 |
- return lib_code.json_encode(x); |
|
838 |
- }, |
|
839 |
- "decode": () => (y) => { |
|
840 |
- return lib_code.json_decode(y); |
|
841 |
- } |
|
842 |
- }); |
|
843 |
-})(lib_code || (lib_code = {})); |
|
844 |
-/* |
|
845 |
-This file is part of »bacterio-plankton:code«. |
|
846 |
- |
|
847 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
848 |
-<info@greenscale.de> |
|
849 |
- |
|
850 |
-»bacterio-plankton:code« is free software: you can redistribute it and/or modify |
|
851 |
-it under the terms of the GNU Lesser General Public License as published by |
|
852 |
-the Free Software Foundation, either version 3 of the License, or |
|
853 |
-(at your option) any later version. |
|
854 |
- |
|
855 |
-»bacterio-plankton:code« is distributed in the hope that it will be useful, |
|
856 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
857 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
858 |
-GNU Lesser General Public License for more details. |
|
859 |
- |
|
860 |
-You should have received a copy of the GNU Lesser General Public License |
|
861 |
-along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
|
862 |
- */ |
|
863 |
-var lib_code; |
|
864 |
-(function (lib_code) { |
|
865 |
- /** |
|
866 |
- * @author fenris |
|
867 |
- */ |
|
868 |
- class class_code_json { |
|
869 |
- /** |
|
870 |
- * @author fenris |
|
871 |
- */ |
|
872 |
- constructor() { |
|
873 |
- } |
|
874 |
- /** |
|
875 |
- * @implementation |
|
876 |
- * @author fenris |
|
877 |
- */ |
|
878 |
- encode(x) { |
|
879 |
- return lib_code.json_encode(x); |
|
880 |
- } |
|
881 |
- /** |
|
882 |
- * @implementation |
|
883 |
- * @author fenris |
|
884 |
- */ |
|
885 |
- decode(x) { |
|
886 |
- return lib_code.json_decode(x); |
|
887 |
- } |
|
888 |
- } |
|
889 |
- lib_code.class_code_json = class_code_json; |
|
890 |
-})(lib_code || (lib_code = {})); |
|
891 |
-/* |
|
892 |
-This file is part of »bacterio-plankton:code«. |
|
893 |
- |
|
894 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
895 |
-<info@greenscale.de> |
|
896 |
- |
|
897 |
-»bacterio-plankton:code« is free software: you can redistribute it and/or modify |
|
898 |
-it under the terms of the GNU Lesser General Public License as published by |
|
899 |
-the Free Software Foundation, either version 3 of the License, or |
|
900 |
-(at your option) any later version. |
|
901 |
- |
|
902 |
-»bacterio-plankton:code« is distributed in the hope that it will be useful, |
|
903 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
904 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
905 |
-GNU Lesser General Public License for more details. |
|
906 |
- |
|
907 | 784 |
You should have received a copy of the GNU Lesser General Public License |
908 | 785 |
along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
909 | 786 |
*/ |
... | ... |
@@ -988,249 +865,3 @@ var lib_code; |
988 | 865 |
} |
989 | 866 |
lib_code.class_code_csv = class_code_csv; |
990 | 867 |
})(lib_code || (lib_code = {})); |
991 |
-/* |
|
992 |
-This file is part of »bacterio-plankton:code«. |
|
993 |
- |
|
994 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
995 |
-<info@greenscale.de> |
|
996 |
- |
|
997 |
-»bacterio-plankton:code« is free software: you can redistribute it and/or modify |
|
998 |
-it under the terms of the GNU Lesser General Public License as published by |
|
999 |
-the Free Software Foundation, either version 3 of the License, or |
|
1000 |
-(at your option) any later version. |
|
1001 |
- |
|
1002 |
-»bacterio-plankton:code« is distributed in the hope that it will be useful, |
|
1003 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1004 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1005 |
-GNU Lesser General Public License for more details. |
|
1006 |
- |
|
1007 |
-You should have received a copy of the GNU Lesser General Public License |
|
1008 |
-along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
|
1009 |
- */ |
|
1010 |
-var lib_code; |
|
1011 |
-(function (lib_code) { |
|
1012 |
- /** |
|
1013 |
- * @author fenris |
|
1014 |
- */ |
|
1015 |
- function uri_encode(x) { |
|
1016 |
- return encodeURIComponent(x); |
|
1017 |
- } |
|
1018 |
- lib_code.uri_encode = uri_encode; |
|
1019 |
- /** |
|
1020 |
- * @author fenris |
|
1021 |
- */ |
|
1022 |
- function uri_decode(x) { |
|
1023 |
- return decodeURIComponent(x); |
|
1024 |
- } |
|
1025 |
- lib_code.uri_decode = uri_decode; |
|
1026 |
-})(lib_code || (lib_code = {})); |
|
1027 |
-/* |
|
1028 |
-This file is part of »bacterio-plankton:code«. |
|
1029 |
- |
|
1030 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1031 |
-<info@greenscale.de> |
|
1032 |
- |
|
1033 |
-»bacterio-plankton:code« is free software: you can redistribute it and/or modify |
|
1034 |
-it under the terms of the GNU Lesser General Public License as published by |
|
1035 |
-the Free Software Foundation, either version 3 of the License, or |
|
1036 |
-(at your option) any later version. |
|
1037 |
- |
|
1038 |
-»bacterio-plankton:code« is distributed in the hope that it will be useful, |
|
1039 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1040 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1041 |
-GNU Lesser General Public License for more details. |
|
1042 |
- |
|
1043 |
-You should have received a copy of the GNU Lesser General Public License |
|
1044 |
-along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
|
1045 |
- */ |
|
1046 |
-var lib_code; |
|
1047 |
-(function (lib_code) { |
|
1048 |
- /** |
|
1049 |
- * @author fenris |
|
1050 |
- */ |
|
1051 |
- lib_trait.attend("code", "uri", { |
|
1052 |
- "from": { |
|
1053 |
- "name": "string" |
|
1054 |
- }, |
|
1055 |
- "to": { |
|
1056 |
- "name": "string" |
|
1057 |
- } |
|
1058 |
- }, { |
|
1059 |
- "encode": () => (x) => { |
|
1060 |
- return lib_code.uri_encode(x); |
|
1061 |
- }, |
|
1062 |
- "decode": () => (y) => { |
|
1063 |
- return lib_code.uri_decode(y); |
|
1064 |
- } |
|
1065 |
- }); |
|
1066 |
-})(lib_code || (lib_code = {})); |
|
1067 |
-/* |
|
1068 |
-This file is part of »bacterio-plankton:code«. |
|
1069 |
- |
|
1070 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1071 |
-<info@greenscale.de> |
|
1072 |
- |
|
1073 |
-»bacterio-plankton:code« is free software: you can redistribute it and/or modify |
|
1074 |
-it under the terms of the GNU Lesser General Public License as published by |
|
1075 |
-the Free Software Foundation, either version 3 of the License, or |
|
1076 |
-(at your option) any later version. |
|
1077 |
- |
|
1078 |
-»bacterio-plankton:code« is distributed in the hope that it will be useful, |
|
1079 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1080 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1081 |
-GNU Lesser General Public License for more details. |
|
1082 |
- |
|
1083 |
-You should have received a copy of the GNU Lesser General Public License |
|
1084 |
-along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
|
1085 |
- */ |
|
1086 |
-var lib_code; |
|
1087 |
-(function (lib_code) { |
|
1088 |
- /** |
|
1089 |
- * @author fenris |
|
1090 |
- */ |
|
1091 |
- class class_code_uri { |
|
1092 |
- /** |
|
1093 |
- * @author fenris |
|
1094 |
- */ |
|
1095 |
- constructor() { |
|
1096 |
- } |
|
1097 |
- /** |
|
1098 |
- * @implementation |
|
1099 |
- * @author fenris |
|
1100 |
- */ |
|
1101 |
- encode(x) { |
|
1102 |
- return lib_code.uri_encode(x); |
|
1103 |
- } |
|
1104 |
- /** |
|
1105 |
- * @implementation |
|
1106 |
- * @author fenris |
|
1107 |
- */ |
|
1108 |
- decode(x) { |
|
1109 |
- return lib_code.uri_decode(x); |
|
1110 |
- } |
|
1111 |
- } |
|
1112 |
- lib_code.class_code_uri = class_code_uri; |
|
1113 |
-})(lib_code || (lib_code = {})); |
|
1114 |
-/* |
|
1115 |
-This file is part of »bacterio-plankton:code«. |
|
1116 |
- |
|
1117 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1118 |
-<info@greenscale.de> |
|
1119 |
- |
|
1120 |
-»bacterio-plankton:code« is free software: you can redistribute it and/or modify |
|
1121 |
-it under the terms of the GNU Lesser General Public License as published by |
|
1122 |
-the Free Software Foundation, either version 3 of the License, or |
|
1123 |
-(at your option) any later version. |
|
1124 |
- |
|
1125 |
-»bacterio-plankton:code« is distributed in the hope that it will be useful, |
|
1126 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1127 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1128 |
-GNU Lesser General Public License for more details. |
|
1129 |
- |
|
1130 |
-You should have received a copy of the GNU Lesser General Public License |
|
1131 |
-along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
|
1132 |
- */ |
|
1133 |
-var lib_code; |
|
1134 |
-(function (lib_code) { |
|
1135 |
- /** |
|
1136 |
- * @author fenris |
|
1137 |
- */ |
|
1138 |
- function base64_encode(x) { |
|
1139 |
- return (new Buffer(x)).toString("base64"); |
|
1140 |
- } |
|
1141 |
- lib_code.base64_encode = base64_encode; |
|
1142 |
- /** |
|
1143 |
- * @author fenris |
|
1144 |
- */ |
|
1145 |
- function base64_decode(x) { |
|
1146 |
- return (new Buffer(x, "base64")).toString(); |
|
1147 |
- } |
|
1148 |
- lib_code.base64_decode = base64_decode; |
|
1149 |
-})(lib_code || (lib_code = {})); |
|
1150 |
-/* |
|
1151 |
-This file is part of »bacterio-plankton:code«. |
|
1152 |
- |
|
1153 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1154 |
-<info@greenscale.de> |
|
1155 |
- |
|
1156 |
-»bacterio-plankton:code« is free software: you can redistribute it and/or modify |
|
1157 |
-it under the terms of the GNU Lesser General Public License as published by |
|
1158 |
-the Free Software Foundation, either version 3 of the License, or |
|
1159 |
-(at your option) any later version. |
|
1160 |
- |
|
1161 |
-»bacterio-plankton:code« is distributed in the hope that it will be useful, |
|
1162 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1163 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1164 |
-GNU Lesser General Public License for more details. |
|
1165 |
- |
|
1166 |
-You should have received a copy of the GNU Lesser General Public License |
|
1167 |
-along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
|
1168 |
- */ |
|
1169 |
-var lib_code; |
|
1170 |
-(function (lib_code) { |
|
1171 |
- /** |
|
1172 |
- * @author fenris |
|
1173 |
- */ |
|
1174 |
- lib_trait.attend("code", "base64", { |
|
1175 |
- "from": { |
|
1176 |
- "name": "string" |
|
1177 |
- }, |
|
1178 |
- "to": { |
|
1179 |
- "name": "string" |
|
1180 |
- } |
|
1181 |
- }, { |
|
1182 |
- "encode": () => (x) => { |
|
1183 |
- return lib_code.base64_encode(x); |
|
1184 |
- }, |
|
1185 |
- "decode": () => (y) => { |
|
1186 |
- return lib_code.base64_decode(y); |
|
1187 |
- } |
|
1188 |
- }); |
|
1189 |
-})(lib_code || (lib_code = {})); |
|
1190 |
-/* |
|
1191 |
-This file is part of »bacterio-plankton:code«. |
|
1192 |
- |
|
1193 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1194 |
-<info@greenscale.de> |
|
1195 |
- |
|
1196 |
-»bacterio-plankton:code« is free software: you can redistribute it and/or modify |
|
1197 |
-it under the terms of the GNU Lesser General Public License as published by |
|
1198 |
-the Free Software Foundation, either version 3 of the License, or |
|
1199 |
-(at your option) any later version. |
|
1200 |
- |
|
1201 |
-»bacterio-plankton:code« is distributed in the hope that it will be useful, |
|
1202 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1203 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1204 |
-GNU Lesser General Public License for more details. |
|
1205 |
- |
|
1206 |
-You should have received a copy of the GNU Lesser General Public License |
|
1207 |
-along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. |
|
1208 |
- */ |
|
1209 |
-var lib_code; |
|
1210 |
-(function (lib_code) { |
|
1211 |
- /** |
|
1212 |
- * @author fenris |
|
1213 |
- */ |
|
1214 |
- class class_code_base64 { |
|
1215 |
- /** |
|
1216 |
- * @author fenris |
|
1217 |
- */ |
|
1218 |
- constructor() { |
|
1219 |
- } |
|
1220 |
- /** |
|
1221 |
- * @implementation |
|
1222 |
- * @author fenris |
|
1223 |
- */ |
|
1224 |
- encode(x) { |
|
1225 |
- return lib_code.base64_encode(x); |
|
1226 |
- } |
|
1227 |
- /** |
|
1228 |
- * @implementation |
|
1229 |
- * @author fenris |
|
1230 |
- */ |
|
1231 |
- decode(x) { |
|
1232 |
- return lib_code.base64_decode(x); |
|
1233 |
- } |
|
1234 |
- } |
|
1235 |
- lib_code.class_code_base64 = class_code_base64; |
|
1236 |
-})(lib_code || (lib_code = {})); |
... | ... |
@@ -1,861 +0,0 @@ |
1 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
2 |
-<info@greenscale.de> |
|
3 |
- |
|
4 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
5 |
-it under the terms of the GNU Lesser General Public License as published by |
|
6 |
-the Free Software Foundation, either version 3 of the License, or |
|
7 |
-(at your option) any later version. |
|
8 |
- |
|
9 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
10 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
-GNU Lesser General Public License for more details. |
|
13 |
- |
|
14 |
-You should have received a copy of the GNU Lesser General Public License |
|
15 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
- |
|
17 |
- |
|
18 |
- |
|
19 |
- GNU GENERAL PUBLIC LICENSE |
|
20 |
- Version 3, 29 June 2007 |
|
21 |
- |
|
22 |
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> |
|
23 |
- Everyone is permitted to copy and distribute verbatim copies |
|
24 |
- of this license document, but changing it is not allowed. |
|
25 |
- |
|
26 |
- Preamble |
|
27 |
- |
|
28 |
- The GNU General Public License is a free, copyleft license for |
|
29 |
-software and other kinds of works. |
|
30 |
- |
|
31 |
- The licenses for most software and other practical works are designed |
|
32 |
-to take away your freedom to share and change the works. By contrast, |
|
33 |
-the GNU General Public License is intended to guarantee your freedom to |
|
34 |
-share and change all versions of a program--to make sure it remains free |
|
35 |
-software for all its users. We, the Free Software Foundation, use the |
|
36 |
-GNU General Public License for most of our software; it applies also to |
|
37 |
-any other work released this way by its authors. You can apply it to |
|
38 |
-your programs, too. |
|
39 |
- |
|
40 |
- When we speak of free software, we are referring to freedom, not |
|
41 |
-price. Our General Public Licenses are designed to make sure that you |
|
42 |
-have the freedom to distribute copies of free software (and charge for |
|
43 |
-them if you wish), that you receive source code or can get it if you |
|
44 |
-want it, that you can change the software or use pieces of it in new |
|
45 |
-free programs, and that you know you can do these things. |
|
46 |
- |
|
47 |
- To protect your rights, we need to prevent others from denying you |
|
48 |
-these rights or asking you to surrender the rights. Therefore, you have |
|
49 |
-certain responsibilities if you distribute copies of the software, or if |
|
50 |
-you modify it: responsibilities to respect the freedom of others. |
|
51 |
- |
|
52 |
- For example, if you distribute copies of such a program, whether |
|
53 |
-gratis or for a fee, you must pass on to the recipients the same |
|
54 |
-freedoms that you received. You must make sure that they, too, receive |
|
55 |
-or can get the source code. And you must show them these terms so they |
|
56 |
-know their rights. |
|
57 |
- |
|
58 |
- Developers that use the GNU GPL protect your rights with two steps: |
|
59 |
-(1) assert copyright on the software, and (2) offer you this License |
|
60 |
-giving you legal permission to copy, distribute and/or modify it. |
|
61 |
- |
|
62 |
- For the developers' and authors' protection, the GPL clearly explains |
|
63 |
-that there is no warranty for this free software. For both users' and |
|
64 |
-authors' sake, the GPL requires that modified versions be marked as |
|
65 |
-changed, so that their problems will not be attributed erroneously to |
|
66 |
-authors of previous versions. |
|
67 |
- |
|
68 |
- Some devices are designed to deny users access to install or run |
|
69 |
-modified versions of the software inside them, although the manufacturer |
|
70 |
-can do so. This is fundamentally incompatible with the aim of |
|
71 |
-protecting users' freedom to change the software. The systematic |
|
72 |
-pattern of such abuse occurs in the area of products for individuals to |
|
73 |
-use, which is precisely where it is most unacceptable. Therefore, we |
|
74 |
-have designed this version of the GPL to prohibit the practice for those |
|
75 |
-products. If such problems arise substantially in other domains, we |
|
76 |
-stand ready to extend this provision to those domains in future versions |
|
77 |
-of the GPL, as needed to protect the freedom of users. |
|
78 |
- |
|
79 |
- Finally, every program is threatened constantly by software patents. |
|
80 |
-States should not allow patents to restrict development and use of |
|
81 |
-software on general-purpose computers, but in those that do, we wish to |
|
82 |
-avoid the special danger that patents applied to a free program could |
|
83 |
-make it effectively proprietary. To prevent this, the GPL assures that |
|
84 |
-patents cannot be used to render the program non-free. |
|
85 |
- |
|
86 |
- The precise terms and conditions for copying, distribution and |
|
87 |
-modification follow. |
|
88 |
- |
|
89 |
- TERMS AND CONDITIONS |
|
90 |
- |
|
91 |
- 0. Definitions. |
|
92 |
- |
|
93 |
- "This License" refers to version 3 of the GNU General Public License. |
|
94 |
- |
|
95 |
- "Copyright" also means copyright-like laws that apply to other kinds of |
|
96 |
-works, such as semiconductor masks. |
|
97 |
- |
|
98 |
- "The Program" refers to any copyrightable work licensed under this |
|
99 |
-License. Each licensee is addressed as "you". "Licensees" and |
|
100 |
-"recipients" may be individuals or organizations. |
|
101 |
- |
|
102 |
- To "modify" a work means to copy from or adapt all or part of the work |
|
103 |
-in a fashion requiring copyright permission, other than the making of an |
|
104 |
-exact copy. The resulting work is called a "modified version" of the |
|
105 |
-earlier work or a work "based on" the earlier work. |
|
106 |
- |
|
107 |
- A "covered work" means either the unmodified Program or a work based |
|
108 |
-on the Program. |
|
109 |
- |
|
110 |
- To "propagate" a work means to do anything with it that, without |
|
111 |
-permission, would make you directly or secondarily liable for |
|
112 |
-infringement under applicable copyright law, except executing it on a |
|
113 |
-computer or modifying a private copy. Propagation includes copying, |
|
114 |
-distribution (with or without modification), making available to the |
|
115 |
-public, and in some countries other activities as well. |
|
116 |
- |
|
117 |
- To "convey" a work means any kind of propagation that enables other |
|
118 |
-parties to make or receive copies. Mere interaction with a user through |
|
119 |
-a computer network, with no transfer of a copy, is not conveying. |
|
120 |
- |
|
121 |
- An interactive user interface displays "Appropriate Legal Notices" |
|
122 |
-to the extent that it includes a convenient and prominently visible |
|
123 |
-feature that (1) displays an appropriate copyright notice, and (2) |
|
124 |
-tells the user that there is no warranty for the work (except to the |
|
125 |
-extent that warranties are provided), that licensees may convey the |
|
126 |
-work under this License, and how to view a copy of this License. If |
|
127 |
-the interface presents a list of user commands or options, such as a |
|
128 |
-menu, a prominent item in the list meets this criterion. |
|
129 |
- |
|
130 |
- 1. Source Code. |
|
131 |
- |
|
132 |
- The "source code" for a work means the preferred form of the work |
|
133 |
-for making modifications to it. "Object code" means any non-source |
|
134 |
-form of a work. |
|
135 |
- |
|
136 |
- A "Standard Interface" means an interface that either is an official |
|
137 |
-standard defined by a recognized standards body, or, in the case of |
|
138 |
-interfaces specified for a particular programming language, one that |
|
139 |
-is widely used among developers working in that language. |
|
140 |
- |
|
141 |
- The "System Libraries" of an executable work include anything, other |
|
142 |
-than the work as a whole, that (a) is included in the normal form of |
|
143 |
-packaging a Major Component, but which is not part of that Major |
|
144 |
-Component, and (b) serves only to enable use of the work with that |
|
145 |
-Major Component, or to implement a Standard Interface for which an |
|
146 |
-implementation is available to the public in source code form. A |
|
147 |
-"Major Component", in this context, means a major essential component |
|
148 |
-(kernel, window system, and so on) of the specific operating system |
|
149 |
-(if any) on which the executable work runs, or a compiler used to |
|
150 |
-produce the work, or an object code interpreter used to run it. |
|
151 |
- |
|
152 |
- The "Corresponding Source" for a work in object code form means all |
|
153 |
-the source code needed to generate, install, and (for an executable |
|
154 |
-work) run the object code and to modify the work, including scripts to |
|
155 |
-control those activities. However, it does not include the work's |
|
156 |
-System Libraries, or general-purpose tools or generally available free |
|
157 |
-programs which are used unmodified in performing those activities but |
|
158 |
-which are not part of the work. For example, Corresponding Source |
|
159 |
-includes interface definition files associated with source files for |
|
160 |
-the work, and the source code for shared libraries and dynamically |
|
161 |
-linked subprograms that the work is specifically designed to require, |
|
162 |
-such as by intimate data communication or control flow between those |
|
163 |
-subprograms and other parts of the work. |
|
164 |
- |
|
165 |
- The Corresponding Source need not include anything that users |
|
166 |
-can regenerate automatically from other parts of the Corresponding |
|
167 |
-Source. |
|
168 |
- |
|
169 |
- The Corresponding Source for a work in source code form is that |
|
170 |
-same work. |
|
171 |
- |
|
172 |
- 2. Basic Permissions. |
|
173 |
- |
|
174 |
- All rights granted under this License are granted for the term of |
|
175 |
-copyright on the Program, and are irrevocable provided the stated |
|
176 |
-conditions are met. This License explicitly affirms your unlimited |
|
177 |
-permission to run the unmodified Program. The output from running a |
|
178 |
-covered work is covered by this License only if the output, given its |
|
179 |
-content, constitutes a covered work. This License acknowledges your |
|
180 |
-rights of fair use or other equivalent, as provided by copyright law. |
|
181 |
- |
|
182 |
- You may make, run and propagate covered works that you do not |
|
183 |
-convey, without conditions so long as your license otherwise remains |
|
184 |
-in force. You may convey covered works to others for the sole purpose |
|
185 |
-of having them make modifications exclusively for you, or provide you |
|
186 |
-with facilities for running those works, provided that you comply with |
|
187 |
-the terms of this License in conveying all material for which you do |
|
188 |
-not control copyright. Those thus making or running the covered works |
|
189 |
-for you must do so exclusively on your behalf, under your direction |
|
190 |
-and control, on terms that prohibit them from making any copies of |
|
191 |
-your copyrighted material outside their relationship with you. |
|
192 |
- |
|
193 |
- Conveying under any other circumstances is permitted solely under |
|
194 |
-the conditions stated below. Sublicensing is not allowed; section 10 |
|
195 |
-makes it unnecessary. |
|
196 |
- |
|
197 |
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
|
198 |
- |
|
199 |
- No covered work shall be deemed part of an effective technological |
|
200 |
-measure under any applicable law fulfilling obligations under article |
|
201 |
-11 of the WIPO copyright treaty adopted on 20 December 1996, or |
|
202 |
-similar laws prohibiting or restricting circumvention of such |
|
203 |
-measures. |
|
204 |
- |
|
205 |
- When you convey a covered work, you waive any legal power to forbid |
|
206 |
-circumvention of technological measures to the extent such circumvention |
|
207 |
-is effected by exercising rights under this License with respect to |
|
208 |
-the covered work, and you disclaim any intention to limit operation or |
|
209 |
-modification of the work as a means of enforcing, against the work's |
|
210 |
-users, your or third parties' legal rights to forbid circumvention of |
|
211 |
-technological measures. |
|
212 |
- |
|
213 |
- 4. Conveying Verbatim Copies. |
|
214 |
- |
|
215 |
- You may convey verbatim copies of the Program's source code as you |
|
216 |
-receive it, in any medium, provided that you conspicuously and |
|
217 |
-appropriately publish on each copy an appropriate copyright notice; |
|
218 |
-keep intact all notices stating that this License and any |
|
219 |
-non-permissive terms added in accord with section 7 apply to the code; |
|
220 |
-keep intact all notices of the absence of any warranty; and give all |
|
221 |
-recipients a copy of this License along with the Program. |
|
222 |
- |
|
223 |
- You may charge any price or no price for each copy that you convey, |
|
224 |
-and you may offer support or warranty protection for a fee. |
|
225 |
- |
|
226 |
- 5. Conveying Modified Source Versions. |
|
227 |
- |
|
228 |
- You may convey a work based on the Program, or the modifications to |
|
229 |
-produce it from the Program, in the form of source code under the |
|
230 |
-terms of section 4, provided that you also meet all of these conditions: |
|
231 |
- |
|
232 |
- a) The work must carry prominent notices stating that you modified |
|
233 |
- it, and giving a relevant date. |
|
234 |
- |
|
235 |
- b) The work must carry prominent notices stating that it is |
|
236 |
- released under this License and any conditions added under section |
|
237 |
- 7. This requirement modifies the requirement in section 4 to |
|
238 |
- "keep intact all notices". |
|
239 |
- |
|
240 |
- c) You must license the entire work, as a whole, under this |
|
241 |
- License to anyone who comes into possession of a copy. This |
|
242 |
- License will therefore apply, along with any applicable section 7 |
|
243 |
- additional terms, to the whole of the work, and all its parts, |
|
244 |
- regardless of how they are packaged. This License gives no |
|
245 |
- permission to license the work in any other way, but it does not |
|
246 |
- invalidate such permission if you have separately received it. |
|
247 |
- |
|
248 |
- d) If the work has interactive user interfaces, each must display |
|
249 |
- Appropriate Legal Notices; however, if the Program has interactive |
|
250 |
- interfaces that do not display Appropriate Legal Notices, your |
|
251 |
- work need not make them do so. |
|
252 |
- |
|
253 |
- A compilation of a covered work with other separate and independent |
|
254 |
-works, which are not by their nature extensions of the covered work, |
|
255 |
-and which are not combined with it such as to form a larger program, |
|
256 |
-in or on a volume of a storage or distribution medium, is called an |
|
257 |
-"aggregate" if the compilation and its resulting copyright are not |
|
258 |
-used to limit the access or legal rights of the compilation's users |
|
259 |
-beyond what the individual works permit. Inclusion of a covered work |
|
260 |
-in an aggregate does not cause this License to apply to the other |
|
261 |
-parts of the aggregate. |
|
262 |
- |
|
263 |
- 6. Conveying Non-Source Forms. |
|
264 |
- |
|
265 |
- You may convey a covered work in object code form under the terms |
|
266 |
-of sections 4 and 5, provided that you also convey the |
|
267 |
-machine-readable Corresponding Source under the terms of this License, |
|
268 |
-in one of these ways: |
|
269 |
- |
|
270 |
- a) Convey the object code in, or embodied in, a physical product |
|
271 |
- (including a physical distribution medium), accompanied by the |
|
272 |
- Corresponding Source fixed on a durable physical medium |
|
273 |
- customarily used for software interchange. |
|
274 |
- |
|
275 |
- b) Convey the object code in, or embodied in, a physical product |
|
276 |
- (including a physical distribution medium), accompanied by a |
|
277 |
- written offer, valid for at least three years and valid for as |
|
278 |
- long as you offer spare parts or customer support for that product |
|
279 |
- model, to give anyone who possesses the object code either (1) a |
|
280 |
- copy of the Corresponding Source for all the software in the |
|
281 |
- product that is covered by this License, on a durable physical |
|
282 |
- medium customarily used for software interchange, for a price no |
|
283 |
- more than your reasonable cost of physically performing this |
|
284 |
- conveying of source, or (2) access to copy the |
|
285 |
- Corresponding Source from a network server at no charge. |
|
286 |
- |
|
287 |
- c) Convey individual copies of the object code with a copy of the |
|
288 |
- written offer to provide the Corresponding Source. This |
|
289 |
- alternative is allowed only occasionally and noncommercially, and |
|
290 |
- only if you received the object code with such an offer, in accord |
|
291 |
- with subsection 6b. |
|
292 |
- |
|
293 |
- d) Convey the object code by offering access from a designated |
|
294 |
- place (gratis or for a charge), and offer equivalent access to the |
|
295 |
- Corresponding Source in the same way through the same place at no |
|
296 |
- further charge. You need not require recipients to copy the |
|
297 |
- Corresponding Source along with the object code. If the place to |
|
298 |
- copy the object code is a network server, the Corresponding Source |
|
299 |
- may be on a different server (operated by you or a third party) |
|
300 |
- that supports equivalent copying facilities, provided you maintain |
|
301 |
- clear directions next to the object code saying where to find the |
|
302 |
- Corresponding Source. Regardless of what server hosts the |
|
303 |
- Corresponding Source, you remain obligated to ensure that it is |
|
304 |
- available for as long as needed to satisfy these requirements. |
|
305 |
- |
|
306 |
- e) Convey the object code using peer-to-peer transmission, provided |
|
307 |
- you inform other peers where the object code and Corresponding |
|
308 |
- Source of the work are being offered to the general public at no |
|
309 |
- charge under subsection 6d. |
|
310 |
- |
|
311 |
- A separable portion of the object code, whose source code is excluded |
|
312 |
-from the Corresponding Source as a System Library, need not be |
|
313 |
-included in conveying the object code work. |
|
314 |
- |
|
315 |
- A "User Product" is either (1) a "consumer product", which means any |
|
316 |
-tangible personal property which is normally used for personal, family, |
|
317 |
-or household purposes, or (2) anything designed or sold for incorporation |
|
318 |
-into a dwelling. In determining whether a product is a consumer product, |
|
319 |
-doubtful cases shall be resolved in favor of coverage. For a particular |
|
320 |
-product received by a particular user, "normally used" refers to a |
|
321 |
-typical or common use of that class of product, regardless of the status |
|
322 |
-of the particular user or of the way in which the particular user |
|
323 |
-actually uses, or expects or is expected to use, the product. A product |
|
324 |
-is a consumer product regardless of whether the product has substantial |
|
325 |
-commercial, industrial or non-consumer uses, unless such uses represent |
|
326 |
-the only significant mode of use of the product. |
|
327 |
- |
|
328 |
- "Installation Information" for a User Product means any methods, |
|
329 |
-procedures, authorization keys, or other information required to install |
|
330 |
-and execute modified versions of a covered work in that User Product from |
|
331 |
-a modified version of its Corresponding Source. The information must |
|
332 |
-suffice to ensure that the continued functioning of the modified object |
|
333 |
-code is in no case prevented or interfered with solely because |
|
334 |
-modification has been made. |
|
335 |
- |
|
336 |
- If you convey an object code work under this section in, or with, or |
|
337 |
-specifically for use in, a User Product, and the conveying occurs as |
|
338 |
-part of a transaction in which the right of possession and use of the |
|
339 |
-User Product is transferred to the recipient in perpetuity or for a |
|
340 |
-fixed term (regardless of how the transaction is characterized), the |
|
341 |
-Corresponding Source conveyed under this section must be accompanied |
|
342 |
-by the Installation Information. But this requirement does not apply |
|
343 |
-if neither you nor any third party retains the ability to install |
|
344 |
-modified object code on the User Product (for example, the work has |
|
345 |
-been installed in ROM). |
|
346 |
- |
|
347 |
- The requirement to provide Installation Information does not include a |
|
348 |
-requirement to continue to provide support service, warranty, or updates |
|
349 |
-for a work that has been modified or installed by the recipient, or for |
|
350 |
-the User Product in which it has been modified or installed. Access to a |
|
351 |
-network may be denied when the modification itself materially and |
|
352 |
-adversely affects the operation of the network or violates the rules and |
|
353 |
-protocols for communication across the network. |
|
354 |
- |
|
355 |
- Corresponding Source conveyed, and Installation Information provided, |
|
356 |
-in accord with this section must be in a format that is publicly |
|
357 |
-documented (and with an implementation available to the public in |
|
358 |
-source code form), and must require no special password or key for |
|
359 |
-unpacking, reading or copying. |
|
360 |
- |
|
361 |
- 7. Additional Terms. |
|
362 |
- |
|
363 |
- "Additional permissions" are terms that supplement the terms of this |
|
364 |
-License by making exceptions from one or more of its conditions. |
|
365 |
-Additional permissions that are applicable to the entire Program shall |
|
366 |
-be treated as though they were included in this License, to the extent |
|
367 |
-that they are valid under applicable law. If additional permissions |
|
368 |
-apply only to part of the Program, that part may be used separately |
|
369 |
-under those permissions, but the entire Program remains governed by |
|
370 |
-this License without regard to the additional permissions. |
|
371 |
- |
|
372 |
- When you convey a copy of a covered work, you may at your option |
|
373 |
-remove any additional permissions from that copy, or from any part of |
|
374 |
-it. (Additional permissions may be written to require their own |
|
375 |
-removal in certain cases when you modify the work.) You may place |
|
376 |
-additional permissions on material, added by you to a covered work, |
|
377 |
-for which you have or can give appropriate copyright permission. |
|
378 |
- |
|
379 |
- Notwithstanding any other provision of this License, for material you |
|
380 |
-add to a covered work, you may (if authorized by the copyright holders of |
|
381 |
-that material) supplement the terms of this License with terms: |
|
382 |
- |
|
383 |
- a) Disclaiming warranty or limiting liability differently from the |
|
384 |
- terms of sections 15 and 16 of this License; or |
|
385 |
- |
|
386 |
- b) Requiring preservation of specified reasonable legal notices or |
|
387 |
- author attributions in that material or in the Appropriate Legal |
|
388 |
- Notices displayed by works containing it; or |
|
389 |
- |
|
390 |
- c) Prohibiting misrepresentation of the origin of that material, or |
|
391 |
- requiring that modified versions of such material be marked in |
|
392 |
- reasonable ways as different from the original version; or |
|
393 |
- |
|
394 |
- d) Limiting the use for publicity purposes of names of licensors or |
|
395 |
- authors of the material; or |
|
396 |
- |
|
397 |
- e) Declining to grant rights under trademark law for use of some |
|
398 |
- trade names, trademarks, or service marks; or |
|
399 |
- |
|
400 |
- f) Requiring indemnification of licensors and authors of that |
|
401 |
- material by anyone who conveys the material (or modified versions of |
|
402 |
- it) with contractual assumptions of liability to the recipient, for |
|
403 |
- any liability that these contractual assumptions directly impose on |
|
404 |
- those licensors and authors. |
|
405 |
- |
|
406 |
- All other non-permissive additional terms are considered "further |
|
407 |
-restrictions" within the meaning of section 10. If the Program as you |
|
408 |
-received it, or any part of it, contains a notice stating that it is |
|
409 |
-governed by this License along with a term that is a further |
|
410 |
-restriction, you may remove that term. If a license document contains |
|
411 |
-a further restriction but permits relicensing or conveying under this |
|
412 |
-License, you may add to a covered work material governed by the terms |
|
413 |
-of that license document, provided that the further restriction does |
|
414 |
-not survive such relicensing or conveying. |
|
415 |
- |
|
416 |
- If you add terms to a covered work in accord with this section, you |
|
417 |
-must place, in the relevant source files, a statement of the |
|
418 |
-additional terms that apply to those files, or a notice indicating |
|
419 |
-where to find the applicable terms. |
|
420 |
- |
|
421 |
- Additional terms, permissive or non-permissive, may be stated in the |
|
422 |
-form of a separately written license, or stated as exceptions; |
|
423 |
-the above requirements apply either way. |
|
424 |
- |
|
425 |
- 8. Termination. |
|
426 |
- |
|
427 |
- You may not propagate or modify a covered work except as expressly |
|
428 |
-provided under this License. Any attempt otherwise to propagate or |
|
429 |
-modify it is void, and will automatically terminate your rights under |
|
430 |
-this License (including any patent licenses granted under the third |
|
431 |
-paragraph of section 11). |
|
432 |
- |
|
433 |
- However, if you cease all violation of this License, then your |
|
434 |
-license from a particular copyright holder is reinstated (a) |
|
435 |
-provisionally, unless and until the copyright holder explicitly and |
|
436 |
-finally terminates your license, and (b) permanently, if the copyright |
|
437 |
-holder fails to notify you of the violation by some reasonable means |
|
438 |
-prior to 60 days after the cessation. |
|
439 |
- |
|
440 |
- Moreover, your license from a particular copyright holder is |
|
441 |
-reinstated permanently if the copyright holder notifies you of the |
|
442 |
-violation by some reasonable means, this is the first time you have |
|
443 |
-received notice of violation of this License (for any work) from that |
|
444 |
-copyright holder, and you cure the violation prior to 30 days after |
|
445 |
-your receipt of the notice. |
|
446 |
- |
|
447 |
- Termination of your rights under this section does not terminate the |
|
448 |
-licenses of parties who have received copies or rights from you under |
|
449 |
-this License. If your rights have been terminated and not permanently |
|
450 |
-reinstated, you do not qualify to receive new licenses for the same |
|
451 |
-material under section 10. |
|
452 |
- |
|
453 |
- 9. Acceptance Not Required for Having Copies. |
|
454 |
- |
|
455 |
- You are not required to accept this License in order to receive or |
|
456 |
-run a copy of the Program. Ancillary propagation of a covered work |
|
457 |
-occurring solely as a consequence of using peer-to-peer transmission |
|
458 |
-to receive a copy likewise does not require acceptance. However, |
|
459 |
-nothing other than this License grants you permission to propagate or |
|
460 |
-modify any covered work. These actions infringe copyright if you do |
|
461 |
-not accept this License. Therefore, by modifying or propagating a |
|
462 |
-covered work, you indicate your acceptance of this License to do so. |
|
463 |
- |
|
464 |
- 10. Automatic Licensing of Downstream Recipients. |
|
465 |
- |
|
466 |
- Each time you convey a covered work, the recipient automatically |
|
467 |
-receives a license from the original licensors, to run, modify and |
|
468 |
-propagate that work, subject to this License. You are not responsible |
|
469 |
-for enforcing compliance by third parties with this License. |
|
470 |
- |
|
471 |
- An "entity transaction" is a transaction transferring control of an |
|
472 |
-organization, or substantially all assets of one, or subdividing an |
|
473 |
-organization, or merging organizations. If propagation of a covered |
|
474 |
-work results from an entity transaction, each party to that |
|
475 |
-transaction who receives a copy of the work also receives whatever |
|
476 |
-licenses to the work the party's predecessor in interest had or could |
|
477 |
-give under the previous paragraph, plus a right to possession of the |
|
478 |
-Corresponding Source of the work from the predecessor in interest, if |
|
479 |
-the predecessor has it or can get it with reasonable efforts. |
|
480 |
- |
|
481 |
- You may not impose any further restrictions on the exercise of the |
|
482 |
-rights granted or affirmed under this License. For example, you may |
|
483 |
-not impose a license fee, royalty, or other charge for exercise of |
|
484 |
-rights granted under this License, and you may not initiate litigation |
|
485 |
-(including a cross-claim or counterclaim in a lawsuit) alleging that |
|
486 |
-any patent claim is infringed by making, using, selling, offering for |
|
487 |
-sale, or importing the Program or any portion of it. |
|
488 |
- |
|
489 |
- 11. Patents. |
|
490 |
- |
|
491 |
- A "contributor" is a copyright holder who authorizes use under this |
|
492 |
-License of the Program or a work on which the Program is based. The |
|
493 |
-work thus licensed is called the contributor's "contributor version". |
|
494 |
- |
|
495 |
- A contributor's "essential patent claims" are all patent claims |
|
496 |
-owned or controlled by the contributor, whether already acquired or |
|
497 |
-hereafter acquired, that would be infringed by some manner, permitted |
|
498 |
-by this License, of making, using, or selling its contributor version, |
|
499 |
-but do not include claims that would be infringed only as a |
|
500 |
-consequence of further modification of the contributor version. For |
|
501 |
-purposes of this definition, "control" includes the right to grant |
|
502 |
-patent sublicenses in a manner consistent with the requirements of |
|
503 |
-this License. |
|
504 |
- |
|
505 |
- Each contributor grants you a non-exclusive, worldwide, royalty-free |
|
506 |
-patent license under the contributor's essential patent claims, to |
|
507 |
-make, use, sell, offer for sale, import and otherwise run, modify and |
|
508 |
-propagate the contents of its contributor version. |
|
509 |
- |
|
510 |
- In the following three paragraphs, a "patent license" is any express |
|
511 |
-agreement or commitment, however denominated, not to enforce a patent |
|
512 |
-(such as an express permission to practice a patent or covenant not to |
|
513 |
-sue for patent infringement). To "grant" such a patent license to a |
|
514 |
-party means to make such an agreement or commitment not to enforce a |
|
515 |
-patent against the party. |
|
516 |
- |
|
517 |
- If you convey a covered work, knowingly relying on a patent license, |
|
518 |
-and the Corresponding Source of the work is not available for anyone |
|
519 |
-to copy, free of charge and under the terms of this License, through a |
|
520 |
-publicly available network server or other readily accessible means, |
|
521 |
-then you must either (1) cause the Corresponding Source to be so |
|
522 |
-available, or (2) arrange to deprive yourself of the benefit of the |
|
523 |
-patent license for this particular work, or (3) arrange, in a manner |
|
524 |
-consistent with the requirements of this License, to extend the patent |
|
525 |
-license to downstream recipients. "Knowingly relying" means you have |
|
526 |
-actual knowledge that, but for the patent license, your conveying the |
|
527 |
-covered work in a country, or your recipient's use of the covered work |
|
528 |
-in a country, would infringe one or more identifiable patents in that |
|
529 |
-country that you have reason to believe are valid. |
|
530 |
- |
|
531 |
- If, pursuant to or in connection with a single transaction or |
|
532 |
-arrangement, you convey, or propagate by procuring conveyance of, a |
|
533 |
-covered work, and grant a patent license to some of the parties |
|
534 |
-receiving the covered work authorizing them to use, propagate, modify |
|
535 |
-or convey a specific copy of the covered work, then the patent license |
|
536 |
-you grant is automatically extended to all recipients of the covered |
|
537 |
-work and works based on it. |
|
538 |
- |
|
539 |
- A patent license is "discriminatory" if it does not include within |
|
540 |
-the scope of its coverage, prohibits the exercise of, or is |
|
541 |
-conditioned on the non-exercise of one or more of the rights that are |
|
542 |
-specifically granted under this License. You may not convey a covered |
|
543 |
-work if you are a party to an arrangement with a third party that is |
|
544 |
-in the business of distributing software, under which you make payment |
|
545 |
-to the third party based on the extent of your activity of conveying |
|
546 |
-the work, and under which the third party grants, to any of the |
|
547 |
-parties who would receive the covered work from you, a discriminatory |
|
548 |
-patent license (a) in connection with copies of the covered work |
|
549 |
-conveyed by you (or copies made from those copies), or (b) primarily |
|
550 |
-for and in connection with specific products or compilations that |
|
551 |
-contain the covered work, unless you entered into that arrangement, |
|
552 |
-or that patent license was granted, prior to 28 March 2007. |
|
553 |
- |
|
554 |
- Nothing in this License shall be construed as excluding or limiting |
|
555 |
-any implied license or other defenses to infringement that may |
|
556 |
-otherwise be available to you under applicable patent law. |
|
557 |
- |
|
558 |
- 12. No Surrender of Others' Freedom. |
|
559 |
- |
|
560 |
- If conditions are imposed on you (whether by court order, agreement or |
|
561 |
-otherwise) that contradict the conditions of this License, they do not |
|
562 |
-excuse you from the conditions of this License. If you cannot convey a |
|
563 |
-covered work so as to satisfy simultaneously your obligations under this |
|
564 |
-License and any other pertinent obligations, then as a consequence you may |
|
565 |
-not convey it at all. For example, if you agree to terms that obligate you |
|
566 |
-to collect a royalty for further conveying from those to whom you convey |
|
567 |
-the Program, the only way you could satisfy both those terms and this |
|
568 |
-License would be to refrain entirely from conveying the Program. |
|
569 |
- |
|
570 |
- 13. Use with the GNU Affero General Public License. |
|
571 |
- |
|
572 |
- Notwithstanding any other provision of this License, you have |
|
573 |
-permission to link or combine any covered work with a work licensed |
|
574 |
-under version 3 of the GNU Affero General Public License into a single |
|
575 |
-combined work, and to convey the resulting work. The terms of this |
|
576 |
-License will continue to apply to the part which is the covered work, |
|
577 |
-but the special requirements of the GNU Affero General Public License, |
|
578 |
-section 13, concerning interaction through a network will apply to the |
|
579 |
-combination as such. |
|
580 |
- |
|
581 |
- 14. Revised Versions of this License. |
|
582 |
- |
|
583 |
- The Free Software Foundation may publish revised and/or new versions of |
|
584 |
-the GNU General Public License from time to time. Such new versions will |
|
585 |
-be similar in spirit to the present version, but may differ in detail to |
|
586 |
-address new problems or concerns. |
|
587 |
- |
|
588 |
- Each version is given a distinguishing version number. If the |
|
589 |
-Program specifies that a certain numbered version of the GNU General |
|
590 |
-Public License "or any later version" applies to it, you have the |
|
591 |
-option of following the terms and conditions either of that numbered |
|
592 |
-version or of any later version published by the Free Software |
|
593 |
-Foundation. If the Program does not specify a version number of the |
|
594 |
-GNU General Public License, you may choose any version ever published |
|
595 |
-by the Free Software Foundation. |
|
596 |
- |
|
597 |
- If the Program specifies that a proxy can decide which future |
|
598 |
-versions of the GNU General Public License can be used, that proxy's |
|
599 |
-public statement of acceptance of a version permanently authorizes you |
|
600 |
-to choose that version for the Program. |
|
601 |
- |
|
602 |
- Later license versions may give you additional or different |
|
603 |
-permissions. However, no additional obligations are imposed on any |
|
604 |
-author or copyright holder as a result of your choosing to follow a |
|
605 |
-later version. |
|
606 |
- |
|
607 |
- 15. Disclaimer of Warranty. |
|
608 |
- |
|
609 |
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
|
610 |
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT |
|
611 |
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY |
|
612 |
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, |
|
613 |
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
614 |
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM |
|
615 |
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF |
|
616 |
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
|
617 |
- |
|
618 |
- 16. Limitation of Liability. |
|
619 |
- |
|
620 |
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
621 |
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS |
|
622 |
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
|
623 |
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE |
|
624 |
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF |
|
625 |
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
|
626 |
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), |
|
627 |
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
628 |
-SUCH DAMAGES. |
|
629 |
- |
|
630 |
- 17. Interpretation of Sections 15 and 16. |
|
631 |
- |
|
632 |
- If the disclaimer of warranty and limitation of liability provided |
|
633 |
-above cannot be given local legal effect according to their terms, |
|
634 |
-reviewing courts shall apply local law that most closely approximates |
|
635 |
-an absolute waiver of all civil liability in connection with the |
|
636 |
-Program, unless a warranty or assumption of liability accompanies a |
|
637 |
-copy of the Program in return for a fee. |
|
638 |
- |
|
639 |
- END OF TERMS AND CONDITIONS |
|
640 |
- |
|
641 |
- How to Apply These Terms to Your New Programs |
|
642 |
- |
|
643 |
- If you develop a new program, and you want it to be of the greatest |
|
644 |
-possible use to the public, the best way to achieve this is to make it |
|
645 |
-free software which everyone can redistribute and change under these terms. |
|
646 |
- |
|
647 |
- To do so, attach the following notices to the program. It is safest |
|
648 |
-to attach them to the start of each source file to most effectively |
|
649 |
-state the exclusion of warranty; and each file should have at least |
|
650 |
-the "copyright" line and a pointer to where the full notice is found. |
|
651 |
- |
|
652 |
- <one line to give the program's name and a brief idea of what it does.> |
|
653 |
- Copyright (C) <year> <name of author> |
|
654 |
- |
|
655 |
- This program is free software: you can redistribute it and/or modify |
|
656 |
- it under the terms of the GNU General Public License as published by |
|
657 |
- the Free Software Foundation, either version 3 of the License, or |
|
658 |
- (at your option) any later version. |
|
659 |
- |
|
660 |
- This program is distributed in the hope that it will be useful, |
|
661 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
662 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
663 |
- GNU General Public License for more details. |
|
664 |
- |
|
665 |
- You should have received a copy of the GNU General Public License |
|
666 |
- along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
667 |
- |
|
668 |
-Also add information on how to contact you by electronic and paper mail. |
|
669 |
- |
|
670 |
- If the program does terminal interaction, make it output a short |
|
671 |
-notice like this when it starts in an interactive mode: |
|
672 |
- |
|
673 |
- <program> Copyright (C) <year> <name of author> |
|
674 |
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
|
675 |
- This is free software, and you are welcome to redistribute it |
|
676 |
- under certain conditions; type `show c' for details. |
|
677 |
- |
|
678 |
-The hypothetical commands `show w' and `show c' should show the appropriate |
|
679 |
-parts of the General Public License. Of course, your program's commands |
|
680 |
-might be different; for a GUI interface, you would use an "about box". |
|
681 |
- |
|
682 |
- You should also get your employer (if you work as a programmer) or school, |
|
683 |
-if any, to sign a "copyright disclaimer" for the program, if necessary. |
|
684 |
-For more information on this, and how to apply and follow the GNU GPL, see |
|
685 |
-<https://www.gnu.org/licenses/>. |
|
686 |
- |
|
687 |
- The GNU General Public License does not permit incorporating your program |
|
688 |
-into proprietary programs. If your program is a subroutine library, you |
|
689 |
-may consider it more useful to permit linking proprietary applications with |
|
690 |
-the library. If this is what you want to do, use the GNU Lesser General |
|
691 |
-Public License instead of this License. But first, please read |
|
692 |
-<https://www.gnu.org/licenses/why-not-lgpl.html>. |
|
693 |
- |
|
694 |
- |
|
695 |
- |
|
696 |
- GNU LESSER GENERAL PUBLIC LICENSE |
|
697 |
- Version 3, 29 June 2007 |
|
698 |
- |
|
699 |
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> |
|
700 |
- Everyone is permitted to copy and distribute verbatim copies |
|
701 |
- of this license document, but changing it is not allowed. |
|
702 |
- |
|
703 |
- |
|
704 |
- This version of the GNU Lesser General Public License incorporates |
|
705 |
-the terms and conditions of version 3 of the GNU General Public |
|
706 |
-License, supplemented by the additional permissions listed below. |
|
707 |
- |
|
708 |
- 0. Additional Definitions. |
|
709 |
- |
|
710 |
- As used herein, "this License" refers to version 3 of the GNU Lesser |
|
711 |
-General Public License, and the "GNU GPL" refers to version 3 of the GNU |
|
712 |
-General Public License. |
|
713 |
- |
|
714 |
- "The Library" refers to a covered work governed by this License, |
|
715 |
-other than an Application or a Combined Work as defined below. |
|
716 |
- |
|
717 |
- An "Application" is any work that makes use of an interface provided |
|
718 |
-by the Library, but which is not otherwise based on the Library. |
|
719 |
-Defining a subclass of a class defined by the Library is deemed a mode |
|
720 |
-of using an interface provided by the Library. |
|
721 |
- |
|
722 |
- A "Combined Work" is a work produced by combining or linking an |
|
723 |
-Application with the Library. The particular version of the Library |
|
724 |
-with which the Combined Work was made is also called the "Linked |
|
725 |
-Version". |
|
726 |
- |
|
727 |
- The "Minimal Corresponding Source" for a Combined Work means the |
|
728 |
-Corresponding Source for the Combined Work, excluding any source code |
|
729 |
-for portions of the Combined Work that, considered in isolation, are |
|
730 |
-based on the Application, and not on the Linked Version. |
|
731 |
- |
|
732 |
- The "Corresponding Application Code" for a Combined Work means the |
|
733 |
-object code and/or source code for the Application, including any data |
|
734 |
-and utility programs needed for reproducing the Combined Work from the |
|
735 |
-Application, but excluding the System Libraries of the Combined Work. |
|
736 |
- |
|
737 |
- 1. Exception to Section 3 of the GNU GPL. |
|
738 |
- |
|
739 |
- You may convey a covered work under sections 3 and 4 of this License |
|
740 |
-without being bound by section 3 of the GNU GPL. |
|
741 |
- |
|
742 |
- 2. Conveying Modified Versions. |
|
743 |
- |
|
744 |
- If you modify a copy of the Library, and, in your modifications, a |
|
745 |
-facility refers to a function or data to be supplied by an Application |
|
746 |
-that uses the facility (other than as an argument passed when the |
|
747 |
-facility is invoked), then you may convey a copy of the modified |
|
748 |
-version: |
|
749 |
- |
|
750 |
- a) under this License, provided that you make a good faith effort to |
|
751 |
- ensure that, in the event an Application does not supply the |
|
752 |
- function or data, the facility still operates, and performs |
|
753 |
- whatever part of its purpose remains meaningful, or |
|
754 |
- |
|
755 |
- b) under the GNU GPL, with none of the additional permissions of |
|
756 |
- this License applicable to that copy. |
|
757 |
- |
|
758 |
- 3. Object Code Incorporating Material from Library Header Files. |
|
759 |
- |
|
760 |
- The object code form of an Application may incorporate material from |
|
761 |
-a header file that is part of the Library. You may convey such object |
|
762 |
-code under terms of your choice, provided that, if the incorporated |
|
763 |
-material is not limited to numerical parameters, data structure |
|
764 |
-layouts and accessors, or small macros, inline functions and templates |
|
765 |
-(ten or fewer lines in length), you do both of the following: |
|
766 |
- |
|
767 |
- a) Give prominent notice with each copy of the object code that the |
|
768 |
- Library is used in it and that the Library and its use are |
|
769 |
- covered by this License. |
|
770 |
- |
|
771 |
- b) Accompany the object code with a copy of the GNU GPL and this license |
|
772 |
- document. |
|
773 |
- |
|
774 |
- 4. Combined Works. |
|
775 |
- |
|
776 |
- You may convey a Combined Work under terms of your choice that, |
|
777 |
-taken together, effectively do not restrict modification of the |
|
778 |
-portions of the Library contained in the Combined Work and reverse |
|
779 |
-engineering for debugging such modifications, if you also do each of |
|
780 |
-the following: |
|
781 |
- |
|
782 |
- a) Give prominent notice with each copy of the Combined Work that |
|
783 |
- the Library is used in it and that the Library and its use are |
|
784 |
- covered by this License. |
|
785 |
- |
|
786 |
- b) Accompany the Combined Work with a copy of the GNU GPL and this license |
|
787 |
- document. |
|
788 |
- |
|
789 |
- c) For a Combined Work that displays copyright notices during |
|
790 |
- execution, include the copyright notice for the Library among |
|
791 |
- these notices, as well as a reference directing the user to the |
|
792 |
- copies of the GNU GPL and this license document. |
|
793 |
- |
|
794 |
- d) Do one of the following: |
|
795 |
- |
|
796 |
- 0) Convey the Minimal Corresponding Source under the terms of this |
|
797 |
- License, and the Corresponding Application Code in a form |
|
798 |
- suitable for, and under terms that permit, the user to |
|
799 |
- recombine or relink the Application with a modified version of |
|
800 |
- the Linked Version to produce a modified Combined Work, in the |
|
801 |
- manner specified by section 6 of the GNU GPL for conveying |
|
802 |
- Corresponding Source. |
|
803 |
- |
|
804 |
- 1) Use a suitable shared library mechanism for linking with the |
|
805 |
- Library. A suitable mechanism is one that (a) uses at run time |
|
806 |
- a copy of the Library already present on the user's computer |
|
807 |
- system, and (b) will operate properly with a modified version |
|
808 |
- of the Library that is interface-compatible with the Linked |
|
809 |
- Version. |
|
810 |
- |
|
811 |
- e) Provide Installation Information, but only if you would otherwise |
|
812 |
- be required to provide such information under section 6 of the |
|
813 |
- GNU GPL, and only to the extent that such information is |
|
814 |
- necessary to install and execute a modified version of the |
|
815 |
- Combined Work produced by recombining or relinking the |
|
816 |
- Application with a modified version of the Linked Version. (If |
|
817 |
- you use option 4d0, the Installation Information must accompany |
|
818 |
- the Minimal Corresponding Source and Corresponding Application |
|
819 |
- Code. If you use option 4d1, you must provide the Installation |
|
820 |
- Information in the manner specified by section 6 of the GNU GPL |
|
821 |
- for conveying Corresponding Source.) |
|
822 |
- |
|
823 |
- 5. Combined Libraries. |
|
824 |
- |
|
825 |
- You may place library facilities that are a work based on the |
|
826 |
-Library side by side in a single library together with other library |
|
827 |
-facilities that are not Applications and are not covered by this |
|
828 |
-License, and convey such a combined library under terms of your |
|
829 |
-choice, if you do both of the following: |
|
830 |
- |
|
831 |
- a) Accompany the combined library with a copy of the same work based |
|
832 |
- on the Library, uncombined with any other library facilities, |
|
833 |
- conveyed under the terms of this License. |
|
834 |
- |
|
835 |
- b) Give prominent notice with the combined library that part of it |
|
836 |
- is a work based on the Library, and explaining where to find the |
|
837 |
- accompanying uncombined form of the same work. |
|
838 |
- |
|
839 |
- 6. Revised Versions of the GNU Lesser General Public License. |
|
840 |
- |
|
841 |
- The Free Software Foundation may publish revised and/or new versions |
|
842 |
-of the GNU Lesser General Public License from time to time. Such new |
|
843 |
-versions will be similar in spirit to the present version, but may |
|
844 |
-differ in detail to address new problems or concerns. |
|
845 |
- |
|
846 |
- Each version is given a distinguishing version number. If the |
|
847 |
-Library as you received it specifies that a certain numbered version |
|
848 |
-of the GNU Lesser General Public License "or any later version" |
|
849 |
-applies to it, you have the option of following the terms and |
|
850 |
-conditions either of that published version or of any later version |
|
851 |
-published by the Free Software Foundation. If the Library as you |
|
852 |
-received it does not specify a version number of the GNU Lesser |
|
853 |
-General Public License, you may choose any version of the GNU Lesser |
|
854 |
-General Public License ever published by the Free Software Foundation. |
|
855 |
- |
|
856 |
- If the Library as you received it specifies that a proxy can decide |
|
857 |
-whether future versions of the GNU Lesser General Public License shall |
|
858 |
-apply, that proxy's public statement of acceptance of any version is |
|
859 |
-permanent authorization for you to choose that version for the |
|
860 |
-Library. |
|
861 |
- |
... | ... |
@@ -1,206 +0,0 @@ |
1 |
-declare module lib_comm { |
|
2 |
- /** |
|
3 |
- * @author fenris |
|
4 |
- */ |
|
5 |
- type type_answering_executor<type_message_in, type_message_out> = (message: type_message_in) => lib_call.type_executor<type_message_out, Error>; |
|
6 |
- /** |
|
7 |
- * @author fenris |
|
8 |
- */ |
|
9 |
- type type_answering_promise<type_message_in, type_message_out> = (message: type_message_in) => lib_call.type_promise<type_message_out, Error>; |
|
10 |
- /** |
|
11 |
- * @author fenris |
|
12 |
- */ |
|
13 |
- type type_answering<type_message_in, type_message_out> = type_answering_promise<type_message_in, type_message_out>; |
|
14 |
-} |
|
15 |
-declare module lib_comm { |
|
16 |
-} |
|
17 |
-declare module lib_comm { |
|
18 |
- /** |
|
19 |
- * @author fenris |
|
20 |
- */ |
|
21 |
- interface interface_server<type_message_in, type_message_out> { |
|
22 |
- /** |
|
23 |
- * @desc this method shall prepare the server to a point, where it just needs to be started afterwards |
|
24 |
- * @param {type_answering<type_message_in, type_message_out>} answering specifies how the server should handle incoming messages to formulate an answer |
|
25 |
- * @author fenris |
|
26 |
- */ |
|
27 |
- setup(answering: type_answering<type_message_in, type_message_out>): lib_call.type_promise<void, Error>; |
|
28 |
- /** |
|
29 |
- * @desc starts to listen |
|
30 |
- * @author fenris |
|
31 |
- */ |
|
32 |
- run(): void; |
|
33 |
- } |
|
34 |
-} |
|
35 |
-declare module lib_comm { |
|
36 |
- /** |
|
37 |
- * @author fenris |
|
38 |
- */ |
|
39 |
- type type_response_server_http = { |
|
40 |
- code: int; |
|
41 |
- text: string; |
|
42 |
- }; |
|
43 |
- /** |
|
44 |
- * @author fenris |
|
45 |
- */ |
|
46 |
- type type_parameters_server_http = { |
|
47 |
- protocol?: string; |
|
48 |
- port?: int; |
|
49 |
- headers?: { |
|
50 |
- [name: string]: string; |
|
51 |
- }; |
|
52 |
- ssl_key?: string; |
|
53 |
- ssl_cert?: string; |
|
54 |
- ssl_ca?: string; |
|
55 |
- }; |
|
56 |
- /** |
|
57 |
- * @author fenris |
|
58 |
- */ |
|
59 |
- var default_parameters_server_http: type_parameters_server_http; |
|
60 |
-} |
|
61 |
-declare module lib_comm { |
|
62 |
- /** |
|
63 |
- * @author fenris |
|
64 |
- */ |
|
65 |
- type type_server_http = { |
|
66 |
- parameters: type_parameters_server_http; |
|
67 |
- answering: type_answering<string, type_response_server_http>; |
|
68 |
- serverinstance: any; |
|
69 |
- }; |
|
70 |
- /** |
|
71 |
- * @author fenris |
|
72 |
- */ |
|
73 |
- function server_http_construct(parameters?: type_parameters_server_http): type_server_http; |
|
74 |
- /** |
|
75 |
- * @author fenris |
|
76 |
- */ |
|
77 |
- function server_http_setup(subject: type_server_http, answering: type_answering<string, type_response_server_http>): lib_call.type_promise<void, Error>; |
|
78 |
- /** |
|
79 |
- * @author fenris |
|
80 |
- */ |
|
81 |
- function server_http_run(subject: type_server_http): void; |
|
82 |
-} |
|
83 |
-declare module lib_comm { |
|
84 |
-} |
|
85 |
-declare module lib_comm { |
|
86 |
- /** |
|
87 |
- * @author fenris |
|
88 |
- */ |
|
89 |
- class class_server_http implements interface_server<string, type_response_server_http> { |
|
90 |
- /** |
|
91 |
- * @author fenris |
|
92 |
- */ |
|
93 |
- protected subject: type_server_http; |
|
94 |
- /** |
|
95 |
- * @author fenris |
|
96 |
- */ |
|
97 |
- constructor(parameters?: type_parameters_server_http); |
|
98 |
- /** |
|
99 |
- * @author fenris |
|
100 |
- * @implementation |
|
101 |
- */ |
|
102 |
- setup(answering: type_answering<string, type_response_server_http>): lib_call.type_promise<void, Error>; |
|
103 |
- /** |
|
104 |
- * @author fenris |
|
105 |
- * @implementation |
|
106 |
- */ |
|
107 |
- run(): void; |
|
108 |
- } |
|
109 |
-} |
|
110 |
-declare module lib_comm { |
|
111 |
- /** |
|
112 |
- * @author fenris |
|
113 |
- */ |
|
114 |
- class class_server_mhttp implements interface_server<string, string> { |
|
115 |
- /** |
|
116 |
- * @author fenris |
|
117 |
- */ |
|
118 |
- protected core: class_server_http; |
|
119 |
- /** |
|
120 |
- * @author fenris |
|
121 |
- */ |
|
122 |
- constructor(parameters?: type_parameters_server_http); |
|
123 |
- /** |
|
124 |
- * @author fenris |
|
125 |
- * @implementation |
|
126 |
- */ |
|
127 |
- setup(answering: type_answering<string, string>): lib_call.type_promise<void, Error>; |
|
128 |
- /** |
|
129 |
- * @author fenris |
|
130 |
- * @implementation |
|
131 |
- */ |
|
132 |
- run(): void; |
|
133 |
- } |
|
134 |
-} |
|
135 |
-declare module lib_comm { |
|
136 |
- /** |
|
137 |
- * @desc wrapper for string-based servers |
|
138 |
- * @author fenris |
|
139 |
- */ |
|
140 |
- class class_server_complex implements interface_server<any, any> { |
|
141 |
- /** |
|
142 |
- * @author fenris |
|
143 |
- */ |
|
144 |
- protected core: interface_server<string, string>; |
|
145 |
- /** |
|
146 |
- * @author fenris |
|
147 |
- */ |
|
148 |
- protected code: lib_code.interface_code<any, string>; |
|
149 |
- /** |
|
150 |
- * @author fenris |
|
151 |
- */ |
|
152 |
- constructor(core: interface_server<string, string>, code?: lib_code.interface_code<any, string>); |
|
153 |
- /** |
|
154 |
- * @author fenris |
|
155 |
- * @implementation |
|
156 |
- */ |
|
157 |
- setup(answering: type_answering<any, any>): lib_call.type_promise<void, Error>; |
|
158 |
- /** |
|
159 |
- * @author fenris |
|
160 |
- * @implementation |
|
161 |
- */ |
|
162 |
- run(): void; |
|
163 |
- } |
|
164 |
-} |
|
165 |
-declare module lib_comm { |
|
166 |
- /** |
|
167 |
- */ |
|
168 |
- type type_server_common = { |
|
169 |
- port: int; |
|
170 |
- handle: (input: string) => Promise<string>; |
|
171 |
- verbosity: int; |
|
172 |
- server: any; |
|
173 |
- }; |
|
174 |
- /** |
|
175 |
- */ |
|
176 |
- function server_common_make(port: int, handle: (input: string) => Promise<string>, verbosity?: int): type_server_common; |
|
177 |
- /** |
|
178 |
- */ |
|
179 |
- function server_common_start(subject: type_server_common, finish?: () => void): void; |
|
180 |
- /** |
|
181 |
- */ |
|
182 |
- function server_common_kill(subject: type_server_common): void; |
|
183 |
-} |
|
184 |
-declare module lib_comm { |
|
185 |
- /** |
|
186 |
- * @author fenris |
|
187 |
- */ |
|
188 |
- class class_server_common { |
|
189 |
- /** |
|
190 |
- * @author fenris |
|
191 |
- */ |
|
192 |
- protected subject: type_server_common; |
|
193 |
- /** |
|
194 |
- * @author fenris |
|
195 |
- */ |
|
196 |
- constructor(port: int, handle: (input: string) => Promise<string>, verbosity?: int); |
|
197 |
- /** |
|
198 |
- * @author fenris |
|
199 |
- */ |
|
200 |
- start(finish?: () => void): void; |
|
201 |
- /** |
|
202 |
- * @author fenris |
|
203 |
- */ |
|
204 |
- kill(): void; |
|
205 |
- } |
|
206 |
-} |
... | ... |
@@ -1,206 +0,0 @@ |
1 |
-declare module lib_comm { |
|
2 |
- /** |
|
3 |
- * @author fenris |
|
4 |
- */ |
|
5 |
- type type_answering_executor<type_message_in, type_message_out> = (message: type_message_in) => lib_call.type_executor<type_message_out, Error>; |
|
6 |
- /** |
|
7 |
- * @author fenris |
|
8 |
- */ |
|
9 |
- type type_answering_promise<type_message_in, type_message_out> = (message: type_message_in) => lib_call.type_promise<type_message_out, Error>; |
|
10 |
- /** |
|
11 |
- * @author fenris |
|
12 |
- */ |
|
13 |
- type type_answering<type_message_in, type_message_out> = type_answering_promise<type_message_in, type_message_out>; |
|
14 |
-} |
|
15 |
-declare module lib_comm { |
|
16 |
-} |
|
17 |
-declare module lib_comm { |
|
18 |
- /** |
|
19 |
- * @author fenris |
|
20 |
- */ |
|
21 |
- interface interface_server<type_message_in, type_message_out> { |
|
22 |
- /** |
|
23 |
- * @desc this method shall prepare the server to a point, where it just needs to be started afterwards |
|
24 |
- * @param {type_answering<type_message_in, type_message_out>} answering specifies how the server should handle incoming messages to formulate an answer |
|
25 |
- * @author fenris |
|
26 |
- */ |
|
27 |
- setup(answering: type_answering<type_message_in, type_message_out>): lib_call.type_promise<void, Error>; |
|
28 |
- /** |
|
29 |
- * @desc starts to listen |
|
30 |
- * @author fenris |
|
31 |
- */ |
|
32 |
- run(): void; |
|
33 |
- } |
|
34 |
-} |
|
35 |
-declare module lib_comm { |
|
36 |
- /** |
|
37 |
- * @author fenris |
|
38 |
- */ |
|
39 |
- type type_response_server_http = { |
|
40 |
- code: int; |
|
41 |
- text: string; |
|
42 |
- }; |
|
43 |
- /** |
|
44 |
- * @author fenris |
|
45 |
- */ |
|
46 |
- type type_parameters_server_http = { |
|
47 |
- protocol?: string; |
|
48 |
- port?: int; |
|
49 |
- headers?: { |
|
50 |
- [name: string]: string; |
|
51 |
- }; |
|
52 |
- ssl_key?: string; |
|
53 |
- ssl_cert?: string; |
|
54 |
- ssl_ca?: string; |
|
55 |
- }; |
|
56 |
- /** |
|
57 |
- * @author fenris |
|
58 |
- */ |
|
59 |
- var default_parameters_server_http: type_parameters_server_http; |
|
60 |
-} |
|
61 |
-declare module lib_comm { |
|
62 |
- /** |
|
63 |
- * @author fenris |
|
64 |
- */ |
|
65 |
- type type_server_http = { |
|
66 |
- parameters: type_parameters_server_http; |
|
67 |
- answering: type_answering<string, type_response_server_http>; |
|
68 |
- serverinstance: any; |
|
69 |
- }; |
|
70 |
- /** |
|
71 |
- * @author fenris |
|
72 |
- */ |
|
73 |
- function server_http_construct(parameters?: type_parameters_server_http): type_server_http; |
|
74 |
- /** |
|
75 |
- * @author fenris |
|
76 |
- */ |
|
77 |
- function server_http_setup(subject: type_server_http, answering: type_answering<string, type_response_server_http>): lib_call.type_promise<void, Error>; |
|
78 |
- /** |
|
79 |
- * @author fenris |
|
80 |
- */ |
|
81 |
- function server_http_run(subject: type_server_http): void; |
|
82 |
-} |
|
83 |
-declare module lib_comm { |
|
84 |
-} |
|
85 |
-declare module lib_comm { |
|
86 |
- /** |
|
87 |
- * @author fenris |
|
88 |
- */ |
|
89 |
- class class_server_http implements interface_server<string, type_response_server_http> { |
|
90 |
- /** |
|
91 |
- * @author fenris |
|
92 |
- */ |
|
93 |
- protected subject: type_server_http; |
|
94 |
- /** |
|
95 |
- * @author fenris |
|
96 |
- */ |
|
97 |
- constructor(parameters?: type_parameters_server_http); |
|
98 |
- /** |
|
99 |
- * @author fenris |
|
100 |
- * @implementation |
|
101 |
- */ |
|
102 |
- setup(answering: type_answering<string, type_response_server_http>): lib_call.type_promise<void, Error>; |
|
103 |
- /** |
|
104 |
- * @author fenris |
|
105 |
- * @implementation |
|
106 |
- */ |
|
107 |
- run(): void; |
|
108 |
- } |
|
109 |
-} |
|
110 |
-declare module lib_comm { |
|
111 |
- /** |
|
112 |
- * @author fenris |
|
113 |
- */ |
|
114 |
- class class_server_mhttp implements interface_server<string, string> { |
|
115 |
- /** |
|
116 |
- * @author fenris |
|
117 |
- */ |
|
118 |
- protected core: class_server_http; |
|
119 |
- /** |
|
120 |
- * @author fenris |
|
121 |
- */ |
|
122 |
- constructor(parameters?: type_parameters_server_http); |
|
123 |
- /** |
|
124 |
- * @author fenris |
|
125 |
- * @implementation |
|
126 |
- */ |
|
127 |
- setup(answering: type_answering<string, string>): lib_call.type_promise<void, Error>; |
|
128 |
- /** |
|
129 |
- * @author fenris |
|
130 |
- * @implementation |
|
131 |
- */ |
|
132 |
- run(): void; |
|
133 |
- } |
|
134 |
-} |
|
135 |
-declare module lib_comm { |
|
136 |
- /** |
|
137 |
- * @desc wrapper for string-based servers |
|
138 |
- * @author fenris |
|
139 |
- */ |
|
140 |
- class class_server_complex implements interface_server<any, any> { |
|
141 |
- /** |
|
142 |
- * @author fenris |
|
143 |
- */ |
|
144 |
- protected core: interface_server<string, string>; |
|
145 |
- /** |
|
146 |
- * @author fenris |
|
147 |
- */ |
|
148 |
- protected code: lib_code.interface_code<any, string>; |
|
149 |
- /** |
|
150 |
- * @author fenris |
|
151 |
- */ |
|
152 |
- constructor(core: interface_server<string, string>, code?: lib_code.interface_code<any, string>); |
|
153 |
- /** |
|
154 |
- * @author fenris |
|
155 |
- * @implementation |
|
156 |
- */ |
|
157 |
- setup(answering: type_answering<any, any>): lib_call.type_promise<void, Error>; |
|
158 |
- /** |
|
159 |
- * @author fenris |
|
160 |
- * @implementation |
|
161 |
- */ |
|
162 |
- run(): void; |
|
163 |
- } |
|
164 |
-} |
|
165 |
-declare module lib_comm { |
|
166 |
- /** |
|
167 |
- */ |
|
168 |
- type type_server_common = { |
|
169 |
- port: int; |
|
170 |
- handle: (input: string) => Promise<string>; |
|
171 |
- verbosity: int; |
|
172 |
- server: any; |
|
173 |
- }; |
|
174 |
- /** |
|
175 |
- */ |
|
176 |
- function server_common_make(port: int, handle: (input: string) => Promise<string>, verbosity?: int): type_server_common; |
|
177 |
- /** |
|
178 |
- */ |
|
179 |
- function server_common_start(subject: type_server_common, finish?: () => void): void; |
|
180 |
- /** |
|
181 |
- */ |
|
182 |
- function server_common_kill(subject: type_server_common): void; |
|
183 |
-} |
|
184 |
-declare module lib_comm { |
|
185 |
- /** |
|
186 |
- * @author fenris |
|
187 |
- */ |
|
188 |
- class class_server_common { |
|
189 |
- /** |
|
190 |
- * @author fenris |
|
191 |
- */ |
|
192 |
- protected subject: type_server_common; |
|
193 |
- /** |
|
194 |
- * @author fenris |
|
195 |
- */ |
|
196 |
- constructor(port: int, handle: (input: string) => Promise<string>, verbosity?: int); |
|
197 |
- /** |
|
198 |
- * @author fenris |
|
199 |
- */ |
|
200 |
- start(finish?: () => void): void; |
|
201 |
- /** |
|
202 |
- * @author fenris |
|
203 |
- */ |
|
204 |
- kill(): void; |
|
205 |
- } |
|
206 |
-} |
... | ... |
@@ -1,611 +0,0 @@ |
1 |
-/* |
|
2 |
-This file is part of »bacterio-plankton:comm-server«. |
|
3 |
- |
|
4 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
5 |
-<info@greenscale.de> |
|
6 |
- |
|
7 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
8 |
-it under the terms of the GNU Lesser General Public License as published by |
|
9 |
-the Free Software Foundation, either version 3 of the License, or |
|
10 |
-(at your option) any later version. |
|
11 |
- |
|
12 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
13 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
-GNU Lesser General Public License for more details. |
|
16 |
- |
|
17 |
-You should have received a copy of the GNU Lesser General Public License |
|
18 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
19 |
- */ |
|
20 |
-/* |
|
21 |
-This file is part of »bacterio-plankton:comm-server«. |
|
22 |
- |
|
23 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
24 |
-<info@greenscale.de> |
|
25 |
- |
|
26 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
27 |
-it under the terms of the GNU Lesser General Public License as published by |
|
28 |
-the Free Software Foundation, either version 3 of the License, or |
|
29 |
-(at your option) any later version. |
|
30 |
- |
|
31 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
32 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
33 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
34 |
-GNU Lesser General Public License for more details. |
|
35 |
- |
|
36 |
-You should have received a copy of the GNU Lesser General Public License |
|
37 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
38 |
- */ |
|
39 |
-var lib_comm; |
|
40 |
-(function (lib_comm) { |
|
41 |
- /** |
|
42 |
- * @author fenris |
|
43 |
- */ |
|
44 |
- lib_trait.define("comm-server", { |
|
45 |
- "state": null, |
|
46 |
- "message_in": null, |
|
47 |
- "message_out": null |
|
48 |
- }, { |
|
49 |
- "setup": { |
|
50 |
- "shape": { |
|
51 |
- "name": "function", |
|
52 |
- "parameters": { |
|
53 |
- "shape_input": { |
|
54 |
- "name": "variable", |
|
55 |
- "parameters": { |
|
56 |
- "name": "state" |
|
57 |
- } |
|
58 |
- }, |
|
59 |
- "shape_output": { |
|
60 |
- "name": "function", |
|
61 |
- "parameters": { |
|
62 |
- "shape_input": { |
|
63 |
- "name": "any" |
|
64 |
- }, |
|
65 |
- "shape_output": { |
|
66 |
- "name": "promise", |
|
67 |
- "parameters": { |
|
68 |
- "shape_result": { |
|
69 |
- "name": "variable", |
|
70 |
- "parameters": { |
|
71 |
- "name": "state" |
|
72 |
- } |
|
73 |
- }, |
|
74 |
- "shape_reason": { |
|
75 |
- "name": "any" |
|
76 |
- } |
|
77 |
- } |
|
78 |
- } |
|
79 |
- } |
|
80 |
- } |
|
81 |
- } |
|
82 |
- } |
|
83 |
- }, |
|
84 |
- "run": { |
|
85 |
- "shape": { |
|
86 |
- "name": "function", |
|
87 |
- "parameters": { |
|
88 |
- "shape_input": { |
|
89 |
- "name": "variable", |
|
90 |
- "parameters": { |
|
91 |
- "name": "state" |
|
92 |
- } |
|
93 |
- }, |
|
94 |
- "shape_output": { |
|
95 |
- "name": "void" |
|
96 |
- } |
|
97 |
- } |
|
98 |
- } |
|
99 |
- } |
|
100 |
- }); |
|
101 |
-})(lib_comm || (lib_comm = {})); |
|
102 |
-/* |
|
103 |
-This file is part of »bacterio-plankton:comm-server«. |
|
104 |
- |
|
105 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
106 |
-<info@greenscale.de> |
|
107 |
- |
|
108 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
109 |
-it under the terms of the GNU Lesser General Public License as published by |
|
110 |
-the Free Software Foundation, either version 3 of the License, or |
|
111 |
-(at your option) any later version. |
|
112 |
- |
|
113 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
114 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
115 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
116 |
-GNU Lesser General Public License for more details. |
|
117 |
- |
|
118 |
-You should have received a copy of the GNU Lesser General Public License |
|
119 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
120 |
- */ |
|
121 |
-/* |
|
122 |
-This file is part of »bacterio-plankton:comm-server«. |
|
123 |
- |
|
124 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
125 |
-<info@greenscale.de> |
|
126 |
- |
|
127 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
128 |
-it under the terms of the GNU Lesser General Public License as published by |
|
129 |
-the Free Software Foundation, either version 3 of the License, or |
|
130 |
-(at your option) any later version. |
|
131 |
- |
|
132 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
133 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
134 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
135 |
-GNU Lesser General Public License for more details. |
|
136 |
- |
|
137 |
-You should have received a copy of the GNU Lesser General Public License |
|
138 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
139 |
- */ |
|
140 |
-var lib_comm; |
|
141 |
-(function (lib_comm) { |
|
142 |
- /** |
|
143 |
- * @author fenris |
|
144 |
- */ |
|
145 |
- lib_comm.default_parameters_server_http = { |
|
146 |
- "protocol": "http", |
|
147 |
- "port": 80, |
|
148 |
- "headers": { |
|
149 |
- "Access-Control-Allow-Methods": "OPTIONS, POST", |
|
150 |
- "Access-Control-Allow-Origin": "*", |
|
151 |
- "Access-Control-Allow-Headers": "origin, content-type", |
|
152 |
- "Access-Control-Allow-Credentials": null, |
|
153 |
- "Content-Type": "plain/text; charset=utf-8", |
|
154 |
- } |
|
155 |
- }; |
|
156 |
-})(lib_comm || (lib_comm = {})); |
|
157 |
-/* |
|
158 |
-This file is part of »bacterio-plankton:comm-server«. |
|
159 |
- |
|
160 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
161 |
-<info@greenscale.de> |
|
162 |
- |
|
163 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
164 |
-it under the terms of the GNU Lesser General Public License as published by |
|
165 |
-the Free Software Foundation, either version 3 of the License, or |
|
166 |
-(at your option) any later version. |
|
167 |
- |
|
168 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
169 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
170 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
171 |
-GNU Lesser General Public License for more details. |
|
172 |
- |
|
173 |
-You should have received a copy of the GNU Lesser General Public License |
|
174 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
175 |
- */ |
|
176 |
-var lib_comm; |
|
177 |
-(function (lib_comm) { |
|
178 |
- /** |
|
179 |
- * @author fenris |
|
180 |
- */ |
|
181 |
- function server_http_construct(parameters = {}) { |
|
182 |
- return { |
|
183 |
- "parameters": lib_object.patched(lib_comm.default_parameters_server_http, parameters), |
|
184 |
- "answering": null, |
|
185 |
- "serverinstance": null, |
|
186 |
- }; |
|
187 |
- } |
|
188 |
- lib_comm.server_http_construct = server_http_construct; |
|
189 |
- /** |
|
190 |
- * @author fenris |
|
191 |
- */ |
|
192 |
- function server_http_setup(subject, answering) { |
|
193 |
- subject.answering = answering; |
|
194 |
- let factory; |
|
195 |
- switch (subject.parameters.protocol) { |
|
196 |
- case undefined: |
|
197 |
- case "http": { |
|
198 |
- factory = ((options, listener) => require("http").createServer(listener)); |
|
199 |
- break; |
|
200 |
- } |
|
201 |
- case "https": { |
|
202 |
- factory = ((options, listener) => require("https").createServer(options, listener)); |
|
203 |
- break; |
|
204 |
- } |
|
205 |
- default: { |
|
206 |
- return lib_call.promise_reject(new Error(`no module for protocol '${subject.parameters.protocol}'`)); |
|
207 |
- break; |
|
208 |
- } |
|
209 |
- } |
|
210 |
- const listener = (request, response) => { |
|
211 |
- // headers |
|
212 |
- { |
|
213 |
- Object.keys(subject.parameters.headers) |
|
214 |
- .forEach((name) => { |
|
215 |
- const value = subject.parameters.headers[name]; |
|
216 |
- if (value != null) { |
|
217 |
- response.setHeader(name, value); |
|
218 |
- } |
|
219 |
- }); |
|
220 |
- } |
|
221 |
- let message = null; |
|
222 |
- request.on("data", (buffer) => { |
|
223 |
- message = buffer.toString(); |
|
224 |
- }); |
|
225 |
- request.on("end", () => { |
|
226 |
- switch (request.method) { |
|
227 |
- case "OPTIONS": { |
|
228 |
- response.writeHead(200); |
|
229 |
- response.end("options-echo"); |
|
230 |
- break; |
|
231 |
- } |
|
232 |
- case "POST": { |
|
233 |
- lib_call.promise_then_close(subject.answering(message), (answer) => { |
|
234 |
- response.writeHead(answer.code); |
|
235 |
- response.end(answer.text); |
|
236 |
- }, (error) => { |
|
237 |
- console.error(error); |
|
238 |
- response.writeHead(500); |
|
239 |
- response.end("internal error"); |
|
240 |
- }); |
|
241 |
- break; |
|
242 |
- } |
|
243 |
- default: { |
|
244 |
- response.writeHead(500); |
|
245 |
- response.end(`unhandled method ${request.method}`); |
|
246 |
- break; |
|
247 |
- } |
|
248 |
- } |
|
249 |
- }); |
|
250 |
- }; |
|
251 |
- const _fs = require("fs"); |
|
252 |
- let options = {}; |
|
253 |
- if (subject.parameters.ssl_key !== undefined) { |
|
254 |
- options["key"] = _fs.readFileSync(subject.parameters.ssl_key); |
|
255 |
- } |
|
256 |
- if (subject.parameters.ssl_cert !== undefined) { |
|
257 |
- options["cert"] = _fs.readFileSync(subject.parameters.ssl_cert); |
|
258 |
- } |
|
259 |
- if (subject.parameters.ssl_ca !== undefined) { |
|
260 |
- options["ca"] = _fs.readFileSync(subject.parameters.ssl_ca); |
|
261 |
- } |
|
262 |
- // setup server instance |
|
263 |
- subject.serverinstance = factory(options, listener); |
|
264 |
- subject.serverinstance.on("clientError", (error, socket) => { |
|
265 |
- socket.end("HTTP/1.1 400 Bad Request\r\n\r\n"); |
|
266 |
- }); |
|
267 |
- return lib_call.promise_resolve(undefined); |
|
268 |
- } |
|
269 |
- lib_comm.server_http_setup = server_http_setup; |
|
270 |
- /** |
|
271 |
- * @author fenris |
|
272 |
- */ |
|
273 |
- function server_http_run(subject) { |
|
274 |
- subject.serverinstance.listen(subject.parameters.port); |
|
275 |
- } |
|
276 |
- lib_comm.server_http_run = server_http_run; |
|
277 |
-})(lib_comm || (lib_comm = {})); |
|
278 |
-/* |
|
279 |
-This file is part of »bacterio-plankton:comm-server«. |
|
280 |
- |
|
281 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
282 |
-<info@greenscale.de> |
|
283 |
- |
|
284 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
285 |
-it under the terms of the GNU Lesser General Public License as published by |
|
286 |
-the Free Software Foundation, either version 3 of the License, or |
|
287 |
-(at your option) any later version. |
|
288 |
- |
|
289 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
290 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
291 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
292 |
-GNU Lesser General Public License for more details. |
|
293 |
- |
|
294 |
-You should have received a copy of the GNU Lesser General Public License |
|
295 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
296 |
- */ |
|
297 |
-var lib_comm; |
|
298 |
-(function (lib_comm) { |
|
299 |
- /** |
|
300 |
- * @author fenris |
|
301 |
- */ |
|
302 |
- lib_trait.attend("comm-server", "http", { |
|
303 |
- "state": { |
|
304 |
- "name": "any" |
|
305 |
- }, |
|
306 |
- "message_in": { |
|
307 |
- "name": "string" |
|
308 |
- }, |
|
309 |
- "message_out": { |
|
310 |
- "name": "any" // type_response_http |
|
311 |
- } |
|
312 |
- }, { |
|
313 |
- "setup": () => (state) => (answering) => { |
|
314 |
- return lib_comm.server_http_setup(state, answering).then(() => lib_call.promise_resolve(state)); |
|
315 |
- }, |
|
316 |
- "run": () => (state) => { |
|
317 |
- return lib_comm.server_http_run(state); |
|
318 |
- } |
|
319 |
- }); |
|
320 |
-})(lib_comm || (lib_comm = {})); |
|
321 |
-/* |
|
322 |
-This file is part of »bacterio-plankton:comm-server«. |
|
323 |
- |
|
324 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
325 |
-<info@greenscale.de> |
|
326 |
- |
|
327 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
328 |
-it under the terms of the GNU Lesser General Public License as published by |
|
329 |
-the Free Software Foundation, either version 3 of the License, or |
|
330 |
-(at your option) any later version. |
|
331 |
- |
|
332 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
333 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
334 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
335 |
-GNU Lesser General Public License for more details. |
|
336 |
- |
|
337 |
-You should have received a copy of the GNU Lesser General Public License |
|
338 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
339 |
- */ |
|
340 |
-var lib_comm; |
|
341 |
-(function (lib_comm) { |
|
342 |
- /** |
|
343 |
- * @author fenris |
|
344 |
- */ |
|
345 |
- class class_server_http { |
|
346 |
- /** |
|
347 |
- * @author fenris |
|
348 |
- */ |
|
349 |
- constructor(parameters = lib_comm.default_parameters_server_http) { |
|
350 |
- this.subject = lib_comm.server_http_construct(parameters); |
|
351 |
- } |
|
352 |
- /** |
|
353 |
- * @author fenris |
|
354 |
- * @implementation |
|
355 |
- */ |
|
356 |
- setup(answering) { |
|
357 |
- return lib_comm.server_http_setup(this.subject, answering); |
|
358 |
- } |
|
359 |
- /** |
|
360 |
- * @author fenris |
|
361 |
- * @implementation |
|
362 |
- */ |
|
363 |
- run() { |
|
364 |
- return lib_comm.server_http_run(this.subject); |
|
365 |
- } |
|
366 |
- } |
|
367 |
- lib_comm.class_server_http = class_server_http; |
|
368 |
-})(lib_comm || (lib_comm = {})); |
|
369 |
-/* |
|
370 |
-This file is part of »bacterio-plankton:comm-server«. |
|
371 |
- |
|
372 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
373 |
-<info@greenscale.de> |
|
374 |
- |
|
375 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
376 |
-it under the terms of the GNU Lesser General Public License as published by |
|
377 |
-the Free Software Foundation, either version 3 of the License, or |
|
378 |
-(at your option) any later version. |
|
379 |
- |
|
380 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
381 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
382 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
383 |
-GNU Lesser General Public License for more details. |
|
384 |
- |
|
385 |
-You should have received a copy of the GNU Lesser General Public License |
|
386 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
387 |
- */ |
|
388 |
-var lib_comm; |
|
389 |
-(function (lib_comm) { |
|
390 |
- /** |
|
391 |
- * @author fenris |
|
392 |
- */ |
|
393 |
- class class_server_mhttp { |
|
394 |
- /** |
|
395 |
- * @author fenris |
|
396 |
- */ |
|
397 |
- constructor(parameters = lib_comm.default_parameters_server_http) { |
|
398 |
- this.core = new lib_comm.class_server_http(parameters); |
|
399 |
- } |
|
400 |
- /** |
|
401 |
- * @author fenris |
|
402 |
- * @implementation |
|
403 |
- */ |
|
404 |
- setup(answering) { |
|
405 |
- return (this.core.setup((message) => (answering(message) |
|
406 |
- .then((text) => { |
|
407 |
- let response = { "code": 200, "text": text }; |
|
408 |
- return lib_call.promise_resolve(response); |
|
409 |
- })))); |
|
410 |
- } |
|
411 |
- /** |
|
412 |
- * @author fenris |
|
413 |
- * @implementation |
|
414 |
- */ |
|
415 |
- run() { |
|
416 |
- this.core.run(); |
|
417 |
- } |
|
418 |
- } |
|
419 |
- lib_comm.class_server_mhttp = class_server_mhttp; |
|
420 |
-})(lib_comm || (lib_comm = {})); |
|
421 |
-/* |
|
422 |
-This file is part of »bacterio-plankton:comm-server«. |
|
423 |
- |
|
424 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
425 |
-<info@greenscale.de> |
|
426 |
- |
|
427 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
428 |
-it under the terms of the GNU Lesser General Public License as published by |
|
429 |
-the Free Software Foundation, either version 3 of the License, or |
|
430 |
-(at your option) any later version. |
|
431 |
- |
|
432 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
433 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
434 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
435 |
-GNU Lesser General Public License for more details. |
|
436 |
- |
|
437 |
-You should have received a copy of the GNU Lesser General Public License |
|
438 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
439 |
- */ |
|
440 |
-var lib_comm; |
|
441 |
-(function (lib_comm) { |
|
442 |
- /** |
|
443 |
- * @desc wrapper for string-based servers |
|
444 |
- * @author fenris |
|
445 |
- */ |
|
446 |
- class class_server_complex { |
|
447 |
- /** |
|
448 |
- * @author fenris |
|
449 |
- */ |
|
450 |
- constructor(core, code = new lib_code.class_code_pair(new lib_code.class_code_json(), new lib_code.class_code_uri())) { |
|
451 |
- this.core = core; |
|
452 |
- this.code = code; |
|
453 |
- } |
|
454 |
- /** |
|
455 |
- * @author fenris |
|
456 |
- * @implementation |
|
457 |
- */ |
|
458 |
- setup(answering) { |
|
459 |
- return (this.core.setup((message_in_raw) => { |
|
460 |
- const message_in = ((message_in_raw == null) |
|
461 |
- ? null |
|
462 |
- : this.code.decode(message_in_raw)); |
|
463 |
- return (answering(message_in) |
|
464 |
- .then((message_out) => { |
|
465 |
- const message_out_raw = this.code.encode(message_out); |
|
466 |
- return lib_call.promise_resolve(message_out_raw); |
|
467 |
- })); |
|
468 |
- })); |
|
469 |
- } |
|
470 |
- /** |
|
471 |
- * @author fenris |
|
472 |
- * @implementation |
|
473 |
- */ |
|
474 |
- run() { |
|
475 |
- this.core.run(); |
|
476 |
- } |
|
477 |
- } |
|
478 |
- lib_comm.class_server_complex = class_server_complex; |
|
479 |
-})(lib_comm || (lib_comm = {})); |
|
480 |
-/* |
|
481 |
-This file is part of »bacterio-plankton:comm-server«. |
|
482 |
- |
|
483 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
484 |
-<info@greenscale.de> |
|
485 |
- |
|
486 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
487 |
-it under the terms of the GNU Lesser General Public License as published by |
|
488 |
-the Free Software Foundation, either version 3 of the License, or |
|
489 |
-(at your option) any later version. |
|
490 |
- |
|
491 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
492 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
493 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
494 |
-GNU Lesser General Public License for more details. |
|
495 |
- |
|
496 |
-You should have received a copy of the GNU Lesser General Public License |
|
497 |
-along with »bacterio-plankton:comm-server«. If not, see <http://www.gnu.org/licenses/>. |
|
498 |
- */ |
|
499 |
-var lib_comm; |
|
500 |
-(function (lib_comm) { |
|
501 |
- /** |
|
502 |
- */ |
|
503 |
- function server_common_make(port, handle, verbosity = 1) { |
|
504 |
- return { |
|
505 |
- "port": port, |
|
506 |
- "handle": handle, |
|
507 |
- "verbosity": verbosity, |
|
508 |
- "server": undefined, |
|
509 |
- }; |
|
510 |
- } |
|
511 |
- lib_comm.server_common_make = server_common_make; |
|
512 |
- /** |
|
513 |
- */ |
|
514 |
- function log(subject, level, message) { |
|
515 |
- if (subject.verbosity >= level) { |
|
516 |
- console.log("[server]", message); |
|
517 |
- } |
|
518 |
- else { |
|
519 |
- // do nothing |
|
520 |
- } |
|
521 |
- } |
|
522 |
- /** |
|
523 |
- */ |
|
524 |
- function server_common_start(subject, finish = undefined) { |
|
525 |
- const net = require("net"); |
|
526 |
- subject.server = net.createServer((socket) => { |
|
527 |
- log(subject, 2, "client connected"); |
|
528 |
- socket.on("readable", () => { |
|
529 |
- let chunk; |
|
530 |
- while (!((chunk = socket.read()) === null)) { |
|
531 |
- const input = chunk.toString(); |
|
532 |
- log(subject, 3, "reading: " + input); |
|
533 |
- subject.handle(input) |
|
534 |
- .then((output) => { |
|
535 |
- log(subject, 3, "writing: " + output); |
|
536 |
- socket.write(output); |
|
537 |
- socket.end(); |
|
538 |
- }) |
|
539 |
- .catch((error) => { |
|
540 |
- log(subject, 1, "handle failed: " + error.toString()); |
|
541 |
- }); |
|
542 |
- } |
|
543 |
- }); |
|
544 |
- socket.on("end", () => { |
|
545 |
- log(subject, 2, "client disconnected"); |
|
546 |
- }); |
|
547 |
- }); |
|
548 |
- subject.server.on("error", (error) => { |
|
549 |
- throw error; |
|
550 |
- }); |
|
551 |
- subject.server.listen(subject.port, () => { |
|
552 |
- log(subject, 1, "listening on port " + subject.port.toFixed(0)); |
|
553 |
- if (!(finish === undefined)) { |
|
554 |
- finish(); |
|
555 |
- } |
|
556 |
- }); |
|
557 |
- } |
|
558 |
- lib_comm.server_common_start = server_common_start; |
|
559 |
- /** |
|
560 |
- */ |
|
561 |
- function server_common_kill(subject) { |
|
562 |
- subject.server.close(); |
|
563 |
- } |
|
564 |
- lib_comm.server_common_kill = server_common_kill; |
|
565 |
-})(lib_comm || (lib_comm = {})); |
|
566 |
-/* |
|
567 |
-This file is part of »bacterio-plankton:comm-server«. |
|
568 |
- |
|
569 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
570 |
-<info@greenscale.de> |
|
571 |
- |
|
572 |
-»bacterio-plankton:comm-server« is free software: you can redistribute it and/or modify |
|
573 |
-it under the terms of the GNU Lesser General Public License as published by |
|
574 |
-the Free Software Foundation, either version 3 of the License, or |
|
575 |
-(at your option) any later version. |
|
576 |
- |
|
577 |
-»bacterio-plankton:comm-server« is distributed in the hope that it will be useful, |
|
578 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
579 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
580 |
-GNU Lesser General Public License for more details. |
|
581 |
- |
|
582 |
-You should have received a copy of the GNU Lesser General Public License |
|
583 |
-along with »bacterio-plankton:comm-server«. If not, see <common://www.gnu.org/licenses/>. |
|
584 |
- */ |
|
585 |
-var lib_comm; |
|
586 |
-(function (lib_comm) { |
|
587 |
- /** |
|
588 |
- * @author fenris |
|
589 |
- */ |
|
590 |
- class class_server_common { |
|
591 |
- /** |
|
592 |
- * @author fenris |
|
593 |
- */ |
|
594 |
- constructor(port, handle, verbosity = undefined) { |
|
595 |
- this.subject = lib_comm.server_common_make(port, handle, verbosity); |
|
596 |
- } |
|
597 |
- /** |
|
598 |
- * @author fenris |
|
599 |
- */ |
|
600 |
- start(finish = undefined) { |
|
601 |
- return lib_comm.server_common_start(this.subject, finish); |
|
602 |
- } |
|
603 |
- /** |
|
604 |
- * @author fenris |
|
605 |
- */ |
|
606 |
- kill() { |
|
607 |
- return lib_comm.server_common_kill(this.subject); |
|
608 |
- } |
|
609 |
- } |
|
610 |
- lib_comm.class_server_common = class_server_common; |
|
611 |
-})(lib_comm || (lib_comm = {})); |
... | ... |
@@ -48,3 +48,45 @@ declare module lib_http { |
48 | 48 |
*/ |
49 | 49 |
function decode_response(response_raw: string): type_response; |
50 | 50 |
} |
51 |
+declare module lib_http { |
|
52 |
+ /** |
|
53 |
+ * @author fenris |
|
54 |
+ */ |
|
55 |
+ class class_http_request implements lib_code.interface_code<type_request, string> { |
|
56 |
+ /** |
|
57 |
+ * @author fenris |
|
58 |
+ */ |
|
59 |
+ constructor(); |
|
60 |
+ /** |
|
61 |
+ * @implementation |
|
62 |
+ * @author fenris |
|
63 |
+ */ |
|
64 |
+ encode(x: type_request): string; |
|
65 |
+ /** |
|
66 |
+ * @implementation |
|
67 |
+ * @author fenris |
|
68 |
+ */ |
|
69 |
+ decode(x: string): type_request; |
|
70 |
+ } |
|
71 |
+ /** |
|
72 |
+ * @author fenris |
|
73 |
+ */ |
|
74 |
+ class class_http_response implements lib_code.interface_code<type_response, string> { |
|
75 |
+ /** |
|
76 |
+ * @author fenris |
|
77 |
+ */ |
|
78 |
+ constructor(); |
|
79 |
+ /** |
|
80 |
+ * @implementation |
|
81 |
+ * @author fenris |
|
82 |
+ */ |
|
83 |
+ encode(x: type_response): string; |
|
84 |
+ /** |
|
85 |
+ * @implementation |
|
86 |
+ * @author fenris |
|
87 |
+ */ |
|
88 |
+ decode(x: string): type_response; |
|
89 |
+ } |
|
90 |
+} |
|
91 |
+declare module lib_http { |
|
92 |
+} |
... | ... |
@@ -227,3 +227,133 @@ var lib_http; |
227 | 227 |
} |
228 | 228 |
lib_http.decode_response = decode_response; |
229 | 229 |
})(lib_http || (lib_http = {})); |
230 |
+/* |
|
231 |
+This file is part of »bacterio-plankton:http«. |
|
232 |
+ |
|
233 |
+Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
234 |
+<info@greenscale.de> |
|
235 |
+ |
|
236 |
+»bacterio-plankton:http« is free software: you can redistribute it and/or modify |
|
237 |
+it under the terms of the GNU Lesser General Public License as published by |
|
238 |
+the Free Software Foundation, either version 3 of the License, or |
|
239 |
+(at your option) any later version. |
|
240 |
+ |
|
241 |
+»bacterio-plankton:http« is distributed in the hope that it will be useful, |
|
242 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
243 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
244 |
+GNU Lesser General Public License for more details. |
|
245 |
+ |
|
246 |
+You should have received a copy of the GNU Lesser General Public License |
|
247 |
+along with »bacterio-plankton:http«. If not, see <http://www.gnu.org/licenses/>. |
|
248 |
+ */ |
|
249 |
+var lib_http; |
|
250 |
+(function (lib_http) { |
|
251 |
+ /** |
|
252 |
+ * @author fenris |
|
253 |
+ */ |
|
254 |
+ class class_http_request { |
|
255 |
+ /** |
|
256 |
+ * @author fenris |
|
257 |
+ */ |
|
258 |
+ constructor() { |
|
259 |
+ } |
|
260 |
+ /** |
|
261 |
+ * @implementation |
|
262 |
+ * @author fenris |
|
263 |
+ */ |
|
264 |
+ encode(x) { |
|
265 |
+ return lib_http.encode_request(x); |
|
266 |
+ } |
|
267 |
+ /** |
|
268 |
+ * @implementation |
|
269 |
+ * @author fenris |
|
270 |
+ */ |
|
271 |
+ decode(x) { |
|
272 |
+ return lib_http.decode_request(x); |
|
273 |
+ } |
|
274 |
+ } |
|
275 |
+ lib_http.class_http_request = class_http_request; |
|
276 |
+ /** |
|
277 |
+ * @author fenris |
|
278 |
+ */ |
|
279 |
+ class class_http_response { |
|
280 |
+ /** |
|
281 |
+ * @author fenris |
|
282 |
+ */ |
|
283 |
+ constructor() { |
|
284 |
+ } |
|
285 |
+ /** |
|
286 |
+ * @implementation |
|
287 |
+ * @author fenris |
|
288 |
+ */ |
|
289 |
+ encode(x) { |
|
290 |
+ return lib_http.encode_response(x); |
|
291 |
+ } |
|
292 |
+ /** |
|
293 |
+ * @implementation |
|
294 |
+ * @author fenris |
|
295 |
+ */ |
|
296 |
+ decode(x) { |
|
297 |
+ return lib_http.decode_response(x); |
|
298 |
+ } |
|
299 |
+ } |
|
300 |
+ lib_http.class_http_response = class_http_response; |
|
301 |
+})(lib_http || (lib_http = {})); |
|
302 |
+/* |
|
303 |
+This file is part of »bacterio-plankton:http«. |
|
304 |
+ |
|
305 |
+Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
306 |
+<info@greenscale.de> |
|
307 |
+ |
|
308 |
+»bacterio-plankton:http« is free software: you can redistribute it and/or modify |
|
309 |
+it under the terms of the GNU Lesser General Public License as published by |
|
310 |
+the Free Software Foundation, either version 3 of the License, or |
|
311 |
+(at your option) any later version. |
|
312 |
+ |
|
313 |
+»bacterio-plankton:http« is distributed in the hope that it will be useful, |
|
314 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
315 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
316 |
+GNU Lesser General Public License for more details. |
|
317 |
+ |
|
318 |
+You should have received a copy of the GNU Lesser General Public License |
|
319 |
+along with »bacterio-plankton:http«. If not, see <http://www.gnu.org/licenses/>. |
|
320 |
+ */ |
|
321 |
+var lib_http; |
|
322 |
+(function (lib_http) { |
|
323 |
+ /** |
|
324 |
+ * @author fenris |
|
325 |
+ */ |
|
326 |
+ lib_trait.attend("code", "http_request", { |
|
327 |
+ "from": { |
|
328 |
+ "name": "any" |
|
329 |
+ }, |
|
330 |
+ "to": { |
|
331 |
+ "name": "string" |
|
332 |
+ } |
|
333 |
+ }, { |
|
334 |
+ "encode": () => (x) => { |
|
335 |
+ return lib_http.encode_request(x); |
|
336 |
+ }, |
|
337 |
+ "decode": () => (y) => { |
|
338 |
+ return lib_http.decode_request(y); |
|
339 |
+ } |
|
340 |
+ }); |
|
341 |
+ /** |
|
342 |
+ * @author fenris |
|
343 |
+ */ |
|
344 |
+ lib_trait.attend("code", "http_response", { |
|
345 |
+ "from": { |
|
346 |
+ "name": "any" |
|
347 |
+ }, |
|
348 |
+ "to": { |
|
349 |
+ "name": "string" |
|
350 |
+ } |
|
351 |
+ }, { |
|
352 |
+ "encode": () => (x) => { |
|
353 |
+ return lib_http.encode_response(x); |
|
354 |
+ }, |
|
355 |
+ "decode": () => (y) => { |
|
356 |
+ return lib_http.decode_response(y); |
|
357 |
+ } |
|
358 |
+ }); |
|
359 |
+})(lib_http || (lib_http = {})); |
... | ... |
@@ -1,18 +1,18 @@ |
1 | 1 |
Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
2 | 2 |
<info@greenscale.de> |
3 | 3 |
|
4 |
-»bacterio-plankton:call« is free software: you can redistribute it and/or modify |
|
4 |
+»bacterio-plankton:json« is free software: you can redistribute it and/or modify |
|
5 | 5 |
it under the terms of the GNU Lesser General Public License as published by |
6 | 6 |
the Free Software Foundation, either version 3 of the License, or |
7 | 7 |
(at your option) any later version. |
8 | 8 |
|
9 |
-»bacterio-plankton:call« is distributed in the hope that it will be useful, |
|
9 |
+»bacterio-plankton:json« is distributed in the hope that it will be useful, |
|
10 | 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 |
GNU Lesser General Public License for more details. |
13 | 13 |
|
14 | 14 |
You should have received a copy of the GNU Lesser General Public License |
15 |
-along with »bacterio-plankton:call«. If not, see <http://www.gnu.org/licenses/>. |
|
15 |
+along with »bacterio-plankton:json«. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 |
|
17 | 17 |
|
18 | 18 |
|
... | ... |
@@ -0,0 +1,33 @@ |
1 |
+declare module lib_json { |
|
2 |
+ /** |
|
3 |
+ * @author fenris |
|
4 |
+ */ |
|
5 |
+ function encode(x: any, formatted?: boolean): string; |
|
6 |
+ /** |
|
7 |
+ * @author fenris |
|
8 |
+ */ |
|
9 |
+ function decode(x: string): any; |
|
10 |
+} |
|
11 |
+declare module lib_json { |
|
12 |
+} |
|
13 |
+declare module lib_json { |
|
14 |
+ /** |
|
15 |
+ * @author fenris |
|
16 |
+ */ |
|
17 |
+ class class_json implements lib_code.interface_code<any, string> { |
|
18 |
+ /** |
|
19 |
+ * @author fenris |
|
20 |
+ */ |
|
21 |
+ constructor(); |
|
22 |
+ /** |
|
23 |
+ * @implementation |
|
24 |
+ * @author fenris |
|
25 |
+ */ |
|
26 |
+ encode(x: any): string; |
|
27 |
+ /** |
|
28 |
+ * @implementation |
|
29 |
+ * @author fenris |
|
30 |
+ */ |
|
31 |
+ decode(x: string): any; |
|
32 |
+ } |
|
33 |
+} |
... | ... |
@@ -0,0 +1,123 @@ |
1 |
+/* |
|
2 |
+This file is part of »bacterio-plankton:json«. |
|
3 |
+ |
|
4 |
+Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
5 |
+<info@greenscale.de> |
|
6 |
+ |
|
7 |
+»bacterio-plankton:json« is free software: you can redistribute it and/or modify |
|
8 |
+it under the terms of the GNU Lesser General Public License as published by |
|
9 |
+the Free Software Foundation, either version 3 of the License, or |
|
10 |
+(at your option) any later version. |
|
11 |
+ |
|
12 |
+»bacterio-plankton:json« is distributed in the hope that it will be useful, |
|
13 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
+GNU Lesser General Public License for more details. |
|
16 |
+ |
|
17 |
+You should have received a copy of the GNU Lesser General Public License |
|
18 |
+along with »bacterio-plankton:json«. If not, see <http://www.gnu.org/licenses/>. |
|
19 |
+ */ |
|
20 |
+var lib_json; |
|
21 |
+(function (lib_json) { |
|
22 |
+ /** |
|
23 |
+ * @author fenris |
|
24 |
+ */ |
|
25 |
+ function encode(x, formatted = false) { |
|
26 |
+ return JSON.stringify(x, undefined, formatted ? "\t" : undefined); |
|
27 |
+ } |
|
28 |
+ lib_json.encode = encode; |
|
29 |
+ /** |
|
30 |
+ * @author fenris |
|
31 |
+ */ |
|
32 |
+ function decode(x) { |
|
33 |
+ return JSON.parse(x); |
|
34 |
+ } |
|
35 |
+ lib_json.decode = decode; |
|
36 |
+})(lib_json || (lib_json = {})); |
|
37 |
+/* |
|
38 |
+This file is part of »bacterio-plankton:json«. |
|
39 |
+ |
|
40 |
+Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
41 |
+<info@greenscale.de> |
|
42 |
+ |
|
43 |
+»bacterio-plankton:json« is free software: you can redistribute it and/or modify |
|
44 |
+it under the terms of the GNU Lesser General Public License as published by |
|
45 |
+the Free Software Foundation, either version 3 of the License, or |
|
46 |
+(at your option) any later version. |
|
47 |
+ |
|
48 |
+»bacterio-plankton:json« is distributed in the hope that it will be useful, |
|
49 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
50 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
51 |
+GNU Lesser General Public License for more details. |
|
52 |
+ |
|
53 |
+You should have received a copy of the GNU Lesser General Public License |
|
54 |
+along with »bacterio-plankton:json«. If not, see <http://www.gnu.org/licenses/>. |
|
55 |
+ */ |
|
56 |
+var lib_json; |
|
57 |
+(function (lib_json) { |
|
58 |
+ /** |
|
59 |
+ * @author fenris |
|
60 |
+ */ |
|
61 |
+ lib_trait.attend("code", "json", { |
|
62 |
+ "from": { |
|
63 |
+ "name": "any" |
|
64 |
+ }, |
|
65 |
+ "to": { |
|
66 |
+ "name": "string" |
|
67 |
+ } |
|
68 |
+ }, { |
|
69 |
+ "encode": () => (x) => { |
|
70 |
+ return lib_json.encode(x); |
|
71 |
+ }, |
|
72 |
+ "decode": () => (y) => { |
|
73 |
+ return lib_json.decode(y); |
|
74 |
+ } |
|
75 |
+ }); |
|
76 |
+})(lib_json || (lib_json = {})); |
|
77 |
+/* |
|
78 |
+This file is part of »bacterio-plankton:json«. |
|
79 |
+ |
|
80 |
+Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
81 |
+<info@greenscale.de> |
|
82 |
+ |
|
83 |
+»bacterio-plankton:json« is free software: you can redistribute it and/or modify |
|
84 |
+it under the terms of the GNU Lesser General Public License as published by |
|
85 |
+the Free Software Foundation, either version 3 of the License, or |
|
86 |
+(at your option) any later version. |
|
87 |
+ |
|
88 |
+»bacterio-plankton:json« is distributed in the hope that it will be useful, |
|
89 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
90 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
91 |
+GNU Lesser General Public License for more details. |
|
92 |
+ |
|
93 |
+You should have received a copy of the GNU Lesser General Public License |
|
94 |
+along with »bacterio-plankton:json«. If not, see <http://www.gnu.org/licenses/>. |
|
95 |
+ */ |
|
96 |
+var lib_json; |
|
97 |
+(function (lib_json) { |
|
98 |
+ /** |
|
99 |
+ * @author fenris |
|
100 |
+ */ |
|
101 |
+ class class_json { |
|
102 |
+ /** |
|
103 |
+ * @author fenris |
|
104 |
+ */ |
|
105 |
+ constructor() { |
|
106 |
+ } |
|
107 |
+ /** |
|
108 |
+ * @implementation |
|
109 |
+ * @author fenris |
|
110 |
+ */ |
|
111 |
+ encode(x) { |
|
112 |
+ return lib_json.encode(x); |
|
113 |
+ } |
|
114 |
+ /** |
|
115 |
+ * @implementation |
|
116 |
+ * @author fenris |
|
117 |
+ */ |
|
118 |
+ decode(x) { |
|
119 |
+ return lib_json.decode(x); |
|
120 |
+ } |
|
121 |
+ } |
|
122 |
+ lib_json.class_json = class_json; |
|
123 |
+})(lib_json || (lib_json = {})); |
... | ... |
@@ -1,861 +0,0 @@ |
1 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
2 |
-<info@greenscale.de> |
|
3 |
- |
|
4 |
-»bacterio-plankton:object« is free software: you can redistribute it and/or modify |
|
5 |
-it under the terms of the GNU Lesser General Public License as published by |
|
6 |
-the Free Software Foundation, either version 3 of the License, or |
|
7 |
-(at your option) any later version. |
|
8 |
- |
|
9 |
-»bacterio-plankton:object« is distributed in the hope that it will be useful, |
|
10 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
-GNU Lesser General Public License for more details. |
|
13 |
- |
|
14 |
-You should have received a copy of the GNU Lesser General Public License |
|
15 |
-along with »bacterio-plankton:object«. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
- |
|
17 |
- |
|
18 |
- |
|
19 |
- GNU GENERAL PUBLIC LICENSE |
|
20 |
- Version 3, 29 June 2007 |
|
21 |
- |
|
22 |
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> |
|
23 |
- Everyone is permitted to copy and distribute verbatim copies |
|
24 |
- of this license document, but changing it is not allowed. |
|
25 |
- |
|
26 |
- Preamble |
|
27 |
- |
|
28 |
- The GNU General Public License is a free, copyleft license for |
|
29 |
-software and other kinds of works. |
|
30 |
- |
|
31 |
- The licenses for most software and other practical works are designed |
|
32 |
-to take away your freedom to share and change the works. By contrast, |
|
33 |
-the GNU General Public License is intended to guarantee your freedom to |
|
34 |
-share and change all versions of a program--to make sure it remains free |
|
35 |
-software for all its users. We, the Free Software Foundation, use the |
|
36 |
-GNU General Public License for most of our software; it applies also to |
|
37 |
-any other work released this way by its authors. You can apply it to |
|
38 |
-your programs, too. |
|
39 |
- |
|
40 |
- When we speak of free software, we are referring to freedom, not |
|
41 |
-price. Our General Public Licenses are designed to make sure that you |
|
42 |
-have the freedom to distribute copies of free software (and charge for |
|
43 |
-them if you wish), that you receive source code or can get it if you |
|
44 |
-want it, that you can change the software or use pieces of it in new |
|
45 |
-free programs, and that you know you can do these things. |
|
46 |
- |
|
47 |
- To protect your rights, we need to prevent others from denying you |
|
48 |
-these rights or asking you to surrender the rights. Therefore, you have |
|
49 |
-certain responsibilities if you distribute copies of the software, or if |
|
50 |
-you modify it: responsibilities to respect the freedom of others. |
|
51 |
- |
|
52 |
- For example, if you distribute copies of such a program, whether |
|
53 |
-gratis or for a fee, you must pass on to the recipients the same |
|
54 |
-freedoms that you received. You must make sure that they, too, receive |
|
55 |
-or can get the source code. And you must show them these terms so they |
|
56 |
-know their rights. |
|
57 |
- |
|
58 |
- Developers that use the GNU GPL protect your rights with two steps: |
|
59 |
-(1) assert copyright on the software, and (2) offer you this License |
|
60 |
-giving you legal permission to copy, distribute and/or modify it. |
|
61 |
- |
|
62 |
- For the developers' and authors' protection, the GPL clearly explains |
|
63 |
-that there is no warranty for this free software. For both users' and |
|
64 |
-authors' sake, the GPL requires that modified versions be marked as |
|
65 |
-changed, so that their problems will not be attributed erroneously to |
|
66 |
-authors of previous versions. |
|
67 |
- |
|
68 |
- Some devices are designed to deny users access to install or run |
|
69 |
-modified versions of the software inside them, although the manufacturer |
|
70 |
-can do so. This is fundamentally incompatible with the aim of |
|
71 |
-protecting users' freedom to change the software. The systematic |
|
72 |
-pattern of such abuse occurs in the area of products for individuals to |
|
73 |
-use, which is precisely where it is most unacceptable. Therefore, we |
|
74 |
-have designed this version of the GPL to prohibit the practice for those |
|
75 |
-products. If such problems arise substantially in other domains, we |
|
76 |
-stand ready to extend this provision to those domains in future versions |
|
77 |
-of the GPL, as needed to protect the freedom of users. |
|
78 |
- |
|
79 |
- Finally, every program is threatened constantly by software patents. |
|
80 |
-States should not allow patents to restrict development and use of |
|
81 |
-software on general-purpose computers, but in those that do, we wish to |
|
82 |
-avoid the special danger that patents applied to a free program could |
|
83 |
-make it effectively proprietary. To prevent this, the GPL assures that |
|
84 |
-patents cannot be used to render the program non-free. |
|
85 |
- |
|
86 |
- The precise terms and conditions for copying, distribution and |
|
87 |
-modification follow. |
|
88 |
- |
|
89 |
- TERMS AND CONDITIONS |
|
90 |
- |
|
91 |
- 0. Definitions. |
|
92 |
- |
|
93 |
- "This License" refers to version 3 of the GNU General Public License. |
|
94 |
- |
|
95 |
- "Copyright" also means copyright-like laws that apply to other kinds of |
|
96 |
-works, such as semiconductor masks. |
|
97 |
- |
|
98 |
- "The Program" refers to any copyrightable work licensed under this |
|
99 |
-License. Each licensee is addressed as "you". "Licensees" and |
|
100 |
-"recipients" may be individuals or organizations. |
|
101 |
- |
|
102 |
- To "modify" a work means to copy from or adapt all or part of the work |
|
103 |
-in a fashion requiring copyright permission, other than the making of an |
|
104 |
-exact copy. The resulting work is called a "modified version" of the |
|
105 |
-earlier work or a work "based on" the earlier work. |
|
106 |
- |
|
107 |
- A "covered work" means either the unmodified Program or a work based |
|
108 |
-on the Program. |
|
109 |
- |
|
110 |
- To "propagate" a work means to do anything with it that, without |
|
111 |
-permission, would make you directly or secondarily liable for |
|
112 |
-infringement under applicable copyright law, except executing it on a |
|
113 |
-computer or modifying a private copy. Propagation includes copying, |
|
114 |
-distribution (with or without modification), making available to the |
|
115 |
-public, and in some countries other activities as well. |
|
116 |
- |
|
117 |
- To "convey" a work means any kind of propagation that enables other |
|
118 |
-parties to make or receive copies. Mere interaction with a user through |
|
119 |
-a computer network, with no transfer of a copy, is not conveying. |
|
120 |
- |
|
121 |
- An interactive user interface displays "Appropriate Legal Notices" |
|
122 |
-to the extent that it includes a convenient and prominently visible |
|
123 |
-feature that (1) displays an appropriate copyright notice, and (2) |
|
124 |
-tells the user that there is no warranty for the work (except to the |
|
125 |
-extent that warranties are provided), that licensees may convey the |
|
126 |
-work under this License, and how to view a copy of this License. If |
|
127 |
-the interface presents a list of user commands or options, such as a |
|
128 |
-menu, a prominent item in the list meets this criterion. |
|
129 |
- |
|
130 |
- 1. Source Code. |
|
131 |
- |
|
132 |
- The "source code" for a work means the preferred form of the work |
|
133 |
-for making modifications to it. "Object code" means any non-source |
|
134 |
-form of a work. |
|
135 |
- |
|
136 |
- A "Standard Interface" means an interface that either is an official |
|
137 |
-standard defined by a recognized standards body, or, in the case of |
|
138 |
-interfaces specified for a particular programming language, one that |
|
139 |
-is widely used among developers working in that language. |
|
140 |
- |
|
141 |
- The "System Libraries" of an executable work include anything, other |
|
142 |
-than the work as a whole, that (a) is included in the normal form of |
|
143 |
-packaging a Major Component, but which is not part of that Major |
|
144 |
-Component, and (b) serves only to enable use of the work with that |
|
145 |
-Major Component, or to implement a Standard Interface for which an |
|
146 |
-implementation is available to the public in source code form. A |
|
147 |
-"Major Component", in this context, means a major essential component |
|
148 |
-(kernel, window system, and so on) of the specific operating system |
|
149 |
-(if any) on which the executable work runs, or a compiler used to |
|
150 |
-produce the work, or an object code interpreter used to run it. |
|
151 |
- |
|
152 |
- The "Corresponding Source" for a work in object code form means all |
|
153 |
-the source code needed to generate, install, and (for an executable |
|
154 |
-work) run the object code and to modify the work, including scripts to |
|
155 |
-control those activities. However, it does not include the work's |
|
156 |
-System Libraries, or general-purpose tools or generally available free |
|
157 |
-programs which are used unmodified in performing those activities but |
|
158 |
-which are not part of the work. For example, Corresponding Source |
|
159 |
-includes interface definition files associated with source files for |
|
160 |
-the work, and the source code for shared libraries and dynamically |
|
161 |
-linked subprograms that the work is specifically designed to require, |
|
162 |
-such as by intimate data communication or control flow between those |
|
163 |
-subprograms and other parts of the work. |
|
164 |
- |
|
165 |
- The Corresponding Source need not include anything that users |
|
166 |
-can regenerate automatically from other parts of the Corresponding |
|
167 |
-Source. |
|
168 |
- |
|
169 |
- The Corresponding Source for a work in source code form is that |
|
170 |
-same work. |
|
171 |
- |
|
172 |
- 2. Basic Permissions. |
|
173 |
- |
|
174 |
- All rights granted under this License are granted for the term of |
|
175 |
-copyright on the Program, and are irrevocable provided the stated |
|
176 |
-conditions are met. This License explicitly affirms your unlimited |
|
177 |
-permission to run the unmodified Program. The output from running a |
|
178 |
-covered work is covered by this License only if the output, given its |
|
179 |
-content, constitutes a covered work. This License acknowledges your |
|
180 |
-rights of fair use or other equivalent, as provided by copyright law. |
|
181 |
- |
|
182 |
- You may make, run and propagate covered works that you do not |
|
183 |
-convey, without conditions so long as your license otherwise remains |
|
184 |
-in force. You may convey covered works to others for the sole purpose |
|
185 |
-of having them make modifications exclusively for you, or provide you |
|
186 |
-with facilities for running those works, provided that you comply with |
|
187 |
-the terms of this License in conveying all material for which you do |
|
188 |
-not control copyright. Those thus making or running the covered works |
|
189 |
-for you must do so exclusively on your behalf, under your direction |
|
190 |
-and control, on terms that prohibit them from making any copies of |
|
191 |
-your copyrighted material outside their relationship with you. |
|
192 |
- |
|
193 |
- Conveying under any other circumstances is permitted solely under |
|
194 |
-the conditions stated below. Sublicensing is not allowed; section 10 |
|
195 |
-makes it unnecessary. |
|
196 |
- |
|
197 |
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
|
198 |
- |
|
199 |
- No covered work shall be deemed part of an effective technological |
|
200 |
-measure under any applicable law fulfilling obligations under article |
|
201 |
-11 of the WIPO copyright treaty adopted on 20 December 1996, or |
|
202 |
-similar laws prohibiting or restricting circumvention of such |
|
203 |
-measures. |
|
204 |
- |
|
205 |
- When you convey a covered work, you waive any legal power to forbid |
|
206 |
-circumvention of technological measures to the extent such circumvention |
|
207 |
-is effected by exercising rights under this License with respect to |
|
208 |
-the covered work, and you disclaim any intention to limit operation or |
|
209 |
-modification of the work as a means of enforcing, against the work's |
|
210 |
-users, your or third parties' legal rights to forbid circumvention of |
|
211 |
-technological measures. |
|
212 |
- |
|
213 |
- 4. Conveying Verbatim Copies. |
|
214 |
- |
|
215 |
- You may convey verbatim copies of the Program's source code as you |
|
216 |
-receive it, in any medium, provided that you conspicuously and |
|
217 |
-appropriately publish on each copy an appropriate copyright notice; |
|
218 |
-keep intact all notices stating that this License and any |
|
219 |
-non-permissive terms added in accord with section 7 apply to the code; |
|
220 |
-keep intact all notices of the absence of any warranty; and give all |
|
221 |
-recipients a copy of this License along with the Program. |
|
222 |
- |
|
223 |
- You may charge any price or no price for each copy that you convey, |
|
224 |
-and you may offer support or warranty protection for a fee. |
|
225 |
- |
|
226 |
- 5. Conveying Modified Source Versions. |
|
227 |
- |
|
228 |
- You may convey a work based on the Program, or the modifications to |
|
229 |
-produce it from the Program, in the form of source code under the |
|
230 |
-terms of section 4, provided that you also meet all of these conditions: |
|
231 |
- |
|
232 |
- a) The work must carry prominent notices stating that you modified |
|
233 |
- it, and giving a relevant date. |
|
234 |
- |
|
235 |
- b) The work must carry prominent notices stating that it is |
|
236 |
- released under this License and any conditions added under section |
|
237 |
- 7. This requirement modifies the requirement in section 4 to |
|
238 |
- "keep intact all notices". |
|
239 |
- |
|
240 |
- c) You must license the entire work, as a whole, under this |
|
241 |
- License to anyone who comes into possession of a copy. This |
|
242 |
- License will therefore apply, along with any applicable section 7 |
|
243 |
- additional terms, to the whole of the work, and all its parts, |
|
244 |
- regardless of how they are packaged. This License gives no |
|
245 |
- permission to license the work in any other way, but it does not |
|
246 |
- invalidate such permission if you have separately received it. |
|
247 |
- |
|
248 |
- d) If the work has interactive user interfaces, each must display |
|
249 |
- Appropriate Legal Notices; however, if the Program has interactive |
|
250 |
- interfaces that do not display Appropriate Legal Notices, your |
|
251 |
- work need not make them do so. |
|
252 |
- |
|
253 |
- A compilation of a covered work with other separate and independent |
|
254 |
-works, which are not by their nature extensions of the covered work, |
|
255 |
-and which are not combined with it such as to form a larger program, |
|
256 |
-in or on a volume of a storage or distribution medium, is called an |
|
257 |
-"aggregate" if the compilation and its resulting copyright are not |
|
258 |
-used to limit the access or legal rights of the compilation's users |
|
259 |
-beyond what the individual works permit. Inclusion of a covered work |
|
260 |
-in an aggregate does not cause this License to apply to the other |
|
261 |
-parts of the aggregate. |
|
262 |
- |
|
263 |
- 6. Conveying Non-Source Forms. |
|
264 |
- |
|
265 |
- You may convey a covered work in object code form under the terms |
|
266 |
-of sections 4 and 5, provided that you also convey the |
|
267 |
-machine-readable Corresponding Source under the terms of this License, |
|
268 |
-in one of these ways: |
|
269 |
- |
|
270 |
- a) Convey the object code in, or embodied in, a physical product |
|
271 |
- (including a physical distribution medium), accompanied by the |
|
272 |
- Corresponding Source fixed on a durable physical medium |
|
273 |
- customarily used for software interchange. |
|
274 |
- |
|
275 |
- b) Convey the object code in, or embodied in, a physical product |
|
276 |
- (including a physical distribution medium), accompanied by a |
|
277 |
- written offer, valid for at least three years and valid for as |
|
278 |
- long as you offer spare parts or customer support for that product |
|
279 |
- model, to give anyone who possesses the object code either (1) a |
|
280 |
- copy of the Corresponding Source for all the software in the |
|
281 |
- product that is covered by this License, on a durable physical |
|
282 |
- medium customarily used for software interchange, for a price no |
|
283 |
- more than your reasonable cost of physically performing this |
|
284 |
- conveying of source, or (2) access to copy the |
|
285 |
- Corresponding Source from a network server at no charge. |
|
286 |
- |
|
287 |
- c) Convey individual copies of the object code with a copy of the |
|
288 |
- written offer to provide the Corresponding Source. This |
|
289 |
- alternative is allowed only occasionally and noncommercially, and |
|
290 |
- only if you received the object code with such an offer, in accord |
|
291 |
- with subsection 6b. |
|
292 |
- |
|
293 |
- d) Convey the object code by offering access from a designated |
|
294 |
- place (gratis or for a charge), and offer equivalent access to the |
|
295 |
- Corresponding Source in the same way through the same place at no |
|
296 |
- further charge. You need not require recipients to copy the |
|
297 |
- Corresponding Source along with the object code. If the place to |
|
298 |
- copy the object code is a network server, the Corresponding Source |
|
299 |
- may be on a different server (operated by you or a third party) |
|
300 |
- that supports equivalent copying facilities, provided you maintain |
|
301 |
- clear directions next to the object code saying where to find the |
|
302 |
- Corresponding Source. Regardless of what server hosts the |
|
303 |
- Corresponding Source, you remain obligated to ensure that it is |
|
304 |
- available for as long as needed to satisfy these requirements. |
|
305 |
- |
|
306 |
- e) Convey the object code using peer-to-peer transmission, provided |
|
307 |
- you inform other peers where the object code and Corresponding |
|
308 |
- Source of the work are being offered to the general public at no |
|
309 |
- charge under subsection 6d. |
|
310 |
- |
|
311 |
- A separable portion of the object code, whose source code is excluded |
|
312 |
-from the Corresponding Source as a System Library, need not be |
|
313 |
-included in conveying the object code work. |
|
314 |
- |
|
315 |
- A "User Product" is either (1) a "consumer product", which means any |
|
316 |
-tangible personal property which is normally used for personal, family, |
|
317 |
-or household purposes, or (2) anything designed or sold for incorporation |
|
318 |
-into a dwelling. In determining whether a product is a consumer product, |
|
319 |
-doubtful cases shall be resolved in favor of coverage. For a particular |
|
320 |
-product received by a particular user, "normally used" refers to a |
|
321 |
-typical or common use of that class of product, regardless of the status |
|
322 |
-of the particular user or of the way in which the particular user |
|
323 |
-actually uses, or expects or is expected to use, the product. A product |
|
324 |
-is a consumer product regardless of whether the product has substantial |
|
325 |
-commercial, industrial or non-consumer uses, unless such uses represent |
|
326 |
-the only significant mode of use of the product. |
|
327 |
- |
|
328 |
- "Installation Information" for a User Product means any methods, |
|
329 |
-procedures, authorization keys, or other information required to install |
|
330 |
-and execute modified versions of a covered work in that User Product from |
|
331 |
-a modified version of its Corresponding Source. The information must |
|
332 |
-suffice to ensure that the continued functioning of the modified object |
|
333 |
-code is in no case prevented or interfered with solely because |
|
334 |
-modification has been made. |
|
335 |
- |
|
336 |
- If you convey an object code work under this section in, or with, or |
|
337 |
-specifically for use in, a User Product, and the conveying occurs as |
|
338 |
-part of a transaction in which the right of possession and use of the |
|
339 |
-User Product is transferred to the recipient in perpetuity or for a |
|
340 |
-fixed term (regardless of how the transaction is characterized), the |
|
341 |
-Corresponding Source conveyed under this section must be accompanied |
|
342 |
-by the Installation Information. But this requirement does not apply |
|
343 |
-if neither you nor any third party retains the ability to install |
|
344 |
-modified object code on the User Product (for example, the work has |
|
345 |
-been installed in ROM). |
|
346 |
- |
|
347 |
- The requirement to provide Installation Information does not include a |
|
348 |
-requirement to continue to provide support service, warranty, or updates |
|
349 |
-for a work that has been modified or installed by the recipient, or for |
|
350 |
-the User Product in which it has been modified or installed. Access to a |
|
351 |
-network may be denied when the modification itself materially and |
|
352 |
-adversely affects the operation of the network or violates the rules and |
|
353 |
-protocols for communication across the network. |
|
354 |
- |
|
355 |
- Corresponding Source conveyed, and Installation Information provided, |
|
356 |
-in accord with this section must be in a format that is publicly |
|
357 |
-documented (and with an implementation available to the public in |
|
358 |
-source code form), and must require no special password or key for |
|
359 |
-unpacking, reading or copying. |
|
360 |
- |
|
361 |
- 7. Additional Terms. |
|
362 |
- |
|
363 |
- "Additional permissions" are terms that supplement the terms of this |
|
364 |
-License by making exceptions from one or more of its conditions. |
|
365 |
-Additional permissions that are applicable to the entire Program shall |
|
366 |
-be treated as though they were included in this License, to the extent |
|
367 |
-that they are valid under applicable law. If additional permissions |
|
368 |
-apply only to part of the Program, that part may be used separately |
|
369 |
-under those permissions, but the entire Program remains governed by |
|
370 |
-this License without regard to the additional permissions. |
|
371 |
- |
|
372 |
- When you convey a copy of a covered work, you may at your option |
|
373 |
-remove any additional permissions from that copy, or from any part of |
|
374 |
-it. (Additional permissions may be written to require their own |
|
375 |
-removal in certain cases when you modify the work.) You may place |
|
376 |
-additional permissions on material, added by you to a covered work, |
|
377 |
-for which you have or can give appropriate copyright permission. |
|
378 |
- |
|
379 |
- Notwithstanding any other provision of this License, for material you |
|
380 |
-add to a covered work, you may (if authorized by the copyright holders of |
|
381 |
-that material) supplement the terms of this License with terms: |
|
382 |
- |
|
383 |
- a) Disclaiming warranty or limiting liability differently from the |
|
384 |
- terms of sections 15 and 16 of this License; or |
|
385 |
- |
|
386 |
- b) Requiring preservation of specified reasonable legal notices or |
|
387 |
- author attributions in that material or in the Appropriate Legal |
|
388 |
- Notices displayed by works containing it; or |
|
389 |
- |
|
390 |
- c) Prohibiting misrepresentation of the origin of that material, or |
|
391 |
- requiring that modified versions of such material be marked in |
|
392 |
- reasonable ways as different from the original version; or |
|
393 |
- |
|
394 |
- d) Limiting the use for publicity purposes of names of licensors or |
|
395 |
- authors of the material; or |
|
396 |
- |
|
397 |
- e) Declining to grant rights under trademark law for use of some |
|
398 |
- trade names, trademarks, or service marks; or |
|
399 |
- |
|
400 |
- f) Requiring indemnification of licensors and authors of that |
|
401 |
- material by anyone who conveys the material (or modified versions of |
|
402 |
- it) with contractual assumptions of liability to the recipient, for |
|
403 |
- any liability that these contractual assumptions directly impose on |
|
404 |
- those licensors and authors. |
|
405 |
- |
|
406 |
- All other non-permissive additional terms are considered "further |
|
407 |
-restrictions" within the meaning of section 10. If the Program as you |
|
408 |
-received it, or any part of it, contains a notice stating that it is |
|
409 |
-governed by this License along with a term that is a further |
|
410 |
-restriction, you may remove that term. If a license document contains |
|
411 |
-a further restriction but permits relicensing or conveying under this |
|
412 |
-License, you may add to a covered work material governed by the terms |
|
413 |
-of that license document, provided that the further restriction does |
|
414 |
-not survive such relicensing or conveying. |
|
415 |
- |
|
416 |
- If you add terms to a covered work in accord with this section, you |
|
417 |
-must place, in the relevant source files, a statement of the |
|
418 |
-additional terms that apply to those files, or a notice indicating |
|
419 |
-where to find the applicable terms. |
|
420 |
- |
|
421 |
- Additional terms, permissive or non-permissive, may be stated in the |
|
422 |
-form of a separately written license, or stated as exceptions; |
|
423 |
-the above requirements apply either way. |
|
424 |
- |
|
425 |
- 8. Termination. |
|
426 |
- |
|
427 |
- You may not propagate or modify a covered work except as expressly |
|
428 |
-provided under this License. Any attempt otherwise to propagate or |
|
429 |
-modify it is void, and will automatically terminate your rights under |
|
430 |
-this License (including any patent licenses granted under the third |
|
431 |
-paragraph of section 11). |
|
432 |
- |
|
433 |
- However, if you cease all violation of this License, then your |
|
434 |
-license from a particular copyright holder is reinstated (a) |
|
435 |
-provisionally, unless and until the copyright holder explicitly and |
|
436 |
-finally terminates your license, and (b) permanently, if the copyright |
|
437 |
-holder fails to notify you of the violation by some reasonable means |
|
438 |
-prior to 60 days after the cessation. |
|
439 |
- |
|
440 |
- Moreover, your license from a particular copyright holder is |
|
441 |
-reinstated permanently if the copyright holder notifies you of the |
|
442 |
-violation by some reasonable means, this is the first time you have |
|
443 |
-received notice of violation of this License (for any work) from that |
|
444 |
-copyright holder, and you cure the violation prior to 30 days after |
|
445 |
-your receipt of the notice. |
|
446 |
- |
|
447 |
- Termination of your rights under this section does not terminate the |
|
448 |
-licenses of parties who have received copies or rights from you under |
|
449 |
-this License. If your rights have been terminated and not permanently |
|
450 |
-reinstated, you do not qualify to receive new licenses for the same |
|
451 |
-material under section 10. |
|
452 |
- |
|
453 |
- 9. Acceptance Not Required for Having Copies. |
|
454 |
- |
|
455 |
- You are not required to accept this License in order to receive or |
|
456 |
-run a copy of the Program. Ancillary propagation of a covered work |
|
457 |
-occurring solely as a consequence of using peer-to-peer transmission |
|
458 |
-to receive a copy likewise does not require acceptance. However, |
|
459 |
-nothing other than this License grants you permission to propagate or |
|
460 |
-modify any covered work. These actions infringe copyright if you do |
|
461 |
-not accept this License. Therefore, by modifying or propagating a |
|
462 |
-covered work, you indicate your acceptance of this License to do so. |
|
463 |
- |
|
464 |
- 10. Automatic Licensing of Downstream Recipients. |
|
465 |
- |
|
466 |
- Each time you convey a covered work, the recipient automatically |
|
467 |
-receives a license from the original licensors, to run, modify and |
|
468 |
-propagate that work, subject to this License. You are not responsible |
|
469 |
-for enforcing compliance by third parties with this License. |
|
470 |
- |
|
471 |
- An "entity transaction" is a transaction transferring control of an |
|
472 |
-organization, or substantially all assets of one, or subdividing an |
|
473 |
-organization, or merging organizations. If propagation of a covered |
|
474 |
-work results from an entity transaction, each party to that |
|
475 |
-transaction who receives a copy of the work also receives whatever |
|
476 |
-licenses to the work the party's predecessor in interest had or could |
|
477 |
-give under the previous paragraph, plus a right to possession of the |
|
478 |
-Corresponding Source of the work from the predecessor in interest, if |
|
479 |
-the predecessor has it or can get it with reasonable efforts. |
|
480 |
- |
|
481 |
- You may not impose any further restrictions on the exercise of the |
|
482 |
-rights granted or affirmed under this License. For example, you may |
|
483 |
-not impose a license fee, royalty, or other charge for exercise of |
|
484 |
-rights granted under this License, and you may not initiate litigation |
|
485 |
-(including a cross-claim or counterclaim in a lawsuit) alleging that |
|
486 |
-any patent claim is infringed by making, using, selling, offering for |
|
487 |
-sale, or importing the Program or any portion of it. |
|
488 |
- |
|
489 |
- 11. Patents. |
|
490 |
- |
|
491 |
- A "contributor" is a copyright holder who authorizes use under this |
|
492 |
-License of the Program or a work on which the Program is based. The |
|
493 |
-work thus licensed is called the contributor's "contributor version". |
|
494 |
- |
|
495 |
- A contributor's "essential patent claims" are all patent claims |
|
496 |
-owned or controlled by the contributor, whether already acquired or |
|
497 |
-hereafter acquired, that would be infringed by some manner, permitted |
|
498 |
-by this License, of making, using, or selling its contributor version, |
|
499 |
-but do not include claims that would be infringed only as a |
|
500 |
-consequence of further modification of the contributor version. For |
|
501 |
-purposes of this definition, "control" includes the right to grant |
|
502 |
-patent sublicenses in a manner consistent with the requirements of |
|
503 |
-this License. |
|
504 |
- |
|
505 |
- Each contributor grants you a non-exclusive, worldwide, royalty-free |
|
506 |
-patent license under the contributor's essential patent claims, to |
|
507 |
-make, use, sell, offer for sale, import and otherwise run, modify and |
|
508 |
-propagate the contents of its contributor version. |
|
509 |
- |
|
510 |
- In the following three paragraphs, a "patent license" is any express |
|
511 |
-agreement or commitment, however denominated, not to enforce a patent |
|
512 |
-(such as an express permission to practice a patent or covenant not to |
|
513 |
-sue for patent infringement). To "grant" such a patent license to a |
|
514 |
-party means to make such an agreement or commitment not to enforce a |
|
515 |
-patent against the party. |
|
516 |
- |
|
517 |
- If you convey a covered work, knowingly relying on a patent license, |
|
518 |
-and the Corresponding Source of the work is not available for anyone |
|
519 |
-to copy, free of charge and under the terms of this License, through a |
|
520 |
-publicly available network server or other readily accessible means, |
|
521 |
-then you must either (1) cause the Corresponding Source to be so |
|
522 |
-available, or (2) arrange to deprive yourself of the benefit of the |
|
523 |
-patent license for this particular work, or (3) arrange, in a manner |
|
524 |
-consistent with the requirements of this License, to extend the patent |
|
525 |
-license to downstream recipients. "Knowingly relying" means you have |
|
526 |
-actual knowledge that, but for the patent license, your conveying the |
|
527 |
-covered work in a country, or your recipient's use of the covered work |
|
528 |
-in a country, would infringe one or more identifiable patents in that |
|
529 |
-country that you have reason to believe are valid. |
|
530 |
- |
|
531 |
- If, pursuant to or in connection with a single transaction or |
|
532 |
-arrangement, you convey, or propagate by procuring conveyance of, a |
|
533 |
-covered work, and grant a patent license to some of the parties |
|
534 |
-receiving the covered work authorizing them to use, propagate, modify |
|
535 |
-or convey a specific copy of the covered work, then the patent license |
|
536 |
-you grant is automatically extended to all recipients of the covered |
|
537 |
-work and works based on it. |
|
538 |
- |
|
539 |
- A patent license is "discriminatory" if it does not include within |
|
540 |
-the scope of its coverage, prohibits the exercise of, or is |
|
541 |
-conditioned on the non-exercise of one or more of the rights that are |
|
542 |
-specifically granted under this License. You may not convey a covered |
|
543 |
-work if you are a party to an arrangement with a third party that is |
|
544 |
-in the business of distributing software, under which you make payment |
|
545 |
-to the third party based on the extent of your activity of conveying |
|
546 |
-the work, and under which the third party grants, to any of the |
|
547 |
-parties who would receive the covered work from you, a discriminatory |
|
548 |
-patent license (a) in connection with copies of the covered work |
|
549 |
-conveyed by you (or copies made from those copies), or (b) primarily |
|
550 |
-for and in connection with specific products or compilations that |
|
551 |
-contain the covered work, unless you entered into that arrangement, |
|
552 |
-or that patent license was granted, prior to 28 March 2007. |
|
553 |
- |
|
554 |
- Nothing in this License shall be construed as excluding or limiting |
|
555 |
-any implied license or other defenses to infringement that may |
|
556 |
-otherwise be available to you under applicable patent law. |
|
557 |
- |
|
558 |
- 12. No Surrender of Others' Freedom. |
|
559 |
- |
|
560 |
- If conditions are imposed on you (whether by court order, agreement or |
|
561 |
-otherwise) that contradict the conditions of this License, they do not |
|
562 |
-excuse you from the conditions of this License. If you cannot convey a |
|
563 |
-covered work so as to satisfy simultaneously your obligations under this |
|
564 |
-License and any other pertinent obligations, then as a consequence you may |
|
565 |
-not convey it at all. For example, if you agree to terms that obligate you |
|
566 |
-to collect a royalty for further conveying from those to whom you convey |
|
567 |
-the Program, the only way you could satisfy both those terms and this |
|
568 |
-License would be to refrain entirely from conveying the Program. |
|
569 |
- |
|
570 |
- 13. Use with the GNU Affero General Public License. |
|
571 |
- |
|
572 |
- Notwithstanding any other provision of this License, you have |
|
573 |
-permission to link or combine any covered work with a work licensed |
|
574 |
-under version 3 of the GNU Affero General Public License into a single |
|
575 |
-combined work, and to convey the resulting work. The terms of this |
|
576 |
-License will continue to apply to the part which is the covered work, |
|
577 |
-but the special requirements of the GNU Affero General Public License, |
|
578 |
-section 13, concerning interaction through a network will apply to the |
|
579 |
-combination as such. |
|
580 |
- |
|
581 |
- 14. Revised Versions of this License. |
|
582 |
- |
|
583 |
- The Free Software Foundation may publish revised and/or new versions of |
|
584 |
-the GNU General Public License from time to time. Such new versions will |
|
585 |
-be similar in spirit to the present version, but may differ in detail to |
|
586 |
-address new problems or concerns. |
|
587 |
- |
|
588 |
- Each version is given a distinguishing version number. If the |
|
589 |
-Program specifies that a certain numbered version of the GNU General |
|
590 |
-Public License "or any later version" applies to it, you have the |
|
591 |
-option of following the terms and conditions either of that numbered |
|
592 |
-version or of any later version published by the Free Software |
|
593 |
-Foundation. If the Program does not specify a version number of the |
|
594 |
-GNU General Public License, you may choose any version ever published |
|
595 |
-by the Free Software Foundation. |
|
596 |
- |
|
597 |
- If the Program specifies that a proxy can decide which future |
|
598 |
-versions of the GNU General Public License can be used, that proxy's |
|
599 |
-public statement of acceptance of a version permanently authorizes you |
|
600 |
-to choose that version for the Program. |
|
601 |
- |
|
602 |
- Later license versions may give you additional or different |
|
603 |
-permissions. However, no additional obligations are imposed on any |
|
604 |
-author or copyright holder as a result of your choosing to follow a |
|
605 |
-later version. |
|
606 |
- |
|
607 |
- 15. Disclaimer of Warranty. |
|
608 |
- |
|
609 |
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
|
610 |
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT |
|
611 |
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY |
|
612 |
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, |
|
613 |
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
614 |
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM |
|
615 |
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF |
|
616 |
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
|
617 |
- |
|
618 |
- 16. Limitation of Liability. |
|
619 |
- |
|
620 |
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
621 |
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS |
|
622 |
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
|
623 |
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE |
|
624 |
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF |
|
625 |
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
|
626 |
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), |
|
627 |
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
628 |
-SUCH DAMAGES. |
|
629 |
- |
|
630 |
- 17. Interpretation of Sections 15 and 16. |
|
631 |
- |
|
632 |
- If the disclaimer of warranty and limitation of liability provided |
|
633 |
-above cannot be given local legal effect according to their terms, |
|
634 |
-reviewing courts shall apply local law that most closely approximates |
|
635 |
-an absolute waiver of all civil liability in connection with the |
|
636 |
-Program, unless a warranty or assumption of liability accompanies a |
|
637 |
-copy of the Program in return for a fee. |
|
638 |
- |
|
639 |
- END OF TERMS AND CONDITIONS |
|
640 |
- |
|
641 |
- How to Apply These Terms to Your New Programs |
|
642 |
- |
|
643 |
- If you develop a new program, and you want it to be of the greatest |
|
644 |
-possible use to the public, the best way to achieve this is to make it |
|
645 |
-free software which everyone can redistribute and change under these terms. |
|
646 |
- |
|
647 |
- To do so, attach the following notices to the program. It is safest |
|
648 |
-to attach them to the start of each source file to most effectively |
|
649 |
-state the exclusion of warranty; and each file should have at least |
|
650 |
-the "copyright" line and a pointer to where the full notice is found. |
|
651 |
- |
|
652 |
- <one line to give the program's name and a brief idea of what it does.> |
|
653 |
- Copyright (C) <year> <name of author> |
|
654 |
- |
|
655 |
- This program is free software: you can redistribute it and/or modify |
|
656 |
- it under the terms of the GNU General Public License as published by |
|
657 |
- the Free Software Foundation, either version 3 of the License, or |
|
658 |
- (at your option) any later version. |
|
659 |
- |
|
660 |
- This program is distributed in the hope that it will be useful, |
|
661 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
662 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
663 |
- GNU General Public License for more details. |
|
664 |
- |
|
665 |
- You should have received a copy of the GNU General Public License |
|
666 |
- along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
667 |
- |
|
668 |
-Also add information on how to contact you by electronic and paper mail. |
|
669 |
- |
|
670 |
- If the program does terminal interaction, make it output a short |
|
671 |
-notice like this when it starts in an interactive mode: |
|
672 |
- |
|
673 |
- <program> Copyright (C) <year> <name of author> |
|
674 |
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
|
675 |
- This is free software, and you are welcome to redistribute it |
|
676 |
- under certain conditions; type `show c' for details. |
|
677 |
- |
|
678 |
-The hypothetical commands `show w' and `show c' should show the appropriate |
|
679 |
-parts of the General Public License. Of course, your program's commands |
|
680 |
-might be different; for a GUI interface, you would use an "about box". |
|
681 |
- |
|
682 |
- You should also get your employer (if you work as a programmer) or school, |
|
683 |
-if any, to sign a "copyright disclaimer" for the program, if necessary. |
|
684 |
-For more information on this, and how to apply and follow the GNU GPL, see |
|
685 |
-<https://www.gnu.org/licenses/>. |
|
686 |
- |
|
687 |
- The GNU General Public License does not permit incorporating your program |
|
688 |
-into proprietary programs. If your program is a subroutine library, you |
|
689 |
-may consider it more useful to permit linking proprietary applications with |
|
690 |
-the library. If this is what you want to do, use the GNU Lesser General |
|
691 |
-Public License instead of this License. But first, please read |
|
692 |
-<https://www.gnu.org/licenses/why-not-lgpl.html>. |
|
693 |
- |
|
694 |
- |
|
695 |
- |
|
696 |
- GNU LESSER GENERAL PUBLIC LICENSE |
|
697 |
- Version 3, 29 June 2007 |
|
698 |
- |
|
699 |
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> |
|
700 |
- Everyone is permitted to copy and distribute verbatim copies |
|
701 |
- of this license document, but changing it is not allowed. |
|
702 |
- |
|
703 |
- |
|
704 |
- This version of the GNU Lesser General Public License incorporates |
|
705 |
-the terms and conditions of version 3 of the GNU General Public |
|
706 |
-License, supplemented by the additional permissions listed below. |
|
707 |
- |
|
708 |
- 0. Additional Definitions. |
|
709 |
- |
|
710 |
- As used herein, "this License" refers to version 3 of the GNU Lesser |
|
711 |
-General Public License, and the "GNU GPL" refers to version 3 of the GNU |
|
712 |
-General Public License. |
|
713 |
- |
|
714 |
- "The Library" refers to a covered work governed by this License, |
|
715 |
-other than an Application or a Combined Work as defined below. |
|
716 |
- |
|
717 |
- An "Application" is any work that makes use of an interface provided |
|
718 |
-by the Library, but which is not otherwise based on the Library. |
|
719 |
-Defining a subclass of a class defined by the Library is deemed a mode |
|
720 |
-of using an interface provided by the Library. |
|
721 |
- |
|
722 |
- A "Combined Work" is a work produced by combining or linking an |
|
723 |
-Application with the Library. The particular version of the Library |
|
724 |
-with which the Combined Work was made is also called the "Linked |
|
725 |
-Version". |
|
726 |
- |
|
727 |
- The "Minimal Corresponding Source" for a Combined Work means the |
|
728 |
-Corresponding Source for the Combined Work, excluding any source code |
|
729 |
-for portions of the Combined Work that, considered in isolation, are |
|
730 |
-based on the Application, and not on the Linked Version. |
|
731 |
- |
|
732 |
- The "Corresponding Application Code" for a Combined Work means the |
|
733 |
-object code and/or source code for the Application, including any data |
|
734 |
-and utility programs needed for reproducing the Combined Work from the |
|
735 |
-Application, but excluding the System Libraries of the Combined Work. |
|
736 |
- |
|
737 |
- 1. Exception to Section 3 of the GNU GPL. |
|
738 |
- |
|
739 |
- You may convey a covered work under sections 3 and 4 of this License |
|
740 |
-without being bound by section 3 of the GNU GPL. |
|
741 |
- |
|
742 |
- 2. Conveying Modified Versions. |
|
743 |
- |
|
744 |
- If you modify a copy of the Library, and, in your modifications, a |
|
745 |
-facility refers to a function or data to be supplied by an Application |
|
746 |
-that uses the facility (other than as an argument passed when the |
|
747 |
-facility is invoked), then you may convey a copy of the modified |
|
748 |
-version: |
|
749 |
- |
|
750 |
- a) under this License, provided that you make a good faith effort to |
|
751 |
- ensure that, in the event an Application does not supply the |
|
752 |
- function or data, the facility still operates, and performs |
|
753 |
- whatever part of its purpose remains meaningful, or |
|
754 |
- |
|
755 |
- b) under the GNU GPL, with none of the additional permissions of |
|
756 |
- this License applicable to that copy. |
|
757 |
- |
|
758 |
- 3. Object Code Incorporating Material from Library Header Files. |
|
759 |
- |
|
760 |
- The object code form of an Application may incorporate material from |
|
761 |
-a header file that is part of the Library. You may convey such object |
|
762 |
-code under terms of your choice, provided that, if the incorporated |
|
763 |
-material is not limited to numerical parameters, data structure |
|
764 |
-layouts and accessors, or small macros, inline functions and templates |
|
765 |
-(ten or fewer lines in length), you do both of the following: |
|
766 |
- |
|
767 |
- a) Give prominent notice with each copy of the object code that the |
|
768 |
- Library is used in it and that the Library and its use are |
|
769 |
- covered by this License. |
|
770 |
- |
|
771 |
- b) Accompany the object code with a copy of the GNU GPL and this license |
|
772 |
- document. |
|
773 |
- |
|
774 |
- 4. Combined Works. |
|
775 |
- |
|
776 |
- You may convey a Combined Work under terms of your choice that, |
|
777 |
-taken together, effectively do not restrict modification of the |
|
778 |
-portions of the Library contained in the Combined Work and reverse |
|
779 |
-engineering for debugging such modifications, if you also do each of |
|
780 |
-the following: |
|
781 |
- |
|
782 |
- a) Give prominent notice with each copy of the Combined Work that |
|
783 |
- the Library is used in it and that the Library and its use are |
|
784 |
- covered by this License. |
|
785 |
- |
|
786 |
- b) Accompany the Combined Work with a copy of the GNU GPL and this license |
|
787 |
- document. |
|
788 |
- |
|
789 |
- c) For a Combined Work that displays copyright notices during |
|
790 |
- execution, include the copyright notice for the Library among |
|
791 |
- these notices, as well as a reference directing the user to the |
|
792 |
- copies of the GNU GPL and this license document. |
|
793 |
- |
|
794 |
- d) Do one of the following: |
|
795 |
- |
|
796 |
- 0) Convey the Minimal Corresponding Source under the terms of this |
|
797 |
- License, and the Corresponding Application Code in a form |
|
798 |
- suitable for, and under terms that permit, the user to |
|
799 |
- recombine or relink the Application with a modified version of |
|
800 |
- the Linked Version to produce a modified Combined Work, in the |
|
801 |
- manner specified by section 6 of the GNU GPL for conveying |
|
802 |
- Corresponding Source. |
|
803 |
- |
|
804 |
- 1) Use a suitable shared library mechanism for linking with the |
|
805 |
- Library. A suitable mechanism is one that (a) uses at run time |
|
806 |
- a copy of the Library already present on the user's computer |
|
807 |
- system, and (b) will operate properly with a modified version |
|
808 |
- of the Library that is interface-compatible with the Linked |
|
809 |
- Version. |
|
810 |
- |
|
811 |
- e) Provide Installation Information, but only if you would otherwise |
|
812 |
- be required to provide such information under section 6 of the |
|
813 |
- GNU GPL, and only to the extent that such information is |
|
814 |
- necessary to install and execute a modified version of the |
|
815 |
- Combined Work produced by recombining or relinking the |
|
816 |
- Application with a modified version of the Linked Version. (If |
|
817 |
- you use option 4d0, the Installation Information must accompany |
|
818 |
- the Minimal Corresponding Source and Corresponding Application |
|
819 |
- Code. If you use option 4d1, you must provide the Installation |
|
820 |
- Information in the manner specified by section 6 of the GNU GPL |
|
821 |
- for conveying Corresponding Source.) |
|
822 |
- |
|
823 |
- 5. Combined Libraries. |
|
824 |
- |
|
825 |
- You may place library facilities that are a work based on the |
|
826 |
-Library side by side in a single library together with other library |
|
827 |
-facilities that are not Applications and are not covered by this |
|
828 |
-License, and convey such a combined library under terms of your |
|
829 |
-choice, if you do both of the following: |
|
830 |
- |
|
831 |
- a) Accompany the combined library with a copy of the same work based |
|
832 |
- on the Library, uncombined with any other library facilities, |
|
833 |
- conveyed under the terms of this License. |
|
834 |
- |
|
835 |
- b) Give prominent notice with the combined library that part of it |
|
836 |
- is a work based on the Library, and explaining where to find the |
|
837 |
- accompanying uncombined form of the same work. |
|
838 |
- |
|
839 |
- 6. Revised Versions of the GNU Lesser General Public License. |
|
840 |
- |
|
841 |
- The Free Software Foundation may publish revised and/or new versions |
|
842 |
-of the GNU Lesser General Public License from time to time. Such new |
|
843 |
-versions will be similar in spirit to the present version, but may |
|
844 |
-differ in detail to address new problems or concerns. |
|
845 |
- |
|
846 |
- Each version is given a distinguishing version number. If the |
|
847 |
-Library as you received it specifies that a certain numbered version |
|
848 |
-of the GNU Lesser General Public License "or any later version" |
|
849 |
-applies to it, you have the option of following the terms and |
|
850 |
-conditions either of that published version or of any later version |
|
851 |
-published by the Free Software Foundation. If the Library as you |
|
852 |
-received it does not specify a version number of the GNU Lesser |
|
853 |
-General Public License, you may choose any version of the GNU Lesser |
|
854 |
-General Public License ever published by the Free Software Foundation. |
|
855 |
- |
|
856 |
- If the Library as you received it specifies that a proxy can decide |
|
857 |
-whether future versions of the GNU Lesser General Public License shall |
|
858 |
-apply, that proxy's public statement of acceptance of any version is |
|
859 |
-permanent authorization for you to choose that version for the |
|
860 |
-Library. |
|
861 |
- |
... | ... |
@@ -1,122 +0,0 @@ |
1 |
-declare module lib_object { |
|
2 |
- /** |
|
3 |
- * @author fenris |
|
4 |
- */ |
|
5 |
- function fetch<type_value>(object: Object, fieldname: string, fallback?: type_value, escalation?: int): type_value; |
|
6 |
- /** |
|
7 |
- * @author fenris |
|
8 |
- */ |
|
9 |
- function map<type_from, type_to>(object_from: { |
|
10 |
- [key: string]: type_from; |
|
11 |
- }, transformator: (value_from: type_from, key?: string) => type_to): { |
|
12 |
- [key: string]: type_to; |
|
13 |
- }; |
|
14 |
- /** |
|
15 |
- * @desc gibt ein Objekt mit bestimmten Einträgen des Eingabe-Objekts zurück |
|
16 |
- * @author fenris |
|
17 |
- */ |
|
18 |
- function filter<type_value>(object_from: { |
|
19 |
- [key: string]: type_value; |
|
20 |
- }, predicate: (value_from: type_value, key?: string) => boolean): { |
|
21 |
- [key: string]: type_value; |
|
22 |
- }; |
|
23 |
- /** |
|
24 |
- * @desc wandelt ein Array mit Einträgen der Form {key,value} in ein entsprechendes Objekt um |
|
25 |
- * @author fenris |
|
26 |
- */ |
|
27 |
- function from_array<type_value>(array: Array<{ |
|
28 |
- key: string; |
|
29 |
- value: type_value; |
|
30 |
- }>): { |
|
31 |
- [key: string]: type_value; |
|
32 |
- }; |
|
33 |
- /** |
|
34 |
- * @desc wandelt ein Objekt in ein entsprechendes Array mit Einträgen der Form {key,value} um |
|
35 |
- * @author fenris |
|
36 |
- */ |
|
37 |
- function to_array<type_value>(object: { |
|
38 |
- [key: string]: type_value; |
|
39 |
- }): Array<{ |
|
40 |
- key: string; |
|
41 |
- value: type_value; |
|
42 |
- }>; |
|
43 |
- /** |
|
44 |
- * @desc gibt eine Liste von Schlüsseln eines Objekts zurück |
|
45 |
- * @author fenris |
|
46 |
- */ |
|
47 |
- function keys(object: { |
|
48 |
- [key: string]: any; |
|
49 |
- }): Array<string>; |
|
50 |
- /** |
|
51 |
- * @desc gibt eine Liste von Werten eines Objekts zurück |
|
52 |
- * @author fenris |
|
53 |
- */ |
|
54 |
- function values<type_value>(object: { |
|
55 |
- [key: string]: type_value; |
|
56 |
- }): Array<type_value>; |
|
57 |
- /** |
|
58 |
- * @desc liest ein Baum-artiges Objekt an einer bestimmten Stelle aus |
|
59 |
- * @author fenris |
|
60 |
- */ |
|
61 |
- function path_read<type_value>(object: Object, path: string, fallback?: type_value, escalation?: int): type_value; |
|
62 |
- /** |
|
63 |
- * @desc schreibt einen Wert an eine bestimmte Stelle in einem Baum-artigen Objekt |
|
64 |
- * @author fenris |
|
65 |
- */ |
|
66 |
- function path_write<type_value>(object: Object, path: string, value: type_value, construct?: boolean): void; |
|
67 |
- /** |
|
68 |
- * @desc prüft ob ein Objekt einem bestimmten Muster entspricht |
|
69 |
- * @param {Object} object das zu prüfende Objekt |
|
70 |
- * @param {Object} pattern das einzuhaltende Muster |
|
71 |
- * @param {Function} connlate eine Funktion zum Feststellen der Gleichheit von Einzelwerten |
|
72 |
- * @author fenris |
|
73 |
- */ |
|
74 |
- function matches(object: Object, pattern: Object, collate?: typeof instance_collate): boolean; |
|
75 |
- /** |
|
76 |
- * @desc erzeugt eine Projektion eines Baum-artigen Objekts in ein Listen-artiges Objekt |
|
77 |
- * @param {string} [separator] welches Zeichen als Trenner zwischen zwei Pfad-Schritten verwendet werden soll |
|
78 |
- * @author fenris |
|
79 |
- */ |
|
80 |
- function flatten(value: any, separator?: string, key_for_element?: (index: int) => string): Object; |
|
81 |
- /** |
|
82 |
- * @author fenris |
|
83 |
- */ |
|
84 |
- function clash(x: { |
|
85 |
- [key: string]: any; |
|
86 |
- }, y: { |
|
87 |
- [key: string]: any; |
|
88 |
- }, { "overwrite": overwrite, "hooks": { "existing": hook_existing, }, }?: { |
|
89 |
- overwrite?: boolean; |
|
90 |
- hooks?: { |
|
91 |
- existing?: (key?: string, value_old?: any, value_new?: any) => void; |
|
92 |
- }; |
|
93 |
- }): { |
|
94 |
- [key: string]: any; |
|
95 |
- }; |
|
96 |
- /** |
|
97 |
- * @author fenris |
|
98 |
- */ |
|
99 |
- function patch(core: Object, mantle: Object, deep?: boolean, path?: string): void; |
|
100 |
- /** |
|
101 |
- * @author fenris |
|
102 |
- */ |
|
103 |
- function patched(core: Object, mantle: Object, deep?: boolean): Object; |
|
104 |
- /** |
|
105 |
- * @author fenris |
|
106 |
- */ |
|
107 |
- function attached(object: Object, key: string, value: any): Object; |
|
108 |
- /** |
|
109 |
- * @author fenris |
|
110 |
- */ |
|
111 |
- function copy(object: Object): Object; |
|
112 |
-} |
|
113 |
-/** |
|
114 |
- * @desc adapters for old syntax |
|
115 |
- * @author fenris |
|
116 |
- */ |
|
117 |
-declare var object_fetch: typeof lib_object.fetch; |
|
118 |
-declare var object_map: typeof lib_object.map; |
|
119 |
-declare var object_a2o: typeof lib_object.from_array; |
|
120 |
-declare var object_o2a: typeof lib_object.to_array; |
|
121 |
-declare var object_matches: typeof lib_object.matches; |
|
122 |
-declare var object_clash: typeof lib_object.clash; |
... | ... |
@@ -1,376 +0,0 @@ |
1 |
-/* |
|
2 |
-This file is part of »bacterio-plankton:object«. |
|
3 |
- |
|
4 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
5 |
-<info@greenscale.de> |
|
6 |
- |
|
7 |
-»bacterio-plankton:object« is free software: you can redistribute it and/or modify |
|
8 |
-it under the terms of the GNU Lesser General Public License as published by |
|
9 |
-the Free Software Foundation, either version 3 of the License, or |
|
10 |
-(at your option) any later version. |
|
11 |
- |
|
12 |
-»bacterio-plankton:object« is distributed in the hope that it will be useful, |
|
13 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
-GNU Lesser General Public License for more details. |
|
16 |
- |
|
17 |
-You should have received a copy of the GNU Lesser General Public License |
|
18 |
-along with »bacterio-plankton:object«. If not, see <http://www.gnu.org/licenses/>. |
|
19 |
- */ |
|
20 |
-var lib_object; |
|
21 |
-(function (lib_object) { |
|
22 |
- /** |
|
23 |
- * @author fenris |
|
24 |
- */ |
|
25 |
- function fetch(object, fieldname, fallback, escalation) { |
|
26 |
- if (fallback === void 0) { fallback = null; } |
|
27 |
- if (escalation === void 0) { escalation = 1; } |
|
28 |
- if ((fieldname in object) && (object[fieldname] !== undefined)) { |
|
29 |
- return object[fieldname]; |
|
30 |
- } |
|
31 |
- else { |
|
32 |
- switch (escalation) { |
|
33 |
- case 0: { |
|
34 |
- return fallback; |
|
35 |
- break; |
|
36 |
- } |
|
37 |
- case 1: { |
|
38 |
- var message = ("field '" + fieldname + "' not in structure"); |
|
39 |
- message += ("; using fallback value '" + String(fallback) + "'"); |
|
40 |
- // console.warn(message); |
|
41 |
- return fallback; |
|
42 |
- break; |
|
43 |
- } |
|
44 |
- case 2: { |
|
45 |
- var message = ("field '" + fieldname + "' not in structure"); |
|
46 |
- throw (new Error(message)); |
|
47 |
- break; |
|
48 |
- } |
|
49 |
- default: { |
|
50 |
- throw (new Error("invalid escalation level " + escalation)); |
|
51 |
- break; |
|
52 |
- } |
|
53 |
- } |
|
54 |
- } |
|
55 |
- } |
|
56 |
- lib_object.fetch = fetch; |
|
57 |
- /** |
|
58 |
- * @author fenris |
|
59 |
- */ |
|
60 |
- function map(object_from, transformator) { |
|
61 |
- var object_to = {}; |
|
62 |
- Object.keys(object_from).forEach(function (key) { return (object_to[key] = transformator(object_from[key], key)); }); |
|
63 |
- return object_to; |
|
64 |
- } |
|
65 |
- lib_object.map = map; |
|
66 |
- /** |
|
67 |
- * @desc gibt ein Objekt mit bestimmten Einträgen des Eingabe-Objekts zurück |
|
68 |
- * @author fenris |
|
69 |
- */ |
|
70 |
- function filter(object_from, predicate) { |
|
71 |
- var object_to = {}; |
|
72 |
- Object.keys(object_from).forEach(function (key) { |
|
73 |
- var value = object_from[key]; |
|
74 |
- if (predicate(value, key)) { |
|
75 |
- object_to[key] = value; |
|
76 |
- } |
|
77 |
- }); |
|
78 |
- return object_to; |
|
79 |
- } |
|
80 |
- lib_object.filter = filter; |
|
81 |
- /** |
|
82 |
- * @desc wandelt ein Array mit Einträgen der Form {key,value} in ein entsprechendes Objekt um |
|
83 |
- * @author fenris |
|
84 |
- */ |
|
85 |
- function from_array(array) { |
|
86 |
- var object = {}; |
|
87 |
- array.forEach(function (entry) { return (object[entry.key] = entry.value); }); |
|
88 |
- return object; |
|
89 |
- } |
|
90 |
- lib_object.from_array = from_array; |
|
91 |
- /** |
|
92 |
- * @desc wandelt ein Objekt in ein entsprechendes Array mit Einträgen der Form {key,value} um |
|
93 |
- * @author fenris |
|
94 |
- */ |
|
95 |
- function to_array(object) { |
|
96 |
- var array = []; |
|
97 |
- Object.keys(object).forEach(function (key) { return array.push({ "key": key, "value": object[key] }); }); |
|
98 |
- return array; |
|
99 |
- } |
|
100 |
- lib_object.to_array = to_array; |
|
101 |
- /** |
|
102 |
- * @desc gibt eine Liste von Schlüsseln eines Objekts zurück |
|
103 |
- * @author fenris |
|
104 |
- */ |
|
105 |
- function keys(object) { |
|
106 |
- return Object.keys(object); |
|
107 |
- } |
|
108 |
- lib_object.keys = keys; |
|
109 |
- /** |
|
110 |
- * @desc gibt eine Liste von Werten eines Objekts zurück |
|
111 |
- * @author fenris |
|
112 |
- */ |
|
113 |
- function values(object) { |
|
114 |
- return to_array(object).map(function (entry) { return entry.value; }); |
|
115 |
- } |
|
116 |
- lib_object.values = values; |
|
117 |
- /** |
|
118 |
- * @desc liest ein Baum-artiges Objekt an einer bestimmten Stelle aus |
|
119 |
- * @author fenris |
|
120 |
- */ |
|
121 |
- function path_read(object, path, fallback, escalation) { |
|
122 |
- if (fallback === void 0) { fallback = null; } |
|
123 |
- if (escalation === void 0) { escalation = 1; } |
|
124 |
- var steps = ((path.length == 0) ? [] : path.split(".")); |
|
125 |
- if (steps.length == 0) { |
|
126 |
- throw (new Error("empty path")); |
|
127 |
- } |
|
128 |
- else { |
|
129 |
- var position_1 = object; |
|
130 |
- var reachable = (position_1 != null) && steps.slice(0, steps.length - 1).every(function (step) { |
|
131 |
- position_1 = object_fetch(position_1, step, null, 0); |
|
132 |
- return (position_1 != null); |
|
133 |
- }); |
|
134 |
- if (reachable) { |
|
135 |
- return object_fetch(position_1, steps[steps.length - 1], fallback, escalation); |
|
136 |
- } |
|
137 |
- else { |
|
138 |
- return object_fetch({}, "_dummy_", fallback, escalation); |
|
139 |
- } |
|
140 |
- } |
|
141 |
- } |
|
142 |
- lib_object.path_read = path_read; |
|
143 |
- /** |
|
144 |
- * @desc schreibt einen Wert an eine bestimmte Stelle in einem Baum-artigen Objekt |
|
145 |
- * @author fenris |
|
146 |
- */ |
|
147 |
- function path_write(object, path, value, construct) { |
|
148 |
- if (construct === void 0) { construct = true; } |
|
149 |
- var steps = ((path.length == 0) ? [] : path.split(".")); |
|
150 |
- if (steps.length == 0) { |
|
151 |
- throw (new Error("empty path")); |
|
152 |
- } |
|
153 |
- else { |
|
154 |
- var position_2 = object; |
|
155 |
- var reachable = steps.slice(0, steps.length - 1).every(function (step) { |
|
156 |
- var position_ = object_fetch(position_2, step, null, 0); |
|
157 |
- if (position_ == null) { |
|
158 |
- if (construct) { |
|
159 |
- position_2[step] = {}; |
|
160 |
- position_2 = position_2[step]; |
|
161 |
- return true; |
|
162 |
- } |
|
163 |
- else { |
|
164 |
- return false; |
|
165 |
- } |
|
166 |
- } |
|
167 |
- else { |
|
168 |
- position_2 = position_; |
|
169 |
- return true; |
|
170 |
- } |
|
171 |
- }); |
|
172 |
- if (reachable) { |
|
173 |
- position_2[steps[steps.length - 1]] = value; |
|
174 |
- } |
|
175 |
- else { |
|
176 |
- var message = ("path '" + path + "' does not exist and may not be constructed"); |
|
177 |
- throw (new Error(message)); |
|
178 |
- } |
|
179 |
- } |
|
180 |
- } |
|
181 |
- lib_object.path_write = path_write; |
|
182 |
- /** |
|
183 |
- * @desc prüft ob ein Objekt einem bestimmten Muster entspricht |
|
184 |
- * @param {Object} object das zu prüfende Objekt |
|
185 |
- * @param {Object} pattern das einzuhaltende Muster |
|
186 |
- * @param {Function} connlate eine Funktion zum Feststellen der Gleichheit von Einzelwerten |
|
187 |
- * @author fenris |
|
188 |
- */ |
|
189 |
- function matches(object, pattern, collate) { |
|
190 |
- if (collate === void 0) { collate = instance_collate; } |
|
191 |
- return Object.keys(pattern).every(function (key) { return collate(pattern[key], object[key]); }); |
|
192 |
- } |
|
193 |
- lib_object.matches = matches; |
|
194 |
- /** |
|
195 |
- * @desc erzeugt eine Projektion eines Baum-artigen Objekts in ein Listen-artiges Objekt |
|
196 |
- * @param {string} [separator] welches Zeichen als Trenner zwischen zwei Pfad-Schritten verwendet werden soll |
|
197 |
- * @author fenris |
|
198 |
- */ |
|
199 |
- function flatten(value, separator, key_for_element) { |
|
200 |
- if (separator === void 0) { separator = "."; } |
|
201 |
- if (key_for_element === void 0) { key_for_element = (function (index) { return ("element_" + index.toFixed(0)); }); } |
|
202 |
- var integrate = function (result, key_, value_) { |
|
203 |
- if (value_ == null) { |
|
204 |
- result[key_] = value_; |
|
205 |
- } |
|
206 |
- else { |
|
207 |
- // primitive Werte direkt übernehmen |
|
208 |
- if (typeof (value_) != "object") { |
|
209 |
- result[key_] = value_; |
|
210 |
- } |
|
211 |
- // sonst durch rekursiven Aufruf die flache Variante des Wertes ermitteln und einarbeiten |
|
212 |
- else { |
|
213 |
- var result_1 = flatten(value_); |
|
214 |
- Object.keys(result_1) |
|
215 |
- .forEach(function (key__) { |
|
216 |
- var value__ = result_1[key__]; |
|
217 |
- var key_new = (key_ + separator + key__); |
|
218 |
- result[key_new] = value__; |
|
219 |
- }); |
|
220 |
- } |
|
221 |
- } |
|
222 |
- }; |
|
223 |
- if ((value === null) || (value === undefined)) { |
|
224 |
- return null; |
|
225 |
- } |
|
226 |
- else { |
|
227 |
- var result_2 = {}; |
|
228 |
- if (typeof (value) != "object") { |
|
229 |
- result_2["value"] = value; |
|
230 |
- } |
|
231 |
- else { |
|
232 |
- if (value instanceof Array) { |
|
233 |
- var array = (value); |
|
234 |
- array |
|
235 |
- .forEach(function (element, index) { |
|
236 |
- integrate(result_2, key_for_element(index), element); |
|
237 |
- }); |
|
238 |
- } |
|
239 |
- else { |
|
240 |
- var object_1 = (value); |
|
241 |
- Object.keys(object_1) |
|
242 |
- .forEach(function (key) { |
|
243 |
- integrate(result_2, key, object_1[key]); |
|
244 |
- }); |
|
245 |
- } |
|
246 |
- } |
|
247 |
- return result_2; |
|
248 |
- } |
|
249 |
- } |
|
250 |
- lib_object.flatten = flatten; |
|
251 |
- /** |
|
252 |
- * @author fenris |
|
253 |
- */ |
|
254 |
- function clash(x, y, _a) { |
|
255 |
- var _b = _a === void 0 ? {} : _a, _c = _b["overwrite"], overwrite = _c === void 0 ? true : _c, _d = _b["hooks"], _e = (_d === void 0 ? {} : _d)["existing"], hook_existing = _e === void 0 ? null : _e; |
|
256 |
- if (hook_existing == null) { |
|
257 |
- (function (key, value_old, value_new) { return console.warn("field " + key + " already defined"); }); |
|
258 |
- } |
|
259 |
- var z = {}; |
|
260 |
- Object.keys(x).forEach(function (key) { |
|
261 |
- z[key] = x[key]; |
|
262 |
- }); |
|
263 |
- Object.keys(y).forEach(function (key) { |
|
264 |
- if (key in z) { |
|
265 |
- if (hook_existing != null) { |
|
266 |
- hook_existing(key, z[key], y[key]); |
|
267 |
- } |
|
268 |
- if (overwrite) { |
|
269 |
- z[key] = y[key]; |
|
270 |
- } |
|
271 |
- } |
|
272 |
- else { |
|
273 |
- z[key] = y[key]; |
|
274 |
- } |
|
275 |
- }); |
|
276 |
- return z; |
|
277 |
- } |
|
278 |
- lib_object.clash = clash; |
|
279 |
- /** |
|
280 |
- * @author fenris |
|
281 |
- */ |
|
282 |
- function patch(core, mantle, deep, path) { |
|
283 |
- if (deep === void 0) { deep = true; } |
|
284 |
- if (path === void 0) { path = null; } |
|
285 |
- if (mantle == null) { |
|
286 |
- console.warn("mantle is null; core was", core); |
|
287 |
- } |
|
288 |
- else { |
|
289 |
- Object.keys(mantle).forEach(function (key) { |
|
290 |
- var path_ = ((path == null) ? key : path + "." + key); |
|
291 |
- var value_mantle = mantle[key]; |
|
292 |
- if (!(key in core)) { |
|
293 |
- if ((typeof (value_mantle) == "object") && (value_mantle != null) && deep) { |
|
294 |
- if (value_mantle instanceof Array) { |
|
295 |
- core[key] = []; |
|
296 |
- value_mantle.forEach(function (element) { |
|
297 |
- if ((typeof (element) == "object") && (element != null)) { |
|
298 |
- var element_ = {}; |
|
299 |
- patch(element_, element); |
|
300 |
- core[key].push(element_); |
|
301 |
- } |
|
302 |
- else { |
|
303 |
- core[key].push(element); |
|
304 |
- } |
|
305 |
- }); |
|
306 |
- } |
|
307 |
- else { |
|
308 |
- core[key] = {}; |
|
309 |
- patch(core[key], value_mantle, deep, path_); |
|
310 |
- } |
|
311 |
- } |
|
312 |
- else { |
|
313 |
- core[key] = value_mantle; |
|
314 |
- } |
|
315 |
- } |
|
316 |
- else { |
|
317 |
- var value_core = core[key]; |
|
318 |
- if (typeof (value_core) == typeof (value_mantle)) { |
|
319 |
- if ((typeof (value_mantle) == "object") && (value_mantle != null) && deep) { |
|
320 |
- patch(core[key], value_mantle, deep, path_); |
|
321 |
- } |
|
322 |
- else { |
|
323 |
- core[key] = value_mantle; |
|
324 |
- } |
|
325 |
- } |
|
326 |
- else { |
|
327 |
- if ((value_core != null) && (value_mantle != null)) { |
|
328 |
- var message = "objects have different shapes at path '" + path_ + "'; core has type '" + typeof (value_core) + "' and mantle has type '" + typeof (value_mantle) + "'"; |
|
329 |
- console.warn(message); |
|
330 |
- } |
|
331 |
- core[key] = value_mantle; |
|
332 |
- // throw (new Error(message)); |
|
333 |
- } |
|
334 |
- } |
|
335 |
- }); |
|
336 |
- } |
|
337 |
- } |
|
338 |
- lib_object.patch = patch; |
|
339 |
- /** |
|
340 |
- * @author fenris |
|
341 |
- */ |
|
342 |
- function patched(core, mantle, deep) { |
|
343 |
- if (deep === void 0) { deep = undefined; } |
|
344 |
- var result = {}; |
|
345 |
- patch(result, core, deep); |
|
346 |
- patch(result, mantle, deep); |
|
347 |
- return result; |
|
348 |
- } |
|
349 |
- lib_object.patched = patched; |
|
350 |
- /** |
|
351 |
- * @author fenris |
|
352 |
- */ |
|
353 |
- function attached(object, key, value) { |
|
354 |
- var mantle = {}; |
|
355 |
- mantle[key] = value; |
|
356 |
- return patched(object, mantle, false); |
|
357 |
- } |
|
358 |
- lib_object.attached = attached; |
|
359 |
- /** |
|
360 |
- * @author fenris |
|
361 |
- */ |
|
362 |
- function copy(object) { |
|
363 |
- return patched({}, object); |
|
364 |
- } |
|
365 |
- lib_object.copy = copy; |
|
366 |
-})(lib_object || (lib_object = {})); |
|
367 |
-/** |
|
368 |
- * @desc adapters for old syntax |
|
369 |
- * @author fenris |
|
370 |
- */ |
|
371 |
-var object_fetch = lib_object.fetch; |
|
372 |
-var object_map = lib_object.map; |
|
373 |
-var object_a2o = lib_object.from_array; |
|
374 |
-var object_o2a = lib_object.to_array; |
|
375 |
-var object_matches = lib_object.matches; |
|
376 |
-var object_clash = lib_object.clash; |
... | ... |
@@ -4,21 +4,17 @@ |
4 | 4 |
"/home/fenris/projekte/folksprak/words/server/lib/plankton/./shape/logic-decl.d.ts", |
5 | 5 |
"/home/fenris/projekte/folksprak/words/server/lib/plankton/./trait/logic-decl.d.ts", |
6 | 6 |
"/home/fenris/projekte/folksprak/words/server/lib/plankton/./code/logic-decl.d.ts", |
7 |
+ "/home/fenris/projekte/folksprak/words/server/lib/plankton/./json/logic-decl.d.ts", |
|
7 | 8 |
"/home/fenris/projekte/folksprak/words/server/lib/plankton/./http/logic-decl.d.ts", |
8 |
- "/home/fenris/projekte/folksprak/words/server/lib/plankton/./call/logic-decl.d.ts", |
|
9 |
- "/home/fenris/projekte/folksprak/words/server/lib/plankton/./string/logic-decl.d.ts", |
|
10 |
- "/home/fenris/projekte/folksprak/words/server/lib/plankton/./object/logic-decl.d.ts", |
|
11 |
- "/home/fenris/projekte/folksprak/words/server/lib/plankton/./comm-server/logic-decl.d.ts" |
|
9 |
+ "/home/fenris/projekte/folksprak/words/server/lib/plankton/./server/logic-decl.d.ts" |
|
12 | 10 |
], |
13 | 11 |
"logic-impl": [ |
14 | 12 |
"/home/fenris/projekte/folksprak/words/server/lib/plankton/./base/logic-impl.js", |
15 | 13 |
"/home/fenris/projekte/folksprak/words/server/lib/plankton/./shape/logic-impl.js", |
16 | 14 |
"/home/fenris/projekte/folksprak/words/server/lib/plankton/./trait/logic-impl.js", |
17 | 15 |
"/home/fenris/projekte/folksprak/words/server/lib/plankton/./code/logic-impl.js", |
16 |
+ "/home/fenris/projekte/folksprak/words/server/lib/plankton/./json/logic-impl.js", |
|
18 | 17 |
"/home/fenris/projekte/folksprak/words/server/lib/plankton/./http/logic-impl.js", |
19 |
- "/home/fenris/projekte/folksprak/words/server/lib/plankton/./call/logic-impl.js", |
|
20 |
- "/home/fenris/projekte/folksprak/words/server/lib/plankton/./string/logic-impl.js", |
|
21 |
- "/home/fenris/projekte/folksprak/words/server/lib/plankton/./object/logic-impl.js", |
|
22 |
- "/home/fenris/projekte/folksprak/words/server/lib/plankton/./comm-server/logic-impl.js" |
|
18 |
+ "/home/fenris/projekte/folksprak/words/server/lib/plankton/./server/logic-impl.js" |
|
23 | 19 |
] |
24 | 20 |
} |
... | ... |
@@ -1,18 +1,18 @@ |
1 | 1 |
Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
2 | 2 |
<info@greenscale.de> |
3 | 3 |
|
4 |
-»bacterio-plankton:string« is free software: you can redistribute it and/or modify |
|
4 |
+»bacterio-plankton:server« is free software: you can redistribute it and/or modify |
|
5 | 5 |
it under the terms of the GNU Lesser General Public License as published by |
6 | 6 |
the Free Software Foundation, either version 3 of the License, or |
7 | 7 |
(at your option) any later version. |
8 | 8 |
|
9 |
-»bacterio-plankton:string« is distributed in the hope that it will be useful, |
|
9 |
+»bacterio-plankton:server« is distributed in the hope that it will be useful, |
|
10 | 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 |
GNU Lesser General Public License for more details. |
13 | 13 |
|
14 | 14 |
You should have received a copy of the GNU Lesser General Public License |
15 |
-along with »bacterio-plankton:string«. If not, see <http://www.gnu.org/licenses/>. |
|
15 |
+along with »bacterio-plankton:server«. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 |
|
17 | 17 |
|
18 | 18 |
|
... | ... |
@@ -0,0 +1,46 @@ |
1 |
+declare module lib_server { |
|
2 |
+ /** |
|
3 |
+ * @author fenris |
|
4 |
+ */ |
|
5 |
+ type type_subject = { |
|
6 |
+ port: int; |
|
7 |
+ handle: (input: string) => Promise<string>; |
|
8 |
+ verbosity: int; |
|
9 |
+ serverobj: any; |
|
10 |
+ }; |
|
11 |
+ /** |
|
12 |
+ * @author fenris |
|
13 |
+ */ |
|
14 |
+ function make(port: int, handle: (input: string) => Promise<string>, verbosity?: int): type_subject; |
|
15 |
+ /** |
|
16 |
+ * @author fenris |
|
17 |
+ */ |
|
18 |
+ function start(subject: type_subject): Promise<void>; |
|
19 |
+ /** |
|
20 |
+ * @author fenris |
|
21 |
+ */ |
|
22 |
+ function kill(subject: type_subject): void; |
|
23 |
+} |
|
24 |
+declare module lib_server { |
|
25 |
+ /** |
|
26 |
+ * @author fenris |
|
27 |
+ */ |
|
28 |
+ class class_server { |
|
29 |
+ /** |
|
30 |
+ * @author fenris |
|
31 |
+ */ |
|
32 |
+ protected subject: type_subject; |
|
33 |
+ /** |
|
34 |
+ * @author fenris |
|
35 |
+ */ |
|
36 |
+ constructor(port: int, handle: (input: string) => Promise<string>, verbosity?: int); |
|
37 |
+ /** |
|
38 |
+ * @author fenris |
|
39 |
+ */ |
|
40 |
+ start(): Promise<void>; |
|
41 |
+ /** |
|
42 |
+ * @author fenris |
|
43 |
+ */ |
|
44 |
+ kill(): void; |
|
45 |
+ } |
|
46 |
+} |
... | ... |
@@ -0,0 +1,133 @@ |
1 |
+/* |
|
2 |
+This file is part of »bacterio-plankton:server«. |
|
3 |
+ |
|
4 |
+Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
5 |
+<info@greenscale.de> |
|
6 |
+ |
|
7 |
+»bacterio-plankton:server« is free software: you can redistribute it and/or modify |
|
8 |
+it under the terms of the GNU Lesser General Public License as published by |
|
9 |
+the Free Software Foundation, either version 3 of the License, or |
|
10 |
+(at your option) any later version. |
|
11 |
+ |
|
12 |
+»bacterio-plankton:server« is distributed in the hope that it will be useful, |
|
13 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
+GNU Lesser General Public License for more details. |
|
16 |
+ |
|
17 |
+You should have received a copy of the GNU Lesser General Public License |
|
18 |
+along with »bacterio-plankton:server«. If not, see <http://www.gnu.org/licenses/>. |
|
19 |
+ */ |
|
20 |
+var lib_server; |
|
21 |
+(function (lib_server) { |
|
22 |
+ /** |
|
23 |
+ * @author fenris |
|
24 |
+ */ |
|
25 |
+ function make(port, handle, verbosity = 1) { |
|
26 |
+ return { |
|
27 |
+ "port": port, |
|
28 |
+ "handle": handle, |
|
29 |
+ "verbosity": verbosity, |
|
30 |
+ "serverobj": undefined, |
|
31 |
+ }; |
|
32 |
+ } |
|
33 |
+ lib_server.make = make; |
|
34 |
+ /** |
|
35 |
+ * @author fenris |
|
36 |
+ */ |
|
37 |
+ function log(subject, level, message) { |
|
38 |
+ if (subject.verbosity >= level) { |
|
39 |
+ console.log("[server]", message); |
|
40 |
+ } |
|
41 |
+ else { |
|
42 |
+ // do nothing |
|
43 |
+ } |
|
44 |
+ } |
|
45 |
+ /** |
|
46 |
+ * @author fenris |
|
47 |
+ */ |
|
48 |
+ function start(subject) { |
|
49 |
+ const net = require("net"); |
|
50 |
+ return (new Promise((resolve, reject) => { |
|
51 |
+ subject.serverobj = net.createServer((socket) => { |
|
52 |
+ log(subject, 2, "client connected"); |
|
53 |
+ socket.on("readable", () => { |
|
54 |
+ let chunk; |
|
55 |
+ while (!((chunk = socket.read()) === null)) { |
|
56 |
+ const input = chunk.toString(); |
|
57 |
+ log(subject, 3, "reading: " + input); |
|
58 |
+ subject.handle(input) |
|
59 |
+ .then((output) => { |
|
60 |
+ log(subject, 3, "writing: " + output); |
|
61 |
+ socket.write(output); |
|
62 |
+ socket.end(); |
|
63 |
+ }); |
|
64 |
+ } |
|
65 |
+ }); |
|
66 |
+ socket.on("end", () => { |
|
67 |
+ log(subject, 2, "client disconnected"); |
|
68 |
+ }); |
|
69 |
+ }); |
|
70 |
+ subject.serverobj.on("error", (error) => { |
|
71 |
+ throw error; |
|
72 |
+ }); |
|
73 |
+ subject.serverobj.listen(subject.port, () => { |
|
74 |
+ log(subject, 1, "listening on port " + subject.port.toFixed(0)); |
|
75 |
+ resolve(undefined); |
|
76 |
+ }); |
|
77 |
+ })); |
|
78 |
+ } |
|
79 |
+ lib_server.start = start; |
|
80 |
+ /** |
|
81 |
+ * @author fenris |
|
82 |
+ */ |
|
83 |
+ function kill(subject) { |
|
84 |
+ subject.serverobj.close(); |
|
85 |
+ } |
|
86 |
+ lib_server.kill = kill; |
|
87 |
+})(lib_server || (lib_server = {})); |
|
88 |
+/* |
|
89 |
+This file is part of »bacterio-plankton:server«. |
|
90 |
+ |
|
91 |
+Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
92 |
+<info@greenscale.de> |
|
93 |
+ |
|
94 |
+»bacterio-plankton:server« is free software: you can redistribute it and/or modify |
|
95 |
+it under the terms of the GNU Lesser General Public License as published by |
|
96 |
+the Free Software Foundation, either version 3 of the License, or |
|
97 |
+(at your option) any later version. |
|
98 |
+ |
|
99 |
+»bacterio-plankton:server« is distributed in the hope that it will be useful, |
|
100 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
101 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
102 |
+GNU Lesser General Public License for more details. |
|
103 |
+ |
|
104 |
+You should have received a copy of the GNU Lesser General Public License |
|
105 |
+along with »bacterio-plankton:server«. If not, see <common://www.gnu.org/licenses/>. |
|
106 |
+ */ |
|
107 |
+var lib_server; |
|
108 |
+(function (lib_server) { |
|
109 |
+ /** |
|
110 |
+ * @author fenris |
|
111 |
+ */ |
|
112 |
+ class class_server { |
|
113 |
+ /** |
|
114 |
+ * @author fenris |
|
115 |
+ */ |
|
116 |
+ constructor(port, handle, verbosity = undefined) { |
|
117 |
+ this.subject = lib_server.make(port, handle, verbosity); |
|
118 |
+ } |
|
119 |
+ /** |
|
120 |
+ * @author fenris |
|
121 |
+ */ |
|
122 |
+ start() { |
|
123 |
+ return lib_server.start(this.subject); |
|
124 |
+ } |
|
125 |
+ /** |
|
126 |
+ * @author fenris |
|
127 |
+ */ |
|
128 |
+ kill() { |
|
129 |
+ return lib_server.kill(this.subject); |
|
130 |
+ } |
|
131 |
+ } |
|
132 |
+ lib_server.class_server = class_server; |
|
133 |
+})(lib_server || (lib_server = {})); |
... | ... |
@@ -1,144 +0,0 @@ |
1 |
-declare var plain_text_to_html: (text: string) => string; |
|
2 |
-/** |
|
3 |
- * @desc makes a valid |
|
4 |
- */ |
|
5 |
-declare var format_sentence: (str: string, rtl?: boolean, caseSense?: boolean) => string; |
|
6 |
-declare var fill_string_template: (template_string: string, object: any, fabric: Function, delimiter: string, default_string: string, sloppy: boolean) => string; |
|
7 |
-declare var make_string_template: (_template: string, _fabrics?: Object) => (object: { |
|
8 |
- [key: string]: string; |
|
9 |
-}) => string; |
|
10 |
-declare var make_eml_header: (object: { |
|
11 |
- [key: string]: string; |
|
12 |
-}) => string; |
|
13 |
-declare var make_eml_body: Object; |
|
14 |
-declare module lib_string { |
|
15 |
- /** |
|
16 |
- * @author neuc,frac |
|
17 |
- */ |
|
18 |
- function empty(str: string): boolean; |
|
19 |
- /** |
|
20 |
- * @desc returns a unique string |
|
21 |
- * @param {string} prefix an optional prefix for the generated string |
|
22 |
- * @return {string} |
|
23 |
- * @author fenris |
|
24 |
- */ |
|
25 |
- function generate(prefix?: string): string; |
|
26 |
- /** |
|
27 |
- * @desc splits a string, but returns an empty list, if the string is empty |
|
28 |
- * @param {string} chain |
|
29 |
- * @param {string} separator |
|
30 |
- * @return {Array<string>} |
|
31 |
- * @author fenris |
|
32 |
- */ |
|
33 |
- function split(chain: string, separator?: string): Array<string>; |
|
34 |
- /** |
|
35 |
- * @author neu3no |
|
36 |
- */ |
|
37 |
- function explode(str: string, needle: string, max: int): Array<string>; |
|
38 |
- /** |
|
39 |
- * @desc concats a given word with itself n times |
|
40 |
- * @param {string} word |
|
41 |
- * @param {int} |
|
42 |
- * @return {string} |
|
43 |
- * @author fenris |
|
44 |
- */ |
|
45 |
- function repeat(word: string, count: int): string; |
|
46 |
- /** |
|
47 |
- * @desc lengthens a string by repeatedly appending or prepending another string |
|
48 |
- * @param {string} word the string to pad |
|
49 |
- * @param {int} length the length, which the result shall have |
|
50 |
- * @param {string} symbol the string, which will be added (multiple times) |
|
51 |
- * @param {boolean} [prepend]; whether to prepend (~true) or append (~false); default: false |
|
52 |
- * @return {string} the padded string |
|
53 |
- * @author fenris |
|
54 |
- */ |
|
55 |
- function pad(word: string, length: int, symbol?: string, mode?: string): string; |
|
56 |
- /** |
|
57 |
- * @desc checks if a given string conttains a certain substring |
|
58 |
- * @param {string} string |
|
59 |
- * @param {string} part |
|
60 |
- * @return {boolean} |
|
61 |
- * @author fenris |
|
62 |
- */ |
|
63 |
- function contains(chain: string, part: string): boolean; |
|
64 |
- /** |
|
65 |
- * @desc checks if a given string starts with a certain substring |
|
66 |
- * @param {string} string |
|
67 |
- * @param {string} part |
|
68 |
- * @return {boolean} |
|
69 |
- * @author fenris |
|
70 |
- */ |
|
71 |
- function startsWith(chain: string, part: string): boolean; |
|
72 |
- /** |
|
73 |
- * @desc checks if a given string ends with a certain substring |
|
74 |
- * @param {string} string |
|
75 |
- * @param {string} part |
|
76 |
- * @return {boolean} |
|
77 |
- * @author fenris |
|
78 |
- */ |
|
79 |
- function endsWith(chain: string, part: string): boolean; |
|
80 |
- /** |
|
81 |
- * @desc count the occourrences of a string in a string |
|
82 |
- * @param string haystack_string the string wich should be examined |
|
83 |
- * @param string needle_string the string which should be counted |
|
84 |
- * @author neuc |
|
85 |
- */ |
|
86 |
- function count_occourrences(haystack_string: string, needle_string: string, check_escape: boolean): int; |
|
87 |
- /** |
|
88 |
- * @desc replaces occurences of "${name}" in a string by the corresponding values of an argument object |
|
89 |
- * @author fenris |
|
90 |
- */ |
|
91 |
- function coin(str: string, args: { |
|
92 |
- [id: string]: string; |
|
93 |
- }): string; |
|
94 |
- /** |
|
95 |
- * @author fenris |
|
96 |
- */ |
|
97 |
- var stance: typeof coin; |
|
98 |
- /** |
|
99 |
- * @author fenris |
|
100 |
- */ |
|
101 |
- function url_encode({ "protocol": protocol, "host": host, "port": port, "path": path, "arguments": arguments_, }?: { |
|
102 |
- protocol?: string; |
|
103 |
- host?: string; |
|
104 |
- port?: int; |
|
105 |
- path?: string; |
|
106 |
- arguments?: { |
|
107 |
- [key: string]: string; |
|
108 |
- }; |
|
109 |
- }): string; |
|
110 |
- /** |
|
111 |
- * @author fenris |
|
112 |
- */ |
|
113 |
- var make_url: typeof url_encode; |
|
114 |
- /** |
|
115 |
- * @author fenris |
|
116 |
- * @todo arguments |
|
117 |
- */ |
|
118 |
- function url_decode(url: string): Object; |
|
119 |
- /** |
|
120 |
- * @author fenris |
|
121 |
- */ |
|
122 |
- function cut(str: string, length: int, delimiter?: string): string; |
|
123 |
-} |
|
124 |
-declare module lib_string { |
|
125 |
- /** |
|
126 |
- * an implementation of c sprintf |
|
127 |
- * @param {string} string format string |
|
128 |
- * @param {array} args arguments which should be filled into |
|
129 |
- * @returns {string} |
|
130 |
- */ |
|
131 |
- var sprintf: (input: string, args?: any[], original?: any) => string; |
|
132 |
- /** |
|
133 |
- * an implementation of c printf |
|
134 |
- * @param {string} string format string |
|
135 |
- * @param {array} args arguments which should be filled into |
|
136 |
- * @returns {string} |
|
137 |
- */ |
|
138 |
- function printf(format: any, args: any): void; |
|
139 |
-} |
|
140 |
-declare var sprintf: (input: string, args?: any[], original?: any) => string; |
|
141 |
-declare var printf: typeof lib_string.printf; |
|
142 |
-declare var eml_log: any; |
|
143 |
-declare var track_exports: any; |
|
144 |
-declare var make_logger: (prefix: any, current_loglevel: any) => (obj: any, lvl: any) => void; |
... | ... |
@@ -1,906 +0,0 @@ |
1 |
-/* |
|
2 |
-This file is part of »bacterio-plankton:string«. |
|
3 |
- |
|
4 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
5 |
-<info@greenscale.de> |
|
6 |
- |
|
7 |
-»bacterio-plankton:string« is free software: you can redistribute it and/or modify |
|
8 |
-it under the terms of the GNU Lesser General Public License as published by |
|
9 |
-the Free Software Foundation, either version 3 of the License, or |
|
10 |
-(at your option) any later version. |
|
11 |
- |
|
12 |
-»bacterio-plankton:string« is distributed in the hope that it will be useful, |
|
13 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
-GNU Lesser General Public License for more details. |
|
16 |
- |
|
17 |
-You should have received a copy of the GNU Lesser General Public License |
|
18 |
-along with »bacterio-plankton:string«. If not, see <http://www.gnu.org/licenses/>. |
|
19 |
- */ |
|
20 |
-var plain_text_to_html = function (text) { |
|
21 |
- var ret = text; |
|
22 |
- ret = ret.replace(/ /g, " "); // convert multiple whitespace to forced ones |
|
23 |
- ret = ret.split("\n").join("<br/>"); |
|
24 |
- return ret; |
|
25 |
-}; |
|
26 |
-/** |
|
27 |
- * @desc makes a valid |
|
28 |
- */ |
|
29 |
-var format_sentence = function (str, rtl, caseSense) { |
|
30 |
- if (rtl === void 0) { rtl = false; } |
|
31 |
- if (caseSense === void 0) { caseSense = true; } |
|
32 |
- if (str === "") { |
|
33 |
- return str; |
|
34 |
- } |
|
35 |
- else { |
|
36 |
- var marks = { |
|
37 |
- ".": true, |
|
38 |
- "?": true, |
|
39 |
- "!": true |
|
40 |
- }; |
|
41 |
- var default_mark = "."; |
|
42 |
- var ret = str.split(""); |
|
43 |
- if (!rtl) { |
|
44 |
- ret[0] = ret[0].toLocaleUpperCase(); |
|
45 |
- if (!(ret[ret.length - 1] in marks)) { |
|
46 |
- ret.push(default_mark); |
|
47 |
- } |
|
48 |
- } |
|
49 |
- else { |
|
50 |
- ret[ret.length - 1] = ret[ret.length - 1].toLocaleUpperCase(); |
|
51 |
- if (!(ret[0] in marks)) { |
|
52 |
- ret.unshift(default_mark); |
|
53 |
- } |
|
54 |
- } |
|
55 |
- return ret.join(""); |
|
56 |
- } |
|
57 |
-}; |
|
58 |
-var fill_string_template = function (template_string, object, fabric, delimiter, default_string, sloppy) { |
|
59 |
- if (fabric === void 0) { fabric = function (object, key) { return object[key]; }; } |
|
60 |
- if (delimiter === void 0) { delimiter = "%"; } |
|
61 |
- if (default_string === void 0) { default_string = null; } |
|
62 |
- function get_tags(str) { |
|
63 |
- var r = new RegExp(delimiter + "[^\\s^" + delimiter + "]+" + delimiter, "gi"); |
|
64 |
- return ((str.match(r) || []).map(function (e) { |
|
65 |
- return e.slice(delimiter.length, e.length - delimiter.length); |
|
66 |
- })); |
|
67 |
- } |
|
68 |
- function replace_tag(str, tag, value) { |
|
69 |
- var r = new RegExp(delimiter + tag + delimiter, "gi"); |
|
70 |
- return str.replace(r, value); |
|
71 |
- } |
|
72 |
- function replace_tags(str, obj) { |
|
73 |
- return (get_tags(str).reduce(function (ret, key) { |
|
74 |
- var value = ""; |
|
75 |
- try { |
|
76 |
- value = fabric(obj, key); |
|
77 |
- if ((!sloppy && (value === void 0)) || (sloppy && (value == void 0))) { |
|
78 |
- value = default_string; |
|
79 |
- } |
|
80 |
- } |
|
81 |
- catch (e) { |
|
82 |
- console.warn("invalid placeholder " + key); |
|
83 |
- value = default_string; |
|
84 |
- } |
|
85 |
- return replace_tag(ret, key, value); |
|
86 |
- }, str)); |
|
87 |
- } |
|
88 |
- return replace_tags(template_string, object); |
|
89 |
-}; |
|
90 |
-var make_string_template = function (_template, _fabrics) { |
|
91 |
- if (_fabrics === void 0) { _fabrics = {}; } |
|
92 |
- function replace_tag(str, tag, value) { |
|
93 |
- var r = new RegExp("%" + tag + "%", "gi"); |
|
94 |
- return str.replace(r, value); |
|
95 |
- } |
|
96 |
- function replace_tags(str, obj) { |
|
97 |
- return (Object.keys(obj).reduce(function (ret, key) { |
|
98 |
- return replace_tag(ret, key, _fabrics[key] || obj[key]); |
|
99 |
- }, str)); |
|
100 |
- } |
|
101 |
- return (function (tags) { |
|
102 |
- return replace_tags(_template, tags); |
|
103 |
- }); |
|
104 |
-}; |
|
105 |
-var make_eml_header = (function () { |
|
106 |
- var _template = ""; |
|
107 |
- _template += "From: %from%\n"; |
|
108 |
- _template += "To: %recipient%\n"; |
|
109 |
- _template += "Subject: %subject%\n"; |
|
110 |
- _template += "X-Mailer: greenscale-plankton.emlgen\n"; |
|
111 |
- return make_string_template(_template); |
|
112 |
-})(); |
|
113 |
-var make_eml_body = (function () { |
|
114 |
- var exports = {}; |
|
115 |
- exports["simple_body"] = make_string_template("Content-Type: %contenttype%\n\n%body%\n\n"); |
|
116 |
- // very basic implementation |
|
117 |
- // parts = [{contenttype:"text/html; charset=UTF-8", body: "<h1>foo</h1>" }, {...}] |
|
118 |
- exports["body_boundrary"] = function (parts, boundrary) { |
|
119 |
- var _template = ""; |
|
120 |
- _template += "--%boundrary%\n"; |
|
121 |
- _template += "Content-Type: %contenttype%\n\n%body%\n\n"; |
|
122 |
- //_template += "--%boundrary%--\n\n"; |
|
123 |
- var maker = make_string_template(_template); |
|
124 |
- return (parts.reduce(function (prev, curr) { |
|
125 |
- curr.boundrary = boundrary; |
|
126 |
- return [prev, maker(curr)].join(""); |
|
127 |
- }, "")); |
|
128 |
- }; |
|
129 |
- // body must be base64 encoded! |
|
130 |
- exports["attachment_boundrary"] = function (parts, boundrary) { |
|
131 |
- var _template = ""; |
|
132 |
- _template += "--%boundrary%\n"; |
|
133 |
- _template += "Content-Type: %contenttype%\n"; |
|
134 |
- _template += "Content-Transfer-Encoding: base64\n"; |
|
135 |
- _template += "Content-Disposition: %disposition%; filename=\"%name%\"\n\n"; |
|
136 |
- _template += "%body%\n\n"; |
|
137 |
- //_template += "--%boundrary%--\n\n"; |
|
138 |
- var maker = make_string_template(_template); |
|
139 |
- return (parts.reduce(function (prev, curr) { |
|
140 |
- curr.boundrary = boundrary; |
|
141 |
- if (curr.disposition === void 0) |
|
142 |
- curr.disposition = "inline"; |
|
143 |
- return [prev, maker(curr)].join(""); |
|
144 |
- }, "")); |
|
145 |
- }; |
|
146 |
- exports["gen_boundrary"] = function () { |
|
147 |
- return ("xxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g, function (c) { |
|
148 |
- var r = crypto.getRandomValues(new Uint8Array(1))[0] % 16 | 0, v = c == "x" ? r : (r & 0x3 | 0x8); |
|
149 |
- return v.toString(16); |
|
150 |
- })); |
|
151 |
- }; |
|
152 |
- // simple implementation without alternatives (old rfc) |
|
153 |
- exports["complete_boundrary"] = function (bodyparts, attachments) { |
|
154 |
- var ret = ""; |
|
155 |
- var boundrary = exports["gen_boundrary"](); |
|
156 |
- ret += exports["body_boundrary"](bodyparts, boundrary); |
|
157 |
- ret += exports["attachment_boundrary"](attachments, boundrary); |
|
158 |
- ret += "--" + boundrary + "--\n\nINVISIBLE!!!!"; |
|
159 |
- return (exports["simple_body"]({ |
|
160 |
- "contenttype": sprintf("multipart/mixed; boundary=%s", [boundrary]), |
|
161 |
- "body": ret |
|
162 |
- })); |
|
163 |
- }; |
|
164 |
- return exports; |
|
165 |
-})(); |
|
166 |
-/* |
|
167 |
-This file is part of »bacterio-plankton:string«. |
|
168 |
- |
|
169 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
170 |
-<info@greenscale.de> |
|
171 |
- |
|
172 |
-»bacterio-plankton:string« is free software: you can redistribute it and/or modify |
|
173 |
-it under the terms of the GNU Lesser General Public License as published by |
|
174 |
-the Free Software Foundation, either version 3 of the License, or |
|
175 |
-(at your option) any later version. |
|
176 |
- |
|
177 |
-»bacterio-plankton:string« is distributed in the hope that it will be useful, |
|
178 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
179 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
180 |
-GNU Lesser General Public License for more details. |
|
181 |
- |
|
182 |
-You should have received a copy of the GNU Lesser General Public License |
|
183 |
-along with »bacterio-plankton:string«. If not, see <http://www.gnu.org/licenses/>. |
|
184 |
- */ |
|
185 |
-var lib_string; |
|
186 |
-(function (lib_string) { |
|
187 |
- /** |
|
188 |
- * @author fenris |
|
189 |
- */ |
|
190 |
- var hexdigits = 4; |
|
191 |
- /** |
|
192 |
- * @author fenris |
|
193 |
- */ |
|
194 |
- var index_max = (1 << (4 * hexdigits)); |
|
195 |
- /** |
|
196 |
- * @author fenris |
|
197 |
- */ |
|
198 |
- var index_is = 0; |
|
199 |
- /** |
|
200 |
- * @author neuc,frac |
|
201 |
- */ |
|
202 |
- function empty(str) { |
|
203 |
- return (str.trim() === ""); |
|
204 |
- } |
|
205 |
- lib_string.empty = empty; |
|
206 |
- /** |
|
207 |
- * @desc returns a unique string |
|
208 |
- * @param {string} prefix an optional prefix for the generated string |
|
209 |
- * @return {string} |
|
210 |
- * @author fenris |
|
211 |
- */ |
|
212 |
- function generate(prefix) { |
|
213 |
- if (prefix === void 0) { prefix = "string_"; } |
|
214 |
- if (index_is > index_max) { |
|
215 |
- throw (new Error("[string_generate] out of valid indices")); |
|
216 |
- } |
|
217 |
- else { |
|
218 |
- return lib_string.sprintf(prefix + "%0" + hexdigits.toString() + "X", [index_is++]); |
|
219 |
- } |
|
220 |
- } |
|
221 |
- lib_string.generate = generate; |
|
222 |
- /** |
|
223 |
- * @desc splits a string, but returns an empty list, if the string is empty |
|
224 |
- * @param {string} chain |
|
225 |
- * @param {string} separator |
|
226 |
- * @return {Array<string>} |
|
227 |
- * @author fenris |
|
228 |
- */ |
|
229 |
- function split(chain, separator) { |
|
230 |
- if (separator === void 0) { separator = " "; } |
|
231 |
- if (chain.length == 0) { |
|
232 |
- return []; |
|
233 |
- } |
|
234 |
- else { |
|
235 |
- return chain.split(separator); |
|
236 |
- } |
|
237 |
- } |
|
238 |
- lib_string.split = split; |
|
239 |
- /** |
|
240 |
- * @author neu3no |
|
241 |
- */ |
|
242 |
- function explode(str, needle, max) { |
|
243 |
- var temp = str.split(needle); |
|
244 |
- var right = temp.splice(max - 1); |
|
245 |
- temp.push(right.join(needle)); |
|
246 |
- return temp; |
|
247 |
- } |
|
248 |
- lib_string.explode = explode; |
|
249 |
- /** |
|
250 |
- * @desc concats a given word with itself n times |
|
251 |
- * @param {string} word |
|
252 |
- * @param {int} |
|
253 |
- * @return {string} |
|
254 |
- * @author fenris |
|
255 |
- */ |
|
256 |
- function repeat(word, count) { |
|
257 |
- // return ((count == 0) ? "" : (word + repeat(word, count-1))); |
|
258 |
- var result = ""; |
|
259 |
- for (var n = 0; n < count; n += 1) { |
|
260 |
- result += word; |
|
261 |
- } |
|
262 |
- return result; |
|
263 |
- } |
|
264 |
- lib_string.repeat = repeat; |
|
265 |
- /** |
|
266 |
- * @desc lengthens a string by repeatedly appending or prepending another string |
|
267 |
- * @param {string} word the string to pad |
|
268 |
- * @param {int} length the length, which the result shall have |
|
269 |
- * @param {string} symbol the string, which will be added (multiple times) |
|
270 |
- * @param {boolean} [prepend]; whether to prepend (~true) or append (~false); default: false |
|
271 |
- * @return {string} the padded string |
|
272 |
- * @author fenris |
|
273 |
- */ |
|
274 |
- function pad(word, length, symbol, mode) { |
|
275 |
- if (symbol === void 0) { symbol = " "; } |
|
276 |
- if (mode === void 0) { mode = "append"; } |
|
277 |
- switch (mode) { |
|
278 |
- case "prepend": { |
|
279 |
- // insert symbols only at the beginning |
|
280 |
- while (word.length < length) |
|
281 |
- word = symbol + word; |
|
282 |
- return word.substring(word.length - length); |
|
283 |
- break; |
|
284 |
- } |
|
285 |
- case "append": { |
|
286 |
- // insert symbols only at the end |
|
287 |
- while (word.length < length) |
|
288 |
- word = word + symbol; |
|
289 |
- return word.substring(0, length); |
|
290 |
- break; |
|
291 |
- } |
|
292 |
- case "widen": { |
|
293 |
- // insert symbols at both sides |
|
294 |
- var left = (((length - word.length) & 1) === 0); |
|
295 |
- while (word.length < length) { |
|
296 |
- word = (left |
|
297 |
- ? (symbol + word) |
|
298 |
- : (word + symbol)); |
|
299 |
- left = (!left); |
|
300 |
- } |
|
301 |
- return word.substring(0, length); |
|
302 |
- break; |
|
303 |
- } |
|
304 |
- default: { |
|
305 |
- var message = ("unhandled mode '" + mode + "'"); |
|
306 |
- console.warn(message); |
|
307 |
- return word; |
|
308 |
- break; |
|
309 |
- } |
|
310 |
- } |
|
311 |
- } |
|
312 |
- lib_string.pad = pad; |
|
313 |
- /** |
|
314 |
- * @desc checks if a given string conttains a certain substring |
|
315 |
- * @param {string} string |
|
316 |
- * @param {string} part |
|
317 |
- * @return {boolean} |
|
318 |
- * @author fenris |
|
319 |
- */ |
|
320 |
- function contains(chain, part) { |
|
321 |
- if (typeof (chain) !== "string") { |
|
322 |
- return false; |
|
323 |
- } |
|
324 |
- return (chain.indexOf(part) >= 0); |
|
325 |
- } |
|
326 |
- lib_string.contains = contains; |
|
327 |
- /** |
|
328 |
- * @desc checks if a given string starts with a certain substring |
|
329 |
- * @param {string} string |
|
330 |
- * @param {string} part |
|
331 |
- * @return {boolean} |
|
332 |
- * @author fenris |
|
333 |
- */ |
|
334 |
- function startsWith(chain, part) { |
|
335 |
- if (typeof (chain) !== "string") { |
|
336 |
- return false; |
|
337 |
- } |
|
338 |
- // return (string.indexOf(part) === 0); |
|
339 |
- return ((function (m, n) { |
|
340 |
- if (n === 0) { |
|
341 |
- return true; |
|
342 |
- } |
|
343 |
- else { |
|
344 |
- if (m === 0) { |
|
345 |
- return false; |
|
346 |
- } |
|
347 |
- else { |
|
348 |
- return ((chain[0] == part[0]) |
|
349 |
- && |
|
350 |
- startsWith(chain.substring(1), part.substring(1))); |
|
351 |
- } |
|
352 |
- } |
|
353 |
- })(chain.length, part.length)); |
|
354 |
- } |
|
355 |
- lib_string.startsWith = startsWith; |
|
356 |
- /** |
|
357 |
- * @desc checks if a given string ends with a certain substring |
|
358 |
- * @param {string} string |
|
359 |
- * @param {string} part |
|
360 |
- * @return {boolean} |
|
361 |
- * @author fenris |
|
362 |
- */ |
|
363 |
- function endsWith(chain, part) { |
|
364 |
- if (typeof (chain) !== "string") { |
|
365 |
- return false; |
|
366 |
- } |
|
367 |
- // return (string.lastIndexOf(part) === string.length-part.length); |
|
368 |
- return ((function (m, n) { |
|
369 |
- if (n === 0) { |
|
370 |
- return true; |
|
371 |
- } |
|
372 |
- else { |
|
373 |
- if (m === 0) { |
|
374 |
- return false; |
|
375 |
- } |
|
376 |
- else { |
|
377 |
- // console.info(("(" + string[m-1] + " == " + part[n-1] + ")") + " = " + String(string[m-1] == part[n-1])); |
|
378 |
- return ((chain[m - 1] === part[n - 1]) |
|
379 |
- && |
|
380 |
- endsWith(chain.substring(0, m - 1), part.substring(0, n - 1))); |
|
381 |
- } |
|
382 |
- } |
|
383 |
- })(chain.length, part.length)); |
|
384 |
- } |
|
385 |
- lib_string.endsWith = endsWith; |
|
386 |
- /** |
|
387 |
- * @desc count the occourrences of a string in a string |
|
388 |
- * @param string haystack_string the string wich should be examined |
|
389 |
- * @param string needle_string the string which should be counted |
|
390 |
- * @author neuc |
|
391 |
- */ |
|
392 |
- function count_occourrences(haystack_string, needle_string, check_escape) { |
|
393 |
- var cnt = 0; |
|
394 |
- var pos = -1; |
|
395 |
- do { |
|
396 |
- pos = haystack_string.indexOf(needle_string, pos + 1); |
|
397 |
- if ((!check_escape) || (haystack_string[pos - 1] != "\\")) { |
|
398 |
- cnt++; |
|
399 |
- } |
|
400 |
- } while (pos >= 0); |
|
401 |
- return (cnt - 1); |
|
402 |
- } |
|
403 |
- lib_string.count_occourrences = count_occourrences; |
|
404 |
- /** |
|
405 |
- * @desc replaces occurences of "${name}" in a string by the corresponding values of an argument object |
|
406 |
- * @author fenris |
|
407 |
- */ |
|
408 |
- function coin(str, args) { |
|
409 |
- Object.keys(args).forEach(function (key) { |
|
410 |
- // old syntax |
|
411 |
- { |
|
412 |
- var value = args[key]; |
|
413 |
- var regexp_argument = new RegExp("\\${" + key + "}"); |
|
414 |
- str = str.replace(regexp_argument, value); |
|
415 |
- } |
|
416 |
- // new syntax |
|
417 |
- { |
|
418 |
- var value = args[key]; |
|
419 |
- var regexp_argument = new RegExp("{{" + key + "}}"); |
|
420 |
- str = str.replace(regexp_argument, value); |
|
421 |
- } |
|
422 |
- }); |
|
423 |
- return str; |
|
424 |
- } |
|
425 |
- lib_string.coin = coin; |
|
426 |
- /** |
|
427 |
- * @author fenris |
|
428 |
- */ |
|
429 |
- lib_string.stance = coin; |
|
430 |
- /** |
|
431 |
- * @author fenris |
|
432 |
- */ |
|
433 |
- function url_encode(_a) { |
|
434 |
- var _b = _a === void 0 ? {} : _a, _c = _b["protocol"], protocol = _c === void 0 ? null : _c, _d = _b["host"], host = _d === void 0 ? null : _d, _e = _b["port"], port = _e === void 0 ? null : _e, _f = _b["path"], path = _f === void 0 ? null : _f, _g = _b["arguments"], arguments_ = _g === void 0 ? null : _g; |
|
435 |
- var url = ""; |
|
436 |
- // protocol |
|
437 |
- { |
|
438 |
- if (protocol != null) { |
|
439 |
- url = protocol + ":" + url; |
|
440 |
- } |
|
441 |
- } |
|
442 |
- // host |
|
443 |
- { |
|
444 |
- if (host != null) { |
|
445 |
- url = url + "//" + host; |
|
446 |
- } |
|
447 |
- } |
|
448 |
- // port |
|
449 |
- { |
|
450 |
- if (port != null) { |
|
451 |
- url = url + ":" + port.toString(); |
|
452 |
- } |
|
453 |
- } |
|
454 |
- // path |
|
455 |
- { |
|
456 |
- if (path != null) { |
|
457 |
- var path_ = encodeURI(path); |
|
458 |
- url = "" + url + path_; |
|
459 |
- } |
|
460 |
- } |
|
461 |
- // arguments |
|
462 |
- { |
|
463 |
- if (arguments_ != null) { |
|
464 |
- var suffix = Object.keys(arguments_).map(function (key) { return key + "=" + arguments_[key]; }).join("&"); |
|
465 |
- var suffix_ = encodeURI(suffix); |
|
466 |
- url = url + "?" + suffix_; |
|
467 |
- } |
|
468 |
- } |
|
469 |
- return url; |
|
470 |
- } |
|
471 |
- lib_string.url_encode = url_encode; |
|
472 |
- /** |
|
473 |
- * @author fenris |
|
474 |
- */ |
|
475 |
- lib_string.make_url = url_encode; |
|
476 |
- /** |
|
477 |
- * @author fenris |
|
478 |
- * @todo arguments |
|
479 |
- */ |
|
480 |
- function url_decode(url) { |
|
481 |
- var regexp = new RegExp("^([^:]*)://([^:]*):([^/]*)/(.*)$"); |
|
482 |
- var matching = regexp.exec(url); |
|
483 |
- if (matching === null) { |
|
484 |
- return null; |
|
485 |
- } |
|
486 |
- else { |
|
487 |
- var components = { |
|
488 |
- "protocol": matching[1], |
|
489 |
- "host": matching[2], |
|
490 |
- "port": parseInt(matching[3]), |
|
491 |
- "path": ("/" + matching[4]) |
|
492 |
- }; |
|
493 |
- return components; |
|
494 |
- } |
|
495 |
- } |
|
496 |
- lib_string.url_decode = url_decode; |
|
497 |
- /** |
|
498 |
- * @author fenris |
|
499 |
- */ |
|
500 |
- function cut(str, length, delimiter) { |
|
501 |
- if (delimiter === void 0) { delimiter = "…"; } |
|
502 |
- if (str.length <= length) { |
|
503 |
- return str; |
|
504 |
- } |
|
505 |
- else { |
|
506 |
- return (str.slice(0, length - delimiter.length) + delimiter); |
|
507 |
- } |
|
508 |
- } |
|
509 |
- lib_string.cut = cut; |
|
510 |
-})(lib_string || (lib_string = {})); |
|
511 |
-/* |
|
512 |
-This file is part of »bacterio-plankton:string«. |
|
513 |
- |
|
514 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
515 |
-<info@greenscale.de> |
|
516 |
- |
|
517 |
-»bacterio-plankton:string« is free software: you can redistribute it and/or modify |
|
518 |
-it under the terms of the GNU Lesser General Public License as published by |
|
519 |
-the Free Software Foundation, either version 3 of the License, or |
|
520 |
-(at your option) any later version. |
|
521 |
- |
|
522 |
-»bacterio-plankton:string« is distributed in the hope that it will be useful, |
|
523 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
524 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
525 |
-GNU Lesser General Public License for more details. |
|
526 |
- |
|
527 |
-You should have received a copy of the GNU Lesser General Public License |
|
528 |
-along with »bacterio-plankton:string«. If not, see <http://www.gnu.org/licenses/>. |
|
529 |
- */ |
|
530 |
-var lib_string; |
|
531 |
-(function (lib_string) { |
|
532 |
- var pattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/; |
|
533 |
- var gpattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/g; |
|
534 |
- function split_format(format) { |
|
535 |
- var tmp = format.match(pattern); |
|
536 |
- if (tmp === null) |
|
537 |
- return null; |
|
538 |
- return { |
|
539 |
- 'flags': tmp[1].split(""), |
|
540 |
- 'width': Number(tmp[2]), |
|
541 |
- 'precision': tmp[3] === '' ? null : Number(tmp[3]), |
|
542 |
- 'specifier': tmp[4], |
|
543 |
- 'string': format |
|
544 |
- }; |
|
545 |
- } |
|
546 |
- function make_err(format, arg, should) { |
|
547 |
- return ("[sprintf]" + " " + "argument for '" + format.string + "' has to be '" + should + "' but '" + arg + "' is '" + typeof arg + "'!"); |
|
548 |
- } |
|
549 |
- function test_arg(format, arg, should) { |
|
550 |
- if (typeof arg !== should) { |
|
551 |
- console.warn(make_err(format, arg, should)); |
|
552 |
- return false; |
|
553 |
- } |
|
554 |
- return true; |
|
555 |
- } |
|
556 |
- function string_fill(str, char, len, left) { |
|
557 |
- while (str.length < len) { |
|
558 |
- if (left) { |
|
559 |
- str += char; |
|
560 |
- } |
|
561 |
- else { |
|
562 |
- str = char + str; |
|
563 |
- } |
|
564 |
- } |
|
565 |
- return str; |
|
566 |
- } |
|
567 |
- /** |
|
568 |
- * the known_parameters are used to parse the different identifiers for the welln known syntax: |
|
569 |
- * flag width precision identifier |
|
570 |
- * %{[0#+- ]}{[0-9]*}.{[0-9]*}[fFdiueEgGsoxXaAsn] |
|
571 |
- * flags: |
|
572 |
- * 0 - fill with '0' instead of ' ' if the string length < width |
|
573 |
- * # - not implemented |
|
574 |
- * - - left-justified -> fill on the right side to reach width |
|
575 |
- * + - force using '+' on positive numbers |
|
576 |
- * ' ' - add a single space before positive numbers |
|
577 |
- * |
|
578 |
- * identifiers |
|
579 |
- * %f, %F - interpret given number as float, width: the minimal total width (fill with ' ' or '0' if the |
|
580 |
- * resulting string is too short, precision: cut more then given decimal places |
|
581 |
- * %d, %i, %u - interpret number as integer, decimal places will be cut. width: like float, precision: |
|
582 |
- * fill with '0' on right side until length given in precision is reached |
|
583 |
- * %e - interpret as float and write as scientifical number, width & precision like in float |
|
584 |
- * %E - same es %e but uppercase 'E' |
|
585 |
- * %g - use the shortest string of %f or %e |
|
586 |
- * %G - use the shortest string of %E or %E |
|
587 |
- * %s - simply print a string |
|
588 |
- * %o - print the given number in octal notation |
|
589 |
- * %x - print the given number in hex notation |
|
590 |
- * %X - same as %x but with uppercase characters |
|
591 |
- * %a - alias to %x |
|
592 |
- * %A - alias to %X |
|
593 |
- * %n - just print nothing |
|
594 |
- * @type {{}} |
|
595 |
- */ |
|
596 |
- var known_params = {}; |
|
597 |
- known_params["f"] = function (format, arg) { |
|
598 |
- if (!test_arg(format, arg, "number")) |
|
599 |
- return "Ø"; |
|
600 |
- var tmp = Math.abs(arg); |
|
601 |
- var sign = (arg < 0) ? -1 : 1; |
|
602 |
- var tmp_result = null; |
|
603 |
- if (format.precision !== null) { |
|
604 |
- tmp = Math.floor(Math.pow(10, format.precision) * tmp) / Math.pow(10, format.precision); |
|
605 |
- var tmp_ = (tmp * sign).toString().split("."); |
|
606 |
- if (tmp_.length === 1) |
|
607 |
- tmp_.push(""); |
|
608 |
- tmp_[1] = string_fill(tmp_[1], "0", format.precision, true); |
|
609 |
- tmp_result = tmp_.join("."); |
|
610 |
- } |
|
611 |
- else { |
|
612 |
- tmp_result = (sign * tmp).toString(); |
|
613 |
- } |
|
614 |
- if ((format.flags.indexOf(" ") >= 0) && (arg >= 0)) { |
|
615 |
- tmp_result = " " + tmp; |
|
616 |
- } |
|
617 |
- else if ((format.flags.indexOf("+") >= 0) && (arg >= 0)) { |
|
618 |
- tmp_result = "+" + tmp; |
|
619 |
- } |
|
620 |
- tmp_result = string_fill(tmp, (format.flags.indexOf("0") >= 0) ? "0" : " ", format.width, (format.flags.indexOf("-") >= 0)); |
|
621 |
- return tmp_result; |
|
622 |
- }; |
|
623 |
- known_params["F"] = known_params["f"]; |
|
624 |
- known_params["d"] = function (format, arg) { |
|
625 |
- if (!test_arg(format, arg, 'number')) |
|
626 |
- return 'Ø'; |
|
627 |
- var tmp = (((arg < 0 && format.specifier !== 'u') ? -1 : 1) * Math.floor(Math.abs(arg))).toString(); |
|
628 |
- if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf(' ') >= 0 && arg >= 0) { |
|
629 |
- tmp = ' ' + tmp; |
|
630 |
- } |
|
631 |
- else if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf('+') >= 0 && arg >= 0) { |
|
632 |
- tmp = '+' + tmp; |
|
633 |
- } |
|
634 |
- tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
635 |
- tmp = string_fill(tmp, '0', format.precision === null ? 0 : format.precision, false); |
|
636 |
- return tmp; |
|
637 |
- }; |
|
638 |
- known_params["i"] = known_params["d"]; |
|
639 |
- known_params["u"] = known_params["d"]; |
|
640 |
- known_params["e"] = function (format, arg) { |
|
641 |
- if (!test_arg(format, arg, 'number')) |
|
642 |
- return 'Ø'; |
|
643 |
- var tmp = arg.toExponential(format.precision === null ? undefined : format.precision).toString(); |
|
644 |
- if (format.flags.indexOf(' ') >= 0 && arg >= 0) { |
|
645 |
- tmp = ' ' + tmp; |
|
646 |
- } |
|
647 |
- else if (format.flags.indexOf('+') >= 0 && arg >= 0) { |
|
648 |
- tmp = '+' + tmp; |
|
649 |
- } |
|
650 |
- tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
651 |
- return tmp; |
|
652 |
- }; |
|
653 |
- known_params["E"] = function (format, arg) { |
|
654 |
- return known_params["e"](format, arg).toUpperCase(); |
|
655 |
- }; |
|
656 |
- known_params["g"] = function (format, arg) { |
|
657 |
- if (!test_arg(format, arg, 'number')) |
|
658 |
- return 'Ø'; |
|
659 |
- var tmpf = known_params["f"](format, arg); |
|
660 |
- var tmpe = known_params["e"](format, arg); |
|
661 |
- if (tmpf.length < tmpe.length) { |
|
662 |
- return tmpf; |
|
663 |
- } |
|
664 |
- else { |
|
665 |
- return tmpe; |
|
666 |
- } |
|
667 |
- }; |
|
668 |
- known_params["G"] = function (format, arg) { |
|
669 |
- return known_params["g"](format, arg).toUpperCase(); |
|
670 |
- }; |
|
671 |
- known_params["s"] = function (format, arg) { |
|
672 |
- if (!test_arg(format, arg, 'string')) |
|
673 |
- return 'o.O'; |
|
674 |
- var tmp = format.precision !== null ? arg.substr(0, format.precision) : arg; |
|
675 |
- tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
676 |
- return tmp; |
|
677 |
- }; |
|
678 |
- known_params["o"] = function (format, arg) { |
|
679 |
- if (!test_arg(format, arg, 'number')) |
|
680 |
- return 'Ø'; |
|
681 |
- var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); |
|
682 |
- return known_params["s"](format, tmp.toString(8)); |
|
683 |
- }; |
|
684 |
- known_params["x"] = function (format, arg) { |
|
685 |
- if (!test_arg(format, arg, 'number')) |
|
686 |
- return 'Ø'; |
|
687 |
- var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); |
|
688 |
- return known_params["s"](format, tmp.toString(16)); |
|
689 |
- }; |
|
690 |
- known_params["a"] = known_params["x"]; |
|
691 |
- known_params["X"] = function (format, arg) { |
|
692 |
- if (!test_arg(format, arg, 'number')) |
|
693 |
- return 'Ø'; |
|
694 |
- return known_params["x"](format, arg).toUpperCase(); |
|
695 |
- }; |
|
696 |
- known_params["A"] = known_params["X"]; |
|
697 |
- known_params["c"] = function (format, arg) { |
|
698 |
- var tmp = ""; |
|
699 |
- if (typeof arg === "number") { |
|
700 |
- tmp = String.fromCharCode(arg); |
|
701 |
- } |
|
702 |
- else if ((typeof arg === "string") && (arg.length === 1)) { |
|
703 |
- tmp = arg[0]; |
|
704 |
- } |
|
705 |
- else { |
|
706 |
- console.warn(make_err(format, arg, "number|string") + " and if string it needs to have the length of 1!"); |
|
707 |
- } |
|
708 |
- return known_params["s"](format, tmp); |
|
709 |
- }; |
|
710 |
- known_params["n"] = function () { |
|
711 |
- return ""; |
|
712 |
- }; |
|
713 |
- var decompose = function (chain, regexp) { |
|
714 |
- var result = regexp.exec(chain); |
|
715 |
- if (result == null) { |
|
716 |
- return null; |
|
717 |
- } |
|
718 |
- else { |
|
719 |
- var front = chain.substring(0, result.index); |
|
720 |
- var back = chain.substring(result.index + result[0].length); |
|
721 |
- return { "front": front, "match": result[0], "back": back }; |
|
722 |
- } |
|
723 |
- }; |
|
724 |
- /** |
|
725 |
- * an implementation of c sprintf |
|
726 |
- * @param {string} string format string |
|
727 |
- * @param {array} args arguments which should be filled into |
|
728 |
- * @returns {string} |
|
729 |
- */ |
|
730 |
- lib_string.sprintf = function (input, args, original) { |
|
731 |
- if (args === void 0) { args = []; } |
|
732 |
- if (original === void 0) { original = null; } |
|
733 |
- if (original == null) |
|
734 |
- original = input; |
|
735 |
- var components = decompose(input, pattern); |
|
736 |
- if (components == null) { |
|
737 |
- if (args.length > 0) { |
|
738 |
- console.warn("[sprintf] superfluous arguments while formatting '" + original + "': ", args); |
|
739 |
- } |
|
740 |
- return input; |
|
741 |
- } |
|
742 |
- else { |
|
743 |
- var arg; |
|
744 |
- var rest; |
|
745 |
- if (args.length > 0) { |
|
746 |
- arg = args[0]; |
|
747 |
- rest = args.slice(1); |
|
748 |
- } |
|
749 |
- else { |
|
750 |
- console.warn("[sprintf] out of arguments while formatting '" + original + "'"); |
|
751 |
- arg = null; |
|
752 |
- rest = []; |
|
753 |
- return input; |
|
754 |
- } |
|
755 |
- var fmt = split_format(components["match"]); |
|
756 |
- return (components["front"] |
|
757 |
- + known_params[fmt.specifier](fmt, arg) |
|
758 |
- + lib_string.sprintf(components["back"], rest, original)); |
|
759 |
- } |
|
760 |
- }; |
|
761 |
- /** |
|
762 |
- * an implementation of c printf |
|
763 |
- * @param {string} string format string |
|
764 |
- * @param {array} args arguments which should be filled into |
|
765 |
- * @returns {string} |
|
766 |
- */ |
|
767 |
- function printf(format, args) { |
|
768 |
- console.log(lib_string.sprintf(format, args)); |
|
769 |
- } |
|
770 |
- lib_string.printf = printf; |
|
771 |
-})(lib_string || (lib_string = {})); |
|
772 |
-var sprintf = lib_string.sprintf; |
|
773 |
-var printf = lib_string.printf; |
|
774 |
-/* |
|
775 |
-This file is part of »bacterio-plankton:string«. |
|
776 |
- |
|
777 |
-Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
778 |
-<info@greenscale.de> |
|
779 |
- |
|
780 |
-»bacterio-plankton:string« is free software: you can redistribute it and/or modify |
|
781 |
-it under the terms of the GNU Lesser General Public License as published by |
|
782 |
-the Free Software Foundation, either version 3 of the License, or |
|
783 |
-(at your option) any later version. |
|
784 |
- |
|
785 |
-»bacterio-plankton:string« is distributed in the hope that it will be useful, |
|
786 |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
787 |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
788 |
-GNU Lesser General Public License for more details. |
|
789 |
- |
|
790 |
-You should have received a copy of the GNU Lesser General Public License |
|
791 |
-along with »bacterio-plankton:string«. If not, see <http://www.gnu.org/licenses/>. |
|
792 |
- */ |
|
793 |
-var make_logger = (function () { |
|
794 |
- var _loggers = {}; |
|
795 |
- var make_logger = function (prefix, current_loglevel) { |
|
796 |
- var log = []; |
|
797 |
- var level = [ |
|
798 |
- "LOG", "INFO", "WARNING", "DEBUG" |
|
799 |
- ]; |
|
800 |
- var logger = function (obj, lvl) { |
|
801 |
- var txt = obj.txt || obj; |
|
802 |
- if (lvl == void 0) |
|
803 |
- lvl = 0; |
|
804 |
- var date = new Date(); |
|
805 |
- log.push({ |
|
806 |
- "message": sprintf("%s [%s:%s] %s", [date.toString(), level[lvl], prefix, txt]), |
|
807 |
- "timeStamp": +(date) |
|
808 |
- }); |
|
809 |
- if (lvl <= current_loglevel) { |
|
810 |
- var msg = ["[" + prefix + "]", txt]; |
|
811 |
- if (obj.arg) |
|
812 |
- msg = ["[" + prefix + "]"].concat(Array.prototype.slice.call(obj.arg)); |
|
813 |
- if (lvl === 0) |
|
814 |
- console["_log"].apply(console, msg); |
|
815 |
- else if (lvl === 1) |
|
816 |
- console["_info"].apply(console, msg); |
|
817 |
- else if (lvl === 2) |
|
818 |
- console["_warn"].apply(console, msg); |
|
819 |
- else if (lvl >= 3) |
|
820 |
- console["_log"].apply(console, msg); |
|
821 |
- } |
|
822 |
- }; |
|
823 |
- _loggers[prefix] = { |
|
824 |
- "logger": logger, |
|
825 |
- "log": log |
|
826 |
- }; |
|
827 |
- return logger; |
|
828 |
- }; |
|
829 |
- make_logger["loggers"] = _loggers; |
|
830 |
- make_logger["complete_log"] = function () { |
|
831 |
- var logs = Object.keys(_loggers) |
|
832 |
- .reduce(function (p, c) { |
|
833 |
- return [].concat(p, _loggers[c].log); |
|
834 |
- }, []); |
|
835 |
- logs.sort(function (x, y) { |
|
836 |
- return ((x.timeStamp > y.timeStamp) ? -1 : +1); |
|
837 |
- }); |
|
838 |
- return logs.map(function (x, i, a) { |
|
839 |
- return x.message; |
|
840 |
- }); |
|
841 |
- }; |
|
842 |
- if ( /*!track_exports*/true) { |
|
843 |
- var _log_all = function (log, lvl, next) { |
|
844 |
- if (next === void 0) { next = function () { }; } |
|
845 |
- return function () { |
|
846 |
- var msg = []; |
|
847 |
- for (var i = 0; i < arguments.length; i++) { |
|
848 |
- if (typeof arguments[i] === "string") { |
|
849 |
- msg.push(arguments[i]); |
|
850 |
- } |
|
851 |
- else { |
|
852 |
- msg.push(JSON.stringify(arguments[i])); |
|
853 |
- } |
|
854 |
- } |
|
855 |
- var obj = { |
|
856 |
- txt: msg.join("\t"), |
|
857 |
- arg: arguments |
|
858 |
- }; |
|
859 |
- log(obj, lvl); |
|
860 |
- next(); |
|
861 |
- }; |
|
862 |
- }; |
|
863 |
- { |
|
864 |
- var __warn = make_logger("deprecated console.warn", 99); |
|
865 |
- var __error = make_logger("deprecated console.error", 99); |
|
866 |
- var __log = make_logger("deprecated console.log", 99); |
|
867 |
- var __info = make_logger("deprecated console.info", 99); |
|
868 |
- // bad ass |
|
869 |
- console["_log"] = console.log; |
|
870 |
- console["_error"] = console.error; |
|
871 |
- console["_warn"] = console.warn; |
|
872 |
- console["_info"] = console.info; |
|
873 |
- /* |
|
874 |
- console["log"] = _log_all(__log, 0); |
|
875 |
- console["error"] = _log_all(__error, 2); |
|
876 |
- console["warn"] = _log_all(__warn, 2); |
|
877 |
- console["info"] = _log_all(__info, 0); |
|
878 |
- */ |
|
879 |
- } |
|
880 |
- /* |
|
881 |
- { |
|
882 |
- make_logger["send_log"] = function(){ |
|
883 |
- eml_log( |
|
884 |
- function () { |
|
885 |
- alert("fehlerbericht wurde gesendet!"); |
|
886 |
- } |
|
887 |
- ); |
|
888 |
- }; |
|
889 |
- var error_log = make_logger("global.error", 99); |
|
890 |
- window.onerror = _log_all( |
|
891 |
- error_log, |
|
892 |
- 1, |
|
893 |
- function(){ |
|
894 |
- if (global_config == undefined) { |
|
895 |
- return false; |
|
896 |
- } |
|
897 |
- if (global_config.report_error) { |
|
898 |
- make_logger["send_log"](); |
|
899 |
- } |
|
900 |
- } |
|
901 |
- ); |
|
902 |
- } |
|
903 |
- */ |
|
904 |
- } |
|
905 |
- return make_logger; |
|
906 |
-})(); |
|
907 | 0 |