pagiera 0.2.0-alpha.41 → 0.2.0-alpha.42
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/full-editor.js +18 -6
- package/dist/full-editor.js.map +2 -2
- package/dist/internal/app/p/editor/template-preview.d.ts +3 -1
- package/dist/internal/app/p/editor/template-preview.d.ts.map +1 -1
- package/dist/internal/app/p/editor/template-preview.js +17 -5
- package/dist/internal/app/p/editor/template-preview.js.map +1 -1
- package/dist/internal/app/p/editor/templates-panel.d.ts.map +1 -1
- package/dist/internal/app/p/editor/templates-panel.js +6 -1
- package/dist/internal/app/p/editor/templates-panel.js.map +1 -1
- package/dist/server.js +22 -11
- package/dist/server.js.map +2 -2
- package/package.json +1 -1
package/dist/full-editor.js
CHANGED
|
@@ -9801,16 +9801,23 @@ var FALLBACK_DEVICES = [
|
|
|
9801
9801
|
{ id: "tablet", name: "Tablet", width: 834 },
|
|
9802
9802
|
{ id: "mobile", name: "Mobile", width: 390 }
|
|
9803
9803
|
];
|
|
9804
|
-
function previewUrlFor(templateId) {
|
|
9805
|
-
|
|
9804
|
+
function previewUrlFor(templateId, force) {
|
|
9805
|
+
const base = `${DEFAULT_TEMPLATE_REGISTRY_URL.replace(/registry\.json$/, "")}${encodeURIComponent(templateId)}/preview`;
|
|
9806
|
+
return force ? `${base}?refresh=1` : base;
|
|
9806
9807
|
}
|
|
9807
|
-
function useTemplatePreview(templateId) {
|
|
9808
|
+
function useTemplatePreview(templateId, revision = 0) {
|
|
9808
9809
|
const [pages, setPages] = useState12();
|
|
9809
9810
|
const [error, setError] = useState12("");
|
|
9810
9811
|
const [loading, setLoading] = useState12(false);
|
|
9811
9812
|
const cache = useRef4(/* @__PURE__ */ new Map());
|
|
9813
|
+
const lastRevision = useRef4(revision);
|
|
9812
9814
|
useEffect9(() => {
|
|
9813
9815
|
if (!templateId) return;
|
|
9816
|
+
const force = revision !== lastRevision.current;
|
|
9817
|
+
if (force) {
|
|
9818
|
+
cache.current.clear();
|
|
9819
|
+
lastRevision.current = revision;
|
|
9820
|
+
}
|
|
9814
9821
|
const cached = cache.current.get(templateId);
|
|
9815
9822
|
if (cached) {
|
|
9816
9823
|
setPages(cached);
|
|
@@ -9821,7 +9828,10 @@ function useTemplatePreview(templateId) {
|
|
|
9821
9828
|
setLoading(true);
|
|
9822
9829
|
setError("");
|
|
9823
9830
|
setPages(void 0);
|
|
9824
|
-
fetch(previewUrlFor(templateId
|
|
9831
|
+
fetch(previewUrlFor(templateId, force), {
|
|
9832
|
+
headers: { Accept: "application/json" },
|
|
9833
|
+
cache: force ? "no-store" : "default"
|
|
9834
|
+
}).then(async (response) => {
|
|
9825
9835
|
const payload = await response.json().catch(() => ({}));
|
|
9826
9836
|
if (!response.ok) throw new Error(payload?.error ?? `Preview returned ${response.status}.`);
|
|
9827
9837
|
if (!Array.isArray(payload?.pages) || payload.pages.length === 0) {
|
|
@@ -9841,7 +9851,7 @@ function useTemplatePreview(templateId) {
|
|
|
9841
9851
|
return () => {
|
|
9842
9852
|
active = false;
|
|
9843
9853
|
};
|
|
9844
|
-
}, [templateId]);
|
|
9854
|
+
}, [templateId, revision]);
|
|
9845
9855
|
return { pages, loading, error };
|
|
9846
9856
|
}
|
|
9847
9857
|
function devicesFor(page) {
|
|
@@ -9981,7 +9991,8 @@ function TemplatesPanel({
|
|
|
9981
9991
|
const [selectedFont, setSelectedFont] = useState13("");
|
|
9982
9992
|
const [portalContainer, setPortalContainer] = useState13(null);
|
|
9983
9993
|
const providerFonts = usePagieraFonts2();
|
|
9984
|
-
const
|
|
9994
|
+
const [catalogRevision, setCatalogRevision] = useState13(0);
|
|
9995
|
+
const preview = useTemplatePreview(pendingTemplate?.id, catalogRevision);
|
|
9985
9996
|
const fontOptions = useMemo3(() => {
|
|
9986
9997
|
const options = [
|
|
9987
9998
|
...pendingTemplate?.font?.url ? [{ label: `${pendingTemplate.font.title} \xB7 Template`, value: pendingTemplate.font.family }] : [],
|
|
@@ -9993,6 +10004,7 @@ function TemplatesPanel({
|
|
|
9993
10004
|
const refresh = async (force = false) => {
|
|
9994
10005
|
setStatus("loading");
|
|
9995
10006
|
setError("");
|
|
10007
|
+
if (force) setCatalogRevision((current) => current + 1);
|
|
9996
10008
|
const result = await loadTemplateRegistry(registryUrl, force);
|
|
9997
10009
|
setTemplates(result.registry.templates);
|
|
9998
10010
|
setStatus(result.source);
|