@manifest-editor/projects 1.4.3 → 2.0.1-next.0.d468080
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +44 -1140
- package/dist/index.d.cts +193 -179
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +193 -179
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -1130
- package/dist/index.js.map +1 -0
- package/package.json +21 -26
package/dist/index.js
CHANGED
|
@@ -1,877 +1,4 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __publicField = (obj, key, value) => {
|
|
28
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
29
|
-
return value;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// ../../node_modules/.pnpm/shallowequal@1.1.0/node_modules/shallowequal/index.js
|
|
33
|
-
var require_shallowequal = __commonJS({
|
|
34
|
-
"../../node_modules/.pnpm/shallowequal@1.1.0/node_modules/shallowequal/index.js"(exports, module) {
|
|
35
|
-
"use strict";
|
|
36
|
-
module.exports = function shallowEqual2(objA, objB, compare, compareContext) {
|
|
37
|
-
var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
|
|
38
|
-
if (ret !== void 0) {
|
|
39
|
-
return !!ret;
|
|
40
|
-
}
|
|
41
|
-
if (objA === objB) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
var keysA = Object.keys(objA);
|
|
48
|
-
var keysB = Object.keys(objB);
|
|
49
|
-
if (keysA.length !== keysB.length) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
53
|
-
for (var idx = 0; idx < keysA.length; idx++) {
|
|
54
|
-
var key = keysA[idx];
|
|
55
|
-
if (!bHasOwnProperty(key)) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
var valueA = objA[key];
|
|
59
|
-
var valueB = objB[key];
|
|
60
|
-
ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
|
|
61
|
-
if (ret === false || ret === void 0 && valueA !== valueB) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return true;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// ../../node_modules/.pnpm/slugify@1.6.6/node_modules/slugify/slugify.js
|
|
71
|
-
var require_slugify = __commonJS({
|
|
72
|
-
"../../node_modules/.pnpm/slugify@1.6.6/node_modules/slugify/slugify.js"(exports, module) {
|
|
73
|
-
"use strict";
|
|
74
|
-
(function(name, root, factory) {
|
|
75
|
-
if (typeof exports === "object") {
|
|
76
|
-
module.exports = factory();
|
|
77
|
-
module.exports["default"] = factory();
|
|
78
|
-
} else if (typeof define === "function" && define.amd) {
|
|
79
|
-
define(factory);
|
|
80
|
-
} else {
|
|
81
|
-
root[name] = factory();
|
|
82
|
-
}
|
|
83
|
-
})("slugify", exports, function() {
|
|
84
|
-
var charMap = JSON.parse(`{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","\xA2":"cent","\xA3":"pound","\xA4":"currency","\xA5":"yen","\xA9":"(c)","\xAA":"a","\xAE":"(r)","\xBA":"o","\xC0":"A","\xC1":"A","\xC2":"A","\xC3":"A","\xC4":"A","\xC5":"A","\xC6":"AE","\xC7":"C","\xC8":"E","\xC9":"E","\xCA":"E","\xCB":"E","\xCC":"I","\xCD":"I","\xCE":"I","\xCF":"I","\xD0":"D","\xD1":"N","\xD2":"O","\xD3":"O","\xD4":"O","\xD5":"O","\xD6":"O","\xD8":"O","\xD9":"U","\xDA":"U","\xDB":"U","\xDC":"U","\xDD":"Y","\xDE":"TH","\xDF":"ss","\xE0":"a","\xE1":"a","\xE2":"a","\xE3":"a","\xE4":"a","\xE5":"a","\xE6":"ae","\xE7":"c","\xE8":"e","\xE9":"e","\xEA":"e","\xEB":"e","\xEC":"i","\xED":"i","\xEE":"i","\xEF":"i","\xF0":"d","\xF1":"n","\xF2":"o","\xF3":"o","\xF4":"o","\xF5":"o","\xF6":"o","\xF8":"o","\xF9":"u","\xFA":"u","\xFB":"u","\xFC":"u","\xFD":"y","\xFE":"th","\xFF":"y","\u0100":"A","\u0101":"a","\u0102":"A","\u0103":"a","\u0104":"A","\u0105":"a","\u0106":"C","\u0107":"c","\u010C":"C","\u010D":"c","\u010E":"D","\u010F":"d","\u0110":"DJ","\u0111":"dj","\u0112":"E","\u0113":"e","\u0116":"E","\u0117":"e","\u0118":"e","\u0119":"e","\u011A":"E","\u011B":"e","\u011E":"G","\u011F":"g","\u0122":"G","\u0123":"g","\u0128":"I","\u0129":"i","\u012A":"i","\u012B":"i","\u012E":"I","\u012F":"i","\u0130":"I","\u0131":"i","\u0136":"k","\u0137":"k","\u013B":"L","\u013C":"l","\u013D":"L","\u013E":"l","\u0141":"L","\u0142":"l","\u0143":"N","\u0144":"n","\u0145":"N","\u0146":"n","\u0147":"N","\u0148":"n","\u014C":"O","\u014D":"o","\u0150":"O","\u0151":"o","\u0152":"OE","\u0153":"oe","\u0154":"R","\u0155":"r","\u0158":"R","\u0159":"r","\u015A":"S","\u015B":"s","\u015E":"S","\u015F":"s","\u0160":"S","\u0161":"s","\u0162":"T","\u0163":"t","\u0164":"T","\u0165":"t","\u0168":"U","\u0169":"u","\u016A":"u","\u016B":"u","\u016E":"U","\u016F":"u","\u0170":"U","\u0171":"u","\u0172":"U","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017A":"z","\u017B":"Z","\u017C":"z","\u017D":"Z","\u017E":"z","\u018F":"E","\u0192":"f","\u01A0":"O","\u01A1":"o","\u01AF":"U","\u01B0":"u","\u01C8":"LJ","\u01C9":"lj","\u01CB":"NJ","\u01CC":"nj","\u0218":"S","\u0219":"s","\u021A":"T","\u021B":"t","\u0259":"e","\u02DA":"o","\u0386":"A","\u0388":"E","\u0389":"H","\u038A":"I","\u038C":"O","\u038E":"Y","\u038F":"W","\u0390":"i","\u0391":"A","\u0392":"B","\u0393":"G","\u0394":"D","\u0395":"E","\u0396":"Z","\u0397":"H","\u0398":"8","\u0399":"I","\u039A":"K","\u039B":"L","\u039C":"M","\u039D":"N","\u039E":"3","\u039F":"O","\u03A0":"P","\u03A1":"R","\u03A3":"S","\u03A4":"T","\u03A5":"Y","\u03A6":"F","\u03A7":"X","\u03A8":"PS","\u03A9":"W","\u03AA":"I","\u03AB":"Y","\u03AC":"a","\u03AD":"e","\u03AE":"h","\u03AF":"i","\u03B0":"y","\u03B1":"a","\u03B2":"b","\u03B3":"g","\u03B4":"d","\u03B5":"e","\u03B6":"z","\u03B7":"h","\u03B8":"8","\u03B9":"i","\u03BA":"k","\u03BB":"l","\u03BC":"m","\u03BD":"n","\u03BE":"3","\u03BF":"o","\u03C0":"p","\u03C1":"r","\u03C2":"s","\u03C3":"s","\u03C4":"t","\u03C5":"y","\u03C6":"f","\u03C7":"x","\u03C8":"ps","\u03C9":"w","\u03CA":"i","\u03CB":"y","\u03CC":"o","\u03CD":"y","\u03CE":"w","\u0401":"Yo","\u0402":"DJ","\u0404":"Ye","\u0406":"I","\u0407":"Yi","\u0408":"J","\u0409":"LJ","\u040A":"NJ","\u040B":"C","\u040F":"DZ","\u0410":"A","\u0411":"B","\u0412":"V","\u0413":"G","\u0414":"D","\u0415":"E","\u0416":"Zh","\u0417":"Z","\u0418":"I","\u0419":"J","\u041A":"K","\u041B":"L","\u041C":"M","\u041D":"N","\u041E":"O","\u041F":"P","\u0420":"R","\u0421":"S","\u0422":"T","\u0423":"U","\u0424":"F","\u0425":"H","\u0426":"C","\u0427":"Ch","\u0428":"Sh","\u0429":"Sh","\u042A":"U","\u042B":"Y","\u042C":"","\u042D":"E","\u042E":"Yu","\u042F":"Ya","\u0430":"a","\u0431":"b","\u0432":"v","\u0433":"g","\u0434":"d","\u0435":"e","\u0436":"zh","\u0437":"z","\u0438":"i","\u0439":"j","\u043A":"k","\u043B":"l","\u043C":"m","\u043D":"n","\u043E":"o","\u043F":"p","\u0440":"r","\u0441":"s","\u0442":"t","\u0443":"u","\u0444":"f","\u0445":"h","\u0446":"c","\u0447":"ch","\u0448":"sh","\u0449":"sh","\u044A":"u","\u044B":"y","\u044C":"","\u044D":"e","\u044E":"yu","\u044F":"ya","\u0451":"yo","\u0452":"dj","\u0454":"ye","\u0456":"i","\u0457":"yi","\u0458":"j","\u0459":"lj","\u045A":"nj","\u045B":"c","\u045D":"u","\u045F":"dz","\u0490":"G","\u0491":"g","\u0492":"GH","\u0493":"gh","\u049A":"KH","\u049B":"kh","\u04A2":"NG","\u04A3":"ng","\u04AE":"UE","\u04AF":"ue","\u04B0":"U","\u04B1":"u","\u04BA":"H","\u04BB":"h","\u04D8":"AE","\u04D9":"ae","\u04E8":"OE","\u04E9":"oe","\u0531":"A","\u0532":"B","\u0533":"G","\u0534":"D","\u0535":"E","\u0536":"Z","\u0537":"E'","\u0538":"Y'","\u0539":"T'","\u053A":"JH","\u053B":"I","\u053C":"L","\u053D":"X","\u053E":"C'","\u053F":"K","\u0540":"H","\u0541":"D'","\u0542":"GH","\u0543":"TW","\u0544":"M","\u0545":"Y","\u0546":"N","\u0547":"SH","\u0549":"CH","\u054A":"P","\u054B":"J","\u054C":"R'","\u054D":"S","\u054E":"V","\u054F":"T","\u0550":"R","\u0551":"C","\u0553":"P'","\u0554":"Q'","\u0555":"O''","\u0556":"F","\u0587":"EV","\u0621":"a","\u0622":"aa","\u0623":"a","\u0624":"u","\u0625":"i","\u0626":"e","\u0627":"a","\u0628":"b","\u0629":"h","\u062A":"t","\u062B":"th","\u062C":"j","\u062D":"h","\u062E":"kh","\u062F":"d","\u0630":"th","\u0631":"r","\u0632":"z","\u0633":"s","\u0634":"sh","\u0635":"s","\u0636":"dh","\u0637":"t","\u0638":"z","\u0639":"a","\u063A":"gh","\u0641":"f","\u0642":"q","\u0643":"k","\u0644":"l","\u0645":"m","\u0646":"n","\u0647":"h","\u0648":"w","\u0649":"a","\u064A":"y","\u064B":"an","\u064C":"on","\u064D":"en","\u064E":"a","\u064F":"u","\u0650":"e","\u0652":"","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u067E":"p","\u0686":"ch","\u0698":"zh","\u06A9":"k","\u06AF":"g","\u06CC":"y","\u06F0":"0","\u06F1":"1","\u06F2":"2","\u06F3":"3","\u06F4":"4","\u06F5":"5","\u06F6":"6","\u06F7":"7","\u06F8":"8","\u06F9":"9","\u0E3F":"baht","\u10D0":"a","\u10D1":"b","\u10D2":"g","\u10D3":"d","\u10D4":"e","\u10D5":"v","\u10D6":"z","\u10D7":"t","\u10D8":"i","\u10D9":"k","\u10DA":"l","\u10DB":"m","\u10DC":"n","\u10DD":"o","\u10DE":"p","\u10DF":"zh","\u10E0":"r","\u10E1":"s","\u10E2":"t","\u10E3":"u","\u10E4":"f","\u10E5":"k","\u10E6":"gh","\u10E7":"q","\u10E8":"sh","\u10E9":"ch","\u10EA":"ts","\u10EB":"dz","\u10EC":"ts","\u10ED":"ch","\u10EE":"kh","\u10EF":"j","\u10F0":"h","\u1E62":"S","\u1E63":"s","\u1E80":"W","\u1E81":"w","\u1E82":"W","\u1E83":"w","\u1E84":"W","\u1E85":"w","\u1E9E":"SS","\u1EA0":"A","\u1EA1":"a","\u1EA2":"A","\u1EA3":"a","\u1EA4":"A","\u1EA5":"a","\u1EA6":"A","\u1EA7":"a","\u1EA8":"A","\u1EA9":"a","\u1EAA":"A","\u1EAB":"a","\u1EAC":"A","\u1EAD":"a","\u1EAE":"A","\u1EAF":"a","\u1EB0":"A","\u1EB1":"a","\u1EB2":"A","\u1EB3":"a","\u1EB4":"A","\u1EB5":"a","\u1EB6":"A","\u1EB7":"a","\u1EB8":"E","\u1EB9":"e","\u1EBA":"E","\u1EBB":"e","\u1EBC":"E","\u1EBD":"e","\u1EBE":"E","\u1EBF":"e","\u1EC0":"E","\u1EC1":"e","\u1EC2":"E","\u1EC3":"e","\u1EC4":"E","\u1EC5":"e","\u1EC6":"E","\u1EC7":"e","\u1EC8":"I","\u1EC9":"i","\u1ECA":"I","\u1ECB":"i","\u1ECC":"O","\u1ECD":"o","\u1ECE":"O","\u1ECF":"o","\u1ED0":"O","\u1ED1":"o","\u1ED2":"O","\u1ED3":"o","\u1ED4":"O","\u1ED5":"o","\u1ED6":"O","\u1ED7":"o","\u1ED8":"O","\u1ED9":"o","\u1EDA":"O","\u1EDB":"o","\u1EDC":"O","\u1EDD":"o","\u1EDE":"O","\u1EDF":"o","\u1EE0":"O","\u1EE1":"o","\u1EE2":"O","\u1EE3":"o","\u1EE4":"U","\u1EE5":"u","\u1EE6":"U","\u1EE7":"u","\u1EE8":"U","\u1EE9":"u","\u1EEA":"U","\u1EEB":"u","\u1EEC":"U","\u1EED":"u","\u1EEE":"U","\u1EEF":"u","\u1EF0":"U","\u1EF1":"u","\u1EF2":"Y","\u1EF3":"y","\u1EF4":"Y","\u1EF5":"y","\u1EF6":"Y","\u1EF7":"y","\u1EF8":"Y","\u1EF9":"y","\u2013":"-","\u2018":"'","\u2019":"'","\u201C":"\\"","\u201D":"\\"","\u201E":"\\"","\u2020":"+","\u2022":"*","\u2026":"...","\u20A0":"ecu","\u20A2":"cruzeiro","\u20A3":"french franc","\u20A4":"lira","\u20A5":"mill","\u20A6":"naira","\u20A7":"peseta","\u20A8":"rupee","\u20A9":"won","\u20AA":"new shequel","\u20AB":"dong","\u20AC":"euro","\u20AD":"kip","\u20AE":"tugrik","\u20AF":"drachma","\u20B0":"penny","\u20B1":"peso","\u20B2":"guarani","\u20B3":"austral","\u20B4":"hryvnia","\u20B5":"cedi","\u20B8":"kazakhstani tenge","\u20B9":"indian rupee","\u20BA":"turkish lira","\u20BD":"russian ruble","\u20BF":"bitcoin","\u2120":"sm","\u2122":"tm","\u2202":"d","\u2206":"delta","\u2211":"sum","\u221E":"infinity","\u2665":"love","\u5143":"yuan","\u5186":"yen","\uFDFC":"rial","\uFEF5":"laa","\uFEF7":"laa","\uFEF9":"lai","\uFEFB":"la"}`);
|
|
85
|
-
var locales = JSON.parse('{"bg":{"\u0419":"Y","\u0426":"Ts","\u0429":"Sht","\u042A":"A","\u042C":"Y","\u0439":"y","\u0446":"ts","\u0449":"sht","\u044A":"a","\u044C":"y"},"de":{"\xC4":"AE","\xE4":"ae","\xD6":"OE","\xF6":"oe","\xDC":"UE","\xFC":"ue","\xDF":"ss","%":"prozent","&":"und","|":"oder","\u2211":"summe","\u221E":"unendlich","\u2665":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","\xA2":"centavos","\xA3":"libras","\xA4":"moneda","\u20A3":"francos","\u2211":"suma","\u221E":"infinito","\u2665":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","\xA2":"centime","\xA3":"livre","\xA4":"devise","\u20A3":"franc","\u2211":"somme","\u221E":"infini","\u2665":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","\xA2":"centavo","\u2211":"soma","\xA3":"libra","\u221E":"infinito","\u2665":"amor"},"uk":{"\u0418":"Y","\u0438":"y","\u0419":"Y","\u0439":"y","\u0426":"Ts","\u0446":"ts","\u0425":"Kh","\u0445":"kh","\u0429":"Shch","\u0449":"shch","\u0413":"H","\u0433":"h"},"vi":{"\u0110":"D","\u0111":"d"},"da":{"\xD8":"OE","\xF8":"oe","\xC5":"AA","\xE5":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"st\xF8rre end"},"nb":{"&":"og","\xC5":"AA","\xC6":"AE","\xD8":"OE","\xE5":"aa","\xE6":"ae","\xF8":"oe"},"it":{"&":"e"},"nl":{"&":"en"},"sv":{"&":"och","\xC5":"AA","\xC4":"AE","\xD6":"OE","\xE5":"aa","\xE4":"ae","\xF6":"oe"}}');
|
|
86
|
-
function replace(string, options) {
|
|
87
|
-
if (typeof string !== "string") {
|
|
88
|
-
throw new Error("slugify: string argument expected");
|
|
89
|
-
}
|
|
90
|
-
options = typeof options === "string" ? { replacement: options } : options || {};
|
|
91
|
-
var locale = locales[options.locale] || {};
|
|
92
|
-
var replacement = options.replacement === void 0 ? "-" : options.replacement;
|
|
93
|
-
var trim = options.trim === void 0 ? true : options.trim;
|
|
94
|
-
var slug = string.normalize().split("").reduce(function(result, ch) {
|
|
95
|
-
var appendChar = locale[ch];
|
|
96
|
-
if (appendChar === void 0)
|
|
97
|
-
appendChar = charMap[ch];
|
|
98
|
-
if (appendChar === void 0)
|
|
99
|
-
appendChar = ch;
|
|
100
|
-
if (appendChar === replacement)
|
|
101
|
-
appendChar = " ";
|
|
102
|
-
return result + appendChar.replace(options.remove || /[^\w\s$*_+~.()'"!\-:@]+/g, "");
|
|
103
|
-
}, "");
|
|
104
|
-
if (options.strict) {
|
|
105
|
-
slug = slug.replace(/[^A-Za-z0-9\s]/g, "");
|
|
106
|
-
}
|
|
107
|
-
if (trim) {
|
|
108
|
-
slug = slug.trim();
|
|
109
|
-
}
|
|
110
|
-
slug = slug.replace(/\s+/g, replacement);
|
|
111
|
-
if (options.lower) {
|
|
112
|
-
slug = slug.toLowerCase();
|
|
113
|
-
}
|
|
114
|
-
return slug;
|
|
115
|
-
}
|
|
116
|
-
replace.extend = function(customMap) {
|
|
117
|
-
Object.assign(charMap, customMap);
|
|
118
|
-
};
|
|
119
|
-
return replace;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// src/ProjectContext.tsx
|
|
125
|
-
import { createContext, useContext } from "react";
|
|
126
|
-
|
|
127
|
-
// ../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
128
|
-
var isProduction = false;
|
|
129
|
-
var prefix = "Invariant failed";
|
|
130
|
-
function invariant(condition, message) {
|
|
131
|
-
if (condition) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (isProduction) {
|
|
135
|
-
throw new Error(prefix);
|
|
136
|
-
}
|
|
137
|
-
var provided = typeof message === "function" ? message() : message;
|
|
138
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
139
|
-
throw new Error(value);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// src/ProjectContext.tsx
|
|
143
|
-
var ProjectReactContext = createContext(null);
|
|
144
|
-
var ProjectLoadingReactContext = createContext({
|
|
145
|
-
error: void 0,
|
|
146
|
-
isError: false,
|
|
147
|
-
isLoading: false
|
|
148
|
-
});
|
|
149
|
-
function useProjectLoading() {
|
|
150
|
-
return useContext(ProjectLoadingReactContext);
|
|
151
|
-
}
|
|
152
|
-
function useProjectContext() {
|
|
153
|
-
const ctx = useContext(ProjectReactContext);
|
|
154
|
-
invariant(ctx, "useProjectContext can only be called from inside <ProjectProvider />");
|
|
155
|
-
return ctx;
|
|
156
|
-
}
|
|
157
|
-
function useCurrentProject() {
|
|
158
|
-
const current = useProjectContext().current;
|
|
159
|
-
invariant(current, "No current project");
|
|
160
|
-
return current;
|
|
161
|
-
}
|
|
162
|
-
function useOptionalCurrentProject() {
|
|
163
|
-
const current = useProjectContext().current;
|
|
164
|
-
return current || null;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// src/ProjectContext.hooks.ts
|
|
168
|
-
var import_shallowequal = __toESM(require_shallowequal(), 1);
|
|
169
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
170
|
-
import { useDebounce } from "tiny-use-debounce";
|
|
171
|
-
|
|
172
|
-
// src/helpers/project-from-manifest.ts
|
|
173
|
-
var import_slugify = __toESM(require_slugify(), 1);
|
|
174
|
-
import { getValue } from "@iiif/helpers";
|
|
175
|
-
function randomId() {
|
|
176
|
-
return `${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`;
|
|
177
|
-
}
|
|
178
|
-
function projectFromManifest(manifest, details = {}) {
|
|
179
|
-
const name = getValue(manifest.label) || "Untitled manifest";
|
|
180
|
-
return {
|
|
181
|
-
id: `manifest-editor://project/${randomId()}`,
|
|
182
|
-
filename: (0, import_slugify.default)(name, { lower: true }),
|
|
183
|
-
name,
|
|
184
|
-
metadata: {
|
|
185
|
-
created: Date.now(),
|
|
186
|
-
modified: Date.now()
|
|
187
|
-
},
|
|
188
|
-
resource: {
|
|
189
|
-
id: manifest.id,
|
|
190
|
-
type: "Manifest"
|
|
191
|
-
},
|
|
192
|
-
publications: [],
|
|
193
|
-
previews: [],
|
|
194
|
-
settings: {},
|
|
195
|
-
storage: {
|
|
196
|
-
type: "manifest-storage",
|
|
197
|
-
data: manifest
|
|
198
|
-
},
|
|
199
|
-
...details
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// src/ProjectContext.hooks.ts
|
|
204
|
-
import { convertPresentation2 } from "@iiif/parser/presentation-2";
|
|
205
|
-
|
|
206
|
-
// src/helpers/ensure-unique-filename.ts
|
|
207
|
-
var import_slugify2 = __toESM(require_slugify(), 1);
|
|
208
|
-
function ensureUniqueFilename(project, existing) {
|
|
209
|
-
const filenames = existing.map((project2) => project2.filename);
|
|
210
|
-
const name = (project.name || project.filename || "Untitled project").toLowerCase();
|
|
211
|
-
if (project.filename && filenames.indexOf(project.filename) !== -1) {
|
|
212
|
-
project.filename = void 0;
|
|
213
|
-
}
|
|
214
|
-
if (!project.filename) {
|
|
215
|
-
let counter = 0;
|
|
216
|
-
while (!project.filename) {
|
|
217
|
-
const potentialFilename = `${(0, import_slugify2.default)(name, { lower: true })}${counter ? ` (${counter})` : ""}`;
|
|
218
|
-
if (filenames.indexOf(potentialFilename) === -1) {
|
|
219
|
-
project.filename = potentialFilename;
|
|
220
|
-
project.name = `${project.name} (${counter})`;
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
counter++;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// src/helpers/project-from-collection.ts
|
|
229
|
-
var import_slugify3 = __toESM(require_slugify(), 1);
|
|
230
|
-
import { getValue as getValue2 } from "@iiif/helpers";
|
|
231
|
-
|
|
232
|
-
// src/helpers/random-id.ts
|
|
233
|
-
function randomId2() {
|
|
234
|
-
return `${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// src/helpers/project-from-collection.ts
|
|
238
|
-
function projectFromCollection(collection, details = {}) {
|
|
239
|
-
const name = getValue2(collection.label) || "Untitled collection";
|
|
240
|
-
return {
|
|
241
|
-
id: `manifest-editor://project/${randomId2()}`,
|
|
242
|
-
filename: (0, import_slugify3.default)(name, { lower: true }),
|
|
243
|
-
name,
|
|
244
|
-
metadata: {
|
|
245
|
-
created: Date.now(),
|
|
246
|
-
modified: Date.now()
|
|
247
|
-
},
|
|
248
|
-
resource: {
|
|
249
|
-
id: collection.id,
|
|
250
|
-
type: "Collection"
|
|
251
|
-
},
|
|
252
|
-
publications: [],
|
|
253
|
-
previews: [],
|
|
254
|
-
settings: {},
|
|
255
|
-
storage: {
|
|
256
|
-
type: "collection-storage",
|
|
257
|
-
data: collection
|
|
258
|
-
},
|
|
259
|
-
...details
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// src/ProjectContext.hooks.ts
|
|
264
|
-
import { ClientVault } from "@manifest-editor/client-vault";
|
|
265
|
-
import { getManifestNomalized } from "@manifest-editor/shell";
|
|
266
|
-
function useProjectActionsWithBackend(dispatch, backend, storage) {
|
|
267
|
-
async function createProject(payload) {
|
|
268
|
-
const allProjects = await backend.getAllProjects(true);
|
|
269
|
-
const project = { ...payload };
|
|
270
|
-
ensureUniqueFilename(project, allProjects);
|
|
271
|
-
if (!storage.canCreate()) {
|
|
272
|
-
throw new Error("Cannot create project with this storage backend");
|
|
273
|
-
}
|
|
274
|
-
const backendStorage = await storage.create(project, project.storage.data);
|
|
275
|
-
const createdProject = { ...project, storage: backendStorage };
|
|
276
|
-
await backend.createProject(createdProject);
|
|
277
|
-
dispatch({ type: "createProject", payload: createdProject });
|
|
278
|
-
switchProject(project.id);
|
|
279
|
-
}
|
|
280
|
-
function deleteProject(payload) {
|
|
281
|
-
if (backend.canDelete()) {
|
|
282
|
-
dispatch({ type: "deleteProject", payload });
|
|
283
|
-
backend.deleteProject(payload).then(() => {
|
|
284
|
-
console.log("Loader: project deleted");
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
function switchProject(payload) {
|
|
289
|
-
dispatch({ type: "switchProject", payload });
|
|
290
|
-
backend.setLastProject(payload).then(() => {
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
function deselectProject(payload) {
|
|
294
|
-
dispatch({ type: "deselectProject", payload });
|
|
295
|
-
}
|
|
296
|
-
function forkProject(payload) {
|
|
297
|
-
dispatch({ type: "forkProject", payload });
|
|
298
|
-
throw new Error("Not implemented yet");
|
|
299
|
-
}
|
|
300
|
-
function setLoadingStatus(payload) {
|
|
301
|
-
dispatch({ type: "setLoadingStatus", payload });
|
|
302
|
-
}
|
|
303
|
-
function saveProject(project) {
|
|
304
|
-
console.log("trying to save project...");
|
|
305
|
-
dispatch({ type: "saveProject", payload: project });
|
|
306
|
-
Promise.all([
|
|
307
|
-
//
|
|
308
|
-
backend.updateProject(project),
|
|
309
|
-
storage.saveStorage(project.storage)
|
|
310
|
-
]).then(() => {
|
|
311
|
-
console.log("Loader: project saved");
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
function updateDetails(payload) {
|
|
315
|
-
dispatch({ type: "updateDetails", payload });
|
|
316
|
-
}
|
|
317
|
-
function createPublication(payload) {
|
|
318
|
-
dispatch({ type: "createPublication", payload });
|
|
319
|
-
}
|
|
320
|
-
function updatePublication(payload) {
|
|
321
|
-
dispatch({ type: "updatePublication", payload });
|
|
322
|
-
}
|
|
323
|
-
function removePublication(payload) {
|
|
324
|
-
dispatch({ type: "removePublication", payload });
|
|
325
|
-
}
|
|
326
|
-
function updateSettings(payload) {
|
|
327
|
-
dispatch({ type: "updateSettings", payload });
|
|
328
|
-
}
|
|
329
|
-
function updateThumbnail(payload) {
|
|
330
|
-
dispatch({ type: "updateThumbnail", payload });
|
|
331
|
-
}
|
|
332
|
-
function updateStorage(payload) {
|
|
333
|
-
dispatch({ type: "updateStorage", payload });
|
|
334
|
-
}
|
|
335
|
-
function load(payload) {
|
|
336
|
-
dispatch({ type: "load", payload });
|
|
337
|
-
}
|
|
338
|
-
function setPreview(publication) {
|
|
339
|
-
dispatch({ type: "setPreview", payload: publication });
|
|
340
|
-
}
|
|
341
|
-
function removePreview(id) {
|
|
342
|
-
dispatch({ type: "removePreview", payload: id });
|
|
343
|
-
}
|
|
344
|
-
return useMemo(
|
|
345
|
-
() => ({
|
|
346
|
-
createProject,
|
|
347
|
-
deleteProject,
|
|
348
|
-
switchProject,
|
|
349
|
-
deselectProject,
|
|
350
|
-
forkProject,
|
|
351
|
-
saveProject,
|
|
352
|
-
setLoadingStatus,
|
|
353
|
-
load,
|
|
354
|
-
updateDetails,
|
|
355
|
-
createPublication,
|
|
356
|
-
updatePublication,
|
|
357
|
-
removePublication,
|
|
358
|
-
updateSettings,
|
|
359
|
-
updateThumbnail,
|
|
360
|
-
updateStorage,
|
|
361
|
-
setPreview,
|
|
362
|
-
removePreview
|
|
363
|
-
}),
|
|
364
|
-
// Dispatch always stable.
|
|
365
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
366
|
-
[]
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
function useProjectBackend({ actions, current }, backend) {
|
|
370
|
-
useEffect(() => {
|
|
371
|
-
actions.setLoadingStatus({ loading: true, lastLoaded: 0, loaded: false });
|
|
372
|
-
backend.getAllProjects().then(async (allProjects) => {
|
|
373
|
-
const lastId = await backend.getLastProject();
|
|
374
|
-
const lastValid = allProjects.find((s) => s.id === lastId);
|
|
375
|
-
actions.load({
|
|
376
|
-
allProjects,
|
|
377
|
-
current: lastValid || null,
|
|
378
|
-
loadingStatus: {
|
|
379
|
-
loaded: true,
|
|
380
|
-
loading: false,
|
|
381
|
-
lastLoaded: Date.now()
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
}, []);
|
|
386
|
-
}
|
|
387
|
-
function useProjectLoader({ actions, current }, storage) {
|
|
388
|
-
const currentRef = useRef(null);
|
|
389
|
-
const [ready, setIsReady] = useState(false);
|
|
390
|
-
const [error, setError] = useState("");
|
|
391
|
-
const saveChanges = useCallback(() => {
|
|
392
|
-
const project = currentRef.current;
|
|
393
|
-
if (project) {
|
|
394
|
-
storage.saveStorage(project.storage).then(() => {
|
|
395
|
-
const newStorage = storage.getBackendStorage(project);
|
|
396
|
-
if (!(0, import_shallowequal.default)(newStorage, project.storage)) {
|
|
397
|
-
actions.saveProject({
|
|
398
|
-
...project,
|
|
399
|
-
storage: newStorage
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
}, [actions, storage]);
|
|
405
|
-
const debounceSaveChanges = useDebounce(saveChanges, storage.saveInterval);
|
|
406
|
-
const currentId = current?.id;
|
|
407
|
-
useEffect(() => {
|
|
408
|
-
currentRef.current = current;
|
|
409
|
-
}, [current]);
|
|
410
|
-
const { vault, promise } = useMemo(() => {
|
|
411
|
-
if (current) {
|
|
412
|
-
const [vault2, promise2] = storage.createVaultInstance(current);
|
|
413
|
-
return {
|
|
414
|
-
vault: vault2,
|
|
415
|
-
promise: promise2
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
return { vault: null, promise: null };
|
|
419
|
-
}, [storage, currentId]);
|
|
420
|
-
useEffect(() => {
|
|
421
|
-
const currentStorage = storage;
|
|
422
|
-
const currentProject = current;
|
|
423
|
-
const currentVault = vault;
|
|
424
|
-
return () => {
|
|
425
|
-
if (currentVault && currentProject) {
|
|
426
|
-
currentStorage.closeVaultInstance(currentProject, currentVault);
|
|
427
|
-
} else if (currentVault instanceof ClientVault) {
|
|
428
|
-
currentVault.ws.close();
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
}, [storage, current, vault]);
|
|
432
|
-
useEffect(() => {
|
|
433
|
-
setIsReady(false);
|
|
434
|
-
let cancelled = false;
|
|
435
|
-
if (promise) {
|
|
436
|
-
promise.then(() => {
|
|
437
|
-
if (!cancelled) {
|
|
438
|
-
setIsReady(true);
|
|
439
|
-
}
|
|
440
|
-
}).catch((e) => {
|
|
441
|
-
setError(e.message);
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
return () => {
|
|
445
|
-
cancelled = true;
|
|
446
|
-
};
|
|
447
|
-
}, [promise]);
|
|
448
|
-
useEffect(() => {
|
|
449
|
-
window.addEventListener("beforeunload", saveChanges, false);
|
|
450
|
-
return () => {
|
|
451
|
-
window.removeEventListener("beforeunload", saveChanges);
|
|
452
|
-
};
|
|
453
|
-
}, [saveChanges]);
|
|
454
|
-
useEffect(() => {
|
|
455
|
-
return () => {
|
|
456
|
-
saveChanges();
|
|
457
|
-
};
|
|
458
|
-
}, [saveChanges, currentId]);
|
|
459
|
-
useEffect(() => {
|
|
460
|
-
if (vault && storage.shouldUpdateWithVault()) {
|
|
461
|
-
return vault.subscribe(debounceSaveChanges, true);
|
|
462
|
-
}
|
|
463
|
-
}, [debounceSaveChanges, storage, vault]);
|
|
464
|
-
return {
|
|
465
|
-
vault,
|
|
466
|
-
ready,
|
|
467
|
-
error
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
function useProjectCreators() {
|
|
471
|
-
const { actions } = useProjectContext();
|
|
472
|
-
const createBlankManifest = useCallback(function createBlankManifest2() {
|
|
473
|
-
actions.createProject(
|
|
474
|
-
projectFromManifest({
|
|
475
|
-
"@context": "http://iiif.io/api/presentation/3/context.json",
|
|
476
|
-
id: `https://example.org/${randomId2()}`,
|
|
477
|
-
type: "Manifest",
|
|
478
|
-
label: {
|
|
479
|
-
en: ["Blank Manifest"]
|
|
480
|
-
},
|
|
481
|
-
items: []
|
|
482
|
-
})
|
|
483
|
-
);
|
|
484
|
-
}, []);
|
|
485
|
-
const createProjectFromManifestId = useCallback(
|
|
486
|
-
async function createProjectFromManifestId2(id) {
|
|
487
|
-
let full = await getManifestNomalized(id);
|
|
488
|
-
if (full) {
|
|
489
|
-
if (full["@id"]) {
|
|
490
|
-
full = convertPresentation2(full);
|
|
491
|
-
}
|
|
492
|
-
if (full) {
|
|
493
|
-
actions.createProject(projectFromManifest(full));
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
},
|
|
497
|
-
// Actions are stable.
|
|
498
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
499
|
-
[]
|
|
500
|
-
);
|
|
501
|
-
const createProjectFromCollectionId = useCallback(
|
|
502
|
-
async function createProjectFromCollectionId2(id) {
|
|
503
|
-
let full = await getManifestNomalized(id);
|
|
504
|
-
if (full) {
|
|
505
|
-
if (full["@id"]) {
|
|
506
|
-
full = convertPresentation2(full);
|
|
507
|
-
}
|
|
508
|
-
if (full) {
|
|
509
|
-
actions.createProject(projectFromCollection(full));
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
},
|
|
513
|
-
// Actions are stable.
|
|
514
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
515
|
-
[]
|
|
516
|
-
);
|
|
517
|
-
const createProjectFromManifestJson = useCallback(
|
|
518
|
-
async function createProjectFromManifestId2(json) {
|
|
519
|
-
let full = JSON.parse(json);
|
|
520
|
-
if (full) {
|
|
521
|
-
if (full["@id"]) {
|
|
522
|
-
full = convertPresentation2(full);
|
|
523
|
-
}
|
|
524
|
-
if (full) {
|
|
525
|
-
actions.createProject(projectFromManifest(full));
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
},
|
|
529
|
-
// Actions are stable.
|
|
530
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
531
|
-
[]
|
|
532
|
-
);
|
|
533
|
-
return {
|
|
534
|
-
createProjectFromManifestJson,
|
|
535
|
-
createProjectFromManifestId,
|
|
536
|
-
createProjectFromCollectionId,
|
|
537
|
-
createBlankManifest
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// src/ProjectContext.internal.tsx
|
|
542
|
-
import { useEffect as useEffect2, useMemo as useMemo2, useReducer } from "react";
|
|
543
|
-
import { useApps, AppResourceProvider, AppResourceInstanceProvider } from "@manifest-editor/shell";
|
|
544
|
-
|
|
545
|
-
// src/ProjectContext.reducer.ts
|
|
546
|
-
import { produce } from "immer";
|
|
547
|
-
var projectContextReducer = produce(function projectContextReducer2(state, action) {
|
|
548
|
-
if (state.current) {
|
|
549
|
-
switch (action.type) {
|
|
550
|
-
case "removePublication":
|
|
551
|
-
state.current.publications = state.current.publications.filter((p) => p.id !== action.payload);
|
|
552
|
-
break;
|
|
553
|
-
case "saveProject":
|
|
554
|
-
state.current.metadata.modified = Date.now();
|
|
555
|
-
break;
|
|
556
|
-
case "updateDetails":
|
|
557
|
-
state.current.name = action.payload.name;
|
|
558
|
-
state.current.filename = action.payload.filename;
|
|
559
|
-
break;
|
|
560
|
-
case "updateStorage":
|
|
561
|
-
state.current.storage = action.payload;
|
|
562
|
-
break;
|
|
563
|
-
case "createPublication": {
|
|
564
|
-
if (!state.current.publications.find((s) => s.id === action.payload.id)) {
|
|
565
|
-
state.current.publications.push(action.payload);
|
|
566
|
-
}
|
|
567
|
-
break;
|
|
568
|
-
}
|
|
569
|
-
case "updateThumbnail":
|
|
570
|
-
state.current.thumbnail = action.payload;
|
|
571
|
-
break;
|
|
572
|
-
case "updateSettings":
|
|
573
|
-
state.current.settings = action.payload;
|
|
574
|
-
break;
|
|
575
|
-
case "updatePublication": {
|
|
576
|
-
const found = state.current.publications.find((s) => s.id === action.payload.id);
|
|
577
|
-
if (found) {
|
|
578
|
-
found.config = action.payload.config;
|
|
579
|
-
}
|
|
580
|
-
break;
|
|
581
|
-
}
|
|
582
|
-
case "removePreview": {
|
|
583
|
-
const existing = state.current.previews?.findIndex((p) => p.id === action.payload);
|
|
584
|
-
if (existing !== -1) {
|
|
585
|
-
state.current.previews.splice(existing, 1);
|
|
586
|
-
}
|
|
587
|
-
break;
|
|
588
|
-
}
|
|
589
|
-
case "setPreview": {
|
|
590
|
-
const existing = state.current.previews?.findIndex((p) => p.id === action.payload.id);
|
|
591
|
-
if (existing !== -1) {
|
|
592
|
-
state.current.previews.splice(existing, 1, action.payload);
|
|
593
|
-
} else {
|
|
594
|
-
state.current.previews.push(action.payload);
|
|
595
|
-
}
|
|
596
|
-
break;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
switch (action.type) {
|
|
601
|
-
case "load": {
|
|
602
|
-
state.allProjects = action.payload.allProjects;
|
|
603
|
-
state.current = action.payload.current;
|
|
604
|
-
state.loadingStatus = action.payload.loadingStatus;
|
|
605
|
-
break;
|
|
606
|
-
}
|
|
607
|
-
case "forkProject":
|
|
608
|
-
break;
|
|
609
|
-
case "deleteProject":
|
|
610
|
-
state.allProjects = state.allProjects.filter((p) => p.id !== action.payload);
|
|
611
|
-
if (state.current && state.current.id === action.payload) {
|
|
612
|
-
state.current = null;
|
|
613
|
-
}
|
|
614
|
-
break;
|
|
615
|
-
case "deselectProject":
|
|
616
|
-
state.current = null;
|
|
617
|
-
break;
|
|
618
|
-
case "createProject":
|
|
619
|
-
state.allProjects.push(action.payload);
|
|
620
|
-
state.current = action.payload;
|
|
621
|
-
break;
|
|
622
|
-
case "switchProject":
|
|
623
|
-
state.current = state.allProjects.find((p) => p.id === action.payload) || null;
|
|
624
|
-
break;
|
|
625
|
-
case "setLoadingStatus":
|
|
626
|
-
state.loadingStatus = action.payload;
|
|
627
|
-
break;
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
function getDefaultProjectContextState(status = {
|
|
631
|
-
loading: false,
|
|
632
|
-
loaded: true,
|
|
633
|
-
lastLoaded: 0
|
|
634
|
-
}) {
|
|
635
|
-
return {
|
|
636
|
-
allProjects: [],
|
|
637
|
-
current: null,
|
|
638
|
-
loadingStatus: status
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
// src/backend/LocalStorageBackend.ts
|
|
643
|
-
import * as localforage from "localforage";
|
|
644
|
-
var LocalStorageBackend = class {
|
|
645
|
-
constructor(settings) {
|
|
646
|
-
__publicField(this, "namespace");
|
|
647
|
-
__publicField(this, "saveInterval");
|
|
648
|
-
__publicField(this, "storage");
|
|
649
|
-
this.namespace = settings?.namespace || "default-v1.1";
|
|
650
|
-
this.saveInterval = 5e3;
|
|
651
|
-
this.storage = localforage.createInstance({
|
|
652
|
-
name: "manifest-editor-projects"
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
async deleteProject(id) {
|
|
656
|
-
await this.storage.removeItem(`${this.namespace}/projects/${id}`);
|
|
657
|
-
}
|
|
658
|
-
async createProject(project) {
|
|
659
|
-
const index = await this.getProjectIndex();
|
|
660
|
-
await this.storage.setItem(`${this.namespace}/projects/${project.id}`, JSON.stringify(project));
|
|
661
|
-
if (index.indexOf(project.id) === -1) {
|
|
662
|
-
index.push(project.id);
|
|
663
|
-
await this.saveProjectIndex(index);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
canDelete() {
|
|
667
|
-
return true;
|
|
668
|
-
}
|
|
669
|
-
async getAllProjects() {
|
|
670
|
-
try {
|
|
671
|
-
const index = await this.getProjectIndex();
|
|
672
|
-
const projects = [];
|
|
673
|
-
for (const item of index) {
|
|
674
|
-
if (item === "_index") {
|
|
675
|
-
continue;
|
|
676
|
-
}
|
|
677
|
-
const loaded = await this.storage.getItem(`${this.namespace}/projects/${item}`);
|
|
678
|
-
if (loaded) {
|
|
679
|
-
try {
|
|
680
|
-
projects.push(JSON.parse(loaded));
|
|
681
|
-
} catch (e) {
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
return projects;
|
|
686
|
-
} catch (e) {
|
|
687
|
-
console.error("Error loading from localstorage", e);
|
|
688
|
-
return [];
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
async getLastProject() {
|
|
692
|
-
return this.storage.getItem(`${this.namespace}/last`);
|
|
693
|
-
}
|
|
694
|
-
async setLastProject(id) {
|
|
695
|
-
await this.storage.setItem(`${this.namespace}/last`, id);
|
|
696
|
-
}
|
|
697
|
-
async updateProject(project) {
|
|
698
|
-
await this.storage.setItem(`${this.namespace}/projects/${project.id}`, JSON.stringify(project));
|
|
699
|
-
}
|
|
700
|
-
async saveProjectIndex(index) {
|
|
701
|
-
await this.storage.setItem(`${this.namespace}/_index`, JSON.stringify(index));
|
|
702
|
-
}
|
|
703
|
-
async getProjectIndex() {
|
|
704
|
-
const json = await this.storage.getItem(`${this.namespace}/_index`);
|
|
705
|
-
if (!json) {
|
|
706
|
-
return [];
|
|
707
|
-
}
|
|
708
|
-
const index = JSON.parse(json);
|
|
709
|
-
if (!Array.isArray(index)) {
|
|
710
|
-
return [];
|
|
711
|
-
}
|
|
712
|
-
return index;
|
|
713
|
-
}
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
// src/storage/AbstractVaultLoader.ts
|
|
717
|
-
import { Vault } from "@iiif/helpers/vault";
|
|
718
|
-
var AbstractVaultLoader = class {
|
|
719
|
-
constructor(config = {}) {
|
|
720
|
-
__publicField(this, "vaults", {});
|
|
721
|
-
__publicField(this, "saveInterval");
|
|
722
|
-
this.saveInterval = config.saveInterval || 5e3;
|
|
723
|
-
}
|
|
724
|
-
shouldUpdateWithVault() {
|
|
725
|
-
return true;
|
|
726
|
-
}
|
|
727
|
-
canCreate() {
|
|
728
|
-
return true;
|
|
729
|
-
}
|
|
730
|
-
canDelete() {
|
|
731
|
-
return true;
|
|
732
|
-
}
|
|
733
|
-
createVaultInstance(project) {
|
|
734
|
-
const foundVault = this.vaults[project.storage.data.key];
|
|
735
|
-
if (foundVault) {
|
|
736
|
-
return [foundVault, Promise.resolve()];
|
|
737
|
-
}
|
|
738
|
-
const vault = new Vault();
|
|
739
|
-
const promise = async () => {
|
|
740
|
-
const data = await this.getStorage(project.storage);
|
|
741
|
-
await vault.loadManifest(project.resource.id, JSON.parse(JSON.stringify(data?.data)));
|
|
742
|
-
this.vaults[project.storage.data.key] = vault;
|
|
743
|
-
};
|
|
744
|
-
return [vault, promise()];
|
|
745
|
-
}
|
|
746
|
-
closeVaultInstance(project, vault) {
|
|
747
|
-
}
|
|
748
|
-
async saveStorage(storage) {
|
|
749
|
-
const vault = this.vaults[storage.data.key];
|
|
750
|
-
const manifestRef = {
|
|
751
|
-
id: storage.data.id,
|
|
752
|
-
type: storage.data.type
|
|
753
|
-
};
|
|
754
|
-
if (vault) {
|
|
755
|
-
const data = vault.toPresentation3(manifestRef);
|
|
756
|
-
const stored = data.type === "Collection" ? {
|
|
757
|
-
type: "collection-storage",
|
|
758
|
-
data
|
|
759
|
-
} : {
|
|
760
|
-
type: "manifest-storage",
|
|
761
|
-
data
|
|
762
|
-
};
|
|
763
|
-
await this.saveStorageData(stored, storage);
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
};
|
|
767
|
-
|
|
768
|
-
// src/storage/LocalStorageLoader.ts
|
|
769
|
-
import localforage2 from "localforage";
|
|
770
|
-
var LocalStorageLoader = class extends AbstractVaultLoader {
|
|
771
|
-
constructor(settings) {
|
|
772
|
-
super({ saveInterval: 5e3 });
|
|
773
|
-
__publicField(this, "type", "local-storage");
|
|
774
|
-
__publicField(this, "namespace");
|
|
775
|
-
__publicField(this, "storage");
|
|
776
|
-
__publicField(this, "vaults", {});
|
|
777
|
-
this.namespace = settings?.namespace || "default";
|
|
778
|
-
this.storage = localforage2.createInstance({
|
|
779
|
-
name: "local-storage-resource-loader"
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
|
-
shouldUpdateWithVault() {
|
|
783
|
-
return true;
|
|
784
|
-
}
|
|
785
|
-
async create(project, data) {
|
|
786
|
-
const key = randomId2();
|
|
787
|
-
await localStorage.setItem(`${this.namespace}/store/${key}`, JSON.stringify(data));
|
|
788
|
-
return {
|
|
789
|
-
type: "resource-keyed-storage",
|
|
790
|
-
data: {
|
|
791
|
-
id: data.id,
|
|
792
|
-
type: data.type,
|
|
793
|
-
key
|
|
794
|
-
}
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
async getStorage(storage) {
|
|
798
|
-
try {
|
|
799
|
-
const item = await localStorage.getItem(`${this.namespace}/store/${storage.data.key}`);
|
|
800
|
-
const manifest = item ? JSON.parse(item) : null;
|
|
801
|
-
invariant(manifest, "Resource not found");
|
|
802
|
-
if (manifest.type === "Collection") {
|
|
803
|
-
return {
|
|
804
|
-
type: "collection-storage",
|
|
805
|
-
data: manifest
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
return {
|
|
809
|
-
type: "manifest-storage",
|
|
810
|
-
data: manifest
|
|
811
|
-
};
|
|
812
|
-
} catch (e) {
|
|
813
|
-
return null;
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
async saveStorageData(manifestStorage, storage) {
|
|
817
|
-
await localStorage.setItem(`${this.namespace}/store/${storage.data.key}`, JSON.stringify(manifestStorage.data));
|
|
818
|
-
}
|
|
819
|
-
async deleteStorage(storage) {
|
|
820
|
-
this.vaults[storage.data.key] = null;
|
|
821
|
-
await localStorage.removeItem(`${this.namespace}/store/${storage.data.key}`);
|
|
822
|
-
}
|
|
823
|
-
getBackendStorage(project) {
|
|
824
|
-
return project.storage;
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
|
|
828
|
-
// src/ProjectContext.internal.tsx
|
|
829
|
-
import { VaultProvider } from "react-iiif-vault";
|
|
830
|
-
import { jsx } from "react/jsx-runtime";
|
|
831
|
-
function ProjectProvider(props) {
|
|
832
|
-
const { currentApp, changeApp } = useApps();
|
|
833
|
-
const backend = useMemo2(() => props.backend || new LocalStorageBackend(), []);
|
|
834
|
-
const storage = useMemo2(() => props.storage || new LocalStorageLoader(), []);
|
|
835
|
-
const [state, dispatch] = useReducer(
|
|
836
|
-
projectContextReducer,
|
|
837
|
-
void 0,
|
|
838
|
-
props.initialState || getDefaultProjectContextState
|
|
839
|
-
);
|
|
840
|
-
const actions = useProjectActionsWithBackend(dispatch, backend, storage);
|
|
841
|
-
const context = useMemo2(
|
|
842
|
-
() => ({ actions, canDelete: backend.canDelete(), ...state }),
|
|
843
|
-
[actions, backend, state]
|
|
844
|
-
);
|
|
845
|
-
const { vault, ready, error } = useProjectLoader(context, storage);
|
|
846
|
-
const manifestOrCollection = context.current?.resource;
|
|
847
|
-
const loadingStatus = useMemo2(() => {
|
|
848
|
-
return { isLoading: !ready, isError: !!error, error };
|
|
849
|
-
}, [ready, error]);
|
|
850
|
-
useProjectBackend(context, backend);
|
|
851
|
-
useEffect2(() => {
|
|
852
|
-
if (state.loadingStatus && state.loadingStatus.loaded && ready && (!vault || !manifestOrCollection) && currentApp?.id !== (props.defaultApp || "splash")) {
|
|
853
|
-
changeApp({ id: props.defaultApp || "splash" });
|
|
854
|
-
}
|
|
855
|
-
}, []);
|
|
856
|
-
if (state.loadingStatus && state.loadingStatus.loading || context.current && !manifestOrCollection) {
|
|
857
|
-
return /* @__PURE__ */ jsx("div", { children: "Loading..." });
|
|
858
|
-
}
|
|
859
|
-
return /* @__PURE__ */ jsx(ProjectLoadingReactContext.Provider, { value: loadingStatus, children: /* @__PURE__ */ jsx(ProjectReactContext.Provider, { value: context, children: /* @__PURE__ */ jsx(VaultProvider, { vault: vault || void 0, children: /* @__PURE__ */ jsx(AppResourceInstanceProvider, { id: context.current?.id, children: /* @__PURE__ */ jsx(AppResourceProvider, { resource: manifestOrCollection, children: props.children }) }) }, state.current?.id) }) });
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
// ../ui/icons/MenuIcon.tsx
|
|
863
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
864
|
-
var MenuIcon = () => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", height: "1rem", viewBox: "0 0 24 24", width: "24px", fill: "#000000", children: [
|
|
865
|
-
/* @__PURE__ */ jsx2("path", { d: "M0 0h24v24H0z", fill: "none" }),
|
|
866
|
-
/* @__PURE__ */ jsx2("path", { d: "M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z" })
|
|
867
|
-
] });
|
|
868
|
-
|
|
869
|
-
// ../ui/atoms/Dropdown.tsx
|
|
870
|
-
import styled2, { css } from "styled-components";
|
|
871
|
-
|
|
872
|
-
// ../ui/atoms/Button.tsx
|
|
873
|
-
import styled from "styled-components";
|
|
874
|
-
var ButtonReset = styled.button`
|
|
1
|
+
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useMemo as i,useReducer as a,useRef as o,useState as s}from"react";import{useDebounce as c}from"tiny-use-debounce";import{getValue as l}from"@iiif/helpers";import{convertPresentation2 as u}from"@iiif/parser/presentation-2";import{ClientVault as d}from"@manifest-editor/client-vault";import{AppResourceInstanceProvider as f,AppResourceProvider as p,getManifestNomalized as m,useApps as h,useLocalStorage as g}from"@manifest-editor/shell";import{produce as _}from"immer";import*as v from"localforage";import y from"localforage";import{Vault as b}from"@iiif/helpers/vault";import{VaultProvider as ee}from"react-iiif-vault";import{Fragment as x,jsx as S,jsxs as C}from"react/jsx-runtime";import w,{css as T}from"styled-components";import te from"react-accessible-dropdown-menu-hook";import{flushSync as ne}from"react-dom";var re=Object.create,E=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,ae=Object.getOwnPropertyNames,oe=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty,D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ce=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ae(t),a=0,o=i.length,s;a<o;a++)s=i[a],!se.call(e,s)&&s!==n&&E(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ie(t,s))||r.enumerable});return e},O=(e,t,n)=>(n=e==null?{}:re(oe(e)),ce(t||!e||!e.__esModule?E(n,`default`,{value:e,enumerable:!0}):n,e)),le=!0,k=`Invariant failed`;function A(e,t){if(!e){if(le)throw Error(k);var n=typeof t==`function`?t():t,r=n?`${k}: ${n}`:k;throw Error(r)}}const j=e(null),M=e({error:void 0,isError:!1,isLoading:!1});function ue(){return n(M)}function N(){let e=n(j);return A(e,`useProjectContext can only be called from inside <ProjectProvider />`),e}function de(){let e=N().current;return A(e,`No current project`),e}function fe(){return N().current||null}var pe=D(((e,t)=>{t.exports=function(e,t,n,r){var i=n?n.call(r,e,t):void 0;if(i!==void 0)return!!i;if(e===t)return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var a=Object.keys(e),o=Object.keys(t);if(a.length!==o.length)return!1;for(var s=Object.prototype.hasOwnProperty.bind(t),c=0;c<a.length;c++){var l=a[c];if(!s(l))return!1;var u=e[l],d=t[l];if(i=n?n.call(r,u,d,l):void 0,i===!1||i===void 0&&u!==d)return!1}return!0}})),P=D(((e,t)=>{(function(n,r,i){typeof e==`object`?(t.exports=i(),t.exports.default=i()):typeof define==`function`&&define.amd?define(i):r[n]=i()})(`slugify`,e,function(){var e=JSON.parse(`{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ō":"O","ō":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","Ə":"E","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Lj":"LJ","lj":"lj","Nj":"NJ","nj":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","ə":"e","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","ѝ":"u","џ":"dz","Ґ":"G","ґ":"g","Ғ":"GH","ғ":"gh","Қ":"KH","қ":"kh","Ң":"NG","ң":"ng","Ү":"UE","ү":"ue","Ұ":"U","ұ":"u","Һ":"H","һ":"h","Ә":"AE","ә":"ae","Ө":"OE","ө":"oe","Ա":"A","Բ":"B","Գ":"G","Դ":"D","Ե":"E","Զ":"Z","Է":"E'","Ը":"Y'","Թ":"T'","Ժ":"JH","Ի":"I","Լ":"L","Խ":"X","Ծ":"C'","Կ":"K","Հ":"H","Ձ":"D'","Ղ":"GH","Ճ":"TW","Մ":"M","Յ":"Y","Ն":"N","Շ":"SH","Չ":"CH","Պ":"P","Ջ":"J","Ռ":"R'","Ս":"S","Վ":"V","Տ":"T","Ր":"R","Ց":"C","Փ":"P'","Ք":"Q'","Օ":"O''","Ֆ":"F","և":"EV","ء":"a","آ":"aa","أ":"a","ؤ":"u","إ":"i","ئ":"e","ا":"a","ب":"b","ة":"h","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ى":"a","ي":"y","ً":"an","ٌ":"on","ٍ":"en","َ":"a","ُ":"u","ِ":"e","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","پ":"p","چ":"ch","ژ":"zh","ک":"k","گ":"g","ی":"y","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","Ṣ":"S","ṣ":"s","Ẁ":"W","ẁ":"w","Ẃ":"W","ẃ":"w","Ẅ":"W","ẅ":"w","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","–":"-","‘":"'","’":"'","“":"\\"","”":"\\"","„":"\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₸":"kazakhstani tenge","₹":"indian rupee","₺":"turkish lira","₽":"russian ruble","₿":"bitcoin","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial","ﻵ":"laa","ﻷ":"laa","ﻹ":"lai","ﻻ":"la"}`),t=JSON.parse(`{"bg":{"Й":"Y","Ц":"Ts","Щ":"Sht","Ъ":"A","Ь":"Y","й":"y","ц":"ts","щ":"sht","ъ":"a","ь":"y"},"de":{"Ä":"AE","ä":"ae","Ö":"OE","ö":"oe","Ü":"UE","ü":"ue","ß":"ss","%":"prozent","&":"und","|":"oder","∑":"summe","∞":"unendlich","♥":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","¢":"centavos","£":"libras","¤":"moneda","₣":"francos","∑":"suma","∞":"infinito","♥":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","¢":"centime","£":"livre","¤":"devise","₣":"franc","∑":"somme","∞":"infini","♥":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","¢":"centavo","∑":"soma","£":"libra","∞":"infinito","♥":"amor"},"uk":{"И":"Y","и":"y","Й":"Y","й":"y","Ц":"Ts","ц":"ts","Х":"Kh","х":"kh","Щ":"Shch","щ":"shch","Г":"H","г":"h"},"vi":{"Đ":"D","đ":"d"},"da":{"Ø":"OE","ø":"oe","Å":"AA","å":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"større end"},"nb":{"&":"og","Å":"AA","Æ":"AE","Ø":"OE","å":"aa","æ":"ae","ø":"oe"},"it":{"&":"e"},"nl":{"&":"en"},"sv":{"&":"och","Å":"AA","Ä":"AE","Ö":"OE","å":"aa","ä":"ae","ö":"oe"}}`);function n(n,r){if(typeof n!=`string`)throw Error(`slugify: string argument expected`);r=typeof r==`string`?{replacement:r}:r||{};var i=t[r.locale]||{},a=r.replacement===void 0?`-`:r.replacement,o=r.trim===void 0?!0:r.trim,s=n.normalize().split(``).reduce(function(t,n){var o=i[n];return o===void 0&&(o=e[n]),o===void 0&&(o=n),o===a&&(o=` `),t+o.replace(r.remove||/[^\w\s$*_+~.()'"!\-:@]+/g,``)},``);return r.strict&&(s=s.replace(/[^A-Za-z0-9\s]/g,``)),o&&(s=s.trim()),s=s.replace(/\s+/g,a),r.lower&&(s=s.toLowerCase()),s}return n.extend=function(t){Object.assign(e,t)},n})})),me=O(pe(),1),he=O(P(),1);function ge(){return`${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`}function F(e,t={}){let n=l(e.label)||`Untitled manifest`;return{id:`manifest-editor://project/${ge()}`,filename:(0,he.default)(n,{lower:!0}),name:n,metadata:{created:Date.now(),modified:Date.now()},resource:{id:e.id,type:`Manifest`},publications:[],previews:[],settings:{},storage:{type:`manifest-storage`,data:e},...t}}var _e=O(P(),1);function I(e,t){let n=t.map(e=>e.filename),r=(e.name||e.filename||`Untitled project`).toLowerCase();if(e.filename&&n.indexOf(e.filename)!==-1&&(e.filename=void 0),!e.filename){let t=0;for(;!e.filename;){let i=`${(0,_e.default)(r,{lower:!0})}${t?` (${t})`:``}`;if(n.indexOf(i)===-1){e.filename=i,e.name=`${e.name} (${t})`;break}t++}}}function L(){return`${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`}var R=O(P(),1);function ve(e,t={}){let n=l(e.label)||`Untitled collection`;return{id:`manifest-editor://project/${L()}`,filename:(0,R.default)(n,{lower:!0}),name:n,metadata:{created:Date.now(),modified:Date.now()},resource:{id:e.id,type:`Collection`},publications:[],previews:[],settings:{},storage:{type:`collection-storage`,data:e},...t}}function z(e,t,n){async function r(r){let i=await t.getAllProjects(!0),a={...r};if(I(a,i),!n.canCreate())throw Error(`Cannot create project with this storage backend`);let s=await n.create(a,a.storage.data),c={...a,storage:s};await t.createProject(c),e({type:`createProject`,payload:c}),o(a.id)}function a(n){t.canDelete()&&(e({type:`deleteProject`,payload:n}),t.deleteProject(n).then(()=>{console.log(`Loader: project deleted`)}))}function o(n){e({type:`switchProject`,payload:n}),t.setLastProject(n).then(()=>{})}function s(t){e({type:`deselectProject`,payload:t})}function c(t){throw e({type:`forkProject`,payload:t}),Error(`Not implemented yet`)}function l(t){e({type:`setLoadingStatus`,payload:t})}function u(r){console.log(`trying to save project...`),e({type:`saveProject`,payload:r}),Promise.all([t.updateProject(r),n.saveStorage(r.storage)]).then(()=>{console.log(`Loader: project saved`)})}function d(t){e({type:`updateDetails`,payload:t})}function f(t){e({type:`createPublication`,payload:t})}function p(t){e({type:`updatePublication`,payload:t})}function m(t){e({type:`removePublication`,payload:t})}function h(t){e({type:`updateSettings`,payload:t})}function g(t){e({type:`updateThumbnail`,payload:t})}function _(t){e({type:`updateStorage`,payload:t})}function v(t){e({type:`load`,payload:t})}function y(t){e({type:`setPreview`,payload:t})}function b(t){e({type:`removePreview`,payload:t})}return i(()=>({createProject:r,deleteProject:a,switchProject:o,deselectProject:s,forkProject:c,saveProject:u,setLoadingStatus:l,load:v,updateDetails:d,createPublication:f,updatePublication:p,removePublication:m,updateSettings:h,updateThumbnail:g,updateStorage:_,setPreview:y,removePreview:b}),[])}function B({actions:e,current:t},n){r(()=>{e.setLoadingStatus({loading:!0,lastLoaded:0,loaded:!1}),n.getAllProjects().then(async t=>{let r=await n.getLastProject(),i=t.find(e=>e.id===r);e.load({allProjects:t,current:i||null,loadingStatus:{loaded:!0,loading:!1,lastLoaded:Date.now()}})})},[])}function V({actions:e,current:n},a){let l=o(null),[u,f]=s(!1),[p,m]=s(``),h=t(()=>{let t=l.current;t&&a.saveStorage(t.storage).then(()=>{let n=a.getBackendStorage(t);(0,me.default)(n,t.storage)||e.saveProject({...t,storage:n})})},[e,a]),g=c(h,a.saveInterval),_=n?.id;r(()=>{l.current=n},[n]);let{vault:v,promise:y}=i(()=>{if(n){let[e,t]=a.createVaultInstance(n);return{vault:e,promise:t}}return{vault:null,promise:null}},[a,_]);return r(()=>{let e=a,t=n,r=v;return()=>{r&&t?e.closeVaultInstance(t,r):r instanceof d&&r.ws.close()}},[a,n,v]),r(()=>{f(!1);let e=!1;return y&&y.then(()=>{e||f(!0)}).catch(e=>{m(e.message)}),()=>{e=!0}},[y]),r(()=>(window.addEventListener(`beforeunload`,h,!1),()=>{window.removeEventListener(`beforeunload`,h)}),[h]),r(()=>()=>{h()},[h,_]),r(()=>{if(v&&a.shouldUpdateWithVault())return v.subscribe(g,!0)},[g,a,v]),{vault:v,ready:u,error:p}}function ye(){let{actions:e}=N(),n=t(function(){e.createProject(F({"@context":`http://iiif.io/api/presentation/3/context.json`,id:`https://example.org/${L()}`,type:`Manifest`,label:{en:[`Blank Manifest`]},items:[]}))},[]),r=t(async function(t){let n=await m(t);n&&(n[`@id`]&&(n=u(n)),n&&e.createProject(F(n)))},[]),i=t(async function(t){let n=await m(t);n&&(n[`@id`]&&(n=u(n)),n&&e.createProject(ve(n)))},[]);return{createProjectFromManifestJson:t(async function(t){let n=JSON.parse(t);n&&(n[`@id`]&&(n=u(n)),n&&e.createProject(F(n)))},[]),createProjectFromManifestId:r,createProjectFromCollectionId:i,createBlankManifest:n}}const be=_(function(e,t){if(e.current)switch(t.type){case`removePublication`:e.current.publications=e.current.publications.filter(e=>e.id!==t.payload);break;case`saveProject`:e.current.metadata.modified=Date.now();break;case`updateDetails`:e.current.name=t.payload.name,e.current.filename=t.payload.filename;break;case`updateStorage`:e.current.storage=t.payload;break;case`createPublication`:e.current.publications.find(e=>e.id===t.payload.id)||e.current.publications.push(t.payload);break;case`updateThumbnail`:e.current.thumbnail=t.payload;break;case`updateSettings`:e.current.settings=t.payload;break;case`updatePublication`:{let n=e.current.publications.find(e=>e.id===t.payload.id);n&&(n.config=t.payload.config);break}case`removePreview`:{let n=e.current.previews?.findIndex(e=>e.id===t.payload);n!==-1&&e.current.previews.splice(n,1);break}case`setPreview`:{let n=e.current.previews?.findIndex(e=>e.id===t.payload.id);n===-1?e.current.previews.push(t.payload):e.current.previews.splice(n,1,t.payload);break}}switch(t.type){case`load`:e.allProjects=t.payload.allProjects,e.current=t.payload.current,e.loadingStatus=t.payload.loadingStatus;break;case`forkProject`:break;case`deleteProject`:e.allProjects=e.allProjects.filter(e=>e.id!==t.payload),e.current&&e.current.id===t.payload&&(e.current=null);break;case`deselectProject`:e.current=null;break;case`createProject`:e.allProjects.push(t.payload),e.current=t.payload;break;case`switchProject`:e.current=e.allProjects.find(e=>e.id===t.payload)||null;break;case`setLoadingStatus`:e.loadingStatus=t.payload;break}});function xe(e={loading:!1,loaded:!0,lastLoaded:0}){return{allProjects:[],current:null,loadingStatus:e}}function H(e){"@babel/helpers - typeof";return H=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},H(e)}function Se(e,t){if(H(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(H(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ce(e){var t=Se(e,`string`);return H(t)==`symbol`?t:t+``}function U(e,t,n){return(t=Ce(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var we=class{constructor(e){U(this,`namespace`,void 0),U(this,`saveInterval`,void 0),U(this,`storage`,void 0),this.namespace=e?.namespace||`default-v1.1`,this.saveInterval=5e3,this.storage=v.createInstance({name:`manifest-editor-projects`})}async deleteProject(e){await this.storage.removeItem(`${this.namespace}/projects/${e}`)}async createProject(e){let t=await this.getProjectIndex();await this.storage.setItem(`${this.namespace}/projects/${e.id}`,JSON.stringify(e)),t.indexOf(e.id)===-1&&(t.push(e.id),await this.saveProjectIndex(t))}canDelete(){return!0}async getAllProjects(){try{let e=await this.getProjectIndex(),t=[];for(let n of e){if(n===`_index`)continue;let e=await this.storage.getItem(`${this.namespace}/projects/${n}`);if(e)try{t.push(JSON.parse(e))}catch{}}return t}catch(e){return console.error(`Error loading from localstorage`,e),[]}}async getLastProject(){return this.storage.getItem(`${this.namespace}/last`)}async setLastProject(e){await this.storage.setItem(`${this.namespace}/last`,e)}async updateProject(e){await this.storage.setItem(`${this.namespace}/projects/${e.id}`,JSON.stringify(e))}async saveProjectIndex(e){await this.storage.setItem(`${this.namespace}/_index`,JSON.stringify(e))}async getProjectIndex(){let e=await this.storage.getItem(`${this.namespace}/_index`);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}},Te=class{constructor(e={}){U(this,`vaults`,{}),U(this,`saveInterval`,void 0),this.saveInterval=e.saveInterval||5e3}shouldUpdateWithVault(){return!0}canCreate(){return!0}canDelete(){return!0}createVaultInstance(e){let t=this.vaults[e.storage.data.key];if(t)return[t,Promise.resolve()];let n=new b;return[n,(async()=>{let t=await this.getStorage(e.storage);await n.loadManifest(e.resource.id,JSON.parse(JSON.stringify(t?.data))),this.vaults[e.storage.data.key]=n})()]}closeVaultInstance(e,t){}async saveStorage(e){let t=this.vaults[e.data.key],n={id:e.data.id,type:e.data.type};if(t){let r=t.toPresentation3(n),i=r.type===`Collection`?{type:`collection-storage`,data:r}:{type:`manifest-storage`,data:r};await this.saveStorageData(i,e)}}},Ee=class extends Te{constructor(e){super({saveInterval:5e3}),U(this,`type`,`local-storage`),U(this,`namespace`,void 0),U(this,`storage`,void 0),U(this,`vaults`,{}),this.namespace=e?.namespace||`default`,this.storage=y.createInstance({name:`local-storage-resource-loader`})}shouldUpdateWithVault(){return!0}async create(e,t){let n=L();return await localStorage.setItem(`${this.namespace}/store/${n}`,JSON.stringify(t)),{type:`resource-keyed-storage`,data:{id:t.id,type:t.type,key:n}}}async getStorage(e){try{let t=await localStorage.getItem(`${this.namespace}/store/${e.data.key}`),n=t?JSON.parse(t):null;return A(n,`Resource not found`),n.type===`Collection`?{type:`collection-storage`,data:n}:{type:`manifest-storage`,data:n}}catch{return null}}async saveStorageData(e,t){await localStorage.setItem(`${this.namespace}/store/${t.data.key}`,JSON.stringify(e.data))}async deleteStorage(e){this.vaults[e.data.key]=null,await localStorage.removeItem(`${this.namespace}/store/${e.data.key}`)}getBackendStorage(e){return e.storage}};function De(e){let{currentApp:t,changeApp:n}=h(),o=i(()=>e.backend||new we,[]),s=i(()=>e.storage||new Ee,[]),[c,l]=a(be,void 0,e.initialState||xe),u=z(l,o,s),d=i(()=>({actions:u,canDelete:o.canDelete(),...c}),[u,o,c]),{vault:m,ready:g,error:_}=V(d,s),v=d.current?.resource,y=i(()=>({isLoading:!g,isError:!!_,error:_}),[g,_]);return B(d,o),r(()=>{c.loadingStatus&&c.loadingStatus.loaded&&g&&(!m||!v)&&t?.id!==(e.defaultApp||`splash`)&&n({id:e.defaultApp||`splash`})},[]),c.loadingStatus&&c.loadingStatus.loading||d.current&&!v?S(`div`,{children:`Loading...`}):S(M.Provider,{value:y,children:S(j.Provider,{value:d,children:S(ee,{vault:m||void 0,children:S(f,{id:d.current?.id,children:S(p,{resource:v,children:e.children})})},c.current?.id)})})}const Oe=()=>C(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1rem`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,children:[S(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),S(`path`,{d:`M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z`})]});w.button`
|
|
875
2
|
border: none;
|
|
876
3
|
outline: none;
|
|
877
4
|
background-color: transparent;
|
|
@@ -883,11 +10,10 @@ var ButtonReset = styled.button`
|
|
|
883
10
|
&:hover {
|
|
884
11
|
color: inherit;
|
|
885
12
|
}
|
|
886
|
-
`;
|
|
887
|
-
var Button = styled.button`
|
|
13
|
+
`;const W=w.button`
|
|
888
14
|
padding: 0.5rem 1rem;
|
|
889
|
-
color: ${
|
|
890
|
-
background-color: ${
|
|
15
|
+
color: ${e=>e.theme.color.main||`none`};
|
|
16
|
+
background-color: ${e=>e.theme.color.white||`white`};
|
|
891
17
|
border-radius: inherit;
|
|
892
18
|
border: none;
|
|
893
19
|
cursor: pointer;
|
|
@@ -902,18 +28,16 @@ var Button = styled.button`
|
|
|
902
28
|
&:hover {
|
|
903
29
|
background: #eee;
|
|
904
30
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
padding: 0.25em ${(props) => props.theme.padding.xs || "0.4em"};
|
|
31
|
+
`,ke=w(W)`
|
|
32
|
+
padding: 0.25em ${e=>e.theme.padding.xs||`0.4em`};
|
|
908
33
|
height: unset;
|
|
909
34
|
background: none;
|
|
910
|
-
`;
|
|
911
|
-
var SecondaryButton = styled(Button)`
|
|
35
|
+
`;w(W)`
|
|
912
36
|
{
|
|
913
|
-
padding: 0 ${
|
|
914
|
-
color: ${
|
|
915
|
-
background-color: ${
|
|
916
|
-
border: 1px solid ${
|
|
37
|
+
padding: 0 ${e=>e.theme.padding.medium||`1rem`};
|
|
38
|
+
color: ${e=>e.theme.color.main||`#B84C74;`};
|
|
39
|
+
background-color: ${e=>e.theme.color.white||`white`};
|
|
40
|
+
border: 1px solid ${e=>e.theme.color.main||`#B84C74;`};
|
|
917
41
|
border-radius: 0.25rem;
|
|
918
42
|
cursor: pointer;
|
|
919
43
|
height: 2rem;
|
|
@@ -927,11 +51,10 @@ var SecondaryButton = styled(Button)`
|
|
|
927
51
|
cursor: not-allowed;
|
|
928
52
|
}
|
|
929
53
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
color: ${
|
|
934
|
-
background-color: ${(props) => props.theme.color.main || "#B84C74;"};
|
|
54
|
+
`,w(W)`
|
|
55
|
+
padding: 0 ${e=>e.theme.padding.medium||`1rem`};
|
|
56
|
+
color: ${e=>e.theme.color.white||`white`};
|
|
57
|
+
background-color: ${e=>e.theme.color.main||`#B84C74;`};
|
|
935
58
|
border: 1px solid #eee;
|
|
936
59
|
border-radius: 0.25rem;
|
|
937
60
|
cursor: pointer;
|
|
@@ -939,42 +62,36 @@ var CalltoButton = styled(Button)`
|
|
|
939
62
|
display: flex;
|
|
940
63
|
align-items: center;
|
|
941
64
|
&:hover {
|
|
942
|
-
background-color: ${
|
|
65
|
+
background-color: ${e=>e.theme.color.mainHover||`#B84C74;`};
|
|
943
66
|
}
|
|
944
|
-
|
|
945
|
-
var ButtonGroup = styled.div`
|
|
67
|
+
`,w.div`
|
|
946
68
|
display: flex;
|
|
947
69
|
flex-direction: row;
|
|
948
70
|
flex-wrap: wrap;
|
|
949
71
|
align-items: flex-start;
|
|
950
|
-
justify-content: ${
|
|
951
|
-
`;
|
|
952
|
-
|
|
953
|
-
// ../ui/atoms/Dropdown.tsx
|
|
954
|
-
var Dropdown = styled2.div`
|
|
72
|
+
justify-content: ${e=>e.$right?`flex-end`:`flex-start`};
|
|
73
|
+
`;const Ae=w.div`
|
|
955
74
|
position: relative;
|
|
956
75
|
display: inline-block;
|
|
957
|
-
`;
|
|
958
|
-
var DropdownContent = styled2.div`
|
|
76
|
+
`;w.div`
|
|
959
77
|
display: flex;
|
|
960
78
|
flex-direction: column;
|
|
961
79
|
position: absolute;
|
|
962
|
-
background-color: ${
|
|
963
|
-
color: ${
|
|
80
|
+
background-color: ${e=>e.theme.color.white||`white`};
|
|
81
|
+
color: ${e=>e.theme.color.black||` black`};
|
|
964
82
|
font-size: 0.75rem;
|
|
965
83
|
min-width: 160px;
|
|
966
84
|
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
|
967
85
|
z-index: 150;
|
|
968
86
|
button {
|
|
969
87
|
&:hover {
|
|
970
|
-
background-color: ${
|
|
88
|
+
background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
|
|
971
89
|
}
|
|
972
90
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
color: ${
|
|
977
|
-
background-color: ${(props) => props.theme.color.white || "white"};
|
|
91
|
+
`,w.button`
|
|
92
|
+
padding: 0 ${e=>e.theme.padding.small||`0.5rem`};
|
|
93
|
+
color: ${e=>e.theme.color.main||`none`};
|
|
94
|
+
background-color: ${e=>e.theme.color.white||`white`};
|
|
978
95
|
border-radius: 0;
|
|
979
96
|
border: none;
|
|
980
97
|
cursor: pointer;
|
|
@@ -987,10 +104,10 @@ var DropdownItem = styled2.button`
|
|
|
987
104
|
}
|
|
988
105
|
|
|
989
106
|
&:hover {
|
|
990
|
-
background-color: ${
|
|
107
|
+
background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
|
|
991
108
|
}
|
|
992
109
|
|
|
993
|
-
${
|
|
110
|
+
${e=>e.$active&&T`
|
|
994
111
|
background: #b84c74;
|
|
995
112
|
color: #fff;
|
|
996
113
|
&:hover {
|
|
@@ -998,13 +115,12 @@ var DropdownItem = styled2.button`
|
|
|
998
115
|
color: #fff;
|
|
999
116
|
}
|
|
1000
117
|
`}
|
|
1001
|
-
`;
|
|
1002
|
-
var DropdownMenu = styled2.div`
|
|
118
|
+
`;const je=w.div`
|
|
1003
119
|
display: none;
|
|
1004
120
|
flex-direction: column;
|
|
1005
121
|
position: absolute;
|
|
1006
122
|
background: #fff;
|
|
1007
|
-
color: ${
|
|
123
|
+
color: ${e=>e.theme.color.black||` black`};
|
|
1008
124
|
font-size: 0.75rem;
|
|
1009
125
|
min-width: 190px;
|
|
1010
126
|
top: calc(100% + 0.5em);
|
|
@@ -1017,118 +133,26 @@ var DropdownMenu = styled2.div`
|
|
|
1017
133
|
overflow: hidden;
|
|
1018
134
|
padding-bottom: 3px;
|
|
1019
135
|
|
|
1020
|
-
${
|
|
136
|
+
${W} {
|
|
1021
137
|
&:hover {
|
|
1022
|
-
background-color: ${
|
|
138
|
+
background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
|
|
1023
139
|
}
|
|
1024
140
|
}
|
|
1025
141
|
|
|
1026
|
-
${
|
|
142
|
+
${e=>e.$open&&T`
|
|
1027
143
|
display: flex;
|
|
1028
144
|
`}
|
|
1029
|
-
|
|
1030
|
-
var DropdownLabel = styled2.div`
|
|
145
|
+
`,G=w.div`
|
|
1031
146
|
color: #999;
|
|
1032
147
|
text-transform: uppercase;
|
|
1033
148
|
font-weight: 600;
|
|
1034
149
|
padding: 0.7em;
|
|
1035
150
|
font-size: 0.875em;
|
|
1036
|
-
|
|
1037
|
-
var DropdownDivider = styled2.div`
|
|
151
|
+
`,K=w.div`
|
|
1038
152
|
height: 1px;
|
|
1039
153
|
margin: 0 0.5em;
|
|
1040
154
|
background: #eee;
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
// ../ui/madoc/use-local-storage.ts
|
|
1044
|
-
import { useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
|
|
1045
|
-
|
|
1046
|
-
// ../../node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/dist/mitt.mjs
|
|
1047
|
-
function mitt_default(n) {
|
|
1048
|
-
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
|
|
1049
|
-
var i = n.get(t);
|
|
1050
|
-
i ? i.push(e) : n.set(t, [e]);
|
|
1051
|
-
}, off: function(t, e) {
|
|
1052
|
-
var i = n.get(t);
|
|
1053
|
-
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
|
|
1054
|
-
}, emit: function(t, e) {
|
|
1055
|
-
var i = n.get(t);
|
|
1056
|
-
i && i.slice().map(function(n2) {
|
|
1057
|
-
n2(e);
|
|
1058
|
-
}), (i = n.get("*")) && i.slice().map(function(n2) {
|
|
1059
|
-
n2(t, e);
|
|
1060
|
-
});
|
|
1061
|
-
} };
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
// ../ui/madoc/use-local-storage.ts
|
|
1065
|
-
globalThis.MS_LS_EMITTER = globalThis.MS_LS_EMITTER || mitt_default();
|
|
1066
|
-
var lsEmitter = globalThis.MS_LS_EMITTER;
|
|
1067
|
-
function useLocalStorage(key, initialValue) {
|
|
1068
|
-
const lastStoredValue = useRef2();
|
|
1069
|
-
if (!lastStoredValue.current && initialValue) {
|
|
1070
|
-
lastStoredValue.current = JSON.stringify(initialValue);
|
|
1071
|
-
}
|
|
1072
|
-
const [storedValue, setStoredValue] = useState2(() => {
|
|
1073
|
-
try {
|
|
1074
|
-
if (typeof window === "undefined" || typeof window.localStorage === "undefined") {
|
|
1075
|
-
return initialValue;
|
|
1076
|
-
}
|
|
1077
|
-
const item = window.localStorage.getItem(key);
|
|
1078
|
-
if (item) {
|
|
1079
|
-
lastStoredValue.current = item;
|
|
1080
|
-
}
|
|
1081
|
-
return item ? JSON.parse(item) : initialValue;
|
|
1082
|
-
} catch (error) {
|
|
1083
|
-
console.log(error);
|
|
1084
|
-
return initialValue;
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
1087
|
-
const setValue = (value) => {
|
|
1088
|
-
try {
|
|
1089
|
-
if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
|
|
1090
|
-
let prev = initialValue;
|
|
1091
|
-
try {
|
|
1092
|
-
prev = typeof lastStoredValue.current === "undefined" ? initialValue : JSON.parse(lastStoredValue.current);
|
|
1093
|
-
} catch (e) {
|
|
1094
|
-
}
|
|
1095
|
-
const valueToStore = value instanceof Function ? value(prev) : value;
|
|
1096
|
-
setStoredValue(valueToStore);
|
|
1097
|
-
const valueJson = JSON.stringify(valueToStore);
|
|
1098
|
-
window.localStorage.setItem(key, valueJson);
|
|
1099
|
-
if (valueJson !== lastStoredValue.current) {
|
|
1100
|
-
lastStoredValue.current = valueJson;
|
|
1101
|
-
lsEmitter.emit(`change:${key}`, { valueJson });
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
} catch (error) {
|
|
1105
|
-
console.log(error);
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
useEffect3(() => {
|
|
1109
|
-
const listener = ({ valueJson }) => {
|
|
1110
|
-
if (valueJson && valueJson !== lastStoredValue.current) {
|
|
1111
|
-
try {
|
|
1112
|
-
setStoredValue(JSON.parse(valueJson));
|
|
1113
|
-
lastStoredValue.current = valueJson;
|
|
1114
|
-
} catch (e) {
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1118
|
-
lsEmitter.on(`change:${key}`, listener);
|
|
1119
|
-
return () => {
|
|
1120
|
-
lsEmitter.off(`change:${key}`, listener);
|
|
1121
|
-
};
|
|
1122
|
-
}, [key]);
|
|
1123
|
-
return [storedValue, setValue, lastStoredValue];
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
// src/components/AppMenu.tsx
|
|
1127
|
-
import useDropdownMenu from "react-accessible-dropdown-menu-hook";
|
|
1128
|
-
import { useApps as useApps2 } from "@manifest-editor/shell";
|
|
1129
|
-
import styled3 from "styled-components";
|
|
1130
|
-
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1131
|
-
var IconButton = styled3.button`
|
|
155
|
+
`,q=w.button`
|
|
1132
156
|
height: 1.75em;
|
|
1133
157
|
width: 1.75em;
|
|
1134
158
|
background: #e9e9e9;
|
|
@@ -1147,57 +171,7 @@ var IconButton = styled3.button`
|
|
|
1147
171
|
fill: #fff;
|
|
1148
172
|
}
|
|
1149
173
|
}
|
|
1150
|
-
`;
|
|
1151
|
-
function AppMenu(props) {
|
|
1152
|
-
const { current: currentProject } = useProjectContext();
|
|
1153
|
-
const [isMenuHidden, setIsMenuHidden] = useLocalStorage("menu-hidden");
|
|
1154
|
-
const { apps, changeApp } = useApps2();
|
|
1155
|
-
const type = currentProject?.resource.type;
|
|
1156
|
-
const filteredApps = Object.values(apps).filter((app) => {
|
|
1157
|
-
if (app.metadata.project && app.metadata.projectType !== type) {
|
|
1158
|
-
return false;
|
|
1159
|
-
}
|
|
1160
|
-
if (!currentProject && app.metadata.project) {
|
|
1161
|
-
return false;
|
|
1162
|
-
}
|
|
1163
|
-
if (app.metadata.type === "launcher") {
|
|
1164
|
-
return false;
|
|
1165
|
-
}
|
|
1166
|
-
return true;
|
|
1167
|
-
});
|
|
1168
|
-
const { itemProps, buttonProps, isOpen, setIsOpen } = useDropdownMenu(filteredApps.length + 1);
|
|
1169
|
-
return /* @__PURE__ */ jsxs2(Dropdown, { children: [
|
|
1170
|
-
/* @__PURE__ */ jsx3(IconButton, { ...buttonProps, children: /* @__PURE__ */ jsx3(MenuIcon, {}) }),
|
|
1171
|
-
/* @__PURE__ */ jsxs2(DropdownMenu, { $open: isOpen, children: [
|
|
1172
|
-
/* @__PURE__ */ jsx3(DropdownLabel, { children: "Apps" }),
|
|
1173
|
-
/* @__PURE__ */ jsx3(DropdownDivider, {}),
|
|
1174
|
-
filteredApps.map((app, key) => /* @__PURE__ */ jsx3(
|
|
1175
|
-
Button,
|
|
1176
|
-
{
|
|
1177
|
-
...itemProps[key],
|
|
1178
|
-
onClick: () => {
|
|
1179
|
-
changeApp({ id: app.metadata.id });
|
|
1180
|
-
setIsOpen(false);
|
|
1181
|
-
},
|
|
1182
|
-
children: app.metadata.title
|
|
1183
|
-
},
|
|
1184
|
-
app.metadata.id
|
|
1185
|
-
)),
|
|
1186
|
-
props.hideMenu ? null : /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1187
|
-
/* @__PURE__ */ jsx3(DropdownLabel, { children: "Quick Settings" }),
|
|
1188
|
-
/* @__PURE__ */ jsx3(DropdownDivider, {}),
|
|
1189
|
-
/* @__PURE__ */ jsx3(Button, { ...itemProps[filteredApps.length + 0], onClick: () => setIsMenuHidden(!isMenuHidden), children: isMenuHidden ? "Show menu" : "Hide menu" })
|
|
1190
|
-
] })
|
|
1191
|
-
] })
|
|
1192
|
-
] });
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
// src/components/DraftTitleEditor.tsx
|
|
1196
|
-
import { useState as useState3 } from "react";
|
|
1197
|
-
import { flushSync } from "react-dom";
|
|
1198
|
-
import styled4 from "styled-components";
|
|
1199
|
-
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1200
|
-
var Draft = styled4.div`
|
|
174
|
+
`;function Me(e){let{current:t}=N(),[n,r]=g(`menu-hidden`),{apps:i,changeApp:a}=h(),o=t?.resource.type,s=Object.values(i).filter(e=>!(e.metadata.project&&e.metadata.projectType!==o||!t&&e.metadata.project||e.metadata.type===`launcher`)),{itemProps:c,buttonProps:l,isOpen:u,setIsOpen:d}=te(s.length+1);return C(Ae,{children:[S(q,{...l,children:S(Oe,{})}),C(je,{$open:u,children:[S(G,{children:`Apps`}),S(K,{}),s.map((e,t)=>S(W,{...c[t],onClick:()=>{a({id:e.metadata.id}),d(!1)},children:e.metadata.title},e.metadata.id)),e.hideMenu?null:C(x,{children:[S(G,{children:`Quick Settings`}),S(K,{}),S(W,{...c[s.length+0],onClick:()=>r(!n),children:n?`Show menu`:`Hide menu`})]})]})]})}const J=w.div`
|
|
1201
175
|
display: flex;
|
|
1202
176
|
flex-direction: row;
|
|
1203
177
|
flex: 1;
|
|
@@ -1205,87 +179,28 @@ var Draft = styled4.div`
|
|
|
1205
179
|
padding-left: 0.5em;
|
|
1206
180
|
align-items: center;
|
|
1207
181
|
overflow: hidden;
|
|
1208
|
-
|
|
1209
|
-
var DraftsText = styled4.div`
|
|
182
|
+
`,Y=w.div`
|
|
1210
183
|
color: #828282;
|
|
1211
184
|
padding-right: 1em;
|
|
1212
|
-
|
|
1213
|
-
var DraftTitleEdit = styled4.form`
|
|
185
|
+
`,X=w.form`
|
|
1214
186
|
margin: 0;
|
|
1215
187
|
padding: 0;
|
|
1216
188
|
display: flex;
|
|
1217
189
|
flex: 1;
|
|
1218
|
-
|
|
1219
|
-
var DraftTitleEditInput = styled4.input`
|
|
190
|
+
`,Z=w.input`
|
|
1220
191
|
font-size: 1em;
|
|
1221
192
|
flex: 1;
|
|
1222
193
|
border: 1px solid #999;
|
|
1223
194
|
padding: 0.2em;
|
|
1224
195
|
margin: -0.2em 0;
|
|
1225
|
-
|
|
1226
|
-
var DraftTitleEditButton = styled4(SmallButton)`
|
|
196
|
+
`,Q=w(ke)`
|
|
1227
197
|
font-size: 1em;
|
|
1228
198
|
display: inline-block;
|
|
1229
|
-
|
|
1230
|
-
var DraftTitle = styled4.div`
|
|
199
|
+
`,$=w.div`
|
|
1231
200
|
color: #333;
|
|
1232
201
|
flex: 1;
|
|
1233
202
|
text-overflow: ellipsis;
|
|
1234
203
|
white-space: nowrap;
|
|
1235
204
|
overflow: hidden;
|
|
1236
|
-
`;
|
|
1237
|
-
|
|
1238
|
-
const { actions, current } = useProjectContext();
|
|
1239
|
-
const [editingTitle, setIsEditingTitle] = useState3(false);
|
|
1240
|
-
return /* @__PURE__ */ jsxs3(Draft, { children: [
|
|
1241
|
-
/* @__PURE__ */ jsx4(DraftsText, { children: "Drafts" }),
|
|
1242
|
-
current ? /* @__PURE__ */ jsx4(Fragment2, { children: editingTitle ? /* @__PURE__ */ jsxs3(
|
|
1243
|
-
DraftTitleEdit,
|
|
1244
|
-
{
|
|
1245
|
-
onSubmit: (e) => {
|
|
1246
|
-
const form = new FormData(e.target);
|
|
1247
|
-
const data = Object.fromEntries(form.entries());
|
|
1248
|
-
actions.updateDetails(data);
|
|
1249
|
-
setIsEditingTitle(false);
|
|
1250
|
-
},
|
|
1251
|
-
children: [
|
|
1252
|
-
/* @__PURE__ */ jsx4(DraftTitleEditInput, { id: "project-title", defaultValue: current.name, name: "name" }),
|
|
1253
|
-
/* @__PURE__ */ jsx4(DraftTitleEditButton, { children: "Save" })
|
|
1254
|
-
]
|
|
1255
|
-
}
|
|
1256
|
-
) : /* @__PURE__ */ jsx4(
|
|
1257
|
-
DraftTitle,
|
|
1258
|
-
{
|
|
1259
|
-
onClick: () => {
|
|
1260
|
-
flushSync(() => {
|
|
1261
|
-
setIsEditingTitle(true);
|
|
1262
|
-
});
|
|
1263
|
-
document.getElementById("project-title")?.focus();
|
|
1264
|
-
},
|
|
1265
|
-
children: current.name || "Untitled project"
|
|
1266
|
-
}
|
|
1267
|
-
) }) : null
|
|
1268
|
-
] });
|
|
1269
|
-
}
|
|
1270
|
-
export {
|
|
1271
|
-
AppMenu,
|
|
1272
|
-
Draft,
|
|
1273
|
-
DraftTitle,
|
|
1274
|
-
DraftTitleEdit,
|
|
1275
|
-
DraftTitleEditButton,
|
|
1276
|
-
DraftTitleEditInput,
|
|
1277
|
-
DraftTitleEditor,
|
|
1278
|
-
DraftsText,
|
|
1279
|
-
IconButton,
|
|
1280
|
-
ProjectLoadingReactContext,
|
|
1281
|
-
ProjectProvider,
|
|
1282
|
-
ProjectReactContext,
|
|
1283
|
-
useCurrentProject,
|
|
1284
|
-
useOptionalCurrentProject,
|
|
1285
|
-
useProjectActionsWithBackend,
|
|
1286
|
-
useProjectBackend,
|
|
1287
|
-
useProjectContext,
|
|
1288
|
-
useProjectCreators,
|
|
1289
|
-
useProjectLoader,
|
|
1290
|
-
useProjectLoading
|
|
1291
|
-
};
|
|
205
|
+
`;function Ne(){let{actions:e,current:t}=N(),[n,r]=s(!1);return C(J,{children:[S(Y,{children:`Drafts`}),t?S(x,{children:n?C(X,{onSubmit:t=>{let n=new FormData(t.target),i=Object.fromEntries(n.entries());e.updateDetails(i),r(!1)},children:[S(Z,{id:`project-title`,defaultValue:t.name,name:`name`}),S(Q,{children:`Save`})]}):S($,{onClick:()=>{ne(()=>{r(!0)}),document.getElementById(`project-title`)?.focus()},children:t.name||`Untitled project`})}):null]})}export{Me as AppMenu,J as Draft,$ as DraftTitle,X as DraftTitleEdit,Q as DraftTitleEditButton,Z as DraftTitleEditInput,Ne as DraftTitleEditor,Y as DraftsText,q as IconButton,M as ProjectLoadingReactContext,De as ProjectProvider,j as ProjectReactContext,de as useCurrentProject,fe as useOptionalCurrentProject,z as useProjectActionsWithBackend,B as useProjectBackend,N as useProjectContext,ye as useProjectCreators,V as useProjectLoader,ue as useProjectLoading};
|
|
206
|
+
//# sourceMappingURL=index.js.map
|