manifest-editor 1.4.3 → 2.0.0

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 CHANGED
@@ -1,81 +1 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- ManifestEditor: () => ManifestEditor
34
- });
35
- module.exports = __toCommonJS(src_exports);
36
-
37
- // src/ManifestEditor.tsx
38
- var import_collection_preset = require("@manifest-editor/collection-preset");
39
- var manifestEditorPreset = __toESM(require("@manifest-editor/manifest-preset"), 1);
40
- var import_shell = require("@manifest-editor/shell");
41
- var import_react_iiif_vault = require("react-iiif-vault");
42
-
43
- // ../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
44
- var isProduction = false;
45
- var prefix = "Invariant failed";
46
- function invariant(condition, message) {
47
- if (condition) {
48
- return;
49
- }
50
- if (isProduction) {
51
- throw new Error(prefix);
52
- }
53
- var provided = typeof message === "function" ? message() : message;
54
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
55
- throw new Error(value);
56
- }
57
-
58
- // src/ManifestEditor.tsx
59
- var import_jsx_runtime = require("react/jsx-runtime");
60
- var manifestEditor = (0, import_shell.mapApp)(manifestEditorPreset);
61
- function ManifestEditor(props) {
62
- const vault = (0, import_react_iiif_vault.useExistingVault)(props.vault);
63
- invariant(props.resource);
64
- invariant(props.data, "Data is required");
65
- if (!vault.requestStatus(props.resource.id)) {
66
- vault.loadManifestSync(props.resource.id, props.data);
67
- }
68
- let preset = null;
69
- let appId = null;
70
- if (props.resource.type === "Manifest") {
71
- preset = manifestEditor;
72
- appId = manifestEditor.metadata.id;
73
- } else if (props.resource.type === "Collection") {
74
- preset = import_collection_preset.collectionPreset;
75
- appId = import_collection_preset.collectionPreset.metadata.id;
76
- }
77
- if (preset === null || appId === null) {
78
- return null;
79
- }
80
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shell.AppProvider, { appId, definition: preset, instanceId: "test-1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_iiif_vault.VaultProvider, { vault, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shell.ShellProvider, { resource: props.resource, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shell.Layout, {}) }) }) });
81
- }
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@manifest-editor/collection-preset`),l=require(`@manifest-editor/manifest-preset`);l=s(l);let u=require(`@manifest-editor/shell`),d=require(`react-iiif-vault`),f=require(`react/jsx-runtime`);var p=process.env.NODE_ENV===`production`,m=`Invariant failed`;function h(e,t){if(!e){if(p)throw Error(m);var n=typeof t==`function`?t():t,r=n?`${m}: ${n}`:m;throw Error(r)}}const g=(0,u.mapApp)(l);function _(e){let t=(0,d.useExistingVault)(e.vault);h(e.resource),h(e.data,`Data is required`),t.requestStatus(e.resource.id)||t.loadManifestSync(e.resource.id,e.data);let n=null,r=null;return e.resource.type===`Manifest`?(n=g,r=g.metadata.id):e.resource.type===`Collection`&&(n=c.collectionPreset,r=c.collectionPreset.metadata.id),n===null||r===null?null:(0,f.jsx)(u.AppProvider,{appId:r,definition:n,instanceId:`test-1`,children:(0,f.jsx)(d.VaultProvider,{vault:t,children:(0,f.jsx)(u.ShellProvider,{resource:e.resource,children:(0,f.jsx)(u.Layout,{})})})})}exports.ManifestEditor=_;