=> {
section: 3,
items: {
type: "string",
- enum: licenses,
+ enum: [],
},
group: "legal",
required: true,
diff --git a/src/app/contents/publiccode.ts b/src/app/contents/publiccode.ts
index d90762c0..5d4192b9 100644
--- a/src/app/contents/publiccode.ts
+++ b/src/app/contents/publiccode.ts
@@ -169,3 +169,28 @@ interface Riuso {
}
export const defaultRiuso: Riuso = { codiceIPA: "" };
+
+export const publicCodeDummyObjectFactory = () => ({
+ publiccodeYmlVersion: "0.4",
+ name: '',
+ applicationSuite: '',
+ url: '',
+ landingURL: '',
+ isBasedOn: '',
+ softwareVersion: '',
+ releaseDate: '',
+ logo: '',
+ platforms: [],
+ categories: [],
+ usedBy: [],
+ roadmap: '',
+ developmentStatus: 'stable',
+ softwareType: 'library',
+ intendedAudience: {},
+ description: {},
+ legal: { license: '' },
+ maintenance: { contacts: [], contractors: [], type: 'none' },
+ localisation: { availableLanguages: [], localisationReady: false },
+ dependsOn: {},
+ it: defaultItaly
+} satisfies PublicCode)
diff --git a/src/app/form/index.d.ts b/src/app/form/index.d.ts
deleted file mode 100644
index dd4ab7e9..00000000
--- a/src/app/form/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module "*.svg";
diff --git a/src/app/form/index.js b/src/app/form/index.js
deleted file mode 100644
index 44539b1a..00000000
--- a/src/app/form/index.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import DefaultTheme from "./widgets/";
-import renderFields from "./renderFields";
-import renderField from "./renderField";
-
-export { renderFields, renderField, DefaultTheme };
diff --git a/src/app/form/renderField.js b/src/app/form/renderField.js
deleted file mode 100644
index 386121ef..00000000
--- a/src/app/form/renderField.js
+++ /dev/null
@@ -1,71 +0,0 @@
-import { createElement } from "react";
-import deepmerge from "deepmerge";
-
-const guessWidget = (schema, theme) => {
- if (schema.widget) {
- return schema.widget;
- } else if (Object.prototype.hasOwnProperty.call(schema, "enum")) {
- return "choice";
- } else if (Object.prototype.hasOwnProperty.call(schema, "oneOf")) {
- return "oneOf";
- } else if (theme[schema.format]) {
- return schema.format;
- }
- return schema.type || "object";
-};
-
-export const isRequired = (schema, fieldName) => {
- if (!schema.required) {
- return false;
- }
- return schema.required === true || schema.required.indexOf(fieldName) !== -1;
-};
-
-const renderField = (
- schema,
- fieldName,
- theme,
- prefix = "",
- context = {},
- required = false,
- defaultValue = null,
- t
-) => {
- if (Object.prototype.hasOwnProperty.call(schema, "allOf")) {
- schema = { ...schema, ...deepmerge.all(schema.allOf) };
- delete schema.allOf;
- }
-
- const widget = guessWidget(schema, theme);
- if (!theme[widget]) {
- throw new Error(widget + " is not defined in the theme");
- }
-
- const newFieldName = prefix ? prefix + fieldName : fieldName;
-
- let showLabel = schema.showLabel == false ? false : true;
- // label are same for every element of arrays
- const translationReadyLabel = t(
- `publiccodeyml.${schema.rawTitle || newFieldName.replace(/\[[0-9]+\]/,'') || schema.title}.label`
- );
-
- const lbl = translationReadyLabel || schema.title || fieldName;
- return createElement(theme[widget], {
- key: fieldName,
- fieldName: widget === "oneOf" ? fieldName : newFieldName,
- label: lbl,
- required: required,
- schema: schema,
- maxLength: schema.maxLength,
- minLength: schema.minLength,
- theme,
- context,
- prefix,
- id: schema.id,
- group: schema.group,
- showLabel,
- defaultValue,
- });
-};
-
-export default renderField;
diff --git a/src/app/form/renderFields.js b/src/app/form/renderFields.js
deleted file mode 100644
index 9374737e..00000000
--- a/src/app/form/renderFields.js
+++ /dev/null
@@ -1,58 +0,0 @@
-import renderField from "./renderField";
-
-export const isRequired = (schema, fieldName) => {
- if (!schema.required) {
- return false;
- }
- return schema.required === true || schema.required.indexOf(fieldName) !== -1;
-};
-
-const renderFields = (
- schema,
- theme,
- prefix = null,
- context = {},
- defaultValue,
- t
-) => {
- let props = [];
- for (let i in schema.properties) {
- props.push({ prop: i, propertyOrder: schema.properties[i].propertyOrder });
- }
- props = props.sort((a, b) => {
- if (a.propertyOrder > b.propertyOrder) {
- return 1;
- } else if (a.propertyOrder < b.propertyOrder) {
- return -1;
- } else {
- return 0;
- }
- });
- return props.map((item, i) => {
- const name = item.prop;
- const field = schema.properties[name];
-
- if (schema.isSummary) {
- field.isSummary = schema.isSummary;
- }
-
- return (
-
-
- {renderField(
- field, //{...schema, defaultValue},
- name,
- theme,
- prefix,
- context, //{ ...context, defaultValue },
- isRequired(schema, name),
- defaultValue,
- t
- )}
-
-
- );
- });
-};
-
-export default renderFields;
diff --git a/src/app/form/widgets/ArrayWidget.js b/src/app/form/widgets/ArrayWidget.js
deleted file mode 100644
index 251822b9..00000000
--- a/src/app/form/widgets/ArrayWidget.js
+++ /dev/null
@@ -1,137 +0,0 @@
-import PropTypes from "prop-types";
-import renderField from "../renderField";
-import ChoiceWidget from "./ChoiceWidget";
-import classNames from "classnames";
-import Info from "../../components/Info";
-import CloseButton from "../../components/CloseButton";
-import { useFieldArray, useFormContext } from "react-hook-form";
-import { useTranslation } from "react-i18next";
-import { get } from "lodash";
-
-const renderArrayFields = (
- fields,
- schema,
- theme,
- fieldName,
- remove,
- context,
- swap,
- t
-) => {
- const prefix = fieldName;
- let isSummary = false;
- return (
-
- {fields.map((field, index) => (
-
- {/* {console.log(field, fieldName)} */}
-
- {
- e.preventDefault();
- remove(index);
- }}
- />
-
- {(isSummary = index !== fields.length - 1 ? true : false)}
- {renderField(
- {
- ...schema,
- isSummary,
- showLabel: false,
- },
- // simple string array are not yet supported
- // https://spectrum.chat/react-hook-form/help/usefieldarray-with-array-of-simple-strings-not-objects~99bb71d1-35c4-48cd-a76b-4f895994b794
- schema.type && schema.type === "object"
- ? `[${index}]`
- : `.${index}`,
- theme,
- prefix,
- context, //{ ...context, field },
- null,
- field,
- t
- )}
-
- ))}
-
- );
-};
-
-const CollectionWidget = (props) => {
- const name = props.fieldName;
- const { control, formState } = useFormContext();
- const { fields, append, remove, swap } = useFieldArray({
- control,
- name,
- });
- const error = get(formState.errors, name);
- const invalid = error && error.message;
-
- const { t } = useTranslation();
- const className = classNames(["block__array", { "has-error": invalid }]);
- return (
-
- {props.showLabel && (
-
- )}
- {invalid &&
{error && error.message}}
- {renderArrayFields(
- fields,
- props.schema.items,
- props.theme,
- props.fieldName,
- (idx) => remove(idx),
- props.context,
- (a, b) => {
- swap(a, b);
- },
- t
- )}
-
-
-
- );
-};
-
-const ArrayWidget = (props) => {
- // Arrays are tricky because they can be multiselects or collections
- if (
- // eslint-disable-next-line no-prototype-builtins
- props.schema.items.hasOwnProperty("enum") &&
- // eslint-disable-next-line no-prototype-builtins
- props.schema.hasOwnProperty("uniqueItems") &&
- props.schema.uniqueItems
- ) {
- return ChoiceWidget({
- ...props,
- schema: props.schema.items,
- multiple: true,
- });
- } else {
- return CollectionWidget(props);
- }
-};
-
-ArrayWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- theme: PropTypes.object,
- context: PropTypes.object,
- defaultValue: PropTypes.object,
-};
-
-export default ArrayWidget;
diff --git a/src/app/form/widgets/BaseInputWidget.js b/src/app/form/widgets/BaseInputWidget.js
deleted file mode 100644
index 13623a18..00000000
--- a/src/app/form/widgets/BaseInputWidget.js
+++ /dev/null
@@ -1,100 +0,0 @@
-import { useState } from "react";
-import PropTypes from "prop-types";
-import Info from "../../components/Info";
-import { useController, useFormContext } from "react-hook-form";
-import { useTranslation } from "react-i18next";
-import { get } from "lodash";
-import { Input } from "design-react-kit";
-
-const BaseInputWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
- const { control, formState } = useFormContext();
- const { i18n } = useTranslation();
- const propertyNames = name.split(/\./);
- const propertyName = propertyNames[propertyNames.length - 1];
-
- // when coming from an upload data flow from the top
- // using setValue method of RHF
- // Here we need to check whether props.defaultValue contains
- // a subobject (in case they are from an array field)
- const innerPropertyDefaultValue =
- // eslint-disable-next-line no-prototype-builtins
- props.defaultValue && props.defaultValue.hasOwnProperty(propertyName)
- ? props.defaultValue[propertyName]
- : null;
-
- // if props.defaultValue is an object that not contains
- // the name key an object is returned and to avoid
- // to fill the input with [object Object] we need
- // to allow only certain types.
- // awful.
- const defaultValue =
- typeof props.defaultValue === "string" ||
- typeof props.defaultValue === "number" ||
- typeof props.defaultValue === "boolean"
- ? props.defaultValue
- : null;
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- defaultValue:
- props.schema.value || innerPropertyDefaultValue || defaultValue || "",
- });
- const [count, setCount] = useState(0);
-
- const inLang = props.schema.language
- ? ` (in ${new Intl.DisplayNames([i18n.language], { type: 'language' }).of(props.schema.lang)})`
- : '';
-
- return (
- <>
- {
- setCount(val.target.value.length);
- }}
- />
- {props.maxLength && (
-
- )}
-
- >
- );
-};
-
-BaseInputWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- type: PropTypes.string.isRequired,
- required: PropTypes.bool,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- normalizer: PropTypes.func,
- description: PropTypes.string,
-};
-
-export default BaseInputWidget;
diff --git a/src/app/form/widgets/CheckboxWidget.js b/src/app/form/widgets/CheckboxWidget.js
deleted file mode 100644
index 4c66533c..00000000
--- a/src/app/form/widgets/CheckboxWidget.js
+++ /dev/null
@@ -1,61 +0,0 @@
-import PropTypes from "prop-types";
-import classNames from "classnames";
-import Info from "../../components/Info";
-import { useController, useFormContext } from "react-hook-form";
-import { get } from "lodash";
-
-const CheckboxWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
- const { control, formState } = useFormContext();
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- defaultValue: props.schema.value || false,
- });
- const className = classNames(["form-group", { "has-error": invalid }]);
-
- return (
-
-
- inputProps.onChange(e.target.checked)}
- />
-
-
- {invalid && (
-
- {get(formState.errors, name) && get(formState.errors, name).message}
-
- )}
-
-
-
- );
-};
-
-CheckboxWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- theme: PropTypes.object,
-};
-
-export default CheckboxWidget;
diff --git a/src/app/form/widgets/ChoiceExpandedWidget.js b/src/app/form/widgets/ChoiceExpandedWidget.js
deleted file mode 100644
index 0421d009..00000000
--- a/src/app/form/widgets/ChoiceExpandedWidget.js
+++ /dev/null
@@ -1,74 +0,0 @@
-import classNames from "classnames";
-import Info from "../../components/Info";
-import { useController, useFormContext } from "react-hook-form";
-import { get } from "lodash";
-import { FormGroup, Input, Label } from "design-react-kit";
-
-const zipObject = (props, values) =>
- props.reduce(
- (prev, prop, i) => Object.assign(prev, { [prop]: values[i] }),
- {}
- );
-
-const ChoiceExpandedWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
- const { control, formState } = useFormContext();
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- // rules: { required: props.required },
- defaultValue: props.schema.value || "",
- });
- const className = classNames(["form-group", { "has-error": invalid }]);
- const options = props.schema.enum;
- const optionNames = props.schema.enum_titles || options;
-
- const selectOptions = zipObject(options, optionNames);
- return (
-
-
-
- {invalid && (
-
- {get(formState.errors, name) && get(formState.errors, name).message}
-
- )}
-
-
-
- );
-};
-
-export default ChoiceExpandedWidget;
diff --git a/src/app/form/widgets/ChoiceWidget.js b/src/app/form/widgets/ChoiceWidget.js
deleted file mode 100644
index 122520aa..00000000
--- a/src/app/form/widgets/ChoiceWidget.js
+++ /dev/null
@@ -1,80 +0,0 @@
-import PropTypes from "prop-types";
-import classNames from "classnames";
-import { zipObject as _zipObject, map as _map } from "lodash";
-import Info from "../../components/Info";
-import { useController, useFormContext } from "react-hook-form";
-import { get } from "lodash";
-
-const ChoiceWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
- const { control, formState } = useFormContext();
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- defaultValue: props.schema.value || "",
- });
- const className = classNames(["form-group", { "has-error": invalid }]);
- const options = props.schema.enum;
- const optionNames = props.schema.enum_titles || options;
-
- const selectOptions = _zipObject(options, optionNames);
- return (
-
- {props.showLabel && (
-
- )}
-
-
-
- {invalid && (
-
- {get(formState.errors, name) && get(formState.errors, name).message}
-
- )}
-
-
-
- );
-};
-
-ChoiceWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- theme: PropTypes.object,
- multiple: PropTypes.bool,
- required: PropTypes.bool,
-};
-
-export default ChoiceWidget;
diff --git a/src/app/form/widgets/ComboBoxWidget.js b/src/app/form/widgets/ComboBoxWidget.js
deleted file mode 100644
index 04ecf41a..00000000
--- a/src/app/form/widgets/ComboBoxWidget.js
+++ /dev/null
@@ -1,75 +0,0 @@
-import PropTypes from "prop-types";
-import classNames from "classnames";
-import { Combobox } from "react-widgets";
-import Info from "../../components/Info";
-import { useController, useFormContext } from "react-hook-form";
-import { get } from "lodash";
-
-const filterTextAndValues = (item, search) => {
- const text = item.text.toLowerCase();
- const needle = search.toLowerCase();
-
- if (text.includes(needle)) {
- return true;
- }
-
- const value = item.value.toLowerCase();
-
- return value.includes(search);
-}
-
-const ComboBoxWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
- const { control, formState } = useFormContext();
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- defaultValue: props.schema.value || "",
- });
- const className = classNames(["form-group", { "has-error": invalid }]);
-
- return (
-
-
-
-
-
- {invalid && (
-
- {get(formState.errors, name) && get(formState.errors, name).message}
-
- )}
-
-
- );
-};
-
-ComboBoxWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- theme: PropTypes.object,
- multiple: PropTypes.bool,
- required: PropTypes.bool,
-};
-
-export default ComboBoxWidget;
diff --git a/src/app/form/widgets/DateTimeReactWidget.tsx b/src/app/form/widgets/DateTimeReactWidget.tsx
deleted file mode 100644
index 24578886..00000000
--- a/src/app/form/widgets/DateTimeReactWidget.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import classNames from "classnames";
-import { DatePicker } from "react-widgets";
-import Info from "../../components/Info";
-import { ErrorOption, useController, useFormContext } from "react-hook-form";
-import { get } from "lodash";
-
-const add0 = (t: number) => (t < 10 ? `0${t}` : String(t));
-
-export const getDateStandard = (date: Date | null | undefined) => {
- const dt = date || new Date();
- const y = dt.getFullYear();
- const m = add0(dt.getMonth() + 1);
- const d = add0(dt.getDate()); //day of month
- return `${y}-${m}-${d}`;
-};
-
-interface Props {
- fieldName: string;
- label: string;
- placeholder: string;
- required?: boolean;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- schema: any;
-}
-
-const DateTimeReactWidget = (props: Props): JSX.Element => {
- const name = props.fieldName;
- const id = "field-" + name;
- const { control, formState: {errors} } = useFormContext();
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- defaultValue: props.schema.value || "",
- });
- const className = classNames(["form-group", { "has-error": invalid }]);
-
- return (
-
-
-
- inputProps.onChange(getDateStandard(e))}
- />
-
- {invalid && (
-
- {get(errors, name) && (get(errors, name) as ErrorOption).message}
-
- )}
-
-
- );
-};
-
-export default DateTimeReactWidget;
diff --git a/src/app/form/widgets/EditorWidget.js b/src/app/form/widgets/EditorWidget.js
deleted file mode 100644
index fac21d3e..00000000
--- a/src/app/form/widgets/EditorWidget.js
+++ /dev/null
@@ -1,93 +0,0 @@
-import { useEffect, useState } from "react";
-import PropTypes from "prop-types";
-import classNames from "classnames";
-import RichTextEditor from "react-rte";
-import Info from "../../components/Info";
-import { useController, useFormContext } from "react-hook-form";
-import { get } from "lodash";
-
-const EditorWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
- const { control, formState } = useFormContext();
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- defaultValue: props.schema.value || props.defaultValue || "",
- });
- const className = classNames(["form-group", { "has-error": invalid }]);
- const [count, setCount] = useState(0);
- const [richValue, setRichValue] = useState(RichTextEditor.createEmptyValue());
- const [text, setText] = useState(inputProps.value);
-
- useEffect(() => {
- if (inputProps.value !== text) {
- setText(inputProps.value);
- setRichValue(
- RichTextEditor.createValueFromString(inputProps?.value, "markdown")
- );
- }
- setCount(inputProps.value.trim().length);
- }, [inputProps.value]);
-
- const onChange = (val) => {
- setRichValue(val);
- const r = val.toString("markdown");
- setText(r);
- inputProps.onChange(r);
- };
-
- return (
-
-
-
-
-
- {invalid && (
-
- {get(formState.errors, name) && get(formState.errors, name).message}
-
- )}
- {props.maxLength && (
-
- )}
-
-
- );
-};
-
-EditorWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- theme: PropTypes.object,
- multiple: PropTypes.bool,
- required: PropTypes.bool,
-};
-
-export default EditorWidget;
diff --git a/src/app/form/widgets/EmailWidget.js b/src/app/form/widgets/EmailWidget.js
deleted file mode 100644
index d30bb189..00000000
--- a/src/app/form/widgets/EmailWidget.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import BaseInputWidget from "./BaseInputWidget";
-
-const EmailWidget = props => {
- return ;
-};
-
-export default EmailWidget;
diff --git a/src/app/form/widgets/HiddenWidget.js b/src/app/form/widgets/HiddenWidget.js
deleted file mode 100644
index d2a0e75f..00000000
--- a/src/app/form/widgets/HiddenWidget.js
+++ /dev/null
@@ -1,37 +0,0 @@
-import { useController, useFormContext } from "react-hook-form";
-import PropTypes from "prop-types";
-
-const HiddenWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
- const { control } = useFormContext();
- const {
- field: { ref, ...inputProps },
- } = useController({
- name,
- control,
- defaultValue: props.schema.value || "",
- });
-
- return (
-
- );
-};
-
-HiddenWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- required: PropTypes.bool,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- normalizer: PropTypes.func,
- description: PropTypes.string,
-};
-
-export default HiddenWidget;
diff --git a/src/app/form/widgets/ObjectWidget.js b/src/app/form/widgets/ObjectWidget.js
deleted file mode 100644
index 2d5ab61b..00000000
--- a/src/app/form/widgets/ObjectWidget.js
+++ /dev/null
@@ -1,39 +0,0 @@
-import PropTypes from "prop-types";
-import renderFields from "../renderFields";
-import { useTranslation } from "react-i18next";
-
-const ObjectWidget = (props) => {
- const {t} = useTranslation();
- let isSummary = false;
- if (props && props.schema && props.schema.isSummary) {
- isSummary = props.schema.isSummary;
- }
- return (
-
- {props.showLabel && props.label && (
-
- )}
-
- {renderFields(
- { ...props.schema, isSummary },
- props.theme,
- props.fieldName && props.fieldName + ".",
- props.context,
- props.defaultValue,
- t,
- )}
-
- );
-};
-
-ObjectWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- theme: PropTypes.object,
- context: PropTypes.object,
-};
-
-export default ObjectWidget;
diff --git a/src/app/form/widgets/PhoneWidgets.js b/src/app/form/widgets/PhoneWidgets.js
deleted file mode 100644
index bb44ce12..00000000
--- a/src/app/form/widgets/PhoneWidgets.js
+++ /dev/null
@@ -1,74 +0,0 @@
-import { useState } from "react";
-import PropTypes from "prop-types";
-import classNames from "classnames";
-import Info from "../../components/Info";
-import "react-phone-number-input/style.css";
-import PhoneInput from "react-phone-number-input";
-import { useController, useFormContext } from "react-hook-form";
-import { get } from "lodash";
-
-const PhoneWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
- const { control, formState } = useFormContext();
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- defaultValue: props.schema.value || "",
- });
- const className = classNames(["form-group", { "has-error": invalid }]);
- let [count, setCount] = useState(0);
-
- return (
-
- {props.showLabel && (
-
- )}
-
-
{
- setCount((count = val.target.value.length));
- }}
- />
- {invalid && (
-
- {get(formState.errors, name) && get(formState.errors, name).message}
-
- )}
- {props.maxLength && (
-
- )}
-
-
- );
-};
-
-PhoneWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- // type: PropTypes.string.isRequired,
- required: PropTypes.bool,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- normalizer: PropTypes.func,
- description: PropTypes.string,
-};
-
-export default PhoneWidget;
diff --git a/src/app/form/widgets/RemoteSearchWidget.js b/src/app/form/widgets/RemoteSearchWidget.js
deleted file mode 100644
index c0e4d169..00000000
--- a/src/app/form/widgets/RemoteSearchWidget.js
+++ /dev/null
@@ -1,207 +0,0 @@
-import { useEffect, useState } from "react";
-import PropTypes from "prop-types";
-import classNames from "classnames";
-import Info from "../../components/Info";
-import { Combobox } from "react-widgets";
-import validator from "validator";
-import { useController, useFormContext } from "react-hook-form";
-import { get } from "lodash";
-
-const ListItem = ({ item }) => (
-
- {item.description + " "}
-
- ipa:
- {item.ipa}
- pec:
- {item.pec}
-
-);
-
-/**
- * Data modelling
- * @param result data
- * @param item
- * @returns {{link: string, description: *, ipa: (Document.ipa|*), value: string, pec: string}}
- */
-const modelData = (result) => ({
- ipa: result.ipa,
- description: result.description,
- pec: result.pec,
-});
-
-const manipulateData = (items) => {
- const res = [];
- items?.hits?.hits
- .map((result) => {
- const out = [];
- const _source = result._source;
- out.push(modelData(_source));
- return out;
- })
- .forEach((r) => {
- r.forEach((result) => {
- res.push(result);
- });
- });
- return res;
-};
-
-const getItem = (items) => {
- if (
- items?.hits?.hits &&
- Array.isArray(items.hits.hits) &&
- items.hits.hits.length > 0
- ) {
- const item = items.hits.hits[0];
- return item._source;
- }
- return "";
-};
-
-const RemoteSearchWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
-
- const [error, setError] = useState(null);
- const [text, setText] = useState("");
- const [initialValue, setInitialValue] = useState(false);
- const [items, setItems] = useState([]);
- const { control, formState } = useFormContext();
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- defaultValue: props.schema.value || "",
- });
- const className = classNames(["form-group", { "has-error": invalid }]);
-
- useEffect(() => {
- setInitialValue(true);
- query(inputProps.value);
- }, [inputProps.value]);
-
- const query = (value) => {
- value = typeof value === "object" ? value.ipa : value;
- const callParams = props.schema.ajax;
- const myHeaders = new Headers();
- myHeaders.append("Content-Type", "application/json");
- const query = callParams.params(value);
-
- const myInit = {
- method: "POST",
- headers: myHeaders,
- mode: "cors",
- cache: "default",
- body: JSON.stringify(query),
- };
-
- if (!validator.isURL(callParams.url, { require_tld: false })) return false;
-
- const request = new Request(callParams.url, myInit);
-
- fetch(request)
- .then((res) => res.json())
- .then(
- (result) => {
- if (!result.hits && Array.isArray(result.hits))
- throw Error("query malformed");
- setItems(result);
- },
- // Note: it's important to handle errors here
- // instead of a catch() block so that we don't swallow
- // exceptions from actual bugs in components.
- (error) => {
- console.error(error);
- setText(value);
- setError(error);
- }
- );
- };
-
- const handleChange = (event) => {
- const val = event.target.value;
- if (inputProps.onChange) {
- if (val == null) inputProps.onChange("");
- else inputProps.onChange(val);
- }
- setText(val);
- };
-
- const onChange = (val) => {
- if (val.length > 1) query(val, props.schema);
- else query("", props.schema);
- //return to editor
- if (inputProps.onChange) {
- if (val == null) inputProps.onChange("");
- else inputProps.onChange(val.ipa);
- }
- //setting initial and actual value
- setText(val);
- setInitialValue(false);
- };
-
- return (
-
-
-
- {error ? (
-
- ) : (
-
- typeof item === "string"
- ? item
- : item.description + " (" + item.ipa + ")"
- }
- renderListItem={ListItem}
- data={manipulateData(items)}
- />
- )}
-
- {invalid && (
-
- {get(formState.errors, name) && get(formState.errors, name).message}
-
- )}
-
-
- );
-};
-
-RemoteSearchWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- theme: PropTypes.object,
- multiple: PropTypes.bool,
- required: PropTypes.bool,
-};
-
-export default RemoteSearchWidget;
diff --git a/src/app/form/widgets/StringWidget.js b/src/app/form/widgets/StringWidget.js
deleted file mode 100644
index c84e2820..00000000
--- a/src/app/form/widgets/StringWidget.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import BaseInputWidget from "./BaseInputWidget";
-
-const StringWidget = props => {
- return ;
-};
-
-export default StringWidget;
diff --git a/src/app/form/widgets/TagWidget.js b/src/app/form/widgets/TagWidget.js
deleted file mode 100644
index c08ab24f..00000000
--- a/src/app/form/widgets/TagWidget.js
+++ /dev/null
@@ -1,67 +0,0 @@
-import PropTypes from "prop-types";
-import classNames from "classnames";
-import { Multiselect } from "react-widgets";
-import Info from "../../components/Info";
-import { useController, useFormContext } from "react-hook-form";
-import { get } from "lodash";
-
-const TagWidget = (props) => {
- const name = props.fieldName;
- const id = `field-${name}`;
- const { control, formState } = useFormContext();
- const {
- field: { ref, ...inputProps },
- fieldState: { invalid },
- } = useController({
- name,
- control,
- defaultValue: props.schema.value || "",
- });
- const className = classNames(["form-group", { "has-error": invalid }]);
-
- const multiSelectDataOpts = (props.schema.items.dataKey && props.schema.items.textField)
- ? { dataKey: props.schema.items.dataKey, textField: props.schema.items.textField }
- : {};
-
- return (
-
-
-
- inputProps.onBlur()}
- value={inputProps.value || []}
- data={props.schema.items.enum}
- filter="contains"
- />
-
- {invalid && (
-
- {get(formState.errors, name) && get(formState.errors, name).message}
-
- )}
-
-
- );
-};
-
-TagWidget.propTypes = {
- schema: PropTypes.object.isRequired,
- fieldName: PropTypes.string,
- label: PropTypes.string,
- theme: PropTypes.object,
- multiple: PropTypes.bool,
- required: PropTypes.bool,
-};
-
-export default TagWidget;
diff --git a/src/app/form/widgets/UrlWidget.js b/src/app/form/widgets/UrlWidget.js
deleted file mode 100644
index ab47c36d..00000000
--- a/src/app/form/widgets/UrlWidget.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import BaseInputWidget from "./BaseInputWidget";
-
-const UrlWidget = props => {
- return ;
-};
-
-export default UrlWidget;
diff --git a/src/app/form/widgets/index.js b/src/app/form/widgets/index.js
deleted file mode 100644
index 1a2ce550..00000000
--- a/src/app/form/widgets/index.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import StringWidget from "./StringWidget";
-import EmailWidget from "./EmailWidget";
-import ArrayWidget from "./ArrayWidget";
-import CheckboxWidget from "./CheckboxWidget";
-import ObjectWidget from "./ObjectWidget";
-import UrlWidget from "./UrlWidget";
-import ChoiceWidget from "./ChoiceWidget";
-import ChoiceExpandedWidget from "./ChoiceExpandedWidget";
-import EditorWidget from "./EditorWidget";
-import TagWidget from "./TagWidget";
-import ComboBoxWidget from "./ComboBoxWidget";
-import DateTimeReactWidget from "./DateTimeReactWidget";
-import RemoteSearchWidget from "./RemoteSearchWidget";
-import PhoneWidget from "./PhoneWidgets";
-import HiddenWidget from "./HiddenWidget";
-
-export default {
- editor: EditorWidget,
- tags: TagWidget,
- combobox: ComboBoxWidget,
- object: ObjectWidget,
- string: StringWidget,
- email: EmailWidget,
- array: ArrayWidget,
- boolean: CheckboxWidget,
- url: UrlWidget,
- choice: ChoiceWidget,
- "choice-expanded": ChoiceExpandedWidget,
- date: DateTimeReactWidget,
- phone: PhoneWidget,
- hidden: HiddenWidget,
- rsearch: RemoteSearchWidget
-};
diff --git a/src/app/hooks/useDebounce.ts b/src/app/hooks/useDebounce.ts
deleted file mode 100644
index 4bf990af..00000000
--- a/src/app/hooks/useDebounce.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { useEffect, useState } from "react";
-
-export default function useDebounce(value: T, delay: number) {
- // State and setters for debounced value
- const [debouncedValue, setDebouncedValue] = useState(value);
-
- useEffect(
- () => {
- // Set debouncedValue to value (passed in) after the specified delay
- const handler = setTimeout(() => {
- setDebouncedValue(value);
- }, delay);
-
- // Return a cleanup function that will be called every time ...
- // ... useEffect is re-called. useEffect will only be re-called ...
- // ... if value changes (see the inputs array below).
- // This is how we prevent debouncedValue from changing if value is ...
- // ... changed within the delay period. Timeout gets cleared and restarted.
- // To put it in context, if the user is typing within our app's ...
- // ... search box, we don't want the debouncedValue to update until ...
- // ... they've stopped typing for more than 500ms.
- return () => {
- clearTimeout(handler);
- };
- },
- // Only re-call effect if value changes
- // You could also add the "delay" var to inputs array if you ...
- // ... need to be able to change that dynamically.
- [value]
- );
-
- return debouncedValue;
-}
diff --git a/src/app/hooks/useEditor.ts b/src/app/hooks/useEditor.ts
deleted file mode 100644
index 38ab491a..00000000
--- a/src/app/hooks/useEditor.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { useEffect, useState } from "react";
-import { Block, getData } from "../contents/data";
-import { Field } from "../contents/fields/generic";
-
-export const useEditor = (currentCountry: string, languages: string[]) => {
- const [elements, setElements] = useState(null);
- const [blocks, setBlocks] = useState(null);
- const [allFields, setAllFields] = useState(null);
-
- useEffect(() => {
- const initData = (country: string | null = null, languages: string[]) => {
- const { elements, blocks, allFields } = getData(country, languages);
- setElements(elements);
- setBlocks(blocks);
- setAllFields(allFields);
- };
- initData(currentCountry, languages);
- }, [currentCountry, languages]);
-
- return [elements, blocks, allFields];
-};
diff --git a/src/app/utils/__tests__/calls.test.js b/src/app/utils/__tests__/calls.test.js
deleted file mode 100644
index 38b8c6ff..00000000
--- a/src/app/utils/__tests__/calls.test.js
+++ /dev/null
@@ -1,138 +0,0 @@
-import {
- bitbucketAPIRepoURL,
- bitbucketRepoURL,
- extGitlabAPIRepoURL,
- extGitlabRepoURL,
- githubAPIRepoURL,
- githubRepoURL,
- gitlabAPIRepoURL,
- gitlabRepoURL,
- unknownRepoURL,
- unknownAPIRepoURL,
-} from "../../../__mocks__/apiEndpoints";
-import { getDefaultBranch } from "../calls";
-import { mockFetch } from "./vcs.test";
-
-it("bitbucket default branch retrieval", async () => {
- global.fetch = mockFetch(true, { mainbranch: { name: "develop" } });
- const results = await getDefaultBranch(bitbucketRepoURL);
-
- expect(fetch).toHaveBeenCalledWith(bitbucketAPIRepoURL);
-
- expect(fetch).toHaveBeenCalledTimes(1);
- expect(results).toEqual({ branch: "develop" });
- fetch.mockClear();
-});
-
-describe("github/gitlab default branch retrieval", () => {
- it("github", async () => {
- global.fetch = mockFetch(true, { default_branch: "develop" });
- const results = await getDefaultBranch(githubRepoURL);
-
- expect(fetch).toHaveBeenCalledWith(githubAPIRepoURL);
-
- expect(fetch).toHaveBeenCalledTimes(1);
- expect(results).toEqual({ branch: "develop" });
- fetch.mockClear();
- });
-
- it("gitlab", async () => {
- global.fetch = mockFetch(true, { default_branch: "develop" });
- const results = await getDefaultBranch(gitlabRepoURL);
-
- expect(fetch).toHaveBeenCalledWith(gitlabAPIRepoURL);
-
- expect(fetch).toHaveBeenCalledTimes(1);
- expect(results).toEqual({ branch: "develop" });
- fetch.mockClear();
- });
-
- it("extgitlab", async () => {
- global.fetch = mockFetch(true, { default_branch: "develop" });
- const results = await getDefaultBranch(extGitlabRepoURL);
-
- expect(fetch).toHaveBeenCalledWith(extGitlabAPIRepoURL);
-
- expect(fetch).toHaveBeenCalledTimes(2);
- expect(results).toEqual({ branch: "develop" });
- fetch.mockClear();
- });
-
- it("unknown url with 404 on api call", async () => {
- global.fetch = mockFetch(true, {}, 404);
- const results = await getDefaultBranch(unknownRepoURL);
- expect(fetch.mock.calls).toEqual([
- ["https://google.com/api/v4/projects"], // First call
- [unknownAPIRepoURL], // Second call
- ]);
-
- expect(fetch).toHaveBeenCalledTimes(2);
- expect(results).toEqual({ branch: "master" });
- fetch.mockClear();
- });
-
- it("unknown url with failed (network problem) http request", async () => {
- global.fetch = mockFetch(false, {}, null);
- const results = await getDefaultBranch(unknownRepoURL);
- expect(fetch.mock.calls).toEqual([
- ["https://google.com/api/v4/projects"], // First call
- [unknownAPIRepoURL], // Second call
- ]);
-
- expect(fetch).toHaveBeenCalledTimes(2);
- expect(results).toEqual({ branch: "master" });
- fetch.mockClear();
- });
-
- it("unknown url with 500 http code", async () => {
- global.fetch = mockFetch(true, {}, 500);
- const results = await getDefaultBranch(unknownRepoURL);
- expect(fetch.mock.calls).toEqual([
- ["https://google.com/api/v4/projects"], // First call
- [unknownAPIRepoURL], // Second call
- ]);
-
- expect(fetch).toHaveBeenCalledTimes(2);
- expect(results).toEqual({ branch: "master" });
- fetch.mockClear();
- });
-
- it("unknown url with API is down or blocked by CORS", async () => {
- fetch.mockImplementationOnce(() =>
- Promise.reject("API is down or blocked by CORS")
- );
- const results = await getDefaultBranch(unknownRepoURL);
- expect(fetch.mock.calls).toEqual([
- ["https://google.com/api/v4/projects"], // First call
- [unknownAPIRepoURL], // Second call
- ]);
-
- expect(fetch).toHaveBeenCalledTimes(2);
- expect(results).toEqual({ branch: "master" });
- fetch.mockClear();
- });
-
- it("github url with API is down or blocked by CORS", async () => {
- fetch.mockImplementationOnce(() =>
- Promise.reject("API is down or blocked by CORS")
- );
- const results = await getDefaultBranch(githubRepoURL);
- expect(fetch).toHaveBeenCalledWith(githubAPIRepoURL);
-
- expect(fetch).toHaveBeenCalledTimes(1);
- expect(results).toEqual({ branch: "master" });
- fetch.mockClear();
- });
-
- it("Fetch API cannot load mispelled URL", async () => {
- fetch.mockImplementationOnce(() =>
- Promise.reject("Fetch API cannot load mispelled URL")
- );
- const results = await getDefaultBranch('x' + githubRepoURL);
- expect(fetch).toHaveBeenCalledWith('x' + githubAPIRepoURL);
-
- expect(fetch).toHaveBeenCalledTimes(1);
- expect(results).toEqual({ branch: "master" });
- fetch.mockClear();
- });
-});
diff --git a/src/app/utils/__tests__/dirtyFields.test.js b/src/app/utils/__tests__/dirtyFields.test.js
deleted file mode 100644
index 55b86a34..00000000
--- a/src/app/utils/__tests__/dirtyFields.test.js
+++ /dev/null
@@ -1,74 +0,0 @@
-import { dirtyValues } from "../transform";
-
-test("dirtyValues with nested field and second array item modified", () => {
- const dirtyFields = {
- name: true,
- address: {
- street: true,
- phoneNumbers: [null, true],
- },
- };
- const allValues = {
- name: "Bill",
- friend: true,
- address: {
- street: "Main",
- phoneNumbers: ["unchanged", "new"],
- },
- };
-
- expect(dirtyValues(dirtyFields, allValues)).toEqual({
- name: "Bill",
- address: {
- street: "Main",
- phoneNumbers: ["unchanged", "new"],
- },
- });
-});
-
-test("dirtyValues with first array item modified must return the entire array", () => {
- const dirtyFields = {
- address: {
- country: {
- state: {
- city: true,
- },
- },
- phoneNumbers: [true],
- },
- };
- const allValues = {
- address: {
- country: {
- state: {
- city: "Sydney",
- neighborCity: "Melbs",
- },
- },
- phoneNumbers: ["changed", "but others follow"],
- },
- };
-
- expect(dirtyValues(dirtyFields, allValues)).toEqual({
- address: {
- country: {
- state: {
- city: "Sydney",
- },
- },
- phoneNumbers: ["changed"],
- },
- });
-});
-
-test("changed item in array of objects", () => {
- const dirtyFields = {
- friends: [true, true],
- };
- const allValues = {
- friends: [{ first: "Bill", last: "Maher" }, { first: "Dan", last: "DV" }],
- };
- expect(dirtyValues(dirtyFields, allValues)).toEqual({
- friends: [{ first: "Bill", last: "Maher" }, { first: "Dan", last: "DV" }],
- });
-});
diff --git a/src/app/utils/__tests__/transform.test.js b/src/app/utils/__tests__/transform.test.js
deleted file mode 100644
index 37709503..00000000
--- a/src/app/utils/__tests__/transform.test.js
+++ /dev/null
@@ -1,28 +0,0 @@
-import {
- allFields,
- simpleYaml,
- simpleFormYaml,
- yamlFlattened,
- yamlFlattenedSimpleArray,
-} from "../../../__mocks__/fields";
-import {
- convertSimpleStringArray,
- toFlatPropertyMap,
- transformSimpleStringArrays,
-} from "../transform";
-
-describe("data transformation", () => {
- const flattened = toFlatPropertyMap(simpleYaml);
- const simplified = convertSimpleStringArray(flattened, allFields);
- it("yaml flattened", () => {
- expect(flattened).toEqual(yamlFlattened);
- });
- it("yaml flattened and simplified", () => {
- expect(simplified).toEqual(yamlFlattenedSimpleArray);
- });
- it("yaml transform back", () => {
- expect(transformSimpleStringArrays(simpleFormYaml, allFields)).toEqual(
- simpleYaml
- );
- });
-});
diff --git a/src/app/utils/__tests__/vcs.test.js b/src/app/utils/__tests__/vcs.test.js
deleted file mode 100644
index 841eadcd..00000000
--- a/src/app/utils/__tests__/vcs.test.js
+++ /dev/null
@@ -1,98 +0,0 @@
-import {
- bitbucketAPIRepoURL,
- bitbucketRepoURL,
- extGitlabAPIRepoURL,
- extGitlabRepoURL,
- githubAPIRepoURL,
- githubRepoURL,
- gitlabAPIRepoURL,
- gitlabRepoURL,
- unknownRepoURL,
- unknownAPIRepoURL,
-} from "../../../__mocks__/apiEndpoints";
-import {
- BITBUCKET,
- getAPIURL,
- GITHUB,
- GITLAB,
- isBitBucket,
- isGithub,
- isGitlab,
- UNKNOWN,
-} from "../vcs";
-
-export const mockFetch = (ok, out, status = 200) => {
- return jest.fn(() =>
- Promise.resolve({
- ok,
- status,
- json: () => Promise.resolve(out),
- })
- );
-};
-
-beforeEach(() => {
- global.fetch = mockFetch(false, {});
-});
-afterEach(() => {
- fetch.mockClear();
-});
-
-describe("vcs url identification", () => {
- it("github repo url identification", async () => {
- expect(isGithub(githubRepoURL)).toBeTruthy();
- expect(await isGitlab(githubRepoURL)).toBeFalsy();
- expect(isBitBucket(githubRepoURL)).toBeFalsy();
- });
- it("gitlab repo url identification", async () => {
- expect(isGithub(gitlabRepoURL)).toBeFalsy();
- expect(await isGitlab(gitlabRepoURL)).toBeTruthy();
- expect(isBitBucket(gitlabRepoURL)).toBeFalsy();
- });
- it("external gitlab repo url identification", async () => {
- global.fetch = mockFetch(true, {});
- expect(isGithub(extGitlabRepoURL)).toBeFalsy();
- expect(await isGitlab(extGitlabRepoURL)).toBeTruthy();
- expect(isBitBucket(extGitlabRepoURL)).toBeFalsy();
- });
- it("bitbucket repo url identification", async () => {
- expect(isGithub(bitbucketRepoURL)).toBeFalsy();
- expect(await isGitlab(bitbucketRepoURL)).toBeFalsy();
- expect(isBitBucket(bitbucketRepoURL)).toBeTruthy();
- });
- it("unknown repo url identification", async () => {
- expect(isGithub(unknownRepoURL)).toBeFalsy();
- expect(await isGitlab(unknownRepoURL)).toBeFalsy();
- expect(isBitBucket(unknownRepoURL)).toBeFalsy();
- });
-});
-
-describe("get API from urlString", () => {
- it("get Github repo api url", async () => {
- const { vcs, url } = await getAPIURL(githubRepoURL);
- expect(vcs).toEqual(GITHUB);
- expect(url).toEqual(githubAPIRepoURL);
- });
- it("get GitLab repo api url", async () => {
- global.fetch = mockFetch(true, {});
- const { vcs, url } = await getAPIURL(gitlabRepoURL);
- expect(vcs).toEqual(GITLAB);
- expect(url).toEqual(gitlabAPIRepoURL);
- });
- it("get external Gitlab repo api url", async () => {
- global.fetch = mockFetch(true, {});
- const { vcs, url } = await getAPIURL(extGitlabRepoURL);
- expect(vcs).toEqual(GITLAB);
- expect(url).toEqual(extGitlabAPIRepoURL);
- });
- it("get Bitbucket repo api url", async () => {
- const { vcs, url } = await getAPIURL(bitbucketRepoURL);
- expect(vcs).toEqual(BITBUCKET);
- expect(url).toEqual(bitbucketAPIRepoURL);
- });
- it("get unknown repo api url", async () => {
- const { vcs, url } = await getAPIURL(unknownRepoURL);
- expect(vcs).toEqual(UNKNOWN);
- expect(url).toEqual(unknownAPIRepoURL);
- });
-});
diff --git a/src/app/utils/calls.ts b/src/app/utils/calls.ts
deleted file mode 100644
index 85daf23b..00000000
--- a/src/app/utils/calls.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { defaultBranch } from "../contents/constants";
-import { getAPIURL, BITBUCKET, GITHUB, GITLAB } from "./vcs";
-
-export const getDefaultBranch = async (urlString: string) => {
- const { vcs, url } = await getAPIURL(urlString);
- try {
- const response = await fetch(url);
- if (!response.ok || !(response.status >= 200 && response.status <= 299)) {
- return defaultBranch; // assumption
- }
- const data = await response.json();
- switch (vcs) {
- case GITHUB:
- case GITLAB:
- return { branch: data?.default_branch as string };
- case BITBUCKET:
- return { branch: data?.mainbranch?.name as string };
- default:
- return defaultBranch; // assumption
- }
- } catch (error) {
- return defaultBranch; // assumption
- }
-};
-
-export const getRemotePubliccode = async (yamlURL: string) => {
- const myInit = {
- method: "GET",
- };
-
- const res = await fetch(yamlURL, myInit);
- // 422 should pass as it indicates a failed validation
- if (!res.ok && res.status != 422) {
- throw new Error(`fetch(${yamlURL}) returned ${res.status}`);
- }
- return await res.text();
-};
diff --git a/src/app/utils/transform.js b/src/app/utils/transform.js
deleted file mode 100644
index d5235273..00000000
--- a/src/app/utils/transform.js
+++ /dev/null
@@ -1,313 +0,0 @@
-import { SUMMARY, GROUPS, AVAILABLE_COUNTRIES } from "../contents/data";
-
-import _, { get } from "lodash";
-import u from "updeep";
-import cleanDeep from "clean-deep";
-import { set } from "lodash";
-
-const extractGroup = (items, group) => {
- let field_names = Object.keys(items);
- let filtered = field_names.filter((item) => item.startsWith(group));
- let obj = filtered.reduce((acc, name) => {
- let key = name.split("_")[1];
- let value = items[name];
- acc[key] = value;
- return acc;
- }, {});
- return obj;
-};
-
-export const getGrouped = (data) => {
- let result = _.chain(data)
- .groupBy("group")
- .map((values, group) => ({ values, group }))
- .value();
- return result;
-};
-
-export const flatGroup = (data, group) => {
- if (!data[group]) return null;
- let g = Object.assign({}, data[group]);
- delete data[group];
- let flatten = Object.keys(g).reduce((obj, key) => {
- obj[`${group}_${key}`] = g[key];
- return obj;
- }, {});
- return Object.assign(flatten, data);
-};
-
-export const parseSummary = (data) => {
- if (!data[SUMMARY]) return null;
- // let languages = Object.keys(data[SUMMARY]);
- // let currentLanguage = languages[0];
-};
-
-export const getSummary = (values) => {
- if (!values) return;
- let obj = extractGroup(values, SUMMARY + "_");
- return obj;
-};
-
-export const cleanupGroup = (data, group) => {
- //f
- return _.omitBy(data, (value, key) => {
- return _.startsWith(key, `${group}_`);
- });
-};
-
-export const transformDepensOn = (obj) => {
- let map = {};
- if (obj.dependsOn) {
- obj.dependsOn.map((dp) => {
- let cloned = Object.assign({}, dp);
- delete cloned.type;
-
- if (!map[dp.type]) map[dp.type] = [];
- map[dp.type].push(cloned);
- });
- obj.dependsOn = map;
- }
- return obj;
-};
-
-const importDepensOn = (obj) => {
- // let map = [];
- if (obj.dependsOn) {
- let types = Object.keys(obj.dependsOn);
- let map = types.reduce((a, type) => {
- let items = obj.dependsOn[type].map((i) => {
- i.type = type;
- return i;
- });
- return [...a, ...items];
- }, []);
- obj.dependsOn = map;
- }
- return obj;
-};
-
-export const extractLanguages = (data) => {
- return Object.keys(data[SUMMARY]) || [];
-};
-
-export const transformBack = (obj) => {
- //spit dependsOn child to array with types
- obj = importDepensOn(obj);
-
- //TRANSFORM DATA BACK:
- let groups = GROUPS.slice(0);
-
- let index = groups.indexOf(SUMMARY);
- if (index !== -1) groups.splice(index, 1);
- //- for each country check if data
- let country = null;
- AVAILABLE_COUNTRIES.forEach((cc) => {
- if (obj[cc]) {
- groups.push(cc);
- country = cc;
- }
- });
- //- for each group get keys and read with prefix
- groups.map((group) => {
- if (obj[group]) {
- Object.keys(obj[group]).forEach((k) => {
- obj[`${group}_${k}`] = obj[group][k];
- });
- delete obj[group];
- }
- });
- //- get SUMMARY keys to detect langs
- let values = {};
- let languages = [];
- if (obj[SUMMARY]) {
- Object.keys(obj[SUMMARY]).map((language_key) => {
- languages.push(language_key);
- values[language_key] = {};
- let lng = obj[SUMMARY][language_key];
- //for each language, get fields prefix with SUMMARY group
- Object.keys(lng).map((key) => {
- values[language_key][`${SUMMARY}.${key}`] = lng[key];
- });
- });
- }
- delete obj[SUMMARY];
-
- //merge values per each language
- if (languages) {
- languages.forEach((lang) => {
- values = u(obj, values[lang]);
- });
- } else {
- values = Object.assign({}, obj);
- }
- //TODO Remove fields not in list
- return { languages, values, country };
-};
-
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-const cleanupFields = (element, obj) => {
- let availableKeys = Object.keys(element);
- Object.keys(obj).forEach((k) => {
- if (availableKeys.indexOf(k) == 0 || typeof obj[k] != element[k].type) {
- delete obj[k];
- }
- if (typeof obj[k] === "object" && !Array.isArray(obj[k])) {
- obj[k] = transformBooleanValues(element[k], Object.assign({}, obj[k]));
- }
- });
- return obj;
-};
-
-const getElement = (elements, k) => {
- let e;
- if (typeof elements === "object" && !Array.isArray(elements)) {
- if (elements.title != "dependsOn") e = elements.properties[k];
- else {
- elements = transformDepensOn(elements);
- }
- } else
- e = elements.find((v) => {
- return v.title == k;
- });
- return e;
-};
-
-const transformBooleanValues = (obj, elements) => {
- Object.keys(obj).forEach((k) => {
- if (typeof obj[k] === "object" && !Array.isArray(obj[k])) {
- const e = elements.find((v) => {
- return v.title == k;
- });
- obj[k] = transformBooleanValues(Object.assign({}, obj[k]), e);
- } else if (
- !Array.isArray(obj[k]) &&
- (obj[k] == true ||
- obj[k] == false ||
- obj[k] == "true" ||
- obj[k] == "false")
- ) {
- if (getElement(elements, k).type == "boolean") {
- if (obj[k] == true || obj[k] == "true") obj[k] = true;
- else obj[k] = false;
- }
- }
- });
- return obj;
-};
-
-export const transformSimpleStringArrays = (values, allFields) => {
- const simpleStringArrays = allFields.filter((x) => x.simpleStringArray);
-
- if (!simpleStringArrays.some((x) => get(values, x.title, false)))
- return values; //simpleStringArrays are not in values
-
- const data = simpleStringArrays.map((x) => ({
- title: x.title,
- value: get(values, x.title),
- }));
- const obj = { ...values };
- data.map((x) => {
- Array.isArray(x.value) &&
- set(
- obj,
- x.title,
- x.value.map((y) => y.value)
- );
- });
- return obj;
-};
-
-// flattend down the final tree object
-export const toFlatPropertyMap = (obj, keySeparator = ".") => {
- const flattenRecursive = (obj, parentProperty, propertyMap = {}) => {
- for (const [key, value] of Object.entries(obj)) {
- const property = parentProperty
- ? `${parentProperty}${keySeparator}${key}`
- : key;
- if (value && typeof value === "object") {
- if (Array.isArray(value)) {
- propertyMap[property] = value;
- } else {
- flattenRecursive(value, property, propertyMap);
- }
- } else {
- propertyMap[property] = value;
- }
- }
- return propertyMap;
- };
- return flattenRecursive(obj);
-};
-
-// convert fields with simpleStringArray support
-// in their definition to an array of object
-// useful to overcome react-hook-limitation
-export const convertSimpleStringArray = (data, allFields) => {
- const simpleStringFields = allFields.filter(
- (x) => x.simpleStringArray === true
- );
- if (!simpleStringFields.some((x) => get(data, x.title, false))) return data; //simpleStringArrays are not in values
-
- return simpleStringFields.map((x) => ({
- ...data,
- [x.title]: data[x.title].map((y) => ({ value: y })),
- }))[0];
-};
-
-// Map RHF's dirtyFields over the `data` received by `handleSubmit` and return the changed subset of that data.
-export function dirtyValues(dirtyFields, allValues) {
- if (dirtyFields === true) return allValues;
- if (!dirtyFields) return allValues;
- if (Array.isArray(dirtyFields))
- return dirtyFields.map((x, i) => dirtyValues(x, allValues[i]));
-
- return Object.fromEntries(
- Object.keys(dirtyFields).map((key) => {
- return [key, dirtyValues(dirtyFields[key], allValues[key])];
- })
- );
-}
-
-export const transform = (values, country, elements) => {
- let langs = Object.keys(values);
-
- //GET SUMMARY BEFORE MERGE
- let summary = langs.reduce((obj, lng) => {
- obj[lng] = getSummary(values[lng], lng);
- return obj;
- }, {});
-
- //MERGE ALL
- let merge = langs.reduce((acc, lng) => {
- return u(values[lng], acc);
- }, {});
-
- //GROUP FIELDS
- let obj = Object.assign({}, merge);
- obj = cleanupGroup(obj, SUMMARY);
-
- //DEPENS ON strip type and reorganize in subtype objects
- obj = transformDepensOn(obj);
-
- let groups = GROUPS.slice(0);
- if (country) {
- groups = [...groups, country];
- }
- delete groups[SUMMARY];
-
- //TRANSFORM TRUE IN YES
- obj = transformBooleanValues(Object.assign({}, obj), elements);
-
- //REPLACE GROUPS
- groups.forEach((group) => {
- let sub = extractGroup(obj, group);
- if (sub) {
- obj = cleanupGroup(obj, group);
- obj[group] = sub;
- }
- });
-
- //REPLACE SUMMARY
- obj[SUMMARY] = summary;
- return cleanDeep(obj);
-};
diff --git a/src/app/utils/validate.js b/src/app/utils/validate.js
deleted file mode 100644
index 9b126505..00000000
--- a/src/app/utils/validate.js
+++ /dev/null
@@ -1,42 +0,0 @@
-import { dirtyValues, transformSimpleStringArrays } from "./transform";
-import { validator } from "../validator";
-
-export const validate = (
- data,
- allFields,
- dirtyFields,
- languages,
- handleValidationErrors,
- handleYamlChange,
- defaultBranch
-) => {
- // console.log("originalData", data);
- // console.log("dirtyFields", dirtyFields);
- const dataTouched = dirtyValues(dirtyFields, data);
- // console.log("dataTouched", dataTouched);
-
- const dataSimpleStringArrays = transformSimpleStringArrays(
- dataTouched,
- allFields
- );
- // console.log("dataSimpleStringArrays", dataSimpleStringArrays);
-
- // TODO improve
- // hack to get all description subfield validated
- if (!dataSimpleStringArrays.description)
- dataSimpleStringArrays.description = {};
- languages.map((x) => {
- if (!dataSimpleStringArrays.description[x]) {
- dataSimpleStringArrays.description[x] = {};
- }
- });
- handleYamlChange(dataSimpleStringArrays);
-
- validator(dataSimpleStringArrays, defaultBranch)
- .then((res) => {
- handleValidationErrors(res);
- })
- .catch((e) => {
- handleValidationErrors(e);
- });
-};
diff --git a/src/app/utils/vcs.ts b/src/app/utils/vcs.ts
deleted file mode 100644
index f939667a..00000000
--- a/src/app/utils/vcs.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-export const GITHUB = "github";
-export const GITLAB = "gitlab";
-export const BITBUCKET = "bitbucket";
-export const UNKNOWN = "unknown";
-
-const toURL = (urlString: string) => {
- try {
- return new URL(urlString);
- } catch (error) {
- console.error("error parsing url", error, urlString);
- return null;
- }
-};
-
-export const isGithub = (urlString: string) => {
- const url = toURL(urlString);
- if (url === null) return false;
- const { host } = url;
- return host === "github.com" || host === "raw.githubusercontent.com";
-};
-
-export const isBitBucket = (urlString: string) => {
- const url = toURL(urlString);
- if (url === null) return false;
- return url.host === "bitbucket.org";
-};
-
-const isGitlabAPI = async (url: string) => {
- try {
- const response = await fetch(url);
- if (!response.ok || !(response.status >= 200 && response.status <= 299)) {
- return false;
- }
- return true;
- } catch (error) {
- return false;
- }
-};
-
-export const isGitlab = async (urlString: string) => {
- const url = toURL(urlString);
- if (url === null) return false;
- if (url.host === "gitlab.com") {
- return true;
- }
- if (!isBitBucket(urlString) && !isGithub(urlString)) {
- url.pathname = `api/v4/projects`;
- return isGitlabAPI(url.toString());
- }
- return false;
-};
-
-export const getAPIURL = async (urlString: string) => {
- const url = toURL(urlString);
- if (url === null) throw new Error(`Invalid URL: ${url}`);
- switch (true) {
- case isGithub(urlString):
- url.pathname = `repos${url.pathname}`;
- url.host = `api.${url.host}`;
- return { vcs: GITHUB, url: url.toString() };
- case isBitBucket(urlString):
- url.pathname = `2.0/repositories${url.pathname}`;
- url.host = `api.${url.host}`;
- return { vcs: BITBUCKET, url: url.toString() };
- case await isGitlab(urlString):
- url.pathname = `api/v4/projects/${encodeURIComponent(
- url.pathname.substring(1)
- )}`;
- return { vcs: GITLAB, url: url.toString() };
- default:
- return { vcs: UNKNOWN, url: url.toString() };
- }
-};
diff --git a/src/app/validator.ts b/src/app/validator.ts
index 2a1b3bf0..9c31b181 100644
--- a/src/app/validator.ts
+++ b/src/app/validator.ts
@@ -21,17 +21,33 @@ declare function IsPublicCodeYmlValid(
const path = "main.wasm";
-const loadWasm = async () => {
- const go = new Go();
- const { instance } = await WebAssembly.instantiateStreaming(
- fetch(path),
- go.importObject
- );
- await go.run(instance);
- console.error("Error: Go main returned, this should never happen.");
-};
+export async function loadWasm() {
+ try {
+ const go = new (window as any).Go();
+
+ if (go) {
+ const { instance } = await WebAssembly.instantiateStreaming(
+ fetch(path),
+ go.importObject
+ );
+ go.run(instance);
+ return window;
+ }
+ } catch (error) {
+ console.error("Error: Go main returned, this should never happen.", error);
+ return null;
+ }
+}
+
+loadWasm()
+ .catch((e) => console.error(`Failed to load Wasm: ${e}`))
+ .then((res) => {
+ console.log("loadWasm OK");
+ return res;
+ });
-loadWasm().catch((e) => console.error(`Failed to load Wasm: ${e}`));
+// await loadWasm();
+//.catch((e) => console.error(`Failed to load Wasm: ${e}`));
export const validator = async (
publiccode: string,
diff --git a/src/app/yaml-serializer.ts b/src/app/yaml-serializer.ts
new file mode 100644
index 00000000..d4f36b16
--- /dev/null
+++ b/src/app/yaml-serializer.ts
@@ -0,0 +1,36 @@
+import yaml from 'js-yaml'
+import PublicCode from './contents/publiccode';
+
+async function readStreamAsText(readableStream: ReadableStream) {
+ const reader = readableStream.getReader();
+ let result = '';
+ const decoder = new TextDecoder();
+
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ result += decoder.decode(value, { stream: true });
+ }
+
+ result += decoder.decode(); // Finalize decoding
+ return result;
+}
+
+const serializeYml = (yamlString: string) => {
+ if (!yamlString) {
+ throw new Error('serializeYml: yamlString is a falsy value')
+ }
+ try {
+ return yaml.load(yamlString)
+ } catch {
+ throw new Error('serializeYml: error on load')
+ }
+}
+
+const serializeToPublicCode = async (stream: ReadableStream) => {
+ return await readStreamAsText(stream).then(serializeYml) as Promise;
+}
+
+export default async (stream: ReadableStream) => {
+ return await serializeToPublicCode(stream)
+}
\ No newline at end of file
diff --git a/src/asset/fonts/Lora/Lora-Bold.ttf b/src/assets/fonts/Lora/Lora-Bold.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Lora/Lora-Bold.ttf
rename to src/assets/fonts/Lora/Lora-Bold.ttf
diff --git a/src/asset/fonts/Lora/Lora-Bold.woff b/src/assets/fonts/Lora/Lora-Bold.woff
similarity index 100%
rename from src/asset/fonts/Lora/Lora-Bold.woff
rename to src/assets/fonts/Lora/Lora-Bold.woff
diff --git a/src/asset/fonts/Lora/Lora-Bold.woff2 b/src/assets/fonts/Lora/Lora-Bold.woff2
similarity index 100%
rename from src/asset/fonts/Lora/Lora-Bold.woff2
rename to src/assets/fonts/Lora/Lora-Bold.woff2
diff --git a/src/asset/fonts/Lora/Lora-Regular.ttf b/src/assets/fonts/Lora/Lora-Regular.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Lora/Lora-Regular.ttf
rename to src/assets/fonts/Lora/Lora-Regular.ttf
diff --git a/src/asset/fonts/Lora/Lora-Regular.woff b/src/assets/fonts/Lora/Lora-Regular.woff
similarity index 100%
rename from src/asset/fonts/Lora/Lora-Regular.woff
rename to src/assets/fonts/Lora/Lora-Regular.woff
diff --git a/src/asset/fonts/Lora/Lora-Regular.woff2 b/src/assets/fonts/Lora/Lora-Regular.woff2
similarity index 100%
rename from src/asset/fonts/Lora/Lora-Regular.woff2
rename to src/assets/fonts/Lora/Lora-Regular.woff2
diff --git a/src/asset/fonts/Lora/OFL.txt b/src/assets/fonts/Lora/OFL.txt
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Lora/OFL.txt
rename to src/assets/fonts/Lora/OFL.txt
diff --git a/src/asset/fonts/Roboto_Mono/LICENSE.txt b/src/assets/fonts/Roboto_Mono/LICENSE.txt
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/LICENSE.txt
rename to src/assets/fonts/Roboto_Mono/LICENSE.txt
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Bold.ttf b/src/assets/fonts/Roboto_Mono/RobotoMono-Bold.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Bold.ttf
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Bold.ttf
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Bold.woff b/src/assets/fonts/Roboto_Mono/RobotoMono-Bold.woff
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Bold.woff
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Bold.woff
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Bold.woff2 b/src/assets/fonts/Roboto_Mono/RobotoMono-Bold.woff2
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Bold.woff2
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Bold.woff2
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Light.ttf b/src/assets/fonts/Roboto_Mono/RobotoMono-Light.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Light.ttf
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Light.ttf
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Light.woff b/src/assets/fonts/Roboto_Mono/RobotoMono-Light.woff
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Light.woff
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Light.woff
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Light.woff2 b/src/assets/fonts/Roboto_Mono/RobotoMono-Light.woff2
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Light.woff2
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Light.woff2
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Medium.ttf b/src/assets/fonts/Roboto_Mono/RobotoMono-Medium.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Medium.ttf
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Medium.ttf
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Medium.woff b/src/assets/fonts/Roboto_Mono/RobotoMono-Medium.woff
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Medium.woff
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Medium.woff
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Medium.woff2 b/src/assets/fonts/Roboto_Mono/RobotoMono-Medium.woff2
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Medium.woff2
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Medium.woff2
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Regular.ttf b/src/assets/fonts/Roboto_Mono/RobotoMono-Regular.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Regular.ttf
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Regular.ttf
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Regular.woff b/src/assets/fonts/Roboto_Mono/RobotoMono-Regular.woff
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Regular.woff
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Regular.woff
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Regular.woff2 b/src/assets/fonts/Roboto_Mono/RobotoMono-Regular.woff2
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Regular.woff2
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Regular.woff2
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Thin.ttf b/src/assets/fonts/Roboto_Mono/RobotoMono-Thin.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Thin.ttf
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Thin.ttf
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Thin.woff b/src/assets/fonts/Roboto_Mono/RobotoMono-Thin.woff
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Thin.woff
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Thin.woff
diff --git a/src/asset/fonts/Roboto_Mono/RobotoMono-Thin.woff2 b/src/assets/fonts/Roboto_Mono/RobotoMono-Thin.woff2
similarity index 100%
rename from src/asset/fonts/Roboto_Mono/RobotoMono-Thin.woff2
rename to src/assets/fonts/Roboto_Mono/RobotoMono-Thin.woff2
diff --git a/src/asset/fonts/Titillium_Web/OFL.txt b/src/assets/fonts/Titillium_Web/OFL.txt
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Titillium_Web/OFL.txt
rename to src/assets/fonts/Titillium_Web/OFL.txt
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Black.ttf b/src/assets/fonts/Titillium_Web/TitilliumWeb-Black.ttf
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Black.ttf
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Black.ttf
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Black.woff b/src/assets/fonts/Titillium_Web/TitilliumWeb-Black.woff
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Black.woff
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Black.woff
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Black.woff2 b/src/assets/fonts/Titillium_Web/TitilliumWeb-Black.woff2
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Black.woff2
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Black.woff2
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Bold.ttf b/src/assets/fonts/Titillium_Web/TitilliumWeb-Bold.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Bold.ttf
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Bold.ttf
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Bold.woff b/src/assets/fonts/Titillium_Web/TitilliumWeb-Bold.woff
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Bold.woff
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Bold.woff
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Bold.woff2 b/src/assets/fonts/Titillium_Web/TitilliumWeb-Bold.woff2
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Bold.woff2
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Bold.woff2
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf b/src/assets/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-ExtraLight.woff b/src/assets/fonts/Titillium_Web/TitilliumWeb-ExtraLight.woff
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-ExtraLight.woff
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-ExtraLight.woff
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-ExtraLight.woff2 b/src/assets/fonts/Titillium_Web/TitilliumWeb-ExtraLight.woff2
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-ExtraLight.woff2
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-ExtraLight.woff2
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Light.ttf b/src/assets/fonts/Titillium_Web/TitilliumWeb-Light.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Light.ttf
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Light.ttf
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Light.woff b/src/assets/fonts/Titillium_Web/TitilliumWeb-Light.woff
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Light.woff
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Light.woff
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Light.woff2 b/src/assets/fonts/Titillium_Web/TitilliumWeb-Light.woff2
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Light.woff2
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Light.woff2
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Regular.ttf b/src/assets/fonts/Titillium_Web/TitilliumWeb-Regular.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Regular.ttf
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Regular.ttf
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Regular.woff b/src/assets/fonts/Titillium_Web/TitilliumWeb-Regular.woff
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Regular.woff
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Regular.woff
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-Regular.woff2 b/src/assets/fonts/Titillium_Web/TitilliumWeb-Regular.woff2
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-Regular.woff2
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-Regular.woff2
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf b/src/assets/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf
old mode 100755
new mode 100644
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-SemiBold.woff b/src/assets/fonts/Titillium_Web/TitilliumWeb-SemiBold.woff
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-SemiBold.woff
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-SemiBold.woff
diff --git a/src/asset/fonts/Titillium_Web/TitilliumWeb-SemiBold.woff2 b/src/assets/fonts/Titillium_Web/TitilliumWeb-SemiBold.woff2
similarity index 100%
rename from src/asset/fonts/Titillium_Web/TitilliumWeb-SemiBold.woff2
rename to src/assets/fonts/Titillium_Web/TitilliumWeb-SemiBold.woff2
diff --git a/src/asset/glyphicons/glyphicons-halflings-regular.eot b/src/assets/glyphicons/glyphicons-halflings-regular.eot
similarity index 100%
rename from src/asset/glyphicons/glyphicons-halflings-regular.eot
rename to src/assets/glyphicons/glyphicons-halflings-regular.eot
diff --git a/src/asset/glyphicons/glyphicons-halflings-regular.svg b/src/assets/glyphicons/glyphicons-halflings-regular.svg
similarity index 100%
rename from src/asset/glyphicons/glyphicons-halflings-regular.svg
rename to src/assets/glyphicons/glyphicons-halflings-regular.svg
diff --git a/src/asset/glyphicons/glyphicons-halflings-regular.ttf b/src/assets/glyphicons/glyphicons-halflings-regular.ttf
similarity index 100%
rename from src/asset/glyphicons/glyphicons-halflings-regular.ttf
rename to src/assets/glyphicons/glyphicons-halflings-regular.ttf
diff --git a/src/asset/glyphicons/glyphicons-halflings-regular.woff b/src/assets/glyphicons/glyphicons-halflings-regular.woff
similarity index 100%
rename from src/asset/glyphicons/glyphicons-halflings-regular.woff
rename to src/assets/glyphicons/glyphicons-halflings-regular.woff
diff --git a/src/asset/glyphicons/glyphicons-halflings-regular.woff2 b/src/assets/glyphicons/glyphicons-halflings-regular.woff2
similarity index 100%
rename from src/asset/glyphicons/glyphicons-halflings-regular.woff2
rename to src/assets/glyphicons/glyphicons-halflings-regular.woff2
diff --git a/src/asset/glyphicons/glyphicons.css b/src/assets/glyphicons/glyphicons.css
similarity index 100%
rename from src/asset/glyphicons/glyphicons.css
rename to src/assets/glyphicons/glyphicons.css
diff --git a/src/asset/img/_copy.svg b/src/assets/img/_copy.svg
similarity index 100%
rename from src/asset/img/_copy.svg
rename to src/assets/img/_copy.svg
diff --git a/src/asset/img/_download.svg b/src/assets/img/_download.svg
similarity index 100%
rename from src/asset/img/_download.svg
rename to src/assets/img/_download.svg
diff --git a/src/asset/img/_load.svg b/src/assets/img/_load.svg
similarity index 100%
rename from src/asset/img/_load.svg
rename to src/assets/img/_load.svg
diff --git a/src/asset/img/accordion-closed.svg b/src/assets/img/accordion-closed.svg
similarity index 100%
rename from src/asset/img/accordion-closed.svg
rename to src/assets/img/accordion-closed.svg
diff --git a/src/asset/img/accordion-open.svg b/src/assets/img/accordion-open.svg
similarity index 100%
rename from src/asset/img/accordion-open.svg
rename to src/assets/img/accordion-open.svg
diff --git a/src/asset/img/checkbox-nonselected.svg b/src/assets/img/checkbox-nonselected.svg
similarity index 100%
rename from src/asset/img/checkbox-nonselected.svg
rename to src/assets/img/checkbox-nonselected.svg
diff --git a/src/asset/img/checkbox-selected.svg b/src/assets/img/checkbox-selected.svg
similarity index 100%
rename from src/asset/img/checkbox-selected.svg
rename to src/assets/img/checkbox-selected.svg
diff --git a/src/asset/img/checkbox.svg b/src/assets/img/checkbox.svg
similarity index 100%
rename from src/asset/img/checkbox.svg
rename to src/assets/img/checkbox.svg
diff --git a/src/asset/img/close.svg b/src/assets/img/close.svg
similarity index 100%
rename from src/asset/img/close.svg
rename to src/assets/img/close.svg
diff --git a/src/asset/img/copy.svg b/src/assets/img/copy.svg
similarity index 100%
rename from src/asset/img/copy.svg
rename to src/assets/img/copy.svg
diff --git a/src/asset/img/dots.svg b/src/assets/img/dots.svg
similarity index 100%
rename from src/asset/img/dots.svg
rename to src/assets/img/dots.svg
diff --git a/src/asset/img/download.svg b/src/assets/img/download.svg
similarity index 100%
rename from src/asset/img/download.svg
rename to src/assets/img/download.svg
diff --git a/src/asset/img/load.svg b/src/assets/img/load.svg
similarity index 100%
rename from src/asset/img/load.svg
rename to src/assets/img/load.svg
diff --git a/src/asset/img/option-nonselected.svg b/src/assets/img/option-nonselected.svg
similarity index 100%
rename from src/asset/img/option-nonselected.svg
rename to src/assets/img/option-nonselected.svg
diff --git a/src/asset/img/option-selected.svg b/src/assets/img/option-selected.svg
similarity index 100%
rename from src/asset/img/option-selected.svg
rename to src/assets/img/option-selected.svg
diff --git a/src/asset/img/upload.svg b/src/assets/img/upload.svg
similarity index 100%
rename from src/asset/img/upload.svg
rename to src/assets/img/upload.svg
diff --git a/src/asset/img/x.svg b/src/assets/img/x.svg
similarity index 100%
rename from src/asset/img/x.svg
rename to src/assets/img/x.svg
diff --git a/src/asset/img/xx.svg b/src/assets/img/xx.svg
similarity index 100%
rename from src/asset/img/xx.svg
rename to src/assets/img/xx.svg
diff --git a/src/asset/index.css b/src/assets/index.css
similarity index 99%
rename from src/asset/index.css
rename to src/assets/index.css
index ee8e32cb..97bf20ca 100644
--- a/src/asset/index.css
+++ b/src/assets/index.css
@@ -848,3 +848,6 @@
margin-left: -10px;
}
+.notification {
+ z-index: 999999 !important;
+}
diff --git a/src/assets/react.svg b/src/assets/react.svg
new file mode 100644
index 00000000..6c87de9b
--- /dev/null
+++ b/src/assets/react.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/wasm_exec.js b/src/assets/wasm_exec.js
new file mode 100644
index 00000000..bc6f2102
--- /dev/null
+++ b/src/assets/wasm_exec.js
@@ -0,0 +1,561 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+"use strict";
+
+(() => {
+ const enosys = () => {
+ const err = new Error("not implemented");
+ err.code = "ENOSYS";
+ return err;
+ };
+
+ if (!globalThis.fs) {
+ let outputBuf = "";
+ globalThis.fs = {
+ constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused
+ writeSync(fd, buf) {
+ outputBuf += decoder.decode(buf);
+ const nl = outputBuf.lastIndexOf("\n");
+ if (nl != -1) {
+ console.log(outputBuf.substring(0, nl));
+ outputBuf = outputBuf.substring(nl + 1);
+ }
+ return buf.length;
+ },
+ write(fd, buf, offset, length, position, callback) {
+ if (offset !== 0 || length !== buf.length || position !== null) {
+ callback(enosys());
+ return;
+ }
+ const n = this.writeSync(fd, buf);
+ callback(null, n);
+ },
+ chmod(path, mode, callback) { callback(enosys()); },
+ chown(path, uid, gid, callback) { callback(enosys()); },
+ close(fd, callback) { callback(enosys()); },
+ fchmod(fd, mode, callback) { callback(enosys()); },
+ fchown(fd, uid, gid, callback) { callback(enosys()); },
+ fstat(fd, callback) { callback(enosys()); },
+ fsync(fd, callback) { callback(null); },
+ ftruncate(fd, length, callback) { callback(enosys()); },
+ lchown(path, uid, gid, callback) { callback(enosys()); },
+ link(path, link, callback) { callback(enosys()); },
+ lstat(path, callback) { callback(enosys()); },
+ mkdir(path, perm, callback) { callback(enosys()); },
+ open(path, flags, mode, callback) { callback(enosys()); },
+ read(fd, buffer, offset, length, position, callback) { callback(enosys()); },
+ readdir(path, callback) { callback(enosys()); },
+ readlink(path, callback) { callback(enosys()); },
+ rename(from, to, callback) { callback(enosys()); },
+ rmdir(path, callback) { callback(enosys()); },
+ stat(path, callback) { callback(enosys()); },
+ symlink(path, link, callback) { callback(enosys()); },
+ truncate(path, length, callback) { callback(enosys()); },
+ unlink(path, callback) { callback(enosys()); },
+ utimes(path, atime, mtime, callback) { callback(enosys()); },
+ };
+ }
+
+ if (!globalThis.process) {
+ globalThis.process = {
+ getuid() { return -1; },
+ getgid() { return -1; },
+ geteuid() { return -1; },
+ getegid() { return -1; },
+ getgroups() { throw enosys(); },
+ pid: -1,
+ ppid: -1,
+ umask() { throw enosys(); },
+ cwd() { throw enosys(); },
+ chdir() { throw enosys(); },
+ }
+ }
+
+ if (!globalThis.crypto) {
+ throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");
+ }
+
+ if (!globalThis.performance) {
+ throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");
+ }
+
+ if (!globalThis.TextEncoder) {
+ throw new Error("globalThis.TextEncoder is not available, polyfill required");
+ }
+
+ if (!globalThis.TextDecoder) {
+ throw new Error("globalThis.TextDecoder is not available, polyfill required");
+ }
+
+ const encoder = new TextEncoder("utf-8");
+ const decoder = new TextDecoder("utf-8");
+
+ globalThis.Go = class {
+ constructor() {
+ this.argv = ["js"];
+ this.env = {};
+ this.exit = (code) => {
+ if (code !== 0) {
+ console.warn("exit code:", code);
+ }
+ };
+ this._exitPromise = new Promise((resolve) => {
+ this._resolveExitPromise = resolve;
+ });
+ this._pendingEvent = null;
+ this._scheduledTimeouts = new Map();
+ this._nextCallbackTimeoutID = 1;
+
+ const setInt64 = (addr, v) => {
+ this.mem.setUint32(addr + 0, v, true);
+ this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);
+ }
+
+ const setInt32 = (addr, v) => {
+ this.mem.setUint32(addr + 0, v, true);
+ }
+
+ const getInt64 = (addr) => {
+ const low = this.mem.getUint32(addr + 0, true);
+ const high = this.mem.getInt32(addr + 4, true);
+ return low + high * 4294967296;
+ }
+
+ const loadValue = (addr) => {
+ const f = this.mem.getFloat64(addr, true);
+ if (f === 0) {
+ return undefined;
+ }
+ if (!isNaN(f)) {
+ return f;
+ }
+
+ const id = this.mem.getUint32(addr, true);
+ return this._values[id];
+ }
+
+ const storeValue = (addr, v) => {
+ const nanHead = 0x7FF80000;
+
+ if (typeof v === "number" && v !== 0) {
+ if (isNaN(v)) {
+ this.mem.setUint32(addr + 4, nanHead, true);
+ this.mem.setUint32(addr, 0, true);
+ return;
+ }
+ this.mem.setFloat64(addr, v, true);
+ return;
+ }
+
+ if (v === undefined) {
+ this.mem.setFloat64(addr, 0, true);
+ return;
+ }
+
+ let id = this._ids.get(v);
+ if (id === undefined) {
+ id = this._idPool.pop();
+ if (id === undefined) {
+ id = this._values.length;
+ }
+ this._values[id] = v;
+ this._goRefCounts[id] = 0;
+ this._ids.set(v, id);
+ }
+ this._goRefCounts[id]++;
+ let typeFlag = 0;
+ switch (typeof v) {
+ case "object":
+ if (v !== null) {
+ typeFlag = 1;
+ }
+ break;
+ case "string":
+ typeFlag = 2;
+ break;
+ case "symbol":
+ typeFlag = 3;
+ break;
+ case "function":
+ typeFlag = 4;
+ break;
+ }
+ this.mem.setUint32(addr + 4, nanHead | typeFlag, true);
+ this.mem.setUint32(addr, id, true);
+ }
+
+ const loadSlice = (addr) => {
+ const array = getInt64(addr + 0);
+ const len = getInt64(addr + 8);
+ return new Uint8Array(this._inst.exports.mem.buffer, array, len);
+ }
+
+ const loadSliceOfValues = (addr) => {
+ const array = getInt64(addr + 0);
+ const len = getInt64(addr + 8);
+ const a = new Array(len);
+ for (let i = 0; i < len; i++) {
+ a[i] = loadValue(array + i * 8);
+ }
+ return a;
+ }
+
+ const loadString = (addr) => {
+ const saddr = getInt64(addr + 0);
+ const len = getInt64(addr + 8);
+ return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
+ }
+
+ const timeOrigin = Date.now() - performance.now();
+ this.importObject = {
+ _gotest: {
+ add: (a, b) => a + b,
+ },
+ gojs: {
+ // Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
+ // may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
+ // function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
+ // This changes the SP, thus we have to update the SP used by the imported function.
+
+ // func wasmExit(code int32)
+ "runtime.wasmExit": (sp) => {
+ sp >>>= 0;
+ const code = this.mem.getInt32(sp + 8, true);
+ this.exited = true;
+ delete this._inst;
+ delete this._values;
+ delete this._goRefCounts;
+ delete this._ids;
+ delete this._idPool;
+ this.exit(code);
+ },
+
+ // func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
+ "runtime.wasmWrite": (sp) => {
+ sp >>>= 0;
+ const fd = getInt64(sp + 8);
+ const p = getInt64(sp + 16);
+ const n = this.mem.getInt32(sp + 24, true);
+ fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
+ },
+
+ // func resetMemoryDataView()
+ "runtime.resetMemoryDataView": (sp) => {
+ sp >>>= 0;
+ this.mem = new DataView(this._inst.exports.mem.buffer);
+ },
+
+ // func nanotime1() int64
+ "runtime.nanotime1": (sp) => {
+ sp >>>= 0;
+ setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);
+ },
+
+ // func walltime() (sec int64, nsec int32)
+ "runtime.walltime": (sp) => {
+ sp >>>= 0;
+ const msec = (new Date).getTime();
+ setInt64(sp + 8, msec / 1000);
+ this.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true);
+ },
+
+ // func scheduleTimeoutEvent(delay int64) int32
+ "runtime.scheduleTimeoutEvent": (sp) => {
+ sp >>>= 0;
+ const id = this._nextCallbackTimeoutID;
+ this._nextCallbackTimeoutID++;
+ this._scheduledTimeouts.set(id, setTimeout(
+ () => {
+ this._resume();
+ while (this._scheduledTimeouts.has(id)) {
+ // for some reason Go failed to register the timeout event, log and try again
+ // (temporary workaround for https://github.com/golang/go/issues/28975)
+ console.warn("scheduleTimeoutEvent: missed timeout event");
+ this._resume();
+ }
+ },
+ getInt64(sp + 8),
+ ));
+ this.mem.setInt32(sp + 16, id, true);
+ },
+
+ // func clearTimeoutEvent(id int32)
+ "runtime.clearTimeoutEvent": (sp) => {
+ sp >>>= 0;
+ const id = this.mem.getInt32(sp + 8, true);
+ clearTimeout(this._scheduledTimeouts.get(id));
+ this._scheduledTimeouts.delete(id);
+ },
+
+ // func getRandomData(r []byte)
+ "runtime.getRandomData": (sp) => {
+ sp >>>= 0;
+ crypto.getRandomValues(loadSlice(sp + 8));
+ },
+
+ // func finalizeRef(v ref)
+ "syscall/js.finalizeRef": (sp) => {
+ sp >>>= 0;
+ const id = this.mem.getUint32(sp + 8, true);
+ this._goRefCounts[id]--;
+ if (this._goRefCounts[id] === 0) {
+ const v = this._values[id];
+ this._values[id] = null;
+ this._ids.delete(v);
+ this._idPool.push(id);
+ }
+ },
+
+ // func stringVal(value string) ref
+ "syscall/js.stringVal": (sp) => {
+ sp >>>= 0;
+ storeValue(sp + 24, loadString(sp + 8));
+ },
+
+ // func valueGet(v ref, p string) ref
+ "syscall/js.valueGet": (sp) => {
+ sp >>>= 0;
+ const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 32, result);
+ },
+
+ // func valueSet(v ref, p string, x ref)
+ "syscall/js.valueSet": (sp) => {
+ sp >>>= 0;
+ Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
+ },
+
+ // func valueDelete(v ref, p string)
+ "syscall/js.valueDelete": (sp) => {
+ sp >>>= 0;
+ Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
+ },
+
+ // func valueIndex(v ref, i int) ref
+ "syscall/js.valueIndex": (sp) => {
+ sp >>>= 0;
+ storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
+ },
+
+ // valueSetIndex(v ref, i int, x ref)
+ "syscall/js.valueSetIndex": (sp) => {
+ sp >>>= 0;
+ Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
+ },
+
+ // func valueCall(v ref, m string, args []ref) (ref, bool)
+ "syscall/js.valueCall": (sp) => {
+ sp >>>= 0;
+ try {
+ const v = loadValue(sp + 8);
+ const m = Reflect.get(v, loadString(sp + 16));
+ const args = loadSliceOfValues(sp + 32);
+ const result = Reflect.apply(m, v, args);
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 56, result);
+ this.mem.setUint8(sp + 64, 1);
+ } catch (err) {
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 56, err);
+ this.mem.setUint8(sp + 64, 0);
+ }
+ },
+
+ // func valueInvoke(v ref, args []ref) (ref, bool)
+ "syscall/js.valueInvoke": (sp) => {
+ sp >>>= 0;
+ try {
+ const v = loadValue(sp + 8);
+ const args = loadSliceOfValues(sp + 16);
+ const result = Reflect.apply(v, undefined, args);
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 40, result);
+ this.mem.setUint8(sp + 48, 1);
+ } catch (err) {
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 40, err);
+ this.mem.setUint8(sp + 48, 0);
+ }
+ },
+
+ // func valueNew(v ref, args []ref) (ref, bool)
+ "syscall/js.valueNew": (sp) => {
+ sp >>>= 0;
+ try {
+ const v = loadValue(sp + 8);
+ const args = loadSliceOfValues(sp + 16);
+ const result = Reflect.construct(v, args);
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 40, result);
+ this.mem.setUint8(sp + 48, 1);
+ } catch (err) {
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 40, err);
+ this.mem.setUint8(sp + 48, 0);
+ }
+ },
+
+ // func valueLength(v ref) int
+ "syscall/js.valueLength": (sp) => {
+ sp >>>= 0;
+ setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
+ },
+
+ // valuePrepareString(v ref) (ref, int)
+ "syscall/js.valuePrepareString": (sp) => {
+ sp >>>= 0;
+ const str = encoder.encode(String(loadValue(sp + 8)));
+ storeValue(sp + 16, str);
+ setInt64(sp + 24, str.length);
+ },
+
+ // valueLoadString(v ref, b []byte)
+ "syscall/js.valueLoadString": (sp) => {
+ sp >>>= 0;
+ const str = loadValue(sp + 8);
+ loadSlice(sp + 16).set(str);
+ },
+
+ // func valueInstanceOf(v ref, t ref) bool
+ "syscall/js.valueInstanceOf": (sp) => {
+ sp >>>= 0;
+ this.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0);
+ },
+
+ // func copyBytesToGo(dst []byte, src ref) (int, bool)
+ "syscall/js.copyBytesToGo": (sp) => {
+ sp >>>= 0;
+ const dst = loadSlice(sp + 8);
+ const src = loadValue(sp + 32);
+ if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {
+ this.mem.setUint8(sp + 48, 0);
+ return;
+ }
+ const toCopy = src.subarray(0, dst.length);
+ dst.set(toCopy);
+ setInt64(sp + 40, toCopy.length);
+ this.mem.setUint8(sp + 48, 1);
+ },
+
+ // func copyBytesToJS(dst ref, src []byte) (int, bool)
+ "syscall/js.copyBytesToJS": (sp) => {
+ sp >>>= 0;
+ const dst = loadValue(sp + 8);
+ const src = loadSlice(sp + 16);
+ if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {
+ this.mem.setUint8(sp + 48, 0);
+ return;
+ }
+ const toCopy = src.subarray(0, dst.length);
+ dst.set(toCopy);
+ setInt64(sp + 40, toCopy.length);
+ this.mem.setUint8(sp + 48, 1);
+ },
+
+ "debug": (value) => {
+ console.log(value);
+ },
+ }
+ };
+ }
+
+ async run(instance) {
+ if (!(instance instanceof WebAssembly.Instance)) {
+ throw new Error("Go.run: WebAssembly.Instance expected");
+ }
+ this._inst = instance;
+ this.mem = new DataView(this._inst.exports.mem.buffer);
+ this._values = [ // JS values that Go currently has references to, indexed by reference id
+ NaN,
+ 0,
+ null,
+ true,
+ false,
+ globalThis,
+ this,
+ ];
+ this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id
+ this._ids = new Map([ // mapping from JS values to reference ids
+ [0, 1],
+ [null, 2],
+ [true, 3],
+ [false, 4],
+ [globalThis, 5],
+ [this, 6],
+ ]);
+ this._idPool = []; // unused ids that have been garbage collected
+ this.exited = false; // whether the Go program has exited
+
+ // Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.
+ let offset = 4096;
+
+ const strPtr = (str) => {
+ const ptr = offset;
+ const bytes = encoder.encode(str + "\0");
+ new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);
+ offset += bytes.length;
+ if (offset % 8 !== 0) {
+ offset += 8 - (offset % 8);
+ }
+ return ptr;
+ };
+
+ const argc = this.argv.length;
+
+ const argvPtrs = [];
+ this.argv.forEach((arg) => {
+ argvPtrs.push(strPtr(arg));
+ });
+ argvPtrs.push(0);
+
+ const keys = Object.keys(this.env).sort();
+ keys.forEach((key) => {
+ argvPtrs.push(strPtr(`${key}=${this.env[key]}`));
+ });
+ argvPtrs.push(0);
+
+ const argv = offset;
+ argvPtrs.forEach((ptr) => {
+ this.mem.setUint32(offset, ptr, true);
+ this.mem.setUint32(offset + 4, 0, true);
+ offset += 8;
+ });
+
+ // The linker guarantees global data starts from at least wasmMinDataAddr.
+ // Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr.
+ const wasmMinDataAddr = 4096 + 8192;
+ if (offset >= wasmMinDataAddr) {
+ throw new Error("total length of command line and environment variables exceeds limit");
+ }
+
+ this._inst.exports.run(argc, argv);
+ if (this.exited) {
+ this._resolveExitPromise();
+ }
+ await this._exitPromise;
+ }
+
+ _resume() {
+ if (this.exited) {
+ throw new Error("Go program has already exited");
+ }
+ this._inst.exports.resume();
+ if (this.exited) {
+ this._resolveExitPromise();
+ }
+ }
+
+ _makeFuncWrapper(id) {
+ const go = this;
+ return function () {
+ const event = { id: id, this: this, args: arguments };
+ go._pendingEvent = event;
+ go._resume();
+ return event.result;
+ };
+ }
+ }
+})();
diff --git a/src/generated/licenses.json b/src/generated/licenses.json
new file mode 100644
index 00000000..4f175d4d
--- /dev/null
+++ b/src/generated/licenses.json
@@ -0,0 +1 @@
+[{"text":"BSD Zero Clause License","value":"0BSD"},{"text":"3D Slicer License v1.0","value":"3D-Slicer-1.0"},{"text":"Attribution Assurance License","value":"AAL"},{"text":"Amazon Digital Services License","value":"ADSL"},{"text":"Academic Free License v1.1","value":"AFL-1.1"},{"text":"Academic Free License v1.2","value":"AFL-1.2"},{"text":"Academic Free License v2.0","value":"AFL-2.0"},{"text":"Academic Free License v2.1","value":"AFL-2.1"},{"text":"Academic Free License v3.0","value":"AFL-3.0"},{"text":"Affero General Public License v1.0 only","value":"AGPL-1.0-only"},{"text":"Affero General Public License v1.0 or later","value":"AGPL-1.0-or-later"},{"text":"GNU Affero General Public License v3.0 only","value":"AGPL-3.0-only"},{"text":"GNU Affero General Public License v3.0 or later","value":"AGPL-3.0-or-later"},{"text":"AMD newlib License","value":"AMD-newlib"},{"text":"AMD's plpa_map.c License","value":"AMDPLPA"},{"text":"Apple MIT License","value":"AML"},{"text":"AML glslang variant License","value":"AML-glslang"},{"text":"Academy of Motion Picture Arts and Sciences BSD","value":"AMPAS"},{"text":"ANTLR Software Rights Notice","value":"ANTLR-PD"},{"text":"ANTLR Software Rights Notice with license fallback","value":"ANTLR-PD-fallback"},{"text":"Adobe Postscript AFM License","value":"APAFML"},{"text":"Adaptive Public License 1.0","value":"APL-1.0"},{"text":"Apple Public Source License 1.0","value":"APSL-1.0"},{"text":"Apple Public Source License 1.1","value":"APSL-1.1"},{"text":"Apple Public Source License 1.2","value":"APSL-1.2"},{"text":"Apple Public Source License 2.0","value":"APSL-2.0"},{"text":"ASWF Digital Assets License version 1.0","value":"ASWF-Digital-Assets-1.0"},{"text":"ASWF Digital Assets License 1.1","value":"ASWF-Digital-Assets-1.1"},{"text":"Abstyles License","value":"Abstyles"},{"text":"AdaCore Doc License","value":"AdaCore-doc"},{"text":"Adobe Systems Incorporated Source Code License Agreement","value":"Adobe-2006"},{"text":"Adobe Display PostScript License","value":"Adobe-Display-PostScript"},{"text":"Adobe Glyph List License","value":"Adobe-Glyph"},{"text":"Adobe Utopia Font License","value":"Adobe-Utopia"},{"text":"Afmparse License","value":"Afmparse"},{"text":"Aladdin Free Public License","value":"Aladdin"},{"text":"Apache License 1.0","value":"Apache-1.0"},{"text":"Apache License 1.1","value":"Apache-1.1"},{"text":"Apache License 2.0","value":"Apache-2.0"},{"text":"App::s2p License","value":"App-s2p"},{"text":"Arphic Public License","value":"Arphic-1999"},{"text":"Artistic License 1.0","value":"Artistic-1.0"},{"text":"Artistic License 1.0 (Perl)","value":"Artistic-1.0-Perl"},{"text":"Artistic License 1.0 w/clause 8","value":"Artistic-1.0-cl8"},{"text":"Artistic License 2.0","value":"Artistic-2.0"},{"text":"BSD 1-Clause License","value":"BSD-1-Clause"},{"text":"BSD 2-Clause \"Simplified\" License","value":"BSD-2-Clause"},{"text":"BSD 2-Clause - Ian Darwin variant","value":"BSD-2-Clause-Darwin"},{"text":"BSD-2-Clause Plus Patent License","value":"BSD-2-Clause-Patent"},{"text":"BSD 2-Clause with views sentence","value":"BSD-2-Clause-Views"},{"text":"BSD 2-Clause - first lines requirement","value":"BSD-2-Clause-first-lines"},{"text":"BSD 3-Clause \"New\" or \"Revised\" License","value":"BSD-3-Clause"},{"text":"BSD with attribution","value":"BSD-3-Clause-Attribution"},{"text":"BSD 3-Clause Clear License","value":"BSD-3-Clause-Clear"},{"text":"Hewlett-Packard BSD variant license","value":"BSD-3-Clause-HP"},{"text":"Lawrence Berkeley National Labs BSD variant license","value":"BSD-3-Clause-LBNL"},{"text":"BSD 3-Clause Modification","value":"BSD-3-Clause-Modification"},{"text":"BSD 3-Clause No Military License","value":"BSD-3-Clause-No-Military-License"},{"text":"BSD 3-Clause No Nuclear License","value":"BSD-3-Clause-No-Nuclear-License"},{"text":"BSD 3-Clause No Nuclear License 2014","value":"BSD-3-Clause-No-Nuclear-License-2014"},{"text":"BSD 3-Clause No Nuclear Warranty","value":"BSD-3-Clause-No-Nuclear-Warranty"},{"text":"BSD 3-Clause Open MPI variant","value":"BSD-3-Clause-Open-MPI"},{"text":"BSD 3-Clause Sun Microsystems","value":"BSD-3-Clause-Sun"},{"text":"BSD 3-Clause acpica variant","value":"BSD-3-Clause-acpica"},{"text":"BSD 3-Clause Flex variant","value":"BSD-3-Clause-flex"},{"text":"BSD 4-Clause \"Original\" or \"Old\" License","value":"BSD-4-Clause"},{"text":"BSD 4 Clause Shortened","value":"BSD-4-Clause-Shortened"},{"text":"BSD-4-Clause (University of California-Specific)","value":"BSD-4-Clause-UC"},{"text":"BSD 4.3 RENO License","value":"BSD-4.3RENO"},{"text":"BSD 4.3 TAHOE License","value":"BSD-4.3TAHOE"},{"text":"BSD Advertising Acknowledgement License","value":"BSD-Advertising-Acknowledgement"},{"text":"BSD with Attribution and HPND disclaimer","value":"BSD-Attribution-HPND-disclaimer"},{"text":"BSD-Inferno-Nettverk","value":"BSD-Inferno-Nettverk"},{"text":"BSD Protection License","value":"BSD-Protection"},{"text":"BSD Source Code Attribution","value":"BSD-Source-Code"},{"text":"BSD Source Code Attribution - beginning of file variant","value":"BSD-Source-beginning-file"},{"text":"Systemics BSD variant license","value":"BSD-Systemics"},{"text":"Systemics W3Works BSD variant license","value":"BSD-Systemics-W3Works"},{"text":"Boost Software License 1.0","value":"BSL-1.0"},{"text":"Business Source License 1.1","value":"BUSL-1.1"},{"text":"Baekmuk License","value":"Baekmuk"},{"text":"Bahyph License","value":"Bahyph"},{"text":"Barr License","value":"Barr"},{"text":"Beerware License","value":"Beerware"},{"text":"BitTorrent Open Source License v1.0","value":"BitTorrent-1.0"},{"text":"BitTorrent Open Source License v1.1","value":"BitTorrent-1.1"},{"text":"Bitstream Charter Font License","value":"Bitstream-Charter"},{"text":"Bitstream Vera Font License","value":"Bitstream-Vera"},{"text":"Blue Oak Model License 1.0.0","value":"BlueOak-1.0.0"},{"text":"Boehm-Demers-Weiser GC License","value":"Boehm-GC"},{"text":"Borceux license","value":"Borceux"},{"text":"Brian Gladman 2-Clause License","value":"Brian-Gladman-2-Clause"},{"text":"Brian Gladman 3-Clause License","value":"Brian-Gladman-3-Clause"},{"text":"Computational Use of Data Agreement v1.0","value":"C-UDA-1.0"},{"text":"Cryptographic Autonomy License 1.0","value":"CAL-1.0"},{"text":"Cryptographic Autonomy License 1.0 (Combined Work Exception)","value":"CAL-1.0-Combined-Work-Exception"},{"text":"Computer Associates Trusted Open Source License 1.1","value":"CATOSL-1.1"},{"text":"Creative Commons Attribution 1.0 Generic","value":"CC-BY-1.0"},{"text":"Creative Commons Attribution 2.0 Generic","value":"CC-BY-2.0"},{"text":"Creative Commons Attribution 2.5 Generic","value":"CC-BY-2.5"},{"text":"Creative Commons Attribution 2.5 Australia","value":"CC-BY-2.5-AU"},{"text":"Creative Commons Attribution 3.0 Unported","value":"CC-BY-3.0"},{"text":"Creative Commons Attribution 3.0 Austria","value":"CC-BY-3.0-AT"},{"text":"Creative Commons Attribution 3.0 Australia","value":"CC-BY-3.0-AU"},{"text":"Creative Commons Attribution 3.0 Germany","value":"CC-BY-3.0-DE"},{"text":"Creative Commons Attribution 3.0 IGO","value":"CC-BY-3.0-IGO"},{"text":"Creative Commons Attribution 3.0 Netherlands","value":"CC-BY-3.0-NL"},{"text":"Creative Commons Attribution 3.0 United States","value":"CC-BY-3.0-US"},{"text":"Creative Commons Attribution 4.0 International","value":"CC-BY-4.0"},{"text":"Creative Commons Attribution Non Commercial 1.0 Generic","value":"CC-BY-NC-1.0"},{"text":"Creative Commons Attribution Non Commercial 2.0 Generic","value":"CC-BY-NC-2.0"},{"text":"Creative Commons Attribution Non Commercial 2.5 Generic","value":"CC-BY-NC-2.5"},{"text":"Creative Commons Attribution Non Commercial 3.0 Unported","value":"CC-BY-NC-3.0"},{"text":"Creative Commons Attribution Non Commercial 3.0 Germany","value":"CC-BY-NC-3.0-DE"},{"text":"Creative Commons Attribution Non Commercial 4.0 International","value":"CC-BY-NC-4.0"},{"text":"Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic","value":"CC-BY-NC-ND-1.0"},{"text":"Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic","value":"CC-BY-NC-ND-2.0"},{"text":"Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic","value":"CC-BY-NC-ND-2.5"},{"text":"Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported","value":"CC-BY-NC-ND-3.0"},{"text":"Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany","value":"CC-BY-NC-ND-3.0-DE"},{"text":"Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO","value":"CC-BY-NC-ND-3.0-IGO"},{"text":"Creative Commons Attribution Non Commercial No Derivatives 4.0 International","value":"CC-BY-NC-ND-4.0"},{"text":"Creative Commons Attribution Non Commercial Share Alike 1.0 Generic","value":"CC-BY-NC-SA-1.0"},{"text":"Creative Commons Attribution Non Commercial Share Alike 2.0 Generic","value":"CC-BY-NC-SA-2.0"},{"text":"Creative Commons Attribution Non Commercial Share Alike 2.0 Germany","value":"CC-BY-NC-SA-2.0-DE"},{"text":"Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France","value":"CC-BY-NC-SA-2.0-FR"},{"text":"Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales","value":"CC-BY-NC-SA-2.0-UK"},{"text":"Creative Commons Attribution Non Commercial Share Alike 2.5 Generic","value":"CC-BY-NC-SA-2.5"},{"text":"Creative Commons Attribution Non Commercial Share Alike 3.0 Unported","value":"CC-BY-NC-SA-3.0"},{"text":"Creative Commons Attribution Non Commercial Share Alike 3.0 Germany","value":"CC-BY-NC-SA-3.0-DE"},{"text":"Creative Commons Attribution Non Commercial Share Alike 3.0 IGO","value":"CC-BY-NC-SA-3.0-IGO"},{"text":"Creative Commons Attribution Non Commercial Share Alike 4.0 International","value":"CC-BY-NC-SA-4.0"},{"text":"Creative Commons Attribution No Derivatives 1.0 Generic","value":"CC-BY-ND-1.0"},{"text":"Creative Commons Attribution No Derivatives 2.0 Generic","value":"CC-BY-ND-2.0"},{"text":"Creative Commons Attribution No Derivatives 2.5 Generic","value":"CC-BY-ND-2.5"},{"text":"Creative Commons Attribution No Derivatives 3.0 Unported","value":"CC-BY-ND-3.0"},{"text":"Creative Commons Attribution No Derivatives 3.0 Germany","value":"CC-BY-ND-3.0-DE"},{"text":"Creative Commons Attribution No Derivatives 4.0 International","value":"CC-BY-ND-4.0"},{"text":"Creative Commons Attribution Share Alike 1.0 Generic","value":"CC-BY-SA-1.0"},{"text":"Creative Commons Attribution Share Alike 2.0 Generic","value":"CC-BY-SA-2.0"},{"text":"Creative Commons Attribution Share Alike 2.0 England and Wales","value":"CC-BY-SA-2.0-UK"},{"text":"Creative Commons Attribution Share Alike 2.1 Japan","value":"CC-BY-SA-2.1-JP"},{"text":"Creative Commons Attribution Share Alike 2.5 Generic","value":"CC-BY-SA-2.5"},{"text":"Creative Commons Attribution Share Alike 3.0 Unported","value":"CC-BY-SA-3.0"},{"text":"Creative Commons Attribution Share Alike 3.0 Austria","value":"CC-BY-SA-3.0-AT"},{"text":"Creative Commons Attribution Share Alike 3.0 Germany","value":"CC-BY-SA-3.0-DE"},{"text":"Creative Commons Attribution-ShareAlike 3.0 IGO","value":"CC-BY-SA-3.0-IGO"},{"text":"Creative Commons Attribution Share Alike 4.0 International","value":"CC-BY-SA-4.0"},{"text":"Creative Commons Public Domain Dedication and Certification","value":"CC-PDDC"},{"text":"Creative Commons Zero v1.0 Universal","value":"CC0-1.0"},{"text":"Common Development and Distribution License 1.0","value":"CDDL-1.0"},{"text":"Common Development and Distribution License 1.1","value":"CDDL-1.1"},{"text":"Common Documentation License 1.0","value":"CDL-1.0"},{"text":"Community Data License Agreement Permissive 1.0","value":"CDLA-Permissive-1.0"},{"text":"Community Data License Agreement Permissive 2.0","value":"CDLA-Permissive-2.0"},{"text":"Community Data License Agreement Sharing 1.0","value":"CDLA-Sharing-1.0"},{"text":"CeCILL Free Software License Agreement v1.0","value":"CECILL-1.0"},{"text":"CeCILL Free Software License Agreement v1.1","value":"CECILL-1.1"},{"text":"CeCILL Free Software License Agreement v2.0","value":"CECILL-2.0"},{"text":"CeCILL Free Software License Agreement v2.1","value":"CECILL-2.1"},{"text":"CeCILL-B Free Software License Agreement","value":"CECILL-B"},{"text":"CeCILL-C Free Software License Agreement","value":"CECILL-C"},{"text":"CERN Open Hardware Licence v1.1","value":"CERN-OHL-1.1"},{"text":"CERN Open Hardware Licence v1.2","value":"CERN-OHL-1.2"},{"text":"CERN Open Hardware Licence Version 2 - Permissive","value":"CERN-OHL-P-2.0"},{"text":"CERN Open Hardware Licence Version 2 - Strongly Reciprocal","value":"CERN-OHL-S-2.0"},{"text":"CERN Open Hardware Licence Version 2 - Weakly Reciprocal","value":"CERN-OHL-W-2.0"},{"text":"CFITSIO License","value":"CFITSIO"},{"text":"CMU Mach License","value":"CMU-Mach"},{"text":"CMU Mach - no notices-in-documentation variant","value":"CMU-Mach-nodoc"},{"text":"CNRI Jython License","value":"CNRI-Jython"},{"text":"CNRI Python License","value":"CNRI-Python"},{"text":"CNRI Python Open Source GPL Compatible License Agreement","value":"CNRI-Python-GPL-Compatible"},{"text":"Copyfree Open Innovation License","value":"COIL-1.0"},{"text":"Common Public Attribution License 1.0","value":"CPAL-1.0"},{"text":"Common Public License 1.0","value":"CPL-1.0"},{"text":"Code Project Open License 1.02","value":"CPOL-1.02"},{"text":"CUA Office Public License v1.0","value":"CUA-OPL-1.0"},{"text":"Caldera License","value":"Caldera"},{"text":"Caldera License (without preamble)","value":"Caldera-no-preamble"},{"text":"Catharon License","value":"Catharon"},{"text":"Clarified Artistic License","value":"ClArtistic"},{"text":"Clips License","value":"Clips"},{"text":"Community Specification License 1.0","value":"Community-Spec-1.0"},{"text":"Condor Public License v1.1","value":"Condor-1.1"},{"text":"Cornell Lossless JPEG License","value":"Cornell-Lossless-JPEG"},{"text":"Cronyx License","value":"Cronyx"},{"text":"Crossword License","value":"Crossword"},{"text":"CrystalStacker License","value":"CrystalStacker"},{"text":"Cube License","value":"Cube"},{"text":"Deutsche Freie Software Lizenz","value":"D-FSL-1.0"},{"text":"DEC 3-Clause License","value":"DEC-3-Clause"},{"text":"Data licence Germany – attribution – version 2.0","value":"DL-DE-BY-2.0"},{"text":"Data licence Germany – zero – version 2.0","value":"DL-DE-ZERO-2.0"},{"text":"DOC License","value":"DOC"},{"text":"Detection Rule License 1.0","value":"DRL-1.0"},{"text":"Detection Rule License 1.1","value":"DRL-1.1"},{"text":"DSDP License","value":"DSDP"},{"text":"DocBook Schema License","value":"DocBook-Schema"},{"text":"DocBook XML License","value":"DocBook-XML"},{"text":"Dotseqn License","value":"Dotseqn"},{"text":"Educational Community License v1.0","value":"ECL-1.0"},{"text":"Educational Community License v2.0","value":"ECL-2.0"},{"text":"Eiffel Forum License v1.0","value":"EFL-1.0"},{"text":"Eiffel Forum License v2.0","value":"EFL-2.0"},{"text":"EPICS Open License","value":"EPICS"},{"text":"Eclipse Public License 1.0","value":"EPL-1.0"},{"text":"Eclipse Public License 2.0","value":"EPL-2.0"},{"text":"EU DataGrid Software License","value":"EUDatagrid"},{"text":"European Union Public License 1.0","value":"EUPL-1.0"},{"text":"European Union Public License 1.1","value":"EUPL-1.1"},{"text":"European Union Public License 1.2","value":"EUPL-1.2"},{"text":"Elastic License 2.0","value":"Elastic-2.0"},{"text":"Entessa Public License v1.0","value":"Entessa"},{"text":"Erlang Public License v1.1","value":"ErlPL-1.1"},{"text":"Eurosym License","value":"Eurosym"},{"text":"Fuzzy Bitmap License","value":"FBM"},{"text":"Fraunhofer FDK AAC Codec Library","value":"FDK-AAC"},{"text":"FSF All Permissive License","value":"FSFAP"},{"text":"FSF All Permissive License (without Warranty)","value":"FSFAP-no-warranty-disclaimer"},{"text":"FSF Unlimited License","value":"FSFUL"},{"text":"FSF Unlimited License (with License Retention)","value":"FSFULLR"},{"text":"FSF Unlimited License (With License Retention and Warranty Disclaimer)","value":"FSFULLRWD"},{"text":"Freetype Project License","value":"FTL"},{"text":"Fair License","value":"Fair"},{"text":"Ferguson Twofish License","value":"Ferguson-Twofish"},{"text":"Frameworx Open License 1.0","value":"Frameworx-1.0"},{"text":"FreeBSD Documentation License","value":"FreeBSD-DOC"},{"text":"FreeImage Public License v1.0","value":"FreeImage"},{"text":"Furuseth License","value":"Furuseth"},{"text":"Gnome GCR Documentation License","value":"GCR-docs"},{"text":"GD License","value":"GD"},{"text":"GNU Free Documentation License v1.1 only - invariants","value":"GFDL-1.1-invariants-only"},{"text":"GNU Free Documentation License v1.1 or later - invariants","value":"GFDL-1.1-invariants-or-later"},{"text":"GNU Free Documentation License v1.1 only - no invariants","value":"GFDL-1.1-no-invariants-only"},{"text":"GNU Free Documentation License v1.1 or later - no invariants","value":"GFDL-1.1-no-invariants-or-later"},{"text":"GNU Free Documentation License v1.1 only","value":"GFDL-1.1-only"},{"text":"GNU Free Documentation License v1.1 or later","value":"GFDL-1.1-or-later"},{"text":"GNU Free Documentation License v1.2 only - invariants","value":"GFDL-1.2-invariants-only"},{"text":"GNU Free Documentation License v1.2 or later - invariants","value":"GFDL-1.2-invariants-or-later"},{"text":"GNU Free Documentation License v1.2 only - no invariants","value":"GFDL-1.2-no-invariants-only"},{"text":"GNU Free Documentation License v1.2 or later - no invariants","value":"GFDL-1.2-no-invariants-or-later"},{"text":"GNU Free Documentation License v1.2 only","value":"GFDL-1.2-only"},{"text":"GNU Free Documentation License v1.2 or later","value":"GFDL-1.2-or-later"},{"text":"GNU Free Documentation License v1.3 only - invariants","value":"GFDL-1.3-invariants-only"},{"text":"GNU Free Documentation License v1.3 or later - invariants","value":"GFDL-1.3-invariants-or-later"},{"text":"GNU Free Documentation License v1.3 only - no invariants","value":"GFDL-1.3-no-invariants-only"},{"text":"GNU Free Documentation License v1.3 or later - no invariants","value":"GFDL-1.3-no-invariants-or-later"},{"text":"GNU Free Documentation License v1.3 only","value":"GFDL-1.3-only"},{"text":"GNU Free Documentation License v1.3 or later","value":"GFDL-1.3-or-later"},{"text":"GL2PS License","value":"GL2PS"},{"text":"Good Luck With That Public License","value":"GLWTPL"},{"text":"GNU General Public License v1.0 only","value":"GPL-1.0-only"},{"text":"GNU General Public License v1.0 or later","value":"GPL-1.0-or-later"},{"text":"GNU General Public License v2.0 only","value":"GPL-2.0-only"},{"text":"GNU General Public License v2.0 or later","value":"GPL-2.0-or-later"},{"text":"GNU General Public License v3.0 only","value":"GPL-3.0-only"},{"text":"GNU General Public License v3.0 or later","value":"GPL-3.0-or-later"},{"text":"Giftware License","value":"Giftware"},{"text":"3dfx Glide License","value":"Glide"},{"text":"Glulxe License","value":"Glulxe"},{"text":"Graphics Gems License","value":"Graphics-Gems"},{"text":"Gutmann License","value":"Gutmann"},{"text":"HIDAPI License","value":"HIDAPI"},{"text":"Hewlett-Packard 1986 License","value":"HP-1986"},{"text":"Hewlett-Packard 1989 License","value":"HP-1989"},{"text":"Historical Permission Notice and Disclaimer","value":"HPND"},{"text":"Historical Permission Notice and Disclaimer - DEC variant","value":"HPND-DEC"},{"text":"Historical Permission Notice and Disclaimer - Fenneberg-Livingston variant","value":"HPND-Fenneberg-Livingston"},{"text":"Historical Permission Notice and Disclaimer - INRIA-IMAG variant","value":"HPND-INRIA-IMAG"},{"text":"Historical Permission Notice and Disclaimer - Intel variant","value":"HPND-Intel"},{"text":"Historical Permission Notice and Disclaimer - Kevlin Henney variant","value":"HPND-Kevlin-Henney"},{"text":"Historical Permission Notice and Disclaimer with MIT disclaimer","value":"HPND-MIT-disclaimer"},{"text":"Historical Permission Notice and Disclaimer - Markus Kuhn variant","value":"HPND-Markus-Kuhn"},{"text":"Historical Permission Notice and Disclaimer - Netrek variant","value":"HPND-Netrek"},{"text":"Historical Permission Notice and Disclaimer - Pbmplus variant","value":"HPND-Pbmplus"},{"text":"Historical Permission Notice and Disclaimer - University of California variant","value":"HPND-UC"},{"text":"Historical Permission Notice and Disclaimer - University of California, US export warning","value":"HPND-UC-export-US"},{"text":"Historical Permission Notice and Disclaimer - documentation variant","value":"HPND-doc"},{"text":"Historical Permission Notice and Disclaimer - documentation sell variant","value":"HPND-doc-sell"},{"text":"HPND with US Government export control warning","value":"HPND-export-US"},{"text":"HPND with US Government export control warning and acknowledgment","value":"HPND-export-US-acknowledgement"},{"text":"HPND with US Government export control warning and modification rqmt","value":"HPND-export-US-modify"},{"text":"HPND with US Government export control and 2 disclaimers","value":"HPND-export2-US"},{"text":"Historical Permission Notice and Disclaimer - merchantability variant","value":"HPND-merchantability-variant"},{"text":"Historical Permission Notice and Disclaimer - sell xserver variant with MIT disclaimer","value":"HPND-sell-MIT-disclaimer-xserver"},{"text":"Historical Permission Notice and Disclaimer - sell regexpr variant","value":"HPND-sell-regexpr"},{"text":"Historical Permission Notice and Disclaimer - sell variant","value":"HPND-sell-variant"},{"text":"HPND sell variant with MIT disclaimer","value":"HPND-sell-variant-MIT-disclaimer"},{"text":"HPND sell variant with MIT disclaimer - reverse","value":"HPND-sell-variant-MIT-disclaimer-rev"},{"text":"HTML Tidy License","value":"HTMLTIDY"},{"text":"Haskell Language Report License","value":"HaskellReport"},{"text":"Hippocratic License 2.1","value":"Hippocratic-2.1"},{"text":"IBM PowerPC Initialization and Boot Software","value":"IBM-pibs"},{"text":"ICU License","value":"ICU"},{"text":"IEC Code Components End-user licence agreement","value":"IEC-Code-Components-EULA"},{"text":"Independent JPEG Group License","value":"IJG"},{"text":"Independent JPEG Group License - short","value":"IJG-short"},{"text":"IPA Font License","value":"IPA"},{"text":"IBM Public License v1.0","value":"IPL-1.0"},{"text":"ISC License","value":"ISC"},{"text":"ISC Veillard variant","value":"ISC-Veillard"},{"text":"ImageMagick License","value":"ImageMagick"},{"text":"Imlib2 License","value":"Imlib2"},{"text":"Info-ZIP License","value":"Info-ZIP"},{"text":"Inner Net License v2.0","value":"Inner-Net-2.0"},{"text":"Intel Open Source License","value":"Intel"},{"text":"Intel ACPI Software License Agreement","value":"Intel-ACPI"},{"text":"Interbase Public License v1.0","value":"Interbase-1.0"},{"text":"JPL Image Use Policy","value":"JPL-image"},{"text":"Japan Network Information Center License","value":"JPNIC"},{"text":"JSON License","value":"JSON"},{"text":"Jam License","value":"Jam"},{"text":"JasPer License","value":"JasPer-2.0"},{"text":"Kastrup License","value":"Kastrup"},{"text":"Kazlib License","value":"Kazlib"},{"text":"Knuth CTAN License","value":"Knuth-CTAN"},{"text":"Licence Art Libre 1.2","value":"LAL-1.2"},{"text":"Licence Art Libre 1.3","value":"LAL-1.3"},{"text":"GNU Library General Public License v2 only","value":"LGPL-2.0-only"},{"text":"GNU Library General Public License v2 or later","value":"LGPL-2.0-or-later"},{"text":"GNU Lesser General Public License v2.1 only","value":"LGPL-2.1-only"},{"text":"GNU Lesser General Public License v2.1 or later","value":"LGPL-2.1-or-later"},{"text":"GNU Lesser General Public License v3.0 only","value":"LGPL-3.0-only"},{"text":"GNU Lesser General Public License v3.0 or later","value":"LGPL-3.0-or-later"},{"text":"Lesser General Public License For Linguistic Resources","value":"LGPLLR"},{"text":"Common Lisp LOOP License","value":"LOOP"},{"text":"LPD Documentation License","value":"LPD-document"},{"text":"Lucent Public License Version 1.0","value":"LPL-1.0"},{"text":"Lucent Public License v1.02","value":"LPL-1.02"},{"text":"LaTeX Project Public License v1.0","value":"LPPL-1.0"},{"text":"LaTeX Project Public License v1.1","value":"LPPL-1.1"},{"text":"LaTeX Project Public License v1.2","value":"LPPL-1.2"},{"text":"LaTeX Project Public License v1.3a","value":"LPPL-1.3a"},{"text":"LaTeX Project Public License v1.3c","value":"LPPL-1.3c"},{"text":"LZMA SDK License (versions 9.11 to 9.20)","value":"LZMA-SDK-9.11-to-9.20"},{"text":"LZMA SDK License (versions 9.22 and beyond)","value":"LZMA-SDK-9.22"},{"text":"Latex2e License","value":"Latex2e"},{"text":"Latex2e with translated notice permission","value":"Latex2e-translated-notice"},{"text":"Leptonica License","value":"Leptonica"},{"text":"Licence Libre du Québec – Permissive version 1.1","value":"LiLiQ-P-1.1"},{"text":"Licence Libre du Québec – Réciprocité version 1.1","value":"LiLiQ-R-1.1"},{"text":"Licence Libre du Québec – Réciprocité forte version 1.1","value":"LiLiQ-Rplus-1.1"},{"text":"libpng License","value":"Libpng"},{"text":"Linux Kernel Variant of OpenIB.org license","value":"Linux-OpenIB"},{"text":"Linux man-pages - 1 paragraph","value":"Linux-man-pages-1-para"},{"text":"Linux man-pages Copyleft","value":"Linux-man-pages-copyleft"},{"text":"Linux man-pages Copyleft - 2 paragraphs","value":"Linux-man-pages-copyleft-2-para"},{"text":"Linux man-pages Copyleft Variant","value":"Linux-man-pages-copyleft-var"},{"text":"Lucida Bitmap Fonts License","value":"Lucida-Bitmap-Fonts"},{"text":"MIT License","value":"MIT"},{"text":"MIT No Attribution","value":"MIT-0"},{"text":"CMU License","value":"MIT-CMU"},{"text":"MIT Festival Variant","value":"MIT-Festival"},{"text":"MIT Khronos - old variant","value":"MIT-Khronos-old"},{"text":"MIT License Modern Variant","value":"MIT-Modern-Variant"},{"text":"MIT Tom Wu Variant","value":"MIT-Wu"},{"text":"Enlightenment License (e16)","value":"MIT-advertising"},{"text":"enna License","value":"MIT-enna"},{"text":"feh License","value":"MIT-feh"},{"text":"MIT Open Group variant","value":"MIT-open-group"},{"text":"MIT testregex Variant","value":"MIT-testregex"},{"text":"MIT +no-false-attribs license","value":"MITNFA"},{"text":"MMIXware License","value":"MMIXware"},{"text":"MPEG Software Simulation","value":"MPEG-SSG"},{"text":"Mozilla Public License 1.0","value":"MPL-1.0"},{"text":"Mozilla Public License 1.1","value":"MPL-1.1"},{"text":"Mozilla Public License 2.0","value":"MPL-2.0"},{"text":"Mozilla Public License 2.0 (no copyleft exception)","value":"MPL-2.0-no-copyleft-exception"},{"text":"Microsoft Limited Public License","value":"MS-LPL"},{"text":"Microsoft Public License","value":"MS-PL"},{"text":"Microsoft Reciprocal License","value":"MS-RL"},{"text":"Matrix Template Library License","value":"MTLL"},{"text":"Mackerras 3-Clause License","value":"Mackerras-3-Clause"},{"text":"Mackerras 3-Clause - acknowledgment variant","value":"Mackerras-3-Clause-acknowledgment"},{"text":"MakeIndex License","value":"MakeIndex"},{"text":"Martin Birgmeier License","value":"Martin-Birgmeier"},{"text":"McPhee Slideshow License","value":"McPhee-slideshow"},{"text":"Minpack License","value":"Minpack"},{"text":"The MirOS Licence","value":"MirOS"},{"text":"Motosoto License","value":"Motosoto"},{"text":"Mulan Permissive Software License, Version 1","value":"MulanPSL-1.0"},{"text":"Mulan Permissive Software License, Version 2","value":"MulanPSL-2.0"},{"text":"Multics License","value":"Multics"},{"text":"Mup License","value":"Mup"},{"text":"Nara Institute of Science and Technology License (2003)","value":"NAIST-2003"},{"text":"NASA Open Source Agreement 1.3","value":"NASA-1.3"},{"text":"Net Boolean Public License v1","value":"NBPL-1.0"},{"text":"NCBI Public Domain Notice","value":"NCBI-PD"},{"text":"Non-Commercial Government Licence","value":"NCGL-UK-2.0"},{"text":"NCL Source Code License","value":"NCL"},{"text":"University of Illinois/NCSA Open Source License","value":"NCSA"},{"text":"Nethack General Public License","value":"NGPL"},{"text":"NICTA Public Software License, Version 1.0","value":"NICTA-1.0"},{"text":"NIST Public Domain Notice","value":"NIST-PD"},{"text":"NIST Public Domain Notice with license fallback","value":"NIST-PD-fallback"},{"text":"NIST Software License","value":"NIST-Software"},{"text":"Norwegian Licence for Open Government Data (NLOD) 1.0","value":"NLOD-1.0"},{"text":"Norwegian Licence for Open Government Data (NLOD) 2.0","value":"NLOD-2.0"},{"text":"No Limit Public License","value":"NLPL"},{"text":"Netizen Open Source License","value":"NOSL"},{"text":"Netscape Public License v1.0","value":"NPL-1.0"},{"text":"Netscape Public License v1.1","value":"NPL-1.1"},{"text":"Non-Profit Open Software License 3.0","value":"NPOSL-3.0"},{"text":"NRL License","value":"NRL"},{"text":"NTP License","value":"NTP"},{"text":"NTP No Attribution","value":"NTP-0"},{"text":"Naumen Public License","value":"Naumen"},{"text":"NetCDF license","value":"NetCDF"},{"text":"Newsletr License","value":"Newsletr"},{"text":"Nokia Open Source License","value":"Nokia"},{"text":"Noweb License","value":"Noweb"},{"text":"Open Use of Data Agreement v1.0","value":"O-UDA-1.0"},{"text":"OAR License","value":"OAR"},{"text":"Open CASCADE Technology Public License","value":"OCCT-PL"},{"text":"OCLC Research Public License 2.0","value":"OCLC-2.0"},{"text":"Open Data Commons Attribution License v1.0","value":"ODC-By-1.0"},{"text":"Open Data Commons Open Database License v1.0","value":"ODbL-1.0"},{"text":"OFFIS License","value":"OFFIS"},{"text":"SIL Open Font License 1.0","value":"OFL-1.0"},{"text":"SIL Open Font License 1.0 with Reserved Font Name","value":"OFL-1.0-RFN"},{"text":"SIL Open Font License 1.0 with no Reserved Font Name","value":"OFL-1.0-no-RFN"},{"text":"SIL Open Font License 1.1","value":"OFL-1.1"},{"text":"SIL Open Font License 1.1 with Reserved Font Name","value":"OFL-1.1-RFN"},{"text":"SIL Open Font License 1.1 with no Reserved Font Name","value":"OFL-1.1-no-RFN"},{"text":"OGC Software License, Version 1.0","value":"OGC-1.0"},{"text":"Taiwan Open Government Data License, version 1.0","value":"OGDL-Taiwan-1.0"},{"text":"Open Government Licence - Canada","value":"OGL-Canada-2.0"},{"text":"Open Government Licence v1.0","value":"OGL-UK-1.0"},{"text":"Open Government Licence v2.0","value":"OGL-UK-2.0"},{"text":"Open Government Licence v3.0","value":"OGL-UK-3.0"},{"text":"Open Group Test Suite License","value":"OGTSL"},{"text":"Open LDAP Public License v1.1","value":"OLDAP-1.1"},{"text":"Open LDAP Public License v1.2","value":"OLDAP-1.2"},{"text":"Open LDAP Public License v1.3","value":"OLDAP-1.3"},{"text":"Open LDAP Public License v1.4","value":"OLDAP-1.4"},{"text":"Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)","value":"OLDAP-2.0"},{"text":"Open LDAP Public License v2.0.1","value":"OLDAP-2.0.1"},{"text":"Open LDAP Public License v2.1","value":"OLDAP-2.1"},{"text":"Open LDAP Public License v2.2","value":"OLDAP-2.2"},{"text":"Open LDAP Public License v2.2.1","value":"OLDAP-2.2.1"},{"text":"Open LDAP Public License 2.2.2","value":"OLDAP-2.2.2"},{"text":"Open LDAP Public License v2.3","value":"OLDAP-2.3"},{"text":"Open LDAP Public License v2.4","value":"OLDAP-2.4"},{"text":"Open LDAP Public License v2.5","value":"OLDAP-2.5"},{"text":"Open LDAP Public License v2.6","value":"OLDAP-2.6"},{"text":"Open LDAP Public License v2.7","value":"OLDAP-2.7"},{"text":"Open LDAP Public License v2.8","value":"OLDAP-2.8"},{"text":"Open Logistics Foundation License Version 1.3","value":"OLFL-1.3"},{"text":"Open Market License","value":"OML"},{"text":"Open Public License v1.0","value":"OPL-1.0"},{"text":"United Kingdom Open Parliament Licence v3.0","value":"OPL-UK-3.0"},{"text":"Open Publication License v1.0","value":"OPUBL-1.0"},{"text":"OSET Public License version 2.1","value":"OSET-PL-2.1"},{"text":"Open Software License 1.0","value":"OSL-1.0"},{"text":"Open Software License 1.1","value":"OSL-1.1"},{"text":"Open Software License 2.0","value":"OSL-2.0"},{"text":"Open Software License 2.1","value":"OSL-2.1"},{"text":"Open Software License 3.0","value":"OSL-3.0"},{"text":"OpenPBS v2.3 Software License","value":"OpenPBS-2.3"},{"text":"OpenSSL License","value":"OpenSSL"},{"text":"OpenSSL License - standalone","value":"OpenSSL-standalone"},{"text":"OpenVision License","value":"OpenVision"},{"text":"PADL License","value":"PADL"},{"text":"Open Data Commons Public Domain Dedication & License 1.0","value":"PDDL-1.0"},{"text":"PHP License v3.0","value":"PHP-3.0"},{"text":"PHP License v3.01","value":"PHP-3.01"},{"text":"Peer Production License","value":"PPL"},{"text":"Python Software Foundation License 2.0","value":"PSF-2.0"},{"text":"The Parity Public License 6.0.0","value":"Parity-6.0.0"},{"text":"The Parity Public License 7.0.0","value":"Parity-7.0.0"},{"text":"Pixar License","value":"Pixar"},{"text":"Plexus Classworlds License","value":"Plexus"},{"text":"PolyForm Noncommercial License 1.0.0","value":"PolyForm-Noncommercial-1.0.0"},{"text":"PolyForm Small Business License 1.0.0","value":"PolyForm-Small-Business-1.0.0"},{"text":"PostgreSQL License","value":"PostgreSQL"},{"text":"Python License 2.0","value":"Python-2.0"},{"text":"Python License 2.0.1","value":"Python-2.0.1"},{"text":"Q Public License 1.0","value":"QPL-1.0"},{"text":"Q Public License 1.0 - INRIA 2004 variant","value":"QPL-1.0-INRIA-2004"},{"text":"Qhull License","value":"Qhull"},{"text":"Red Hat eCos Public License v1.1","value":"RHeCos-1.1"},{"text":"Reciprocal Public License 1.1","value":"RPL-1.1"},{"text":"Reciprocal Public License 1.5","value":"RPL-1.5"},{"text":"RealNetworks Public Source License v1.0","value":"RPSL-1.0"},{"text":"RSA Message-Digest License","value":"RSA-MD"},{"text":"Ricoh Source Code Public License","value":"RSCPL"},{"text":"Rdisc License","value":"Rdisc"},{"text":"Ruby License","value":"Ruby"},{"text":"Ruby pty extension license","value":"Ruby-pty"},{"text":"Sax Public Domain Notice","value":"SAX-PD"},{"text":"Sax Public Domain Notice 2.0","value":"SAX-PD-2.0"},{"text":"SCEA Shared Source License","value":"SCEA"},{"text":"SGI Free Software License B v1.0","value":"SGI-B-1.0"},{"text":"SGI Free Software License B v1.1","value":"SGI-B-1.1"},{"text":"SGI Free Software License B v2.0","value":"SGI-B-2.0"},{"text":"SGI OpenGL License","value":"SGI-OpenGL"},{"text":"SGP4 Permission Notice","value":"SGP4"},{"text":"Solderpad Hardware License v0.5","value":"SHL-0.5"},{"text":"Solderpad Hardware License, Version 0.51","value":"SHL-0.51"},{"text":"Sun Industry Standards Source License v1.1","value":"SISSL"},{"text":"Sun Industry Standards Source License v1.2","value":"SISSL-1.2"},{"text":"SL License","value":"SL"},{"text":"Standard ML of New Jersey License","value":"SMLNJ"},{"text":"Secure Messaging Protocol Public License","value":"SMPPL"},{"text":"SNIA Public License 1.1","value":"SNIA"},{"text":"Sun Public License v1.0","value":"SPL-1.0"},{"text":"SSH OpenSSH license","value":"SSH-OpenSSH"},{"text":"SSH short notice","value":"SSH-short"},{"text":"SSLeay License - standalone","value":"SSLeay-standalone"},{"text":"Server Side Public License, v 1","value":"SSPL-1.0"},{"text":"Scheme Widget Library (SWL) Software License Agreement","value":"SWL"},{"text":"Saxpath License","value":"Saxpath"},{"text":"Scheme Language Report License","value":"SchemeReport"},{"text":"Sendmail License","value":"Sendmail"},{"text":"Sendmail License 8.23","value":"Sendmail-8.23"},{"text":"Simple Public License 2.0","value":"SimPL-2.0"},{"text":"Sleepycat License","value":"Sleepycat"},{"text":"Soundex License","value":"Soundex"},{"text":"Spencer License 86","value":"Spencer-86"},{"text":"Spencer License 94","value":"Spencer-94"},{"text":"Spencer License 99","value":"Spencer-99"},{"text":"SugarCRM Public License v1.1.3","value":"SugarCRM-1.1.3"},{"text":"Sun PPP License","value":"Sun-PPP"},{"text":"Sun PPP License (2000)","value":"Sun-PPP-2000"},{"text":"SunPro License","value":"SunPro"},{"text":"Symlinks License","value":"Symlinks"},{"text":"TAPR Open Hardware License v1.0","value":"TAPR-OHL-1.0"},{"text":"TCL/TK License","value":"TCL"},{"text":"TCP Wrappers License","value":"TCP-wrappers"},{"text":"Transitive Grace Period Public Licence 1.0","value":"TGPPL-1.0"},{"text":"TMate Open Source License","value":"TMate"},{"text":"TORQUE v2.5+ Software License v1.1","value":"TORQUE-1.1"},{"text":"Trusster Open Source License","value":"TOSL"},{"text":"Time::ParseDate License","value":"TPDL"},{"text":"THOR Public License 1.0","value":"TPL-1.0"},{"text":"Text-Tabs+Wrap License","value":"TTWL"},{"text":"TTYP0 License","value":"TTYP0"},{"text":"Technische Universitaet Berlin License 1.0","value":"TU-Berlin-1.0"},{"text":"Technische Universitaet Berlin License 2.0","value":"TU-Berlin-2.0"},{"text":"TermReadKey License","value":"TermReadKey"},{"text":"UCAR License","value":"UCAR"},{"text":"Upstream Compatibility License v1.0","value":"UCL-1.0"},{"text":"Michigan/Merit Networks License","value":"UMich-Merit"},{"text":"Universal Permissive License v1.0","value":"UPL-1.0"},{"text":"Utah Raster Toolkit Run Length Encoded License","value":"URT-RLE"},{"text":"Ubuntu Font Licence v1.0","value":"Ubuntu-font-1.0"},{"text":"Unicode License v3","value":"Unicode-3.0"},{"text":"Unicode License Agreement - Data Files and Software (2015)","value":"Unicode-DFS-2015"},{"text":"Unicode License Agreement - Data Files and Software (2016)","value":"Unicode-DFS-2016"},{"text":"Unicode Terms of Use","value":"Unicode-TOU"},{"text":"UnixCrypt License","value":"UnixCrypt"},{"text":"The Unlicense","value":"Unlicense"},{"text":"VOSTROM Public License for Open Source","value":"VOSTROM"},{"text":"Vovida Software License v1.0","value":"VSL-1.0"},{"text":"Vim License","value":"Vim"},{"text":"W3C Software Notice and License (2002-12-31)","value":"W3C"},{"text":"W3C Software Notice and License (1998-07-20)","value":"W3C-19980720"},{"text":"W3C Software Notice and Document License (2015-05-13)","value":"W3C-20150513"},{"text":"Do What The F*ck You Want To Public License","value":"WTFPL"},{"text":"Sybase Open Watcom Public License 1.0","value":"Watcom-1.0"},{"text":"Widget Workshop License","value":"Widget-Workshop"},{"text":"Wsuipa License","value":"Wsuipa"},{"text":"X11 License","value":"X11"},{"text":"X11 License Distribution Modification Variant","value":"X11-distribute-modifications-variant"},{"text":"X11 swapped final paragraphs","value":"X11-swapped"},{"text":"XFree86 License 1.1","value":"XFree86-1.1"},{"text":"XSkat License","value":"XSkat"},{"text":"Xdebug License v 1.03","value":"Xdebug-1.03"},{"text":"Xerox License","value":"Xerox"},{"text":"Xfig License","value":"Xfig"},{"text":"X.Net License","value":"Xnet"},{"text":"Yahoo! Public License v1.0","value":"YPL-1.0"},{"text":"Yahoo! Public License v1.1","value":"YPL-1.1"},{"text":"Zope Public License 1.1","value":"ZPL-1.1"},{"text":"Zope Public License 2.0","value":"ZPL-2.0"},{"text":"Zope Public License 2.1","value":"ZPL-2.1"},{"text":"Zed License","value":"Zed"},{"text":"Zeeff License","value":"Zeeff"},{"text":"Zend License v2.0","value":"Zend-2.0"},{"text":"Zimbra Public License v1.3","value":"Zimbra-1.3"},{"text":"Zimbra Public License v1.4","value":"Zimbra-1.4"},{"text":"zlib License","value":"Zlib"},{"text":"Any OSI License","value":"any-OSI"},{"text":"bcrypt Solar Designer License","value":"bcrypt-Solar-Designer"},{"text":"SQLite Blessing","value":"blessing"},{"text":"bzip2 and libbzip2 License v1.0.6","value":"bzip2-1.0.6"},{"text":"check-cvs License","value":"check-cvs"},{"text":"Checkmk License","value":"checkmk"},{"text":"copyleft-next 0.3.0","value":"copyleft-next-0.3.0"},{"text":"copyleft-next 0.3.1","value":"copyleft-next-0.3.1"},{"text":"curl License","value":"curl"},{"text":"Common Vulnerability Enumeration ToU License","value":"cve-tou"},{"text":"diffmark license","value":"diffmark"},{"text":"David M. Gay dtoa License","value":"dtoa"},{"text":"dvipdfm License","value":"dvipdfm"},{"text":"eGenix.com Public License 1.1.0","value":"eGenix"},{"text":"Etalab Open License 2.0","value":"etalab-2.0"},{"text":"fwlw License","value":"fwlw"},{"text":"gSOAP Public License v1.3b","value":"gSOAP-1.3b"},{"text":"gnuplot License","value":"gnuplot"},{"text":"gtkbook License","value":"gtkbook"},{"text":"hdparm License","value":"hdparm"},{"text":"iMatix Standard Function Library Agreement","value":"iMatix"},{"text":"PNG Reference Library version 2","value":"libpng-2.0"},{"text":"libselinux public domain notice","value":"libselinux-1.0"},{"text":"libtiff License","value":"libtiff"},{"text":"libutil David Nugent License","value":"libutil-David-Nugent"},{"text":"lsof License","value":"lsof"},{"text":"magaz License","value":"magaz"},{"text":"mailprio License","value":"mailprio"},{"text":"metamail License","value":"metamail"},{"text":"mpi Permissive License","value":"mpi-permissive"},{"text":"mpich2 License","value":"mpich2"},{"text":"mplus Font License","value":"mplus"},{"text":"pkgconf License","value":"pkgconf"},{"text":"pnmstitch License","value":"pnmstitch"},{"text":"psfrag License","value":"psfrag"},{"text":"psutils License","value":"psutils"},{"text":"Python ldap License","value":"python-ldap"},{"text":"radvd License","value":"radvd"},{"text":"snprintf License","value":"snprintf"},{"text":"softSurfer License","value":"softSurfer"},{"text":"ssh-keyscan License","value":"ssh-keyscan"},{"text":"swrule License","value":"swrule"},{"text":"threeparttable License","value":"threeparttable"},{"text":"ulem License","value":"ulem"},{"text":"w3m License","value":"w3m"},{"text":"xinetd License","value":"xinetd"},{"text":"xkeyboard-config Zinoviev License","value":"xkeyboard-config-Zinoviev"},{"text":"xlock License","value":"xlock"},{"text":"XPP License","value":"xpp"},{"text":"xzoom License","value":"xzoom"},{"text":"zlib/libpng License with Acknowledgement","value":"zlib-acknowledgement"}]
\ No newline at end of file
diff --git a/src/i18n/index.ts b/src/i18n/index.ts
index 67a97c91..53c1ab28 100644
--- a/src/i18n/index.ts
+++ b/src/i18n/index.ts
@@ -12,9 +12,9 @@ import it from "./locales/it.json";
type LocalizedEntity = 'language' | 'region';
const resources = {
+ it: { translation: it },
en: { translation: en },
fr: { translation: fr },
- it: { translation: it },
};
i18n
@@ -22,6 +22,7 @@ i18n
.use(initReactI18next)
.init({
resources,
+ lng: 'it',
supportedLngs: Object.keys(resources),
nonExplicitSupportedLngs: true, // make pass eg. "en-US" if "en" is in supportedLngs
fallbackLng: FALLBACK_LANGUAGE,
@@ -58,3 +59,15 @@ export const allCountries = (locale: string = i18n.language) => {
return Object.keys(countries)
.map((countryCode) => ({ text: displayName(countryCode, locale, 'region'), value: countryCode }))
}
+
+/**
+ * Get all the languages supported by the app
+ */
+export const getSupportedLanguages = (): Array => {
+ //It's a special language code used by i18next for debugging purposes, and it's automatically included, so you may want to exclude it from the displayed list.
+ const cimode = 'cimode'
+ const supportedLngs = i18n.options.supportedLngs;
+ return (Array.isArray(supportedLngs) ? supportedLngs.filter(l => l !== cimode) : [])
+}
+
+export const formatLanguageLabel = (language: string) => displayName(language, undefined, 'language')?.toUpperCase()
diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json
index 240c7401..38fdc133 100644
--- a/src/i18n/locales/en.json
+++ b/src/i18n/locales/en.json
@@ -10,6 +10,7 @@
"copy": "Copia",
"copytext": "Copied to clipboard",
"download": "Download",
+ "import": "Import",
"genericerror": "There are some errors",
"success": "Success!",
"browsefile": "Browse file from disk",
@@ -28,7 +29,11 @@
"notification_text": "All entered data has been cleared"
},
"upload": "Upload",
- "validate": "Validate",
+ "validate": {
+ "notification_title": "Validation errors",
+ "notification_text": "Check the fields of the form",
+ "button": "Validate"
+ },
"generate": "Generate",
"addnew": "Add new",
"overwrite": "Overwrite form",
diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json
index 4b92f367..8819b7c1 100644
--- a/src/i18n/locales/fr.json
+++ b/src/i18n/locales/fr.json
@@ -10,6 +10,7 @@
"copy": "Copia",
"copytext": "Copied to clipboard",
"download": "Download",
+ "import": "Import",
"genericerror": "There are some errors",
"success": "Success!",
"browsefile": "Browse file from disk",
@@ -17,7 +18,7 @@
"pastefile": "Paste remote publiccode.yaml url",
"load": "Load",
"notvalidurl": "Not a valid url",
- "filenotsupported": "File type not supported",
+ "filenotsupported": "File type not supported",
"errors": {
"yamlloading": "Error loading yaml"
},
@@ -28,7 +29,11 @@
"notification_text": "All entered data has been cleared"
},
"upload": "Upload",
- "validate": "Validate",
+ "validate": {
+ "notification_title": "Validation errors",
+ "notification_text": "Check the fields of the form",
+ "button": "Validate"
+ },
"generate": "Generate",
"addnew": "Add new",
"overwrite": "Overwrite form",
diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json
index 6aec0b3d..fe86cca1 100644
--- a/src/i18n/locales/it.json
+++ b/src/i18n/locales/it.json
@@ -10,6 +10,7 @@
"copy": "Copia",
"copytext": "Copiato negli appunti",
"download": "Scarica",
+ "import": "Importa",
"genericerror": "Ci sono degli errori",
"success": "Ottimo",
"browsefile": "Carica il file dal disco",
@@ -28,7 +29,11 @@
"notification_text": "Tutti i dati inseriti sono stati cancellati"
},
"upload": "Carica",
- "validate": "Valida",
+ "validate": {
+ "notification_title": "Errori di validazione",
+ "notification_text": "Controlla i campi della form",
+ "button": "Valida"
+ },
"generate": "Genera",
"addnew": "Aggiungi",
"overwrite": "Sovrascrivi",
diff --git a/src/index.css b/src/index.css
new file mode 100644
index 00000000..6119ad9a
--- /dev/null
+++ b/src/index.css
@@ -0,0 +1,68 @@
+:root {
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
+ line-height: 1.5;
+ font-weight: 400;
+
+ color-scheme: light dark;
+ color: rgba(255, 255, 255, 0.87);
+ background-color: #242424;
+
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+a {
+ font-weight: 500;
+ color: #646cff;
+ text-decoration: inherit;
+}
+a:hover {
+ color: #535bf2;
+}
+
+body {
+ margin: 0;
+ display: flex;
+ place-items: center;
+ min-width: 320px;
+ min-height: 100vh;
+}
+
+h1 {
+ font-size: 3.2em;
+ line-height: 1.1;
+}
+
+button {
+ border-radius: 8px;
+ border: 1px solid transparent;
+ padding: 0.6em 1.2em;
+ font-size: 1em;
+ font-weight: 500;
+ font-family: inherit;
+ background-color: #1a1a1a;
+ cursor: pointer;
+ transition: border-color 0.25s;
+}
+button:hover {
+ border-color: #646cff;
+}
+button:focus,
+button:focus-visible {
+ outline: 4px auto -webkit-focus-ring-color;
+}
+
+@media (prefers-color-scheme: light) {
+ :root {
+ color: #213547;
+ background-color: #ffffff;
+ }
+ a:hover {
+ color: #747bff;
+ }
+ button {
+ background-color: #f9f9f9;
+ }
+}
diff --git a/src/index.html b/src/index.html
deleted file mode 100644
index 8ad3601a..00000000
--- a/src/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main.tsx b/src/main.tsx
new file mode 100644
index 00000000..ab0c5d69
--- /dev/null
+++ b/src/main.tsx
@@ -0,0 +1,10 @@
+// import { StrictMode } from 'react'
+import { createRoot } from 'react-dom/client'
+import App from './app/App.tsx'
+// import './index.css'
+
+createRoot(document.getElementById('app')!).render(
+ //
+
+ // ,
+)
diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts
new file mode 100644
index 00000000..78c8206e
--- /dev/null
+++ b/src/vite-env.d.ts
@@ -0,0 +1,17 @@
+///
+
+//https://vitejs.dev/guide/env-and-mode#intellisense-for-typescript
+
+interface ImportMetaEnv {
+ readonly VITE_REPOSITORY: string;
+ readonly VITE_ELASTIC_URL: string;
+ readonly VITE_VALIDATOR_URL: string;
+ readonly VITE_VALIDATOR_REMOTE_URL: string;
+ readonly VITE_DEFAULT_COUNTRY: string;
+ readonly VITE_FALLBACK_LANGUAGE?: string;
+ readonly VITE_DEFAULT_COUNTRY_SECTIONS?: string;
+ }
+
+ interface ImportMeta {
+ readonly env: ImportMetaEnv
+ }
diff --git a/tsconfig.app.json b/tsconfig.app.json
new file mode 100644
index 00000000..f0a23505
--- /dev/null
+++ b/tsconfig.app.json
@@ -0,0 +1,24 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "useDefineForClassFields": true,
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "isolatedModules": true,
+ "moduleDetection": "force",
+ "noEmit": true,
+ "jsx": "react-jsx",
+
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "include": ["src"]
+}
diff --git a/tsconfig.json b/tsconfig.json
index d691e3ac..1ffef600 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,25 +1,7 @@
{
- "compilerOptions": {
- "target": "es5",
- "lib": ["dom", "dom.iterable", "esnext"],
- "allowJs": true,
- "skipLibCheck": true,
- "esModuleInterop": true,
- "allowSyntheticDefaultImports": true,
- "strict": true,
- "forceConsistentCasingInFileNames": true,
- "noFallthroughCasesInSwitch": true,
- "module": "esnext",
- "moduleResolution": "node",
- "resolveJsonModule": true,
- "isolatedModules": true,
- "noEmit": true,
- "jsx": "react-jsx"
- },
- "include": ["src"],
- "ts-node": {
- "compilerOptions": {
- "module": "CommonJS"
- }
- }
+ "files": [],
+ "references": [
+ { "path": "./tsconfig.app.json" },
+ { "path": "./tsconfig.node.json" }
+ ]
}
diff --git a/tsconfig.node.json b/tsconfig.node.json
new file mode 100644
index 00000000..0d3d7144
--- /dev/null
+++ b/tsconfig.node.json
@@ -0,0 +1,22 @@
+{
+ "compilerOptions": {
+ "target": "ES2022",
+ "lib": ["ES2023"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "isolatedModules": true,
+ "moduleDetection": "force",
+ "noEmit": true,
+
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "include": ["vite.config.ts"]
+}
diff --git a/vite.config.ts b/vite.config.ts
new file mode 100644
index 00000000..e33ff791
--- /dev/null
+++ b/vite.config.ts
@@ -0,0 +1,12 @@
+import { defineConfig } from "vite";
+import type { UserConfig } from "vite";
+import react from "@vitejs/plugin-react";
+import favicons from "@peterek/vite-plugin-favicons";
+
+// https://vitejs.dev/config/
+export default defineConfig(() => {
+ return {
+ plugins: [react(), favicons("public/assets/img/favicon-32x32.png")],
+ build: { target: "esnext" },
+ } satisfies UserConfig;
+});
diff --git a/webpack.config.ts b/webpack.config.ts
deleted file mode 100644
index 04c9d339..00000000
--- a/webpack.config.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import CopyPlugin from "copy-webpack-plugin";
-import "dotenv/config";
-import HtmlWebpackPlugin from "html-webpack-plugin";
-import MiniCssExtractPlugin from "mini-css-extract-plugin";
-import { Configuration, DefinePlugin } from "webpack";
-
-const config = (
- env: Record,
- { mode }: { mode: "none" | "development" | "production" }
-): Configuration => ({
- entry: "./src/app/app.tsx",
- output: {
- filename: "app.bundle.js",
- },
- plugins: [
- new DefinePlugin({
- "process.env": {
- REPOSITORY: JSON.stringify(process.env.REPOSITORY),
- ELASTIC_URL: JSON.stringify(process.env.ELASTIC_URL),
- VALIDATOR_URL: JSON.stringify(process.env.VALIDATOR_URL),
- VALIDATOR_REMOTE_URL: JSON.stringify(process.env.VALIDATOR_REMOTE_URL),
- FALLBACK_LANGUAGE: JSON.stringify(process.env.FALLBACK_LANGUAGE),
- DEFAULT_COUNTRY_SECTIONS: JSON.stringify(
- process.env.DEFAULT_COUNTRY_SECTIONS
- ),
- },
- }),
- new HtmlWebpackPlugin({
- template: "src/index.html",
- minify: {
- collapseWhitespace: true,
- minifyCSS: true,
- minifyJS: true,
- removeComments: true,
- useShortDoctype: true,
- },
- favicon: "src/asset/img/favicon-32x32.png",
- }),
- new MiniCssExtractPlugin({
- filename: mode !== "production" ? "[name].css" : "[name].[fullhash].css",
- chunkFilename: mode !== "production" ? "[id].css" : "[id].[fullhash].css",
- }),
- new CopyPlugin({
- patterns: ["src/generated/main.wasm", "src/generated/wasm_exec.js"],
- }),
- ],
- module: {
- rules: [
- {
- test: /\.(js|jsx|ts|tsx)$/,
- exclude: /node_modules/,
- use: "swc-loader",
- },
-
- {
- test: /\.css$/,
- use: [
- mode !== "production" ? "style-loader" : MiniCssExtractPlugin.loader,
- "css-loader",
- "postcss-loader",
- ],
- },
-
- {
- test: /\.(png|jpg|gif)$/,
- type: "asset/inline",
- },
- {
- test: /\.(woff|woff2|eot|ttf|otf|svg)$/,
- type: "asset/resource",
- },
- ],
- },
- resolve: {
- extensions: [".js", ".jsx", ".json", ".yml", ".tsx", ".ts"],
- alias: {
- cldr$: "cldrjs",
- cldr: "cldrjs/dist/cldr",
- },
- },
-});
-
-export default config;