@burdenoff/microfe-vibecontrols 2026.1112.1 → 2026.1113.1
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.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface StoreImageProps {
|
|
3
|
+
/** Raw image value from the store API. */
|
|
4
|
+
src: string | null | undefined;
|
|
5
|
+
/** Rendered when the value is not renderable or the image fails to load. */
|
|
6
|
+
fallback: ReactNode;
|
|
7
|
+
alt?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* `<img>` for store catalogue imagery. Values that cannot render (see
|
|
12
|
+
* `classifyStoreImageSrc`) never reach the DOM, and an image that fails to
|
|
13
|
+
* load is swapped for `fallback`. The error state is keyed to the source, so
|
|
14
|
+
* a new `src` gets a fresh attempt.
|
|
15
|
+
*/
|
|
16
|
+
export declare function StoreImage({ src, fallback, alt, className }: StoreImageProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { classifyStoreImageSrc as e } from "../../lib/storeImage.js";
|
|
2
|
+
import { useState as t } from "react";
|
|
3
|
+
import { Fragment as n, jsx as r } from "react/jsx-runtime";
|
|
4
|
+
// src/components/plugins/StoreImage.tsx
|
|
5
|
+
function i({ src: i, fallback: a, alt: o = "", className: s }) {
|
|
6
|
+
let [c, l] = t(null), u = e(i);
|
|
7
|
+
if (u.kind === "none" || c === u.src) return /* @__PURE__ */ r(n, { children: a });
|
|
8
|
+
let d = u.src;
|
|
9
|
+
return /* @__PURE__ */ r("img", {
|
|
10
|
+
src: d,
|
|
11
|
+
alt: o,
|
|
12
|
+
className: s,
|
|
13
|
+
loading: "lazy",
|
|
14
|
+
decoding: "async",
|
|
15
|
+
referrerPolicy: "no-referrer",
|
|
16
|
+
onError: () => l(d)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export { i as StoreImage };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for rendering store catalogue imagery (product icons, banners,
|
|
3
|
+
* screenshots, publisher logos) safely in an `<img>`.
|
|
4
|
+
*
|
|
5
|
+
* Stored icon values are not always browser-renderable: bare Iconify names
|
|
6
|
+
* such as `mdi:robot`, presigned object-storage links that have expired, and
|
|
7
|
+
* insecure or exotic schemes all end up as broken images. global-store-svc
|
|
8
|
+
* resolves `StoreProduct.iconUrl` to an https URL or an offline-rendered
|
|
9
|
+
* `data:image/svg+xml` value (or null), so callers prefer it over the raw
|
|
10
|
+
* `icon` and still pass the result through {@link classifyStoreImageSrc}.
|
|
11
|
+
* This mirrors the helpers in `@burdenoff/web-sdk` (`src/store/store-image.tsx`).
|
|
12
|
+
*/
|
|
13
|
+
/** Result of deciding whether a stored image value can go into an `<img src>`. */
|
|
14
|
+
export type StoreImageSource = {
|
|
15
|
+
kind: 'url';
|
|
16
|
+
src: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'none';
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Decides whether a store image value is safe and likely to render.
|
|
22
|
+
*
|
|
23
|
+
* Accepted: absolute `https:` URLs that are not signed expiring links,
|
|
24
|
+
* `data:image/...` URIs, and root-relative paths such as `/icon.png`.
|
|
25
|
+
* Rejected: bare Iconify names, protocol-relative `//host` URLs, `http:`,
|
|
26
|
+
* `javascript:` and every other scheme, signed URLs, and empty or malformed
|
|
27
|
+
* values.
|
|
28
|
+
*/
|
|
29
|
+
export declare function classifyStoreImageSrc(value: string | null | undefined): StoreImageSource;
|
|
30
|
+
/**
|
|
31
|
+
* The image value to render for a store product's icon: the server-resolved
|
|
32
|
+
* `iconUrl` when present, else the raw `icon`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function storeProductIconSrc(product: {
|
|
35
|
+
icon?: string | null;
|
|
36
|
+
iconUrl?: string | null;
|
|
37
|
+
}): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* True when a GraphQL response failed only because the gateway's supergraph
|
|
40
|
+
* does not know `StoreProduct.iconUrl` yet (for example a stale CDN edge or an
|
|
41
|
+
* environment that has not picked up the field). The caller then retries the
|
|
42
|
+
* query without that field.
|
|
43
|
+
*/
|
|
44
|
+
export declare function storeQueryRejectedIconUrl(body: {
|
|
45
|
+
data?: unknown;
|
|
46
|
+
errors?: ReadonlyArray<{
|
|
47
|
+
message?: string;
|
|
48
|
+
}>;
|
|
49
|
+
}): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/lib/storeImage.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"x-amz-signature",
|
|
4
|
+
"x-amz-expires",
|
|
5
|
+
"x-amz-credential",
|
|
6
|
+
"x-goog-signature",
|
|
7
|
+
"x-goog-expires"
|
|
8
|
+
], t = { kind: "none" };
|
|
9
|
+
function n(t) {
|
|
10
|
+
for (let n of t.searchParams.keys()) if (e.includes(n.toLowerCase())) return !0;
|
|
11
|
+
return !1;
|
|
12
|
+
}
|
|
13
|
+
function r(e) {
|
|
14
|
+
if (typeof e != "string") return t;
|
|
15
|
+
let r = e.trim();
|
|
16
|
+
if (!r) return t;
|
|
17
|
+
if (/^data:image\//i.test(r)) return {
|
|
18
|
+
kind: "url",
|
|
19
|
+
src: r
|
|
20
|
+
};
|
|
21
|
+
if (r.startsWith("/")) return r.startsWith("//") || r.startsWith("/\\") ? t : {
|
|
22
|
+
kind: "url",
|
|
23
|
+
src: r
|
|
24
|
+
};
|
|
25
|
+
let i;
|
|
26
|
+
try {
|
|
27
|
+
i = new URL(r);
|
|
28
|
+
} catch {
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
return i.protocol !== "https:" || !i.hostname || n(i) ? t : {
|
|
32
|
+
kind: "url",
|
|
33
|
+
src: r
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function i(e) {
|
|
37
|
+
return e.iconUrl ?? e.icon ?? null;
|
|
38
|
+
}
|
|
39
|
+
function a(e) {
|
|
40
|
+
return e.errors?.length ? e.errors.some((e) => typeof e.message == "string" && /Cannot query field ["']?iconUrl["']?/i.test(e.message)) : !1;
|
|
41
|
+
}
|
|
42
|
+
export { r as classifyStoreImageSrc, i as storeProductIconSrc, a as storeQueryRejectedIconUrl };
|