miral 0.0.7 → 0.0.9
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/Viewer.js +6 -7
- package/dist/cli.js +2 -1
- package/dist/main.js +6 -0
- package/package.json +1 -1
package/dist/Viewer.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { createRoot } from "react-dom/client";
|
|
4
3
|
import { Icon } from "./icons.js";
|
|
5
4
|
import "/__miral-viewer.css";
|
|
6
5
|
import { Assets } from "./Assets.js";
|
|
@@ -163,18 +162,20 @@ const FrameLoading = () => {
|
|
|
163
162
|
}, []);
|
|
164
163
|
return null;
|
|
165
164
|
};
|
|
166
|
-
const
|
|
165
|
+
const Catalog = () => {
|
|
167
166
|
const [url, setUrl] = React.useState(initialUrl);
|
|
168
167
|
const entry = assets &&
|
|
169
168
|
(url.searchParams.get("component") === assetsEntry.path || !entries.length)
|
|
170
169
|
? assetsEntry
|
|
171
170
|
: (entries.find((item) => item.path === url.searchParams.get("component")) ?? entries[0]);
|
|
172
171
|
const example = url.searchParams.get("example") || "Preview";
|
|
172
|
+
const pendingPage = entry && entry !== assetsEntry ? loadPage(entry.path) : null;
|
|
173
|
+
const deferredPage = React.useDeferredValue(pendingPage);
|
|
173
174
|
let page = emptyPage;
|
|
174
175
|
if (entry === assetsEntry)
|
|
175
176
|
page = assetsPage;
|
|
176
|
-
else if (
|
|
177
|
-
page = React.use(
|
|
177
|
+
else if (deferredPage)
|
|
178
|
+
page = React.use(deferredPage);
|
|
178
179
|
const [values, setValues] = React.useState(() => readValues(page, url));
|
|
179
180
|
const [previousUrl, setPreviousUrl] = React.useState(url);
|
|
180
181
|
if (previousUrl !== url) {
|
|
@@ -359,6 +360,4 @@ const Viewer = () => {
|
|
|
359
360
|
transform: isolated || scale === 1 ? "none" : "scale(" + scale + ")",
|
|
360
361
|
}, title: entry.name, width: size?.[0] ?? "100%", height: size?.[1] ?? "100%", src: frameUrl }, frameUrl) }) }), selected === "Playground" && !!page.PropsSchema && (_jsx(Controls, { schema: page.PropsSchema, values: values, onChange: setValues }))] })) })] }));
|
|
361
362
|
};
|
|
362
|
-
const
|
|
363
|
-
if (container)
|
|
364
|
-
createRoot(container).render(_jsx(React.Suspense, { fallback: frame && parent !== window ? _jsx(FrameLoading, {}) : _jsx(Spinner, {}), children: _jsx(Viewer, {}) }));
|
|
363
|
+
export const Viewer = () => (_jsx(React.Suspense, { fallback: frame && parent !== window ? _jsx(FrameLoading, {}) : _jsx(Spinner, {}), children: _jsx(Catalog, {}) }));
|
package/dist/cli.js
CHANGED
|
@@ -63,10 +63,11 @@ const frameworkPlugins = (preset.default.plugins ?? [])
|
|
|
63
63
|
/^(vite:react|preact:|vite:preact|prefresh$)/.test(plugin.name));
|
|
64
64
|
const htmlId = path.join(root, "index.html");
|
|
65
65
|
const extension = import.meta.filename.endsWith(".ts") ? "tsx" : "js";
|
|
66
|
-
const entry = `/@miral/
|
|
66
|
+
const entry = `/@miral/main.${extension}`;
|
|
67
67
|
const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Miral</title></head><body><div id="root"></div><script type="module" src="${entry}"></script></body></html>`;
|
|
68
68
|
const sources = new Map();
|
|
69
69
|
for (const name of [
|
|
70
|
+
"main",
|
|
70
71
|
"Viewer",
|
|
71
72
|
"icons",
|
|
72
73
|
"Assets",
|
package/dist/main.js
ADDED