manifest-editor 2.2.0 → 2.2.1-next.0.eefc2e3
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/ManifestEditor-C1Rcg3CO.d.cts +24 -0
- package/dist/ManifestEditor-C1Rcg3CO.d.cts.map +1 -0
- package/dist/ManifestEditor-CMWoRdqp.d.ts +24 -0
- package/dist/ManifestEditor-CMWoRdqp.d.ts.map +1 -0
- package/dist/browser/release.json +14 -0
- package/dist/browser/runtime.css +32296 -0
- package/dist/browser/runtime.js +4975 -0
- package/dist/index.d.cts +3 -24
- package/dist/index.d.ts +3 -24
- package/dist/remote.cjs +2 -0
- package/dist/remote.cjs.map +1 -0
- package/dist/remote.d.cts +85 -0
- package/dist/remote.d.cts.map +1 -0
- package/dist/remote.d.ts +85 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +2 -0
- package/dist/remote.js.map +1 -0
- package/package.json +25 -17
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/ManifestEditor.d.ts
|
|
5
|
-
interface ManifestEditorProps {
|
|
6
|
-
resource: string | {
|
|
7
|
-
id: string;
|
|
8
|
-
type: "Manifest" | "Collection";
|
|
9
|
-
};
|
|
10
|
-
data?: Manifest | Collection;
|
|
11
|
-
vault?: Vault;
|
|
12
|
-
config?: Partial<Config$1>;
|
|
13
|
-
saveConfig?: (config: Partial<Config$1>) => void;
|
|
14
|
-
globalPluginConfig?: Config$1["plugins"];
|
|
15
|
-
saveGlobalPluginConfig?: (config: Config$1["plugins"]) => void | Promise<void>;
|
|
16
|
-
plugins?: PluginInput$1[];
|
|
17
|
-
enabledPlugins?: string[];
|
|
18
|
-
disabledPlugins?: string[];
|
|
19
|
-
layoutMode?: "default" | "focused";
|
|
20
|
-
}
|
|
21
|
-
declare function ManifestEditor(props: ManifestEditorProps): import("react").JSX.Element | null;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { type Config, type LazyPluginModule, ManifestEditor, ManifestEditorProps, type MappedPlugin, type PluginInput, type PluginModule };
|
|
24
|
-
//# sourceMappingURL=index.d.cts.map
|
|
1
|
+
import { n as ManifestEditorProps, t as ManifestEditor } from "./ManifestEditor-C1Rcg3CO.cjs";
|
|
2
|
+
import { Config, LazyPluginModule, MappedPlugin, PluginInput, PluginModule } from "@manifest-editor/shell";
|
|
3
|
+
export { type Config, type LazyPluginModule, ManifestEditor, ManifestEditorProps, type MappedPlugin, type PluginInput, type PluginModule };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/ManifestEditor.d.ts
|
|
5
|
-
interface ManifestEditorProps {
|
|
6
|
-
resource: string | {
|
|
7
|
-
id: string;
|
|
8
|
-
type: "Manifest" | "Collection";
|
|
9
|
-
};
|
|
10
|
-
data?: Manifest | Collection;
|
|
11
|
-
vault?: Vault;
|
|
12
|
-
config?: Partial<Config$1>;
|
|
13
|
-
saveConfig?: (config: Partial<Config$1>) => void;
|
|
14
|
-
globalPluginConfig?: Config$1["plugins"];
|
|
15
|
-
saveGlobalPluginConfig?: (config: Config$1["plugins"]) => void | Promise<void>;
|
|
16
|
-
plugins?: PluginInput$1[];
|
|
17
|
-
enabledPlugins?: string[];
|
|
18
|
-
disabledPlugins?: string[];
|
|
19
|
-
layoutMode?: "default" | "focused";
|
|
20
|
-
}
|
|
21
|
-
declare function ManifestEditor(props: ManifestEditorProps): import("react").JSX.Element | null;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { type Config, type LazyPluginModule, ManifestEditor, ManifestEditorProps, type MappedPlugin, type PluginInput, type PluginModule };
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { n as ManifestEditorProps, t as ManifestEditor } from "./ManifestEditor-CMWoRdqp.js";
|
|
2
|
+
import { Config, LazyPluginModule, MappedPlugin, PluginInput, PluginModule } from "@manifest-editor/shell";
|
|
3
|
+
export { type Config, type LazyPluginModule, ManifestEditor, ManifestEditorProps, type MappedPlugin, type PluginInput, type PluginModule };
|
package/dist/remote.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/,t=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$/,n=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.x$/;function r(e){return e.length<100&&t.test(e)}function i(t){if(!t||typeof t!=`object`)throw Error(`Invalid release catalog`);let n=t;if(!Array.isArray(n.releases)||n.latest!==null&&typeof n.latest!=`string`)throw Error(`Invalid release catalog`);let i=new Set;for(let e of n.releases){if(!e||typeof e.version!=`string`||!r(e.version)||typeof e.buildId!=`string`||!/^[a-f0-9]{32}$/.test(e.buildId)||!Number.isInteger(e.runtimeApiVersion)||e.runtimeApiVersion<1||!Number.isInteger(e.reactMajor)||e.reactMajor<1||i.has(e.version))throw Error(`Invalid or duplicate release`);for(let[t,n]of[[e.script,`runtime.js`],[e.stylesheet,`runtime.css`]]){if(!t||typeof t.url!=`string`||typeof t.integrity!=`string`||!/^sha384-[A-Za-z0-9+/]{64}$/.test(t.integrity))throw Error(`Invalid release asset`);if(t.url!==`/remote-editor/assets/${e.buildId}/${n}`&&t.url!==`https://cdn.jsdelivr.net/npm/manifest-editor@${e.version}/dist/browser/${n}`)throw Error(`Release asset origin or path is not allowed`)}i.add(e.version)}if(n.latest!==null&&(!e.test(n.latest)||!i.has(n.latest)))throw Error(`Latest must reference a catalogued stable release`)}function a(t,a,o){if(i(t),typeof a!=`string`||a.length>100||!(a===`latest`||n.test(a)||r(a)))throw Error(`Choose an exact version, a minor line such as 2.2.x, or latest`);let s;if(n.test(a)){let n=a.slice(0,-1);s=t.releases.filter(t=>e.test(t.version)&&t.version.startsWith(n)).sort((e,t)=>Number(t.version.split(`.`)[2])-Number(e.version.split(`.`)[2]))[0]}else s=t.releases.find(e=>e.version===(a===`latest`?t.latest:a));if(!s)throw Error(`No approved browser runtime for ${a}`);if(o.runtimeApiVersion!==s.runtimeApiVersion||o.reactMajor!==s.reactMajor)throw Error(`Release ${s.version} requires runtime API ${s.runtimeApiVersion} and React ${s.reactMajor}`);return s}const o=new Map,s=new WeakMap;function c(e){return new Promise((t,n)=>{let r=setTimeout(()=>i(Error(`Remote editor asset timed out`)),3e4);function i(i){clearTimeout(r),e.onload=null,e.onerror=null,i?(e.remove(),n(i)):t()}e.crossOrigin=`anonymous`,e.onload=()=>i(),e.onerror=()=>i(Error(`Remote editor asset failed to load or failed its integrity check`)),document.head.appendChild(e)})}async function l(e,t){if(i({releases:[e],latest:null}),e.runtimeApiVersion!==1||Number(t.react.version.split(`.`)[0])!==e.reactMajor)throw Error(`Remote editor is incompatible with this host`);let n=`${e.script.url}:${e.script.integrity}`,r=o.get(n);if(!r){let t=document.createElement(`script`);t.src=e.script.url,t.integrity=e.script.integrity,r=c(t).then(()=>{t.remove();let n=globalThis.__manifestEditorFactories?.[e.buildId];if(typeof n!=`function`)throw Error(`Remote editor did not register its runtime`);return n}).catch(e=>{throw o.delete(n),e}),o.set(n,r)}let a=document.createElement(`link`);a.rel=`stylesheet`,a.href=e.stylesheet.url,a.integrity=e.stylesheet.integrity;try{let[i]=await Promise.all([r,c(a)]),o=s.get(t.react);o||s.set(t.react,o=new Map);let l=o.get(n);if(!l){if(l=i(t),l.runtimeApiVersion!==1||typeof l.shell?.mapApp!=`function`||typeof l.Vault!=`function`)throw Error(`Remote editor exports do not match runtime API 1`);o.set(n,l)}return{runtime:l,release:e,dispose:()=>a.remove()}}catch(e){throw a.remove(),e}}exports.isExactVersion=r,exports.loadManifestEditor=l,exports.resolveRelease=a,exports.validateCatalog=i;
|
|
2
|
+
//# sourceMappingURL=remote.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.cjs","names":[],"sources":["../src/remote/releases.ts","../src/remote/loader.ts"],"sourcesContent":["export interface RemoteRelease {\n version: string;\n buildId: string;\n runtimeApiVersion: number;\n reactMajor: number;\n script: { url: string; integrity: string };\n stylesheet: { url: string; integrity: string };\n}\n\nexport interface ReleaseCatalog {\n releases: RemoteRelease[];\n latest: string | null;\n}\n\n// Deliberately supports exact versions, a minor line, and latest, rather than arbitrary npm ranges.\nconst stable = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$/;\nconst exact =\n /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$/;\nconst minor = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.x$/;\n\nexport function isExactVersion(value: string) {\n return value.length < 100 && exact.test(value);\n}\n\nexport function validateCatalog(value: unknown): asserts value is ReleaseCatalog {\n if (!value || typeof value !== \"object\") throw new Error(\"Invalid release catalog\");\n const catalog = value as ReleaseCatalog;\n if (!Array.isArray(catalog.releases) || !(catalog.latest === null || typeof catalog.latest === \"string\")) {\n throw new Error(\"Invalid release catalog\");\n }\n const versions = new Set<string>();\n for (const release of catalog.releases) {\n if (\n !release ||\n typeof release.version !== \"string\" ||\n !isExactVersion(release.version) ||\n typeof release.buildId !== \"string\" ||\n !/^[a-f0-9]{32}$/.test(release.buildId) ||\n !Number.isInteger(release.runtimeApiVersion) ||\n release.runtimeApiVersion < 1 ||\n !Number.isInteger(release.reactMajor) ||\n release.reactMajor < 1 ||\n versions.has(release.version)\n ) {\n throw new Error(\"Invalid or duplicate release\");\n }\n for (const [asset, filename] of [\n [release.script, \"runtime.js\"],\n [release.stylesheet, \"runtime.css\"],\n ] as const) {\n if (\n !asset ||\n typeof asset.url !== \"string\" ||\n typeof asset.integrity !== \"string\" ||\n !/^sha384-[A-Za-z0-9+/]{64}$/.test(asset.integrity)\n )\n throw new Error(\"Invalid release asset\");\n if (\n asset.url !== `/remote-editor/assets/${release.buildId}/${filename}` &&\n asset.url !== `https://cdn.jsdelivr.net/npm/manifest-editor@${release.version}/dist/browser/${filename}`\n ) {\n throw new Error(\"Release asset origin or path is not allowed\");\n }\n }\n versions.add(release.version);\n }\n if (catalog.latest !== null && (!stable.test(catalog.latest) || !versions.has(catalog.latest))) {\n throw new Error(\"Latest must reference a catalogued stable release\");\n }\n}\n\nexport function resolveRelease(\n catalog: ReleaseCatalog,\n selection: string,\n host: { runtimeApiVersion: number; reactMajor: number }\n) {\n validateCatalog(catalog);\n if (\n typeof selection !== \"string\" ||\n selection.length > 100 ||\n !(selection === \"latest\" || minor.test(selection) || isExactVersion(selection))\n ) {\n throw new Error(\"Choose an exact version, a minor line such as 2.2.x, or latest\");\n }\n let release: RemoteRelease | undefined;\n if (minor.test(selection)) {\n const prefix = selection.slice(0, -1);\n release = catalog.releases\n .filter((item) => stable.test(item.version) && item.version.startsWith(prefix))\n .sort((a, b) => Number(b.version.split(\".\")[2]) - Number(a.version.split(\".\")[2]))[0];\n } else {\n release = catalog.releases.find((item) => item.version === (selection === \"latest\" ? catalog.latest : selection));\n }\n if (!release) throw new Error(`No approved browser runtime for ${selection}`);\n if (host.runtimeApiVersion !== release.runtimeApiVersion || host.reactMajor !== release.reactMajor) {\n throw new Error(\n `Release ${release.version} requires runtime API ${release.runtimeApiVersion} and React ${release.reactMajor}`\n );\n }\n return release;\n}\n","import { validateCatalog, type RemoteRelease } from \"./releases\";\n\nexport type EditorRuntime = typeof import(\"../../browser/entry\");\nexport interface RuntimeHost {\n react: typeof import(\"react\");\n \"react-reconciler\": unknown;\n \"react-dom\": typeof import(\"react-dom\");\n \"react-dom/client\": typeof import(\"react-dom/client\");\n \"react-dom/server\": typeof import(\"react-dom/server\");\n \"react-dom/server.browser\": typeof import(\"react-dom/server\");\n \"react/jsx-runtime\": typeof import(\"react/jsx-runtime\");\n}\n\ntype Factory = (host: RuntimeHost) => EditorRuntime;\nexport interface BrowserRuntimeOptions {\n React: RuntimeHost[\"react\"];\n ReactDOM: RuntimeHost[\"react-dom\"];\n ReactDOMClient: RuntimeHost[\"react-dom/client\"];\n ReactDOMServer: RuntimeHost[\"react-dom/server\"];\n jsxRuntime: RuntimeHost[\"react/jsx-runtime\"];\n ReactReconciler: RuntimeHost[\"react-reconciler\"];\n}\nexport interface BrowserRuntimeApi {\n readonly version: string;\n readonly buildId: string;\n createRuntime(host: BrowserRuntimeOptions): EditorRuntime;\n automaticRuntime(): Promise<EditorRuntime & {\n React: RuntimeHost[\"react\"];\n ReactDOM: RuntimeHost[\"react-dom\"];\n ReactDOMClient: RuntimeHost[\"react-dom/client\"];\n }>;\n}\ndeclare global {\n var __manifestEditorFactories: Record<string, Factory> | undefined;\n var ManifestEditor: BrowserRuntimeApi;\n}\n\nconst scripts = new Map<string, Promise<Factory>>();\nconst runtimes = new WeakMap<RuntimeHost[\"react\"], Map<string, EditorRuntime>>();\n\nfunction appendVerified(element: HTMLScriptElement | HTMLLinkElement) {\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => finish(new Error(\"Remote editor asset timed out\")), 30_000);\n function finish(error?: Error) {\n clearTimeout(timer);\n element.onload = null;\n element.onerror = null;\n if (error) {\n element.remove();\n reject(error);\n } else resolve();\n }\n element.crossOrigin = \"anonymous\";\n element.onload = () => finish();\n element.onerror = () => finish(new Error(\"Remote editor asset failed to load or failed its integrity check\"));\n document.head.appendChild(element);\n });\n}\n\n/** Load only descriptors received from your trusted release resolver. */\nexport async function loadManifestEditor(release: RemoteRelease, host: RuntimeHost) {\n validateCatalog({ releases: [release], latest: null });\n if (release.runtimeApiVersion !== 1 || Number(host.react.version.split(\".\")[0]) !== release.reactMajor) {\n throw new Error(\"Remote editor is incompatible with this host\");\n }\n const key = `${release.script.url}:${release.script.integrity}`;\n let scriptPromise = scripts.get(key);\n if (!scriptPromise) {\n const script = document.createElement(\"script\");\n script.src = release.script.url;\n script.integrity = release.script.integrity;\n scriptPromise = appendVerified(script)\n .then(() => {\n script.remove();\n const factory = globalThis.__manifestEditorFactories?.[release.buildId];\n if (typeof factory !== \"function\") throw new Error(\"Remote editor did not register its runtime\");\n return factory;\n })\n .catch((error) => {\n scripts.delete(key);\n throw error;\n });\n scripts.set(key, scriptPromise);\n }\n\n const stylesheet = document.createElement(\"link\");\n stylesheet.rel = \"stylesheet\";\n stylesheet.href = release.stylesheet.url;\n stylesheet.integrity = release.stylesheet.integrity;\n try {\n const [factory] = await Promise.all([scriptPromise, appendVerified(stylesheet)]);\n let instances = runtimes.get(host.react);\n if (!instances) runtimes.set(host.react, (instances = new Map()));\n let runtime = instances.get(key);\n if (!runtime) {\n runtime = factory(host);\n if (\n runtime.runtimeApiVersion !== 1 ||\n typeof runtime.shell?.mapApp !== \"function\" ||\n typeof runtime.Vault !== \"function\"\n ) {\n throw new Error(\"Remote editor exports do not match runtime API 1\");\n }\n instances.set(key, runtime);\n }\n return { runtime, release, dispose: () => stylesheet.remove() };\n } catch (error) {\n stylesheet.remove();\n throw error;\n }\n}\n"],"mappings":"mEAeA,MAAM,EAAS,6CACT,EACJ,4IACI,EAAQ,kCAEd,SAAgB,EAAe,EAAe,CAC5C,OAAO,EAAM,OAAS,KAAO,EAAM,KAAK,CAAK,CAC/C,CAEA,SAAgB,EAAgB,EAAiD,CAC/E,GAAI,CAAC,GAAS,OAAO,GAAU,SAAU,MAAU,MAAM,yBAAyB,EAClF,IAAM,EAAU,EAChB,GAAI,CAAC,MAAM,QAAQ,EAAQ,QAAQ,GAAO,EAAQ,SAAW,MAAQ,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estEditor-C1Rcg3CO.cjs";
|
|
2
|
+
import * as collectionPreset from "@manifest-editor/collection-preset";
|
|
3
|
+
import * as components from "@manifest-editor/components";
|
|
4
|
+
import * as creatorApi from "@manifest-editor/creator-api";
|
|
5
|
+
import * as creators from "@manifest-editor/creators";
|
|
6
|
+
import * as editorApi from "@manifest-editor/editor-api";
|
|
7
|
+
import * as exhibitionPreset from "@manifest-editor/exhibition-preset";
|
|
8
|
+
import { Vault as Vault$1 } from "@iiif/helpers";
|
|
9
|
+
import * as shell from "@manifest-editor/shell";
|
|
10
|
+
import * as manifestPreset from "@manifest-editor/manifest-preset";
|
|
11
|
+
import * as vault from "react-iiif-vault";
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/remote/releases.d.ts
|
|
14
|
+
interface RemoteRelease {
|
|
15
|
+
version: string;
|
|
16
|
+
buildId: string;
|
|
17
|
+
runtimeApiVersion: number;
|
|
18
|
+
reactMajor: number;
|
|
19
|
+
script: {
|
|
20
|
+
url: string;
|
|
21
|
+
integrity: string;
|
|
22
|
+
};
|
|
23
|
+
stylesheet: {
|
|
24
|
+
url: string;
|
|
25
|
+
integrity: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface ReleaseCatalog {
|
|
29
|
+
releases: RemoteRelease[];
|
|
30
|
+
latest: string | null;
|
|
31
|
+
}
|
|
32
|
+
declare function isExactVersion(value: string): boolean;
|
|
33
|
+
declare function validateCatalog(value: unknown): asserts value is ReleaseCatalog;
|
|
34
|
+
declare function resolveRelease(catalog: ReleaseCatalog, selection: string, host: {
|
|
35
|
+
runtimeApiVersion: number;
|
|
36
|
+
reactMajor: number;
|
|
37
|
+
}): RemoteRelease;
|
|
38
|
+
declare namespace entry_d_exports {
|
|
39
|
+
export { ManifestEditor, Vault$1 as Vault, collectionPreset, components, creatorApi, creators, editorApi, exhibitionPreset, manifestPreset, runtimeApiVersion, shell, vault };
|
|
40
|
+
}
|
|
41
|
+
declare const runtimeApiVersion = 1;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/remote/loader.d.ts
|
|
44
|
+
type EditorRuntime = typeof entry_d_exports;
|
|
45
|
+
interface RuntimeHost {
|
|
46
|
+
react: typeof import("react");
|
|
47
|
+
"react-reconciler": unknown;
|
|
48
|
+
"react-dom": typeof import("react-dom");
|
|
49
|
+
"react-dom/client": typeof import("react-dom/client");
|
|
50
|
+
"react-dom/server": typeof import("react-dom/server");
|
|
51
|
+
"react-dom/server.browser": typeof import("react-dom/server");
|
|
52
|
+
"react/jsx-runtime": typeof import("react/jsx-runtime");
|
|
53
|
+
}
|
|
54
|
+
type Factory = (host: RuntimeHost) => EditorRuntime;
|
|
55
|
+
interface BrowserRuntimeOptions {
|
|
56
|
+
React: RuntimeHost["react"];
|
|
57
|
+
ReactDOM: RuntimeHost["react-dom"];
|
|
58
|
+
ReactDOMClient: RuntimeHost["react-dom/client"];
|
|
59
|
+
ReactDOMServer: RuntimeHost["react-dom/server"];
|
|
60
|
+
jsxRuntime: RuntimeHost["react/jsx-runtime"];
|
|
61
|
+
ReactReconciler: RuntimeHost["react-reconciler"];
|
|
62
|
+
}
|
|
63
|
+
interface BrowserRuntimeApi {
|
|
64
|
+
readonly version: string;
|
|
65
|
+
readonly buildId: string;
|
|
66
|
+
createRuntime(host: BrowserRuntimeOptions): EditorRuntime;
|
|
67
|
+
automaticRuntime(): Promise<EditorRuntime & {
|
|
68
|
+
React: RuntimeHost["react"];
|
|
69
|
+
ReactDOM: RuntimeHost["react-dom"];
|
|
70
|
+
ReactDOMClient: RuntimeHost["react-dom/client"];
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
declare global {
|
|
74
|
+
var __manifestEditorFactories: Record<string, Factory> | undefined;
|
|
75
|
+
var ManifestEditor: BrowserRuntimeApi;
|
|
76
|
+
}
|
|
77
|
+
/** Load only descriptors received from your trusted release resolver. */
|
|
78
|
+
declare function loadManifestEditor(release: RemoteRelease, host: RuntimeHost): Promise<{
|
|
79
|
+
runtime: typeof entry_d_exports;
|
|
80
|
+
release: RemoteRelease;
|
|
81
|
+
dispose: () => void;
|
|
82
|
+
}>;
|
|
83
|
+
//#endregion
|
|
84
|
+
export { BrowserRuntimeApi, BrowserRuntimeOptions, EditorRuntime, ReleaseCatalog, RemoteRelease, RuntimeHost, isExactVersion, loadManifestEditor, resolveRelease, validateCatalog };
|
|
85
|
+
//# sourceMappingURL=remote.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.cts","names":[],"sources":["../src/remote/releases.ts","../browser/entry.ts","../src/remote/loader.ts"],"mappings":";;;;;;;;;;;;;UAAiB;EACf;EACA;EACA;EACA;EACA;IAAU;IAAa;;EACvB;IAAc;IAAa;;;UAGZ;EACf,UAAU;EACV;;iBASc,eAAe;iBAIf,gBAAgB,yBAAyB,SAAS;iBA+ClD,eACd,SAAS,gBACT,mBACA;EAAQ;EAA2B;IAAoB;;;;cC9D5C;;;KCVD,uBAAA;UACK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;KAGG,WAAW,MAAM,gBAAgB;UACrB;EACf,OAAO;EACP,UAAU;EACV,gBAAgB;EAChB,gBAAgB;EAChB,YAAY;EACZ,iBAAiB;;UAEF;WACN;WACA;EACT,cAAc,MAAM,wBAAwB;EAC5C,oBAAoB,QAAQ;IAC1B,OAAO;IACP,UAAU;IACV,gBAAgB;;;QAGZ;MACF,2BAA2B,eAAe;MAC1C,gBAAgB;;;iBA0BA,mBAAmB,SAAS,eAAe,MAAM,cAAW;kBAAX"}
|
package/dist/remote.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { t as ManifestEditor } from "./ManifestEditor-CMWoRdqp.js";
|
|
2
|
+
import * as collectionPreset$1 from "@manifest-editor/collection-preset";
|
|
3
|
+
import * as manifestPreset from "@manifest-editor/manifest-preset";
|
|
4
|
+
import * as shell from "@manifest-editor/shell";
|
|
5
|
+
import * as vault from "react-iiif-vault";
|
|
6
|
+
import * as components from "@manifest-editor/components";
|
|
7
|
+
import * as editorApi from "@manifest-editor/editor-api";
|
|
8
|
+
import * as creators from "@manifest-editor/creators";
|
|
9
|
+
import * as creatorApi from "@manifest-editor/creator-api";
|
|
10
|
+
import * as exhibitionPreset from "@manifest-editor/exhibition-preset";
|
|
11
|
+
import { Vault as Vault$1 } from "@iiif/helpers";
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/remote/releases.d.ts
|
|
14
|
+
interface RemoteRelease {
|
|
15
|
+
version: string;
|
|
16
|
+
buildId: string;
|
|
17
|
+
runtimeApiVersion: number;
|
|
18
|
+
reactMajor: number;
|
|
19
|
+
script: {
|
|
20
|
+
url: string;
|
|
21
|
+
integrity: string;
|
|
22
|
+
};
|
|
23
|
+
stylesheet: {
|
|
24
|
+
url: string;
|
|
25
|
+
integrity: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface ReleaseCatalog {
|
|
29
|
+
releases: RemoteRelease[];
|
|
30
|
+
latest: string | null;
|
|
31
|
+
}
|
|
32
|
+
declare function isExactVersion(value: string): boolean;
|
|
33
|
+
declare function validateCatalog(value: unknown): asserts value is ReleaseCatalog;
|
|
34
|
+
declare function resolveRelease(catalog: ReleaseCatalog, selection: string, host: {
|
|
35
|
+
runtimeApiVersion: number;
|
|
36
|
+
reactMajor: number;
|
|
37
|
+
}): RemoteRelease;
|
|
38
|
+
declare namespace entry_d_exports {
|
|
39
|
+
export { ManifestEditor, Vault$1 as Vault, collectionPreset$1 as collectionPreset, components, creatorApi, creators, editorApi, exhibitionPreset, manifestPreset, runtimeApiVersion, shell, vault };
|
|
40
|
+
}
|
|
41
|
+
declare const runtimeApiVersion = 1;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/remote/loader.d.ts
|
|
44
|
+
type EditorRuntime = typeof entry_d_exports;
|
|
45
|
+
interface RuntimeHost {
|
|
46
|
+
react: typeof import("react");
|
|
47
|
+
"react-reconciler": unknown;
|
|
48
|
+
"react-dom": typeof import("react-dom");
|
|
49
|
+
"react-dom/client": typeof import("react-dom/client");
|
|
50
|
+
"react-dom/server": typeof import("react-dom/server");
|
|
51
|
+
"react-dom/server.browser": typeof import("react-dom/server");
|
|
52
|
+
"react/jsx-runtime": typeof import("react/jsx-runtime");
|
|
53
|
+
}
|
|
54
|
+
type Factory = (host: RuntimeHost) => EditorRuntime;
|
|
55
|
+
interface BrowserRuntimeOptions {
|
|
56
|
+
React: RuntimeHost["react"];
|
|
57
|
+
ReactDOM: RuntimeHost["react-dom"];
|
|
58
|
+
ReactDOMClient: RuntimeHost["react-dom/client"];
|
|
59
|
+
ReactDOMServer: RuntimeHost["react-dom/server"];
|
|
60
|
+
jsxRuntime: RuntimeHost["react/jsx-runtime"];
|
|
61
|
+
ReactReconciler: RuntimeHost["react-reconciler"];
|
|
62
|
+
}
|
|
63
|
+
interface BrowserRuntimeApi {
|
|
64
|
+
readonly version: string;
|
|
65
|
+
readonly buildId: string;
|
|
66
|
+
createRuntime(host: BrowserRuntimeOptions): EditorRuntime;
|
|
67
|
+
automaticRuntime(): Promise<EditorRuntime & {
|
|
68
|
+
React: RuntimeHost["react"];
|
|
69
|
+
ReactDOM: RuntimeHost["react-dom"];
|
|
70
|
+
ReactDOMClient: RuntimeHost["react-dom/client"];
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
declare global {
|
|
74
|
+
var __manifestEditorFactories: Record<string, Factory> | undefined;
|
|
75
|
+
var ManifestEditor: BrowserRuntimeApi;
|
|
76
|
+
}
|
|
77
|
+
/** Load only descriptors received from your trusted release resolver. */
|
|
78
|
+
declare function loadManifestEditor(release: RemoteRelease, host: RuntimeHost): Promise<{
|
|
79
|
+
runtime: typeof entry_d_exports;
|
|
80
|
+
release: RemoteRelease;
|
|
81
|
+
dispose: () => void;
|
|
82
|
+
}>;
|
|
83
|
+
//#endregion
|
|
84
|
+
export { BrowserRuntimeApi, BrowserRuntimeOptions, EditorRuntime, ReleaseCatalog, RemoteRelease, RuntimeHost, isExactVersion, loadManifestEditor, resolveRelease, validateCatalog };
|
|
85
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","names":[],"sources":["../src/remote/releases.ts","../browser/entry.ts","../src/remote/loader.ts"],"mappings":";;;;;;;;;;;;;UAAiB;EACf;EACA;EACA;EACA;EACA;IAAU;IAAa;;EACvB;IAAc;IAAa;;;UAGZ;EACf,UAAU;EACV;;iBASc,eAAe;iBAIf,gBAAgB,yBAAyB,SAAS;iBA+ClD,eACd,SAAS,gBACT,mBACA;EAAQ;EAA2B;IAAoB;;;;cC9D5C;;;KCVD,uBAAA;UACK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;KAGG,WAAW,MAAM,gBAAgB;UACrB;EACf,OAAO;EACP,UAAU;EACV,gBAAgB;EAChB,gBAAgB;EAChB,YAAY;EACZ,iBAAiB;;UAEF;WACN;WACA;EACT,cAAc,MAAM,wBAAwB;EAC5C,oBAAoB,QAAQ;IAC1B,OAAO;IACP,UAAU;IACV,gBAAgB;;;QAGZ;MACF,2BAA2B,eAAe;MAC1C,gBAAgB;;;iBA0BA,mBAAmB,SAAS,eAAe,MAAM,cAAW;kBAAX"}
|
package/dist/remote.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/,t=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$/,n=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.x$/;function r(e){return e.length<100&&t.test(e)}function i(t){if(!t||typeof t!=`object`)throw Error(`Invalid release catalog`);let n=t;if(!Array.isArray(n.releases)||n.latest!==null&&typeof n.latest!=`string`)throw Error(`Invalid release catalog`);let i=new Set;for(let e of n.releases){if(!e||typeof e.version!=`string`||!r(e.version)||typeof e.buildId!=`string`||!/^[a-f0-9]{32}$/.test(e.buildId)||!Number.isInteger(e.runtimeApiVersion)||e.runtimeApiVersion<1||!Number.isInteger(e.reactMajor)||e.reactMajor<1||i.has(e.version))throw Error(`Invalid or duplicate release`);for(let[t,n]of[[e.script,`runtime.js`],[e.stylesheet,`runtime.css`]]){if(!t||typeof t.url!=`string`||typeof t.integrity!=`string`||!/^sha384-[A-Za-z0-9+/]{64}$/.test(t.integrity))throw Error(`Invalid release asset`);if(t.url!==`/remote-editor/assets/${e.buildId}/${n}`&&t.url!==`https://cdn.jsdelivr.net/npm/manifest-editor@${e.version}/dist/browser/${n}`)throw Error(`Release asset origin or path is not allowed`)}i.add(e.version)}if(n.latest!==null&&(!e.test(n.latest)||!i.has(n.latest)))throw Error(`Latest must reference a catalogued stable release`)}function a(t,a,o){if(i(t),typeof a!=`string`||a.length>100||!(a===`latest`||n.test(a)||r(a)))throw Error(`Choose an exact version, a minor line such as 2.2.x, or latest`);let s;if(n.test(a)){let n=a.slice(0,-1);s=t.releases.filter(t=>e.test(t.version)&&t.version.startsWith(n)).sort((e,t)=>Number(t.version.split(`.`)[2])-Number(e.version.split(`.`)[2]))[0]}else s=t.releases.find(e=>e.version===(a===`latest`?t.latest:a));if(!s)throw Error(`No approved browser runtime for ${a}`);if(o.runtimeApiVersion!==s.runtimeApiVersion||o.reactMajor!==s.reactMajor)throw Error(`Release ${s.version} requires runtime API ${s.runtimeApiVersion} and React ${s.reactMajor}`);return s}const o=new Map,s=new WeakMap;function c(e){return new Promise((t,n)=>{let r=setTimeout(()=>i(Error(`Remote editor asset timed out`)),3e4);function i(i){clearTimeout(r),e.onload=null,e.onerror=null,i?(e.remove(),n(i)):t()}e.crossOrigin=`anonymous`,e.onload=()=>i(),e.onerror=()=>i(Error(`Remote editor asset failed to load or failed its integrity check`)),document.head.appendChild(e)})}async function l(e,t){if(i({releases:[e],latest:null}),e.runtimeApiVersion!==1||Number(t.react.version.split(`.`)[0])!==e.reactMajor)throw Error(`Remote editor is incompatible with this host`);let n=`${e.script.url}:${e.script.integrity}`,r=o.get(n);if(!r){let t=document.createElement(`script`);t.src=e.script.url,t.integrity=e.script.integrity,r=c(t).then(()=>{t.remove();let n=globalThis.__manifestEditorFactories?.[e.buildId];if(typeof n!=`function`)throw Error(`Remote editor did not register its runtime`);return n}).catch(e=>{throw o.delete(n),e}),o.set(n,r)}let a=document.createElement(`link`);a.rel=`stylesheet`,a.href=e.stylesheet.url,a.integrity=e.stylesheet.integrity;try{let[i]=await Promise.all([r,c(a)]),o=s.get(t.react);o||s.set(t.react,o=new Map);let l=o.get(n);if(!l){if(l=i(t),l.runtimeApiVersion!==1||typeof l.shell?.mapApp!=`function`||typeof l.Vault!=`function`)throw Error(`Remote editor exports do not match runtime API 1`);o.set(n,l)}return{runtime:l,release:e,dispose:()=>a.remove()}}catch(e){throw a.remove(),e}}export{r as isExactVersion,l as loadManifestEditor,a as resolveRelease,i as validateCatalog};
|
|
2
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","names":[],"sources":["../src/remote/releases.ts","../src/remote/loader.ts"],"sourcesContent":["export interface RemoteRelease {\n version: string;\n buildId: string;\n runtimeApiVersion: number;\n reactMajor: number;\n script: { url: string; integrity: string };\n stylesheet: { url: string; integrity: string };\n}\n\nexport interface ReleaseCatalog {\n releases: RemoteRelease[];\n latest: string | null;\n}\n\n// Deliberately supports exact versions, a minor line, and latest, rather than arbitrary npm ranges.\nconst stable = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$/;\nconst exact =\n /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$/;\nconst minor = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.x$/;\n\nexport function isExactVersion(value: string) {\n return value.length < 100 && exact.test(value);\n}\n\nexport function validateCatalog(value: unknown): asserts value is ReleaseCatalog {\n if (!value || typeof value !== \"object\") throw new Error(\"Invalid release catalog\");\n const catalog = value as ReleaseCatalog;\n if (!Array.isArray(catalog.releases) || !(catalog.latest === null || typeof catalog.latest === \"string\")) {\n throw new Error(\"Invalid release catalog\");\n }\n const versions = new Set<string>();\n for (const release of catalog.releases) {\n if (\n !release ||\n typeof release.version !== \"string\" ||\n !isExactVersion(release.version) ||\n typeof release.buildId !== \"string\" ||\n !/^[a-f0-9]{32}$/.test(release.buildId) ||\n !Number.isInteger(release.runtimeApiVersion) ||\n release.runtimeApiVersion < 1 ||\n !Number.isInteger(release.reactMajor) ||\n release.reactMajor < 1 ||\n versions.has(release.version)\n ) {\n throw new Error(\"Invalid or duplicate release\");\n }\n for (const [asset, filename] of [\n [release.script, \"runtime.js\"],\n [release.stylesheet, \"runtime.css\"],\n ] as const) {\n if (\n !asset ||\n typeof asset.url !== \"string\" ||\n typeof asset.integrity !== \"string\" ||\n !/^sha384-[A-Za-z0-9+/]{64}$/.test(asset.integrity)\n )\n throw new Error(\"Invalid release asset\");\n if (\n asset.url !== `/remote-editor/assets/${release.buildId}/${filename}` &&\n asset.url !== `https://cdn.jsdelivr.net/npm/manifest-editor@${release.version}/dist/browser/${filename}`\n ) {\n throw new Error(\"Release asset origin or path is not allowed\");\n }\n }\n versions.add(release.version);\n }\n if (catalog.latest !== null && (!stable.test(catalog.latest) || !versions.has(catalog.latest))) {\n throw new Error(\"Latest must reference a catalogued stable release\");\n }\n}\n\nexport function resolveRelease(\n catalog: ReleaseCatalog,\n selection: string,\n host: { runtimeApiVersion: number; reactMajor: number }\n) {\n validateCatalog(catalog);\n if (\n typeof selection !== \"string\" ||\n selection.length > 100 ||\n !(selection === \"latest\" || minor.test(selection) || isExactVersion(selection))\n ) {\n throw new Error(\"Choose an exact version, a minor line such as 2.2.x, or latest\");\n }\n let release: RemoteRelease | undefined;\n if (minor.test(selection)) {\n const prefix = selection.slice(0, -1);\n release = catalog.releases\n .filter((item) => stable.test(item.version) && item.version.startsWith(prefix))\n .sort((a, b) => Number(b.version.split(\".\")[2]) - Number(a.version.split(\".\")[2]))[0];\n } else {\n release = catalog.releases.find((item) => item.version === (selection === \"latest\" ? catalog.latest : selection));\n }\n if (!release) throw new Error(`No approved browser runtime for ${selection}`);\n if (host.runtimeApiVersion !== release.runtimeApiVersion || host.reactMajor !== release.reactMajor) {\n throw new Error(\n `Release ${release.version} requires runtime API ${release.runtimeApiVersion} and React ${release.reactMajor}`\n );\n }\n return release;\n}\n","import { validateCatalog, type RemoteRelease } from \"./releases\";\n\nexport type EditorRuntime = typeof import(\"../../browser/entry\");\nexport interface RuntimeHost {\n react: typeof import(\"react\");\n \"react-reconciler\": unknown;\n \"react-dom\": typeof import(\"react-dom\");\n \"react-dom/client\": typeof import(\"react-dom/client\");\n \"react-dom/server\": typeof import(\"react-dom/server\");\n \"react-dom/server.browser\": typeof import(\"react-dom/server\");\n \"react/jsx-runtime\": typeof import(\"react/jsx-runtime\");\n}\n\ntype Factory = (host: RuntimeHost) => EditorRuntime;\nexport interface BrowserRuntimeOptions {\n React: RuntimeHost[\"react\"];\n ReactDOM: RuntimeHost[\"react-dom\"];\n ReactDOMClient: RuntimeHost[\"react-dom/client\"];\n ReactDOMServer: RuntimeHost[\"react-dom/server\"];\n jsxRuntime: RuntimeHost[\"react/jsx-runtime\"];\n ReactReconciler: RuntimeHost[\"react-reconciler\"];\n}\nexport interface BrowserRuntimeApi {\n readonly version: string;\n readonly buildId: string;\n createRuntime(host: BrowserRuntimeOptions): EditorRuntime;\n automaticRuntime(): Promise<EditorRuntime & {\n React: RuntimeHost[\"react\"];\n ReactDOM: RuntimeHost[\"react-dom\"];\n ReactDOMClient: RuntimeHost[\"react-dom/client\"];\n }>;\n}\ndeclare global {\n var __manifestEditorFactories: Record<string, Factory> | undefined;\n var ManifestEditor: BrowserRuntimeApi;\n}\n\nconst scripts = new Map<string, Promise<Factory>>();\nconst runtimes = new WeakMap<RuntimeHost[\"react\"], Map<string, EditorRuntime>>();\n\nfunction appendVerified(element: HTMLScriptElement | HTMLLinkElement) {\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => finish(new Error(\"Remote editor asset timed out\")), 30_000);\n function finish(error?: Error) {\n clearTimeout(timer);\n element.onload = null;\n element.onerror = null;\n if (error) {\n element.remove();\n reject(error);\n } else resolve();\n }\n element.crossOrigin = \"anonymous\";\n element.onload = () => finish();\n element.onerror = () => finish(new Error(\"Remote editor asset failed to load or failed its integrity check\"));\n document.head.appendChild(element);\n });\n}\n\n/** Load only descriptors received from your trusted release resolver. */\nexport async function loadManifestEditor(release: RemoteRelease, host: RuntimeHost) {\n validateCatalog({ releases: [release], latest: null });\n if (release.runtimeApiVersion !== 1 || Number(host.react.version.split(\".\")[0]) !== release.reactMajor) {\n throw new Error(\"Remote editor is incompatible with this host\");\n }\n const key = `${release.script.url}:${release.script.integrity}`;\n let scriptPromise = scripts.get(key);\n if (!scriptPromise) {\n const script = document.createElement(\"script\");\n script.src = release.script.url;\n script.integrity = release.script.integrity;\n scriptPromise = appendVerified(script)\n .then(() => {\n script.remove();\n const factory = globalThis.__manifestEditorFactories?.[release.buildId];\n if (typeof factory !== \"function\") throw new Error(\"Remote editor did not register its runtime\");\n return factory;\n })\n .catch((error) => {\n scripts.delete(key);\n throw error;\n });\n scripts.set(key, scriptPromise);\n }\n\n const stylesheet = document.createElement(\"link\");\n stylesheet.rel = \"stylesheet\";\n stylesheet.href = release.stylesheet.url;\n stylesheet.integrity = release.stylesheet.integrity;\n try {\n const [factory] = await Promise.all([scriptPromise, appendVerified(stylesheet)]);\n let instances = runtimes.get(host.react);\n if (!instances) runtimes.set(host.react, (instances = new Map()));\n let runtime = instances.get(key);\n if (!runtime) {\n runtime = factory(host);\n if (\n runtime.runtimeApiVersion !== 1 ||\n typeof runtime.shell?.mapApp !== \"function\" ||\n typeof runtime.Vault !== \"function\"\n ) {\n throw new Error(\"Remote editor exports do not match runtime API 1\");\n }\n instances.set(key, runtime);\n }\n return { runtime, release, dispose: () => stylesheet.remove() };\n } catch (error) {\n stylesheet.remove();\n throw error;\n }\n}\n"],"mappings":"AAeA,MAAM,EAAS,6CACT,EACJ,4IACI,EAAQ,kCAEd,SAAgB,EAAe,EAAe,CAC5C,OAAO,EAAM,OAAS,KAAO,EAAM,KAAK,CAAK,CAC/C,CAEA,SAAgB,EAAgB,EAAiD,CAC/E,GAAI,CAAC,GAAS,OAAO,GAAU,SAAU,MAAU,MAAM,yBAAyB,EAClF,IAAM,EAAU,EAChB,GAAI,CAAC,MAAM,QAAQ,EAAQ,QAAQ,GAAO,EAAQ,SAAW,MAAQ,OAAO,EAAQ,QAAW,SAC7F,MAAU,MAAM,yBAAyB,EAE3C,IAAM,EAAW,IAAI,IACrB,IAAK,IAAM,KAAW,EAAQ,SAAU,CACtC,GACE,CAAC,GACD,OAAO,EAAQ,SAAY,UAC3B,CAAC,EAAe,EAAQ,OAAO,GAC/B,OAAO,EAAQ,SAAY,UAC3B,CAAC,iBAAiB,KAAK,EAAQ,OAAO,GACtC,CAAC,OAAO,UAAU,EAAQ,iBAAiB,GAC3C,EAAQ,kBAAoB,GAC5B,CAAC,OAAO,UAAU,EAAQ,UAAU,GACpC,EAAQ,WAAa,GACrB,EAAS,IAAI,EAAQ,OAAO,EAE5B,MAAU,MAAM,8BAA8B,EAEhD,IAAK,GAAM,CAAC,EAAO,IAAa,CAC9B,CAAC,EAAQ,OAAQ,YAAY,EAC7B,CAAC,EAAQ,WAAY,aAAa,CACpC,EAAY,CACV,GACE,CAAC,GACD,OAAO,EAAM,KAAQ,UACrB,OAAO,EAAM,WAAc,UAC3B,CAAC,6BAA6B,KAAK,EAAM,SAAS,EAElD,MAAU,MAAM,uBAAuB,EACzC,GACE,EAAM,MAAQ,yBAAyB,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e,CAAU,CAAC,CAAC,EAC3E,EAAY,EAAS,IAAI,EAAK,KAAK,EAClC,GAAW,EAAS,IAAI,EAAK,MAAQ,EAAY,IAAI,GAAM,EAChE,IAAI,EAAU,EAAU,IAAI,CAAG,EAC/B,GAAI,CAAC,EAAS,CAEZ,GADA,EAAU,EAAQ,CAAI,EAEpB,EAAQ,oBAAsB,GAC9B,OAAO,EAAQ,OAAO,QAAW,YACjC,OAAO,EAAQ,OAAU,WAEzB,MAAU,MAAM,kDAAkD,EAEpE,EAAU,IAAI,EAAK,CAAO,CAC5B,CACA,MAAO,CAAE,UAAS,UAAS,YAAe,EAAW,OAAO,CAAE,CAChE,OAAS,EAAO,CAEd,MADA,EAAW,OAAO,EACZ,CACR,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "manifest-editor",
|
|
3
|
-
"version": "2.2.0",
|
|
3
|
+
"version": "2.2.1-next.0.eefc2e3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bugs": "https://github.com/digirati-co-uk/iiif-manifest-editor/issues",
|
|
6
6
|
"repository": {
|
|
@@ -68,6 +68,10 @@
|
|
|
68
68
|
"import": "./dist/parser.js",
|
|
69
69
|
"require": "./dist/parser.cjs"
|
|
70
70
|
},
|
|
71
|
+
"./remote": {
|
|
72
|
+
"import": "./dist/remote.js",
|
|
73
|
+
"require": "./dist/remote.cjs"
|
|
74
|
+
},
|
|
71
75
|
"./shell": {
|
|
72
76
|
"import": "./dist/shell.js",
|
|
73
77
|
"require": "./dist/shell.cjs"
|
|
@@ -86,34 +90,37 @@
|
|
|
86
90
|
"dev": "tsdown --watch",
|
|
87
91
|
"lint": "publint",
|
|
88
92
|
"typecheck": "tsc --noEmit",
|
|
89
|
-
"prepack": "tsdown"
|
|
93
|
+
"prepack": "tsdown && node browser/build.mjs",
|
|
94
|
+
"test:remote": "vitest run src/remote/releases.test.ts browser/runtime-api.test.mjs"
|
|
90
95
|
},
|
|
91
96
|
"dependencies": {
|
|
92
|
-
"@atlas-viewer/atlas": "3.
|
|
93
|
-
"@iiif/helpers": "
|
|
94
|
-
"@iiif/parser": "
|
|
97
|
+
"@atlas-viewer/atlas": "3.3.0",
|
|
98
|
+
"@iiif/helpers": "4.0.0",
|
|
99
|
+
"@iiif/parser": "4.0.1",
|
|
95
100
|
"@iiif/presentation-3": "^2.2.3",
|
|
96
101
|
"@iiif/presentation-3-normalized": "^0.9.7",
|
|
97
|
-
"@manifest-editor/collection-preset": "2.2.0",
|
|
98
|
-
"@manifest-editor/components": "2.2.0",
|
|
99
|
-
"@manifest-editor/creator-api": "2.2.0",
|
|
100
|
-
"@manifest-editor/creators": "2.2.0",
|
|
101
|
-
"@manifest-editor/editor-api": "2.2.0",
|
|
102
|
-
"@manifest-editor/editors": "2.2.0",
|
|
103
|
-
"@manifest-editor/exhibition-preset": "2.2.0",
|
|
104
|
-
"@manifest-editor/manifest-preset": "2.2.0",
|
|
105
|
-
"@manifest-editor/shell": "2.2.0",
|
|
102
|
+
"@manifest-editor/collection-preset": "2.2.1-next.0.eefc2e3",
|
|
103
|
+
"@manifest-editor/components": "2.2.1-next.0.eefc2e3",
|
|
104
|
+
"@manifest-editor/creator-api": "2.2.1-next.0.eefc2e3",
|
|
105
|
+
"@manifest-editor/creators": "2.2.1-next.0.eefc2e3",
|
|
106
|
+
"@manifest-editor/editor-api": "2.2.1-next.0.eefc2e3",
|
|
107
|
+
"@manifest-editor/editors": "2.2.1-next.0.eefc2e3",
|
|
108
|
+
"@manifest-editor/exhibition-preset": "2.2.1-next.0.eefc2e3",
|
|
109
|
+
"@manifest-editor/manifest-preset": "2.2.1-next.0.eefc2e3",
|
|
110
|
+
"@manifest-editor/shell": "2.2.1-next.0.eefc2e3",
|
|
106
111
|
"@mdxeditor/editor": "^4.0.4",
|
|
107
112
|
"iiif-browser": "https://pkg.pr.new/digirati-co-uk/iiif-browser/iiif-browser@4934ee2",
|
|
108
113
|
"react": "19.2.8",
|
|
109
114
|
"react-dom": "19.2.8",
|
|
110
|
-
"react-iiif-vault": "
|
|
115
|
+
"react-iiif-vault": "4.0.0"
|
|
111
116
|
},
|
|
112
117
|
"devDependencies": {
|
|
113
118
|
"@manifest-editor/ui": "2.2.0",
|
|
119
|
+
"@tailwindcss/typography": "0.5.20",
|
|
114
120
|
"@tsdown/css": "0.22.14",
|
|
115
121
|
"@types/react": "19.2.18",
|
|
116
122
|
"@types/react-dom": "19.2.4",
|
|
123
|
+
"autoprefixer": "10.5.4",
|
|
117
124
|
"postcss": "^8.4.38",
|
|
118
125
|
"postcss-import": "^16.1.0",
|
|
119
126
|
"postcss-nested": "^7.0.2",
|
|
@@ -122,10 +129,11 @@
|
|
|
122
129
|
"react-datetime-picker": "^5.6.0",
|
|
123
130
|
"tailwindcss": "^3.4.3",
|
|
124
131
|
"tiny-invariant": "^1.3.3",
|
|
125
|
-
"tsdown": "0.22.14"
|
|
132
|
+
"tsdown": "0.22.14",
|
|
133
|
+
"vitest": "4.1.10"
|
|
126
134
|
},
|
|
127
135
|
"publishConfig": {
|
|
128
136
|
"access": "public"
|
|
129
137
|
},
|
|
130
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "eefc2e321c6da5d194285621f4d26376088f2bb2"
|
|
131
139
|
}
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/ManifestEditor.tsx"],"mappings":";;;;UAmBiB;EACf;IAAqB;IAAY;;EACjC,OAAO,WAAW;EAClB,QAAQ;EACR,SAAS,QAAQ;EACjB,cAAc,QAAQ,QAAQ;EAC9B,qBAAqB;EACrB,0BAA0B,QAAQ,+BAA6B;EAC/D,UAAU;EACV;EACA;EACA;;iBA6Bc,eAAe,OAAO,sCAAmB,IAAA"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/ManifestEditor.tsx"],"mappings":";;;;UAmBiB;EACf;IAAqB;IAAY;;EACjC,OAAO,WAAW;EAClB,QAAQ;EACR,SAAS,QAAQ;EACjB,cAAc,QAAQ,QAAQ;EAC9B,qBAAqB;EACrB,0BAA0B,QAAQ,+BAA6B;EAC/D,UAAU;EACV;EACA;EACA;;iBA6Bc,eAAe,OAAO,sCAAmB,IAAA"}
|