diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index 5051ea6..91457ef 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -1,11 +1,11 @@ /** * @author fenris */ -type int = number; +declare type int = number; /** * @author fenris */ -type float = number; +declare type float = number; declare class Buffer { constructor(x: string, modifier?: string); toString(modifier?: string): string; @@ -19,7 +19,7 @@ declare namespace lib_plankton.base { /** * @author fenris */ -type type_pseudopointer = { +declare type type_pseudopointer = { value: type_value; }; /** @@ -1969,7 +1969,7 @@ declare namespace lib_plankton.storage.memory { clear(): Promise; write(key: any, value: any): Promise; delete(key: any): Promise; - read(key: any): Promise>; + read(key: any): Promise; search(term: any): Promise<{ key: string; preview: string; @@ -2037,6 +2037,513 @@ declare namespace lib_plankton.storage.localstorage { }[]>; } } +declare namespace lib_plankton.shape { + /** + * @todo + */ + type type_jsonschema = any; + /** + * @todo + */ + type type_oas_schema = any; + /** + * @author fenris + */ + type type_inspection = { + flaws: Array; + sub: Array<{ + position: string; + inspection: type_inspection; + }>; + }; + /** + * @author fenris + */ + function inspection_create(): type_inspection; + /** + * @author fenris + */ + function inspection_add(main: type_inspection, flaw: string): void; + /** + * @author fenris + */ + function inspection_extend(main: type_inspection, prefix: string, sub: type_inspection): void; + /** + */ + type type_shape = { + kind: string; + parameters: Record; + }; + /** + * @author fenris + */ + type type_logic = { + inspect: ((sub_inspect: ((shape: type_shape, value: any) => type_inspection), value: any) => type_inspection); + show: ((sub_show: ((shape: type_shape) => string)) => string); + to_typescript_type: ((sub_to_typescript_type: ((shape: type_shape) => string)) => string); + to_jsonschema: ((sub_to_json_schema: ((shape: type_shape) => type_jsonschema)) => type_jsonschema); + to_oas_schema: ((sub_to_oas_schema: ((shape: type_shape) => type_oas_schema)) => type_oas_schema); + example: ((sub_example: ((shape: type_shape) => any)) => any); + }; + /** + */ + function inspect(shape: type_shape, value: any): type_inspection; + /** + */ + function inspect_flat(shape: type_shape, value: any): Array; + /** + */ + function show(shape: type_shape): string; + /** + */ + function to_typescript_type(shape: type_shape): string; + /** + */ + function to_jsonschema(shape: type_shape): type_jsonschema; + /** + */ + function to_oas_schema(shape: type_shape): type_oas_schema; + /** + */ + function example(shape: type_shape): any; + /** + */ + function register(name: string, construct: ((parameters: type_parameters) => type_subject), logic: ((subject: type_subject) => type_logic)): void; +} +declare namespace lib_plankton.shape.any { + /** + */ + type type_subject = {}; + /** + */ + export function make(options?: {}): type_subject; + export {}; +} +declare namespace lib_plankton.shape.null_ { + /** + */ + type type_subject = {}; + /** + */ + export function make(options?: {}): type_subject; + export {}; +} +declare namespace lib_plankton.shape.boolean { + /** + */ + type type_subject = { + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | boolean); + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.integer { + /** + */ + type type_subject = { + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + minimum: lib_plankton.pod.type_pod; + maximum: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | int); + description?: string; + minimum?: int; + maximum?: int; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.float { + /** + */ + type type_subject = { + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + minimum: lib_plankton.pod.type_pod; + maximum: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | float); + description?: string; + minimum?: float; + maximum?: float; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.string { + /** + */ + type type_subject = { + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + pattern: lib_plankton.pod.type_pod; + min_length: lib_plankton.pod.type_pod; + max_length: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | int); + description?: string; + pattern?: string; + min_length?: int; + max_length?: int; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.email { + /** + */ + type type_subject = { + core: type_shape; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | int); + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.list_ { + /** + */ + type type_subject = { + shape_element: type_shape; + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(shape_element: type_shape, options?: { + soft?: boolean; + defaultvalue?: any; + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.map { + /** + */ + type type_subject = { + shape_key: type_shape; + shape_value: type_shape; + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(shape_key: type_shape, shape_value: type_shape, options?: { + soft?: boolean; + defaultvalue?: any; + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.record { + /** + */ + type type_field = { + name: string; + shape: type_shape; + required: boolean; + }; + /** + */ + type type_subject = { + fields: Array; + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(fields_raw: Array<{ + name: string; + shape: type_shape; + required?: boolean; + }>, options?: { + soft?: boolean; + defaultvalue?: any; + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.www_form { + /** + */ + type type_source = Record; + /** + */ + type type_target = string; + /** + * @author fenris + */ + function encode(source: type_source): type_target; + /** + * @author fenris + */ + function decode(target: type_target): type_source; +} +declare namespace lib_plankton.www_form { + /** + * @author fenris + */ + class class_www_form implements lib_plankton.code.interface_code { + /** + * @author fenris + */ + constructor(); + /** + * @implementation + * @author fenris + */ + encode(source: type_source): type_target; + /** + * @implementation + * @author fenris + */ + decode(target: type_target): type_source; + } +} +declare namespace lib_plankton.url { + /** + * @author fenris + */ + type type_url = { + scheme: (null | string); + host: (null | string); + username: (null | string); + password: (null | string); + port: (null | int); + path: (null | string); + query: (null | string); + hash: (null | string); + }; +} +declare namespace lib_plankton.url { + /** + * @author fenris + */ + function encode(url: type_url): string; + /** + * @author fenris + * @todo arguments + */ + function decode(url_raw: string): type_url; + /** + * @author fenris + */ + function implementation_code(): lib_plankton.code.type_code; +} +declare namespace lib_plankton.url { + /** + * @author fenris + */ + class class_url implements lib_plankton.code.interface_code { + /** + * @author fenris + */ + constructor(); + /** + * @implementation + * @author fenris + */ + encode(x: any): string; + /** + * @implementation + * @author fenris + */ + decode(x: string): any; + } +} +declare namespace lib_plankton.random { + /** + * @author fenris + */ + type type_state = { + builtin: boolean; + seed?: int; + }; + /** + * @author fenris + */ + function state_push(state: type_state): void; + /** + * @author fenris + */ + function state_pop(): type_state; + /** + * returns a random floating point number in the interval [0,1[ + * + * @author fenris + */ + function generate_unit(): float; + /** + * returns a random boolean value + * + * @param {float} [probability] the probability for the return-value "true"; default: 0.5 + * @author fenris + */ + function generate_boolean(options?: { + probability?: float; + }): boolean; + /** + * returns a random integer number in the interval [a,b] + * + * @param {int} [minimum] the left side of the halfopen interval (i.e. the smallest included value in the range) + * @param {int} [minimum] the right side of the halfopen interval (i.e. the smallest excluded value in the range) + * @author fenris + */ + function generate_integer(options?: { + minimum?: int; + maximum?: int; + }): int; + var generate_int: typeof generate_integer; + /** + * returns a random floating point number in the given interval + * + * @author fenris + */ + function generate_float(options?: { + minimum?: int; + maximum?: int; + }): float; + /** + * returns a random date + * + * @author fenris + */ + function generate_date(options?: { + minimum?: Date; + maximum?: Date; + }): Date; + /** + * @author fenris + */ + function generate_hexdigit(): string; + /** + * generates a random string with an optional prefix + * + * @author fenris + */ + function generate_string(options?: { + length?: int; + }): string; + /** + * chooses a value randomly from a list of values with weights (a higher weight means a higher probability to be chosen) + * + * @author fenris + */ + function choose_weighted(sets: Array<{ + weight: float; + value: type_value; + }>): type_value; + /** + * chooses a value randomly from a list of values with equal probabilities + * + * @author fenris + */ + function choose_uniformly(values: Array): type_value; + /** + * @author fenris + */ + function shuffle(list: Array): Array; + /** + * @author fenris + */ + function generate_vowel(): string; + /** + * @author fenris + */ + function generate_halfvowel(): string; + /** + * @author fenris + */ + function generate_consonant(): string; + /** + * @author fenris + */ + function generate_letter(): string; + /** + * @author fenris + */ + function generate_syllable(): string; + /** + * @author fenris + */ + function generate_word(options?: { + syllable_count_minimum?: int; + syllable_count_maximum?: int; + }): string; + /** + * @author fenris + */ + function generate_text(options?: { + word_count?: int; + }): string; + /** + * @author fenris + */ + function generate_city(): string; + /** + * @author fenris + */ + function generate_street(): string; + /** + * @author fenris + */ + function generate_guid(options?: { + with_braces?: boolean; + }): string; + /** + * @author fenris + */ + function generate_url(): string; + /** + * @author fenris + */ + function generate_email_address(): string; + /** + * @author fenris + */ + function generate_telephone_number(): string; + /** + * @author fenris + */ + function generate_time(): any; + /** + * @author fenris + * @deprecated + * @todo remove + */ + function generate_for_shape(shape: any): any; + /** + * @author fenris + */ +} declare namespace lib_plankton.map { /** */ @@ -2775,6 +3282,9 @@ declare namespace lib_plankton.color { /** */ function make_rgb(model_rgb: type_model_rgb): type_color; + /** + */ + function from_hex(hex: string): type_color; /** */ function to_hsv(color: type_color): type_model_hsv; @@ -3033,57 +3543,6 @@ declare namespace lib_plankton.http { implementation?: ("fetch" | "http_module"); }): Promise; } -declare namespace lib_plankton.url { - /** - * @author fenris - */ - type type_url = { - scheme: (null | string); - host: (null | string); - username: (null | string); - password: (null | string); - port: (null | int); - path: (null | string); - query: (null | string); - hash: (null | string); - }; -} -declare namespace lib_plankton.url { - /** - * @author fenris - */ - function encode(url: type_url): string; - /** - * @author fenris - * @todo arguments - */ - function decode(url_raw: string): type_url; - /** - * @author fenris - */ - function implementation_code(): lib_plankton.code.type_code; -} -declare namespace lib_plankton.url { - /** - * @author fenris - */ - class class_url implements lib_plankton.code.interface_code { - /** - * @author fenris - */ - constructor(); - /** - * @implementation - * @author fenris - */ - encode(x: any): string; - /** - * @implementation - * @author fenris - */ - decode(x: string): any; - } -} declare namespace lib_plankton.pit { /** */ @@ -3257,43 +3716,6 @@ declare namespace lib_plankton.pit { omit_date?: boolean; }): string; } -declare namespace lib_plankton.www_form { - /** - */ - type type_source = Record; - /** - */ - type type_target = string; - /** - * @author fenris - */ - function encode(source: type_source): type_target; - /** - * @author fenris - */ - function decode(target: type_target): type_source; -} -declare namespace lib_plankton.www_form { - /** - * @author fenris - */ - class class_www_form implements lib_plankton.code.interface_code { - /** - * @author fenris - */ - constructor(); - /** - * @implementation - * @author fenris - */ - encode(source: type_source): type_target; - /** - * @implementation - * @author fenris - */ - decode(target: type_target): type_source; - } -} declare namespace lib_plankton.translate { /** * @author fenris @@ -3436,6 +3858,191 @@ declare namespace lib_plankton.zoo_page { export function start(): void; export {}; } +declare namespace lib_plankton.zoo_widget { + /** + */ + interface interface_widget { + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_empty implements interface_widget { + /** + */ + constructor(); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_string implements interface_widget { + /** + */ + private content; + /** + */ + constructor(content: string); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_link implements interface_widget { + /** + */ + private target; + /** + */ + private text; + /** + */ + private open_in_new_tab; + /** + */ + constructor(target: string, { "text": text, "open_in_new_tab": open_in_new_tab, }?: { + text?: (null | string); + open_in_new_tab?: boolean; + }); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_text implements interface_widget { + /** + */ + private paragraphs; + /** + */ + constructor(paragraphs: Array); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_list implements interface_widget { + /** + */ + private elements; + /** + */ + constructor(elements: Array); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel implements interface_widget { + /** + */ + private content; + /** + */ + private collapseable; + /** + */ + private collapsed_initial_value; + /** + */ + private classes; + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel_info extends class_panel { + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel_warning extends class_panel { + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel_error extends class_panel { + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel_success extends class_panel { + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_bunch implements interface_widget { + /** + */ + private elements; + /** + */ + constructor(elements: Array); + /** + */ + load(target_element: HTMLElement): Promise; + } +} declare namespace lib_plankton.zoo_input { /** * @author fenris @@ -3889,12 +4496,31 @@ declare namespace lib_plankton.zoo_input { * @author fenris */ class class_input_password implements interface_input { + /** + */ + private exhibit; + /** + */ + private character_hide; + /** + */ + private character_show; /** */ private dom_input; /** */ - constructor(); + private dom_exhibit; + /** + */ + constructor({ "exhibit_initial_value": exhibit_initial_value, "character_hide": character_hide, "character_show": character_show, }?: { + exhibit_initial_value?: boolean; + character_hide?: string; + character_show?: string; + }); + /** + */ + private toggle_exhibition; /** * [implementation] */ @@ -3976,7 +4602,7 @@ declare namespace lib_plankton.zoo_input { name: string; input: interface_input; label?: (null | string); - help?: (null | string); + help?: (null | lib_plankton.zoo_widget.interface_widget); }>); /** * [implementation] @@ -4069,6 +4695,39 @@ declare namespace lib_plankton.zoo_input { write(value: lib_plankton.pit.type_datetime): Promise; } } +declare namespace lib_plankton.zoo_input { + /** + */ + class class_input_color implements interface_input<(null | lib_plankton.color.type_color)> { + /** + */ + private dom_input; + /** + */ + constructor(); + /** + * [implementation] + */ + setup(parent: HTMLElement): Promise; + /** + * [implementation] + */ + read(): Promise<(null | lib_plankton.color.type_color)>; + /** + * [implementation] + */ + write(value: (null | lib_plankton.color.type_color)): Promise; + } +} +declare namespace lib_plankton.zoo_input { + /** + */ + class class_input_hue extends class_input_wrapped<(null | lib_plankton.color.type_color), (null | float)> implements interface_input<(null | float)> { + /** + */ + constructor(); + } +} declare namespace lib_plankton.zoo_form { /** */ diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index e04b6f9..6ff86ef 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -2151,7 +2151,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -5781,6 +5781,2455 @@ var lib_plankton; })(storage = lib_plankton.storage || (lib_plankton.storage = {})); })(lib_plankton || (lib_plankton = {})); /* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_1) { + /** + * @author fenris + */ + function inspection_create() { + return { + "flaws": [], + "sub": [] + }; + } + shape_1.inspection_create = inspection_create; + /** + * @author fenris + */ + function inspection_add(main, flaw) { + main.flaws.push(flaw); + } + shape_1.inspection_add = inspection_add; + /** + * @author fenris + */ + function inspection_extend(main, prefix, sub) { + if ((sub.flaws.length <= 0) + && + (sub.sub.length <= 0)) { + // do nothing + } + else { + main.sub.push({ "position": prefix, "inspection": sub }); + } + } + shape_1.inspection_extend = inspection_extend; + /** + */ + function inspection_flatten(inspection) { + return (inspection.flaws + .concat(inspection.sub + .map((entry) => (inspection_flatten(entry.inspection) + .map(rest => lib_plankton.string.coin("[{{position}}] {{rest}}", { + "position": entry.position, + "rest": rest + })))) + .reduce((x, y) => x.concat(y), []))); + } + /** + */ + var _pool = {}; + /** + * @todo cache + */ + function construct(shape) { + return _pool[shape.kind].construct(shape.parameters); + } + /** + */ + function get_logic(shape) { + if (!(shape.kind in _pool)) { + throw (new Error("missing shape: " + shape.kind)); + } + else { + return _pool[shape.kind].logic(construct(shape)); + } + } + /** + */ + function inspect(shape, value) { + return get_logic(shape).inspect(inspect, value); + } + shape_1.inspect = inspect; + /** + */ + function inspect_flat(shape, value) { + return inspection_flatten(inspect(shape, value)); + } + shape_1.inspect_flat = inspect_flat; + /** + */ + function show(shape) { + return get_logic(shape).show(show); + } + shape_1.show = show; + /** + */ + function to_typescript_type(shape) { + return get_logic(shape).to_typescript_type(to_typescript_type); + } + shape_1.to_typescript_type = to_typescript_type; + /** + */ + function to_jsonschema(shape) { + return get_logic(shape).to_jsonschema(to_jsonschema); + } + shape_1.to_jsonschema = to_jsonschema; + /** + */ + function to_oas_schema(shape) { + return get_logic(shape).to_oas_schema(to_oas_schema); + } + shape_1.to_oas_schema = to_oas_schema; + /** + */ + function example(shape) { + return get_logic(shape).example(example); + } + shape_1.example = example; + /** + */ + function register(name, construct, logic) { + _pool[name] = { + "construct": construct, + "logic": logic, + }; + } + shape_1.register = register; + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_2) { + var any; + (function (any) { + /** + */ + function make(options = {}) { + return {}; + } + any.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_2.inspection_create(); + return inspection; + } + /** + */ + function show(sub_show, subject) { + return "any"; + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + return "any"; + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + return {}; + } + /** + */ + function example(sub_example, subject) { + return null; + } + shape_2.register("any", (parameters) => make({}), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(any = shape_2.any || (shape_2.any = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_3) { + var null_; + (function (null_) { + /** + */ + function make(options = {}) { + return {}; + } + null_.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_3.inspection_create(); + if (!(value === null)) { + shape_3.inspection_add(inspection, "null expected"); + } + else { + // all good + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + return "null"; + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + return "null"; + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + return { + "type": "null", + }; + } + /** + */ + function example(sub_example, subject) { + return null; + } + shape_3.register("null", (parameters) => make({}), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(null_ = shape_3.null_ || (shape_3.null_ = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_4) { + var boolean; + (function (boolean) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + }, options); + return { + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + }; + } + boolean.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_4.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_4.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "boolean"; + if (jstype_actual === jstype_expected) { + // all good + } + else { + shape_4.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = "boolean"; + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = "boolean"; + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "boolean", + }; + return (subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ], + } + : core); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft ? null : false); + } + shape_4.register("boolean", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(boolean = shape_4.boolean || (shape_4.boolean = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_5) { + var integer; + (function (integer) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + "minimum": undefined, + "maximum": undefined, + }, options); + return { + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + "minimum": ((options.minimum === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.minimum)), + "maximum": ((options.minimum === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.maximum)), + }; + } + integer.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_5.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_5.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "number"; + if (!(jstype_actual === jstype_expected)) { + shape_5.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + else { + if (isNaN(parseInt(value))) { + shape_5.inspection_add(inspection, "value is not parsable to a valid int"); + } + else { + // minimum + { + if (!lib_plankton.pod.distinguish(subject.minimum, () => true, x => (value >= x))) { + shape_5.inspection_add(inspection, lib_plankton.string.coin("value is below the minimum of '{{minimum}}'", { + "minimum": lib_plankton.pod.cull(subject.minimum).toFixed(0), + })); + } + else { + // do nothing + } + } + // maximum + { + if (!lib_plankton.pod.distinguish(subject.maximum, () => true, x => (value <= x))) { + shape_5.inspection_add(inspection, lib_plankton.string.coin("value is beyond the maximum of '{{maximum}}'", { + "maximum": lib_plankton.pod.cull(subject.maximum).toFixed(0), + })); + } + else { + // do nothing + } + } + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = "integer"; + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = "number"; + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "integer", + "minimum": lib_plankton.pod.distinguish(subject.minimum, () => undefined, x => x), + "maximum": lib_plankton.pod.distinguish(subject.maximum, () => undefined, x => x), + }; + return (subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ], + } + : core); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft ? null : 0); + } + shape_5.register("integer", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + "minimum": parameters.minimum, + "maximum": parameters.maximum, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(integer = shape_5.integer || (shape_5.integer = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_6) { + var float; + (function (float) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + "minimum": undefined, + "maximum": undefined, + }, options); + return { + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + "minimum": ((options.minimum === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.minimum)), + "maximum": ((options.minimum === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.maximum)), + }; + } + float.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_6.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_6.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "number"; + if (!(jstype_actual === jstype_expected)) { + shape_6.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + else { + if (isNaN(parseInt(value))) { + shape_6.inspection_add(inspection, "value is not parsable to a valid float"); + } + else { + // minimum + { + if (!lib_plankton.pod.distinguish(subject.minimum, () => true, x => (value >= x))) { + shape_6.inspection_add(inspection, lib_plankton.string.coin("value is below the minimum of '{{minimum}}'", { + "minimum": lib_plankton.pod.cull(subject.minimum).toFixed(0), + })); + } + else { + // do nothing + } + } + // maximum + { + if (!lib_plankton.pod.distinguish(subject.maximum, () => true, x => (value <= x))) { + shape_6.inspection_add(inspection, lib_plankton.string.coin("value is beyond the maximum of '{{maximum}}'", { + "maximum": lib_plankton.pod.cull(subject.maximum).toFixed(0), + })); + } + else { + // do nothing + } + } + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = "float"; + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = "number"; + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "float", + "minimum": lib_plankton.pod.distinguish(subject.minimum, () => undefined, x => x), + "maximum": lib_plankton.pod.distinguish(subject.maximum, () => undefined, x => x), + }; + return (subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ], + } + : core); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft ? null : 0); + } + shape_6.register("float", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + "minimum": parameters.minimum, + "maximum": parameters.maximum, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(float = shape_6.float || (shape_6.float = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_7) { + var string; + (function (string) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + "pattern": undefined, + "min_length": undefined, + "max_lenth": undefined, + }, options); + return { + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + "pattern": ((options.pattern === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.pattern)), + "min_length": ((options.min_length === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.min_length)), + "max_length": ((options.max_length === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.max_length)), + }; + } + string.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_7.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_7.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "string"; + if (!(jstype_actual === jstype_expected)) { + shape_7.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + else { + const value_ = value; + // pattern + { + if (!lib_plankton.pod.distinguish(subject.pattern, () => true, x => (new RegExp(x)).test(value_))) { + shape_7.inspection_add(inspection, lib_plankton.string.coin("string does not match the pattern '{{pattern}}'", { + "pattern": lib_plankton.pod.cull(subject.pattern), + })); + } + else { + // do nothing + } + } + // min_length + { + if (!lib_plankton.pod.distinguish(subject.min_length, () => true, x => (value_.length >= x))) { + shape_7.inspection_add(inspection, lib_plankton.string.coin("string is shorter than '{{min_length}}'", { + "min_length": lib_plankton.pod.cull(subject.min_length).toFixed(0), + })); + } + else { + // do nothing + } + } + // max_length + { + if (!lib_plankton.pod.distinguish(subject.max_length, () => true, x => (value_.length <= x))) { + shape_7.inspection_add(inspection, lib_plankton.string.coin("string is longer than '{{max_length}}'", { + "min_length": lib_plankton.pod.cull(subject.max_length).toFixed(0), + })); + } + else { + // do nothing + } + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = "string"; + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = "string"; + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "string", + // TODO: transform? + "pattern": lib_plankton.pod.distinguish(subject.pattern, () => undefined, x => x), + "minLength": lib_plankton.pod.distinguish(subject.min_length, () => undefined, x => x), + "maxLenth": lib_plankton.pod.distinguish(subject.max_length, () => undefined, x => x), + }; + return (subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ], + } + : core); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft ? null : ""); + } + shape_7.register("string", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + "pattern": parameters.pattern, + "min_length": parameters.min_length, + "max_length": parameters.max_length, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_chema) => to_jsonschema(sub_to_oas_chema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(string = shape_7.string || (shape_7.string = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_8) { + var email; + (function (email) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + }, options); + return { + "core": { + "kind": "string", + "parameters": { + "soft": options.soft, + "defaultvalue": options.defaultvalue, + "description": options.description, + "pattern": "[^@]*@[^@]*", + "min_length": 0, + "max_length": 255, + } + }, + }; + } + email.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + return sub_inspect(subject.core, value); + } + /** + */ + function show(sub_show, subject) { + return sub_show(subject.core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + return sub_to_typescript_type(subject.core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + return sub_to_jsonschema(subject.core); + } + /** + */ + function example(sub_example, subject) { + return sub_example(subject.core); + } + shape_8.register("email", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_chema) => to_jsonschema(sub_to_oas_chema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(email = shape_8.email || (shape_8.email = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_9) { + var list_; + (function (list_) { + /** + */ + function make(shape_element, options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": lib_plankton.pod.make_empty(), + "description": lib_plankton.pod.make_empty(), + }, options); + return { + "shape_element": shape_element, + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + }; + } + list_.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_9.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_9.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "object"; + if (!(jstype_actual === jstype_expected)) { + lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + }); + } + else { + if (!(value instanceof Array)) { + shape_9.inspection_add(inspection, "value does not seem to be an array-instance"); + } + else { + value.forEach((element, index) => { + shape_9.inspection_extend(inspection, lib_plankton.string.coin("element #{{index}}", { + "index": index.toFixed(0), + }), + // subject.shape_element.inspect(element) + sub_inspect(subject.shape_element, element)); + }); + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = lib_plankton.string.coin("list<{{element}}>", { + "element": sub_show(subject.shape_element), + }); + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = lib_plankton.string.coin("Array<{{element}}>", { + "element": sub_to_typescript_type(subject.shape_element), + }); + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "array", + "items": sub_to_jsonschema(subject.shape_element), + }; + return ((subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ] + } + : core)); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft + ? null + : [ + sub_example(subject.shape_element) + ]); + } + shape_9.register("list", (parameters) => make(parameters.shape_element, { + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(list_ = shape_9.list_ || (shape_9.list_ = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_10) { + var map; + (function (map) { + /** + */ + function make(shape_key, shape_value, options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": lib_plankton.pod.make_empty(), + "description": lib_plankton.pod.make_empty(), + }, options); + return { + "shape_key": shape_key, + "shape_value": shape_value, + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + }; + } + map.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_10.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_10.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "object"; + if (!(jstype_actual === jstype_expected)) { + lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + }); + } + else { + Object.entries(value) + .forEach(([key, value]) => { + shape_10.inspection_extend(inspection, lib_plankton.string.coin("key '{{key}}'", { + "key": String(key), + }), sub_inspect(subject.shape_key, key)); + shape_10.inspection_extend(inspection, lib_plankton.string.coin("value for '{{key}}'", { + "key": String(key), + }), sub_inspect(subject.shape_value, value)); + }); + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = lib_plankton.string.coin("map<{{key}},{{value}}>", { + "key": sub_show(subject.shape_key), + "value": sub_show(subject.shape_value), + }); + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = lib_plankton.string.coin("Record<{{key}},{{value}}>", { + "key": sub_to_typescript_type(subject.shape_key), + "value": sub_to_typescript_type(subject.shape_key), + }); + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "object", + "additionalProperties": sub_to_jsonschema(subject.shape_value), + "properties": {}, + "required": [], + }; + return ((subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ] + } + : core)); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft + ? null + : {}); + } + shape_10.register("map", (parameters) => make(parameters.shape_key, parameters.shape_value, { + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(map = shape_10.map || (shape_10.map = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:shape« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_11) { + var record; + (function (record) { + /** + */ + function make(fields_raw, options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": lib_plankton.pod.make_empty(), + "description": lib_plankton.pod.make_empty(), + }, options); + return { + "fields": fields_raw.map(field_raw => ({ + "name": field_raw.name, + "shape": field_raw.shape, + "required": (field_raw.required ?? true) + })), + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + }; + } + record.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_11.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_11.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "object"; + if (!(jstype_actual === jstype_expected)) { + shape_11.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + else { + subject.fields.forEach(field => { + if (!(field.name in value)) { + if (field.required) { + shape_11.inspection_add(inspection, "missing field '" + field.name + "'"); + } + else { + // do nothing + } + } + else { + const value_ = value[field.name]; + shape_11.inspection_extend(inspection, ("field '" + field.name + "'"), sub_inspect(field.shape, value_)); + } + }); + // extra fields + { + const allowed = subject.fields.map(field => field.name); + (Object.keys(value) + .filter(name => (!allowed.includes(name))) + .forEach(name => { + shape_11.inspection_add(inspection, "extra field '" + name + "'"); + })); + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = lib_plankton.string.coin("record<{{fields}}>", { + "fields": (subject.fields + .map(field => lib_plankton.string.coin("{{prefix}}{{name}}:{{shape}}", { + "prefix": (field.required ? "" : "?"), + "name": field.name, + "shape": sub_show(field.shape), + })) + .join(",")), + }); + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = lib_plankton.string.coin("{{{fields}}}", { + "fields": (subject.fields + .map(field => lib_plankton.string.coin("{{name}}{{infix}}{{shape}}", { + "name": field.name, + "infix": (field.required ? ":" : "?:"), + "shape": sub_to_typescript_type(field.shape), + })) + .join(";")), + }); + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "object", + "additionalProperties": false, + "properties": (Object.fromEntries(subject.fields + .map(field => ([ + field.name, + sub_to_jsonschema(field.shape) + ])))), + "required": (subject.fields + .filter(field => field.required) + .map(field => field.name)), + }; + return ((subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ] + } + : core)); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft + ? null + : (Object.fromEntries(subject.fields + .filter(field => field.required) + .map(field => ([ + field.name, + sub_example(field.shape) + ]))))); + } + shape_11.register("record", (parameters) => make((parameters.fields + .map(field_raw => ({ + "name": field_raw.name, + "shape": field_raw.shape, + "required": field_raw.required, + }))), { + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(record = shape_11.record || (shape_11.record = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:www_form«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:www_form« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:www_form« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:www_form«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var www_form; + (function (www_form) { + /** + * @author fenris + */ + function encode(source) { + return (Object.entries(source) + .map(function (_a) { + var key = _a[0], value = _a[1]; + return (key + "=" + encodeURIComponent(value)); + }) + .join("&")); + } + www_form.encode = encode; + /** + * @author fenris + */ + function decode(target) { + return (Object.fromEntries(target.split("&") + .map(function (part) { + var components = part.split("="); + var key = components[0]; + var value = decodeURIComponent(components.slice(1).join("=")); + return [key, value]; + }))); + } + www_form.decode = decode; + })(www_form = lib_plankton.www_form || (lib_plankton.www_form = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:www_form«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:www_form« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:www_form« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:www_form«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var www_form; + (function (www_form) { + /** + * @author fenris + */ + var class_www_form = /** @class */ (function () { + /** + * @author fenris + */ + function class_www_form() { + } + /** + * @implementation + * @author fenris + */ + class_www_form.prototype.encode = function (source) { + return www_form.encode(source); + }; + /** + * @implementation + * @author fenris + */ + class_www_form.prototype.decode = function (target) { + return www_form.decode(target); + }; + return class_www_form; + }()); + www_form.class_www_form = class_www_form; + })(www_form = lib_plankton.www_form || (lib_plankton.www_form = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:url«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:url« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:url« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:url«. If not, see . + */ +/* +This file is part of »bacterio-plankton:url«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:url« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:url« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:url«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var url; + (function (url_1) { + /** + * @author fenris + */ + function encode(url) { + let result = ""; + // scheme + { + if (url.scheme !== null) { + result += (url.scheme + ":"); + } + } + // host + { + if (url.host !== null) { + result += "//"; + // username + { + if (url.username !== null) { + result += url.username; + // password + { + if (url.password !== null) { + result += (":" + url.password); + } + } + result += "@"; + } + } + result += url.host; + } + } + // port + { + if (url.port !== null) { + result += (":" + url.port.toString()); + } + } + // path + { + if (url.path !== null) { + result += url.path; + } + } + // query + { + if (url.query !== null) { + result += ("?" + url.query); + } + } + // hash + { + if (url.hash !== null) { + result += ("#" + url.hash); + } + } + return result; + } + url_1.encode = encode; + /** + * @author fenris + * @todo arguments + */ + function decode(url_raw) { + const builtin_url = new URL(url_raw); + return { + "scheme": builtin_url.protocol.slice(0, -1), + "host": builtin_url.hostname, + "username": ((builtin_url.username !== "") + ? + builtin_url.username + : + null), + "password": ((builtin_url.password !== "") + ? + builtin_url.password + : + null), + "port": ((builtin_url.port !== "") + ? + parseInt(builtin_url.port) + : + null), + "path": builtin_url.pathname, + "query": builtin_url.search.slice(1), + "hash": ((builtin_url.hash !== "") + ? + builtin_url.hash.slice(1) + : + null), + }; + } + url_1.decode = decode; + /** + * @author fenris + */ + function implementation_code() { + return { + "encode": encode, + "decode": decode, + }; + } + url_1.implementation_code = implementation_code; + })(url = lib_plankton.url || (lib_plankton.url = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:url«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:url« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:url« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:url«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var url; + (function (url) { + /** + * @author fenris + */ + class class_url { + /** + * @author fenris + */ + constructor() { + } + /** + * @implementation + * @author fenris + */ + encode(x) { + return url.encode(x); + } + /** + * @implementation + * @author fenris + */ + decode(x) { + return url.decode(x); + } + } + url.class_url = class_url; + })(url = lib_plankton.url || (lib_plankton.url = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:random«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:random« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:random« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:random«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var random; + (function (random) { + /** + * @author fenris + */ + function sequence(n) { + return ((n <= 0) ? [] : sequence(n - 1).concat([n - 1])); + } + /** + * @author fenris + */ + function interpolate(x, y, t) { + return (((1 - t) * x) + (t * y)); + } + /** + * @author fenris + */ + var _statestack = [ + { + "builtin": true, + "seed": Date.now() + }, + ]; + /** + * @author fenris + */ + function state_get() { + return _statestack[_statestack.length - 1]; + } + /** + * @author fenris + */ + function state_push(state) { + _statestack.push(state); + } + random.state_push = state_push; + /** + * @author fenris + */ + function state_pop() { + if (_statestack.length <= 1) { + throw (new Error("no state to pop")); + } + else { + return _statestack.pop(); + } + } + random.state_pop = state_pop; + /** + * @author fenris + */ + function seed_tick() { + var state = state_get(); + state.seed = ((state.seed << 8) % 99767); + } + /** + * @author fenris + */ + function seed_get(tick) { + if (tick === void 0) { tick = true; } + if (tick) { + seed_tick(); + } + else { + // do nothing + } + return state_get().seed; + } + /** + * returns a random floating point number in the interval [0,1[ + * + * @author fenris + */ + function generate_unit() { + if (state_get().builtin) { + return Math.random(); + } + else { + return ((Math.sin(seed_get() << 8) + 1) / 2); + } + } + random.generate_unit = generate_unit; + /** + * returns a random boolean value + * + * @param {float} [probability] the probability for the return-value "true"; default: 0.5 + * @author fenris + */ + function generate_boolean(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "probability": 0.5 + }, options); + return (generate_unit() < options.probability); + } + random.generate_boolean = generate_boolean; + /** + * returns a random integer number in the interval [a,b] + * + * @param {int} [minimum] the left side of the halfopen interval (i.e. the smallest included value in the range) + * @param {int} [minimum] the right side of the halfopen interval (i.e. the smallest excluded value in the range) + * @author fenris + */ + function generate_integer(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "minimum": 0, + "maximum": ((1 << 16) - 1) + }, options); + return Math.floor(interpolate(options.minimum, options.maximum + 1, generate_unit())); + } + random.generate_integer = generate_integer; + random.generate_int = generate_integer; + /** + * returns a random floating point number in the given interval + * + * @author fenris + */ + function generate_float(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "minimum": 0.0, + "maximum": 1.0 + }, options); + return interpolate(options.minimum, options.maximum, generate_unit()); + } + random.generate_float = generate_float; + /** + * returns a random date + * + * @author fenris + */ + function generate_date(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "minimum": new Date(0), + "maximum": new Date(Date.now()) + }, options); + return (new Date(generate_integer({ + "minimum": options.minimum.getTime(), + "maximum": options.maximum.getTime() + }))); + } + random.generate_date = generate_date; + /** + * @author fenris + */ + function generate_hexdigit() { + return (this.generate_integer({ "minimum": 0, "maximum": 15 }).toString(16).toUpperCase()); + } + random.generate_hexdigit = generate_hexdigit; + /** + * generates a random string with an optional prefix + * + * @author fenris + */ + function generate_string(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "length": 8 + }, options); + return (sequence(options.length) + .map(function (x) { return generate_integer({ "minimum": 65, "maximum": 90 }); }) + .map(function (x) { return String.fromCharCode(x); }) + .join("") + .toLowerCase()); + } + random.generate_string = generate_string; + /** + * chooses a value randomly from a list of values with weights (a higher weight means a higher probability to be chosen) + * + * @author fenris + */ + function choose_weighted(sets) { + var sum = sets.reduce(function (sum, set_) { return (sum + set_.weight); }, 0); + if (sum === 0) { + throw (new Error("weights sum up to zero; are all zero or are negative weights included?")); + } + else { + var position_1 = generate_unit(); + return (sets.reduce(function (current, set_) { + var next = { "index": null, "value": null }; + next.index = (current.index + (set_.weight / sum)); + next.value = (((current.index <= position_1) && (position_1 < next.index)) + ? set_.value + : current.value); + return next; + }, { "index": 0, "value": null }).value); + } + } + random.choose_weighted = choose_weighted; + /** + * chooses a value randomly from a list of values with equal probabilities + * + * @author fenris + */ + function choose_uniformly(values) { + return (choose_weighted(values.map(function (value) { return ({ "weight": 1, "value": value }); }))); + } + random.choose_uniformly = choose_uniformly; + /** + * @author fenris + */ + function shuffle(list) { + var list_ = []; + list.forEach(function (element) { + var index = generate_integer({ "minimum": 0, "maximum": list_.length }); + list_.splice(index, 0, element); + }); + return list_; + } + random.shuffle = shuffle; + /** + * @author fenris + */ + function generate_vowel() { + return (choose_weighted([ + { "weight": 1.0, "value": "u" }, + { "weight": 4.0, "value": "o" }, + { "weight": 6.0, "value": "a" }, + { "weight": 4.0, "value": "e" }, + { "weight": 1.0, "value": "i" }, + ])); + } + random.generate_vowel = generate_vowel; + /** + * @author fenris + */ + function generate_halfvowel() { + return (choose_weighted([ + { "weight": 4.0, "value": "y" }, + { "weight": 1.0, "value": "w" }, + ])); + } + random.generate_halfvowel = generate_halfvowel; + /** + * @author fenris + */ + function generate_consonant() { + return (choose_weighted([ + { "weight": 5.0, "value": "l" }, + { "weight": 5.0, "value": "m" }, + { "weight": 5.0, "value": "n" }, + { "weight": 4.0, "value": "b" }, + { "weight": 4.0, "value": "p" }, + { "weight": 4.0, "value": "d" }, + { "weight": 2.0, "value": "dj" }, + { "weight": 4.0, "value": "t" }, + { "weight": 2.0, "value": "tc" }, + { "weight": 4.0, "value": "g" }, + { "weight": 4.0, "value": "k" }, + { "weight": 3.0, "value": "v" }, + { "weight": 3.0, "value": "f" }, + { "weight": 3.0, "value": "z" }, + { "weight": 3.0, "value": "s" }, + { "weight": 3.0, "value": "j" }, + { "weight": 3.0, "value": "c" }, + { "weight": 2.0, "value": "r" }, + { "weight": 1.0, "value": "h" }, + { "weight": 1.0, "value": "x" }, + ])); + } + random.generate_consonant = generate_consonant; + /** + * @author fenris + */ + function generate_letter() { + return choose_uniformly([ + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + ]); + } + random.generate_letter = generate_letter; + /** + * @author fenris + */ + function generate_syllable() { + return (generate_consonant() + + + generate_vowel() + + + (generate_boolean({ "probability": 1 / 8 }) + ? generate_halfvowel() + : "") + + + (generate_boolean({ "probability": 1 / 4 }) + ? generate_consonant() + : "")); + } + random.generate_syllable = generate_syllable; + /** + * @author fenris + */ + function generate_word(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "syllable_count_minimum": 2, + "syllable_count_maximum": 5 + }, options); + return (sequence(generate_integer({ + "minimum": options.syllable_count_minimum, + "maximum": options.syllable_count_maximum + })) + .map(function (x) { return generate_syllable(); }) + .join("")); + } + random.generate_word = generate_word; + /** + * @author fenris + */ + function generate_text(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "word_count": generate_integer({ "minimum": 20, "maximum": 80 }) + }, options); + return sequence(options.word_count).map(function (x) { return generate_word(); }).join(" "); + } + random.generate_text = generate_text; + /** + * @author fenris + */ + function generate_city() { + var str = ( + // prefix + (generate_boolean({ "probability": 0.25 }) + ? choose_uniformly([ + "unter", + "ober", + "mittel", + "groß", + "klein", + "neu", + "alt", + ]) + : "") + + + // infix + choose_uniformly([ + "stein", + "frei", + "berns", + "kirch", + "fels", + "weiden", + "buchen", + "eichen", + "eiben", + "linden", + "ulmen", + "birken", + "eschen", + "erlen", + "grün", + "kreuz", + "wald", + "reichen", + "lieben", + "schön", + "heinrichs", + "friedrichs", + "johann", + "walters", + "günthers", + "rupperts", + "wilhems", + "albert", + ]) + + + // suffix + choose_uniformly([ + "feld", + "thal", + "berg", + "burg", + "stadt", + "dorf", + "heim", + "bach", + "au", + "rode", + "ing", + "nitz", + "hausen", + ])); + return (str[0].toUpperCase() + str.substring(1)); + } + random.generate_city = generate_city; + /** + * @author fenris + */ + function generate_street() { + var str = ( + // prefix + choose_uniformly([ + "haupt", + "neben", + "bahnhof", + "markt", + "augustus", + "wilhelm", + "albert", + "friedrich", + "maximilian", + "wagner", + "linden", + "eichen", + "buchen", + "tannen", + "pappel", + "ulmen", + "eschen", + ]) + + + // core + choose_uniformly([ + "straße", + "weg", + "allee", + "pfad", + "hain", + "anger", + "passage", + "platz", + ]) + + + // number + (" " + generate_integer({ "minimum": 1, "maximum": 80 }).toString())); + return (str[0].toUpperCase() + str.substring(1)); + } + random.generate_street = generate_street; + /** + * @author fenris + */ + function generate_guid(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "with_braces": false + }, options); + /* + return ( + [8,4,4,4,12] + .map(length => sequence(length).map(_ => this.generate_hexdigit()).join("")) + .join("-") + ); + */ + var guid = ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(new RegExp("[xy]", "g"), function (symbol) { + var r = generate_integer({ "minimum": 0, "maximum": 15 }); + var v = ((symbol == "y") ? ((r & 0x3) | 0x8) : r); + return (v.toString(16).toUpperCase()); + })); + return (options.with_braces + ? ("{" + guid + "}") + : guid); + } + random.generate_guid = generate_guid; + /** + * @author fenris + */ + function generate_domain(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "steps": 3 + }, options); + return (sequence(generate_integer({ "minimum": 1, "maximum": options.steps })) + .map(function () { return generate_word(); }) + // tld + .concat(sequence(generate_integer({ "minimum": 2, "maximum": 3 })) + .map(function () { return generate_letter(); }) + .join(""))).join("."); + } + /** + * @author fenris + */ + function generate_url() { + return (lib_plankton.url.encode({ + "scheme": choose_uniformly([ + "http", + "https", + "git", + "smb", + "ftp", + ]), + "host": generate_domain(), + "username": null, + "password": null, + "port": generate_integer({ "minimum": 20, "maximum": 99999 }), + "path": ("/" + + + (sequence(generate_integer({ "minimum": 0, "maximum": 3 })) + .map(function () { return generate_word(); }) + .join("/"))), + "query": choose_uniformly([ + null, + lib_plankton.www_form.encode(Object.fromEntries(sequence(generate_integer({ "minimum": 0, "maximum": 3 })) + .map(function () { return ([ + generate_word(), + generate_integer().toFixed(0), + ]); }))), + ]), + "hash": null + })); + } + random.generate_url = generate_url; + /** + * @author fenris + */ + function generate_email_address() { + return ( + // user + generate_word() + + + "@" + + + generate_domain({ "steps": 1 })); + } + random.generate_email_address = generate_email_address; + /** + * @author fenris + */ + function generate_telephone_number() { + return ( + // country prefix + ("+" + + + generate_integer({ "minimum": 1, "maximum": 999 }).toFixed(0)) + + + " " + + + // provider + +(sequence(3) + .map(function () { return generate_integer({ "minimum": 0, "maximum": 9 }); }) + .join("")) + + + " " + + + // custom + +(sequence(7) + .map(function () { return generate_integer({ "minimum": 0, "maximum": 9 }); }) + .join(""))); + } + random.generate_telephone_number = generate_telephone_number; + /** + * @author fenris + */ + function generate_time() { + return { + "hour": generate_integer({ "minimum": 0, "maximum": 23 }), + "minute": generate_integer({ "minimum": 0, "maximum": 59 }), + "second": generate_integer({ "minimum": 0, "maximum": 59 }) + }; + } + random.generate_time = generate_time; + /** + * @author fenris + * @deprecated + * @todo remove + */ + function generate_for_shape(shape) { + throw (new Error("deprecated! use lib_shape!")); + } + random.generate_for_shape = generate_for_shape; + /** + * @author fenris + */ + /* + export function generate_for_shape_( + shape : lib_plankton.shape.type_shape + ) : any + { + switch (shape.name) { + case "boolean": { + return generate_boolean(); + break; + } + case "int": { + const min = shape.parameters["min"]; + const max = shape.parameters["max"]; + return generate_integer( + { + "minimum": ((min == null) ? undefined : min), + "maximum": ((max == null) ? undefined : max), + } + ); + break; + } + case "float": { + return generate_float( + { + "minimum": shape.parameters["min"], + "maximum": shape.parameters["max"], + } + ); + break; + } + case "string": { + return generate_string(); + break; + } + case "url": { + return generate_url(); + break; + } + case "email": { + return generate_email_address(); + break; + } + case "time": { + return generate_time(); + break; + } + case "array": { + return ( + sequence(generate_integer({"minimum": 2, "maximum": 5})) + .map(() => generate_for_shape_(shape.parameters["shape_element"])) + ); + break; + } + case "object": { + return Object.fromEntries( + shape.parameters["fields"] + .map( + field => ([ + field["name"], + generate_for_shape_(field["shape"]), + ]) + ) + ); + break; + } + case "date": { + return generate_date(); + break; + } + case "enumeration": { + return choose_uniformly(shape.parameters["options"])["value"]; + break; + } + default: { + const message : string = `unhandled shape kind '${shape.name}'`; + // console.warn(message); + // return null; + throw (new Error(message)); + break; + } + } + } + */ + })(random = lib_plankton.random || (lib_plankton.random = {})); +})(lib_plankton || (lib_plankton = {})); +/* This file is part of »bacterio-plankton:map«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -7000,12 +9449,6 @@ var lib_plankton; * @author fenris */ class class_relation { - /** - * @author fenris - */ - check(value, reference) { - return this.predicate(value, reference); - } /** * @author fenris */ @@ -7015,6 +9458,12 @@ var lib_plankton; this.name = name; this.predicate = predicate; } + /** + * @author fenris + */ + check(value, reference) { + return this.predicate(value, reference); + } /** * @author fenris */ @@ -7462,6 +9911,22 @@ var lib_plankton; }; } color_1.make_rgb = make_rgb; + /** + */ + function from_hex(hex) { + if (!(hex[0] === "#")) { + throw (new Error("malformed")); + } + else { + const factor = (1 / 255); + return make_rgb({ + "red": (parseInt(hex.slice(1, 3), 16) * factor), + "green": (parseInt(hex.slice(3, 5), 16) * factor), + "blue": (parseInt(hex.slice(5, 7), 16) * factor), + }); + } + } + color_1.from_hex = from_hex; /** */ function to_hsv(color) { @@ -8312,202 +10777,6 @@ var lib_plankton; })(http = lib_plankton.http || (lib_plankton.http = {})); })(lib_plankton || (lib_plankton = {})); /* -This file is part of »bacterio-plankton:url«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:url« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:url« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:url«. If not, see . - */ -/* -This file is part of »bacterio-plankton:url«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:url« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:url« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:url«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var url; - (function (url_1) { - /** - * @author fenris - */ - function encode(url) { - let result = ""; - // scheme - { - if (url.scheme !== null) { - result += (url.scheme + ":"); - } - } - // host - { - if (url.host !== null) { - result += "//"; - // username - { - if (url.username !== null) { - result += url.username; - // password - { - if (url.password !== null) { - result += (":" + url.password); - } - } - result += "@"; - } - } - result += url.host; - } - } - // port - { - if (url.port !== null) { - result += (":" + url.port.toString()); - } - } - // path - { - if (url.path !== null) { - result += url.path; - } - } - // query - { - if (url.query !== null) { - result += ("?" + url.query); - } - } - // hash - { - if (url.hash !== null) { - result += ("#" + url.hash); - } - } - return result; - } - url_1.encode = encode; - /** - * @author fenris - * @todo arguments - */ - function decode(url_raw) { - const builtin_url = new URL(url_raw); - return { - "scheme": builtin_url.protocol.slice(0, -1), - "host": builtin_url.hostname, - "username": ((builtin_url.username !== "") - ? - builtin_url.username - : - null), - "password": ((builtin_url.password !== "") - ? - builtin_url.password - : - null), - "port": ((builtin_url.port !== "") - ? - parseInt(builtin_url.port) - : - null), - "path": builtin_url.pathname, - "query": builtin_url.search.slice(1), - "hash": ((builtin_url.hash !== "") - ? - builtin_url.hash.slice(1) - : - null), - }; - } - url_1.decode = decode; - /** - * @author fenris - */ - function implementation_code() { - return { - "encode": encode, - "decode": decode, - }; - } - url_1.implementation_code = implementation_code; - })(url = lib_plankton.url || (lib_plankton.url = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:url«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:url« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:url« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:url«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var url; - (function (url) { - /** - * @author fenris - */ - class class_url { - /** - * @author fenris - */ - constructor() { - } - /** - * @implementation - * @author fenris - */ - encode(x) { - return url.encode(x); - } - /** - * @implementation - * @author fenris - */ - decode(x) { - return url.decode(x); - } - } - url.class_url = class_url; - })(url = lib_plankton.url || (lib_plankton.url = {})); -})(lib_plankton || (lib_plankton = {})); -/* This file is part of »bacterio-plankton:pit«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -9105,107 +11374,6 @@ var lib_plankton; })(pit = lib_plankton.pit || (lib_plankton.pit = {})); })(lib_plankton || (lib_plankton = {})); /* -This file is part of »bacterio-plankton:www_form«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:www_form« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:www_form« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:www_form«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var www_form; - (function (www_form) { - /** - * @author fenris - */ - function encode(source) { - return (Object.entries(source) - .map(function (_a) { - var key = _a[0], value = _a[1]; - return (key + "=" + encodeURIComponent(value)); - }) - .join("&")); - } - www_form.encode = encode; - /** - * @author fenris - */ - function decode(target) { - return (Object.fromEntries(target.split("&") - .map(function (part) { - var components = part.split("="); - var key = components[0]; - var value = decodeURIComponent(components.slice(1).join("=")); - return [key, value]; - }))); - } - www_form.decode = decode; - })(www_form = lib_plankton.www_form || (lib_plankton.www_form = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:www_form«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:www_form« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:www_form« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:www_form«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var www_form; - (function (www_form) { - /** - * @author fenris - */ - var class_www_form = /** @class */ (function () { - /** - * @author fenris - */ - function class_www_form() { - } - /** - * @implementation - * @author fenris - */ - class_www_form.prototype.encode = function (source) { - return www_form.encode(source); - }; - /** - * @implementation - * @author fenris - */ - class_www_form.prototype.decode = function (target) { - return www_form.decode(target); - }; - return class_www_form; - }()); - www_form.class_www_form = class_www_form; - })(www_form = lib_plankton.www_form || (lib_plankton.www_form = {})); -})(lib_plankton || (lib_plankton = {})); -/* This file is part of »bacterio-plankton:translate«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -9754,6 +11922,525 @@ var lib_plankton; })(zoo_page = lib_plankton.zoo_page || (lib_plankton.zoo_page = {})); })(lib_plankton || (lib_plankton = {})); /* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_empty { + /** + */ + constructor() { + } + /** + */ + load(target_element) { + return Promise.resolve(undefined); + } + } + zoo_widget.class_empty = class_empty; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_string { + /** + */ + constructor(content) { + this.content = content; + } + /** + */ + load(target_element) { + const dom_element = document.createElement("span"); + dom_element.classList.add("widget-string"); + dom_element.textContent = this.content; + target_element.appendChild(dom_element); + return Promise.resolve(undefined); + } + } + zoo_widget.class_string = class_string; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_link { + /** + */ + constructor(target, { "text": text = null, "open_in_new_tab": open_in_new_tab = false, } = {}) { + this.target = target; + this.text = text; + this.open_in_new_tab = open_in_new_tab; + } + /** + */ + load(target_element) { + const dom_element = document.createElement("a"); + dom_element.classList.add("widget-link"); + dom_element.textContent = (this.text ?? this.target); + dom_element.setAttribute("href", this.target); + dom_element.setAttribute("target", this.open_in_new_tab ? "_blank" : "_self"); + target_element.appendChild(dom_element); + return Promise.resolve(undefined); + } + } + zoo_widget.class_link = class_link; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_text { + /** + */ + constructor(paragraphs) { + this.paragraphs = paragraphs; + } + /** + */ + load(target_element) { + const dom_container = document.createElement("div"); + dom_container.classList.add("widget-text"); + this.paragraphs.forEach(paragraph => { + const dom_paragraph = document.createElement("p"); + dom_paragraph.textContent = paragraph; + dom_container.appendChild(dom_paragraph); + }); + target_element.appendChild(dom_container); + return Promise.resolve(undefined); + } + } + zoo_widget.class_text = class_text; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_list { + /** + */ + constructor(elements) { + this.elements = elements; + } + /** + */ + async load(target_element) { + const dom_ul = document.createElement("ul"); + dom_ul.classList.add("widget-list"); + for (const element of this.elements) { + const dom_li = document.createElement("li"); + dom_li.classList.add("widget-list-element"); + await element.load(dom_li); + dom_ul.appendChild(dom_li); + } + target_element.appendChild(dom_ul); + } + } + zoo_widget.class_list = class_list; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + this.content = content; + this.collapseable = collapseable; + this.collapsed_initial_value = collapsed_initial_value; + this.classes = classes; + } + /** + */ + async load(target_element) { + const dom_container = document.createElement("div"); + dom_container.classList.add("widget-panel"); + this.classes.forEach(class_ => { + dom_container.classList.add(class_); + }); + // vertical rule + { + const dom_rule = document.createElement("div"); + dom_rule.classList.add("widget-panel-rule"); + if (!this.collapseable) { + // do nothing + } + else { + dom_rule.addEventListener("click", () => { + dom_container.classList.toggle("widget-panel-collapsed"); + }); + } + dom_container.classList.toggle("widget-panel-collapsed", this.collapsed_initial_value); + dom_container.appendChild(dom_rule); + } + // content + { + const dom_content = document.createElement("div"); + dom_content.classList.add("widget-panel-content"); + await this.content.load(dom_content); + dom_container.appendChild(dom_content); + } + target_element.appendChild(dom_container); + } + } + zoo_widget.class_panel = class_panel; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel_info extends zoo_widget.class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + super(content, { + "collapseable": collapseable, + "collapsed_initial_value": collapsed_initial_value, + "classes": ["widget-panel_info"].concat(classes), + }); + } + } + zoo_widget.class_panel_info = class_panel_info; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel_warning extends zoo_widget.class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + super(content, { + "collapseable": collapseable, + "collapsed_initial_value": collapsed_initial_value, + "classes": ["widget-panel_warning"].concat(classes), + }); + } + } + zoo_widget.class_panel_warning = class_panel_warning; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel_error extends zoo_widget.class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + super(content, { + "collapseable": collapseable, + "collapsed_initial_value": collapsed_initial_value, + "classes": ["widget-panel_error"].concat(classes), + }); + } + } + zoo_widget.class_panel_error = class_panel_error; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel_success extends zoo_widget.class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + super(content, { + "collapseable": collapseable, + "collapsed_initial_value": collapsed_initial_value, + "classes": ["widget-panel_success"].concat(classes), + }); + } + } + zoo_widget.class_panel_success = class_panel_success; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-widget« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_bunch { + /** + */ + constructor(elements) { + this.elements = elements; + } + /** + */ + async load(target_element) { + const dom_container = document.createElement("div"); + dom_container.classList.add("widget-bunch"); + for (const element of this.elements) { + const dom_li = document.createElement("li"); + await element.load(dom_li); + dom_container.appendChild(dom_li); + } + target_element.appendChild(dom_container); + } + } + zoo_widget.class_bunch = class_bunch; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* This file is part of »bacterio-plankton:zoo-input«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -10885,16 +13572,56 @@ var lib_plankton; class class_input_password { /** */ - constructor() { + constructor({ "exhibit_initial_value": exhibit_initial_value = false, "character_hide": character_hide = "~", "character_show": character_show = "o", } = {}) { + this.exhibit = exhibit_initial_value; + this.character_hide = character_hide; + this.character_show = character_show; this.dom_input = null; + this.dom_exhibit = null; + } + /** + */ + toggle_exhibition({ "value": value = null, } = {}) { + this.exhibit = ((value !== null) + ? + value + : + (!this.exhibit)); + this.dom_exhibit.textContent = (this.exhibit + ? + this.character_hide + : + this.character_show); + this.dom_input.setAttribute("type", (this.exhibit + ? + "text" + : + "password")); } /** * [implementation] */ setup(parent) { - this.dom_input = document.createElement("input"); - this.dom_input.setAttribute("type", "password"); - parent.appendChild(this.dom_input); + const dom_container = document.createElement("div"); + dom_container.classList.add("plankton_input_password_container"); + // input + { + this.dom_input = document.createElement("input"); + this.dom_input.setAttribute("type", "password"); + this.dom_input.classList.add("plankton_input_password_input"); + dom_container.appendChild(this.dom_input); + } + // exhibit + { + this.dom_exhibit = document.createElement("div"); + this.dom_exhibit.classList.add("plankton_input_password_exhibit"); + this.dom_exhibit.addEventListener("click", () => { + this.toggle_exhibition(); + }); + dom_container.appendChild(this.dom_exhibit); + } + parent.appendChild(dom_container); + this.toggle_exhibition({ "value": this.exhibit }); return Promise.resolve(undefined); } /** @@ -11113,7 +13840,7 @@ var lib_plankton; dom_field.setAttribute("rel", field.name); await Promise.all([ // label - new Promise((resolve, reject) => { + (async () => { if (field.label === null) { // do nothing } @@ -11123,22 +13850,19 @@ var lib_plankton; dom_label.textContent = field.label; dom_field.appendChild(dom_label); } - resolve(undefined); - }), + })(), // help - new Promise((resolve, reject) => { + (async () => { if (field.help === null) { // do nothing } else { - let dom_help = document.createElement("span"); - dom_help.classList.add("plankton_input_group_field_help"); - dom_help.textContent = "(?)"; - dom_help.setAttribute("title", field.help); - dom_field.appendChild(dom_help); + let dom_help_content = document.createElement("div"); + dom_help_content.classList.add("plankton_input_group_field_help_content"); + dom_field.appendChild(dom_help_content); + await field.help.load(dom_help_content); } - resolve(undefined); - }), + })(), // input field.input.setup(dom_field), ]); @@ -11419,6 +14143,120 @@ var lib_plankton; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); })(lib_plankton || (lib_plankton = {})); /* +This file is part of »bacterio-plankton:zoo-input«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-input« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-input« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-input«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_input; + (function (zoo_input) { + /** + */ + class class_input_color { + /** + */ + constructor() { + this.dom_input = null; + } + /** + * [implementation] + */ + setup(parent) { + this.dom_input = document.createElement("input"); + this.dom_input.setAttribute("type", "color"); + parent.appendChild(this.dom_input); + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + read() { + return Promise.resolve((this.dom_input.value === "") + ? null + : lib_plankton.color.from_hex(this.dom_input.value)); + } + /** + * [implementation] + */ + write(value) { + this.dom_input.value = ((value === null) + ? "" + : lib_plankton.color.output_hex(value)); + return Promise.resolve(undefined); + } + } + zoo_input.class_input_color = class_input_color; + })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-input«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-input« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-input« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-input«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_input; + (function (zoo_input) { + /** + */ + function unwrap(hue) { + return lib_plankton.color.make_hsv({ + "hue": (hue ?? 0), + "saturation": 0.5, + "value": 0.5, + }); + } + /** + */ + function wrap(color) { + return ((color === null) + ? + null + : + lib_plankton.color.to_hsv(color).hue); + } + /** + */ + class class_input_hue extends zoo_input.class_input_wrapped { + /** + */ + constructor() { + super(new zoo_input.class_input_color(), wrap, unwrap); + } + } + zoo_input.class_input_hue = class_input_hue; + })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); +})(lib_plankton || (lib_plankton = {})); +/* This file is part of »bacterio-plankton:zoo-form«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'