@opengeni/react 5.2.0-canary.1 → 6.0.0-canary.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.
@@ -1,5 +1,15 @@
1
1
  // src/timeline/retained-image.ts
2
2
  import { useEffect, useRef, useState } from "react";
3
+ function isRetainedImageContentType(contentType) {
4
+ return [
5
+ "image/png",
6
+ "image/jpeg",
7
+ "image/gif",
8
+ "image/webp",
9
+ "image/avif",
10
+ "image/svg+xml"
11
+ ].includes(contentType);
12
+ }
3
13
  function useRetainedImageObjectUrl(artifact, load) {
4
14
  const [state, setState] = useState({ kind: "loading" });
5
15
  const artifactValue = retainedArtifactValue(artifact);
@@ -68,6 +78,7 @@ function retainedArtifactValue(artifact) {
68
78
  }
69
79
 
70
80
  export {
81
+ isRetainedImageContentType,
71
82
  useRetainedImageObjectUrl
72
83
  };
73
- //# sourceMappingURL=chunk-2TKI3WEG.js.map
84
+ //# sourceMappingURL=chunk-WYWRYUNQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/timeline/retained-image.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport type { RetainedArtifactReference } from \"@opengeni/sdk\";\nimport type { ToolRendererProps } from \"./registry\";\ntype RetainedImageState =\n | { kind: \"loading\" }\n | { kind: \"ready\"; url: string }\n | { kind: \"unavailable\"; label: string }\n | { kind: \"error\"; message: string };\n\n/** Shared browser preview allowlist; other published files remain downloads. */\nexport function isRetainedImageContentType(contentType: string): boolean {\n return [\n \"image/png\",\n \"image/jpeg\",\n \"image/gif\",\n \"image/webp\",\n \"image/avif\",\n \"image/svg+xml\",\n ].includes(contentType);\n}\n\nexport function useRetainedImageObjectUrl(\n artifact: RetainedArtifactReference,\n load: ToolRendererProps[\"loadRetainedArtifact\"],\n): RetainedImageState {\n const [state, setState] = useState<RetainedImageState>({ kind: \"loading\" });\n // Function outputs are commonly serialized JSON. Parsing them creates a new\n // object on every render, so depend on the immutable wire value rather than\n // object identity; otherwise the loader can refetch after its own setState.\n const artifactValue = retainedArtifactValue(artifact);\n const stableArtifactRef = useRef({ value: artifactValue, artifact });\n if (stableArtifactRef.current.value !== artifactValue) {\n stableArtifactRef.current = { value: artifactValue, artifact };\n }\n const stableArtifact = stableArtifactRef.current.artifact;\n useEffect(() => {\n if (!load) {\n setState({ kind: \"unavailable\", label: \"retrieval is not configured\" });\n return;\n }\n const controller = new AbortController();\n let objectUrl: string | null = null;\n setState({ kind: \"loading\" });\n void load(stableArtifact, controller.signal)\n .then((source) => {\n if (controller.signal.aborted) return;\n if (!source) {\n setState({ kind: \"unavailable\", label: \"bytes are unavailable\" });\n return;\n }\n if (!(source instanceof Uint8Array)) {\n if (!source.url.trim()) {\n setState({ kind: \"unavailable\", label: \"URL is unavailable\" });\n return;\n }\n setState({ kind: \"ready\", url: source.url });\n return;\n }\n objectUrl = URL.createObjectURL(\n new Blob([source as unknown as BlobPart], { type: stableArtifact.contentType }),\n );\n setState({ kind: \"ready\", url: objectUrl });\n })\n .catch((error: unknown) => {\n if (controller.signal.aborted) return;\n const status =\n error && typeof error === \"object\" && \"status\" in error\n ? Number((error as { status?: unknown }).status)\n : null;\n setState(\n status === 404\n ? { kind: \"unavailable\", label: \"deleted\" }\n : status === 410\n ? { kind: \"unavailable\", label: \"expired or unavailable\" }\n : { kind: \"error\", message: \"retrieval failed\" },\n );\n });\n return () => {\n controller.abort();\n if (objectUrl) URL.revokeObjectURL(objectUrl);\n };\n }, [stableArtifact, load]);\n return state;\n}\n\nfunction retainedArtifactValue(artifact: RetainedArtifactReference): string {\n return [\n artifact.artifactId,\n artifact.kind,\n artifact.contentType,\n artifact.originalBytes,\n artifact.sha256,\n artifact.retainedAt,\n artifact.dimensions?.width ?? \"\",\n artifact.dimensions?.height ?? \"\",\n artifact.retention.policy,\n artifact.retention.expiresAt ?? \"\",\n artifact.retrieval.method,\n artifact.retrieval.path,\n artifact.retrieval.acceptRanges,\n artifact.retrieval.maxRangeBytes,\n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eAAS,EAAE,MAAM,SAAS,KAAK,UAAU,CAAC;AAAA,IAC5C,CAAC,EACA,MAAM,CAAC,UAAmB;AACzB,UAAI,WAAW,OAAO,QAAS;AAC/B,YAAM,SACJ,SAAS,OAAO,UAAU,YAAY,YAAY,QAC9C,OAAQ,MAA+B,MAAM,IAC7C;AACN;AAAA,QACE,WAAW,MACP,EAAE,MAAM,eAAe,OAAO,UAAU,IACxC,WAAW,MACT,EAAE,MAAM,eAAe,OAAO,yBAAyB,IACvD,EAAE,MAAM,SAAS,SAAS,mBAAmB;AAAA,MACrD;AAAA,IACF,CAAC;AACH,WAAO,MAAM;AACX,iBAAW,MAAM;AACjB,UAAI,UAAW,KAAI,gBAAgB,SAAS;AAAA,IAC9C;AAAA,EACF,GAAG,CAAC,gBAAgB,IAAI,CAAC;AACzB,SAAO;AACT;AAEA,SAAS,sBAAsB,UAA6C;AAC1E,SAAO;AAAA,IACL,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS,YAAY,SAAS;AAAA,IAC9B,SAAS,YAAY,UAAU;AAAA,IAC/B,SAAS,UAAU;AAAA,IACnB,SAAS,UAAU,aAAa;AAAA,IAChC,SAAS,UAAU;AAAA,IACnB,SAAS,UAAU;AAAA,IACnB,SAAS,UAAU;AAAA,IACnB,SAAS,UAAU;AAAA,EACrB,EAAE,KAAK,IAAI;AACb;","names":[]}
package/dist/connect.js CHANGED
@@ -326,20 +326,8 @@ function ScopedSetup({ controller, onAuthorize, onBrowseResources, className })
326
326
 
327
327
  // src/connection-catalog.tsx
328
328
  import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
329
- function ConnectionDetailsAction({
330
- option,
331
- name = option.name
332
- }) {
333
- return /* @__PURE__ */ jsx3(
334
- "button",
335
- {
336
- type: "button",
337
- className: "og-connection-details-action",
338
- "aria-label": `View ${name} details`,
339
- onClick: option.onOpen,
340
- children: /* @__PURE__ */ jsx3("span", { "aria-hidden": true, children: option.connected ? "\u203A" : "+" })
341
- }
342
- );
329
+ function ConnectionDetailsIndicator() {
330
+ return /* @__PURE__ */ jsx3("span", { "aria-hidden": true, className: "og-connection-group-chevron", children: "\u203A" });
343
331
  }
344
332
  function ConnectionOptionRow({ option }) {
345
333
  return /* @__PURE__ */ jsxs3("div", { className: "og-connection-catalog-action-row og-connection-option", children: [
@@ -348,9 +336,10 @@ function ConnectionOptionRow({ option }) {
348
336
  /* @__PURE__ */ jsx3("strong", { children: option.name }),
349
337
  /* @__PURE__ */ jsx3("span", { children: option.description })
350
338
  ] }),
351
- /* @__PURE__ */ jsx3("span", { className: "og-connection-catalog-status", children: option.status })
339
+ /* @__PURE__ */ jsx3("span", { className: "og-connection-catalog-status", children: option.status }),
340
+ !option.action ? /* @__PURE__ */ jsx3(ConnectionDetailsIndicator, {}) : null
352
341
  ] }),
353
- /* @__PURE__ */ jsx3("span", { className: "og-connection-option-action", children: option.action ?? /* @__PURE__ */ jsx3(ConnectionDetailsAction, { option }) })
342
+ option.action ? /* @__PURE__ */ jsx3("span", { className: "og-connection-option-action", children: option.action }) : null
354
343
  ] });
355
344
  }
356
345
  function ConnectionServiceRow({ service }) {
@@ -365,16 +354,19 @@ function ConnectionServiceRow({ service }) {
365
354
  /* @__PURE__ */ jsx3("span", { className: "og-connection-catalog-status", children: service.options.length === 1 ? service.options[0]?.status : `${connected} of ${service.options.length} connected` })
366
355
  ] });
367
356
  return service.options.length === 1 ? /* @__PURE__ */ jsxs3("div", { className: "og-connection-catalog-action-row", children: [
368
- /* @__PURE__ */ jsx3(
357
+ /* @__PURE__ */ jsxs3(
369
358
  "button",
370
359
  {
371
360
  type: "button",
372
361
  className: "og-connection-catalog-row",
373
362
  onClick: service.options[0].onOpen,
374
- children: identity
363
+ children: [
364
+ identity,
365
+ !service.options[0]?.action ? /* @__PURE__ */ jsx3(ConnectionDetailsIndicator, {}) : null
366
+ ]
375
367
  }
376
368
  ),
377
- service.options[0]?.action ?? /* @__PURE__ */ jsx3(ConnectionDetailsAction, { option: service.options[0], name: service.name })
369
+ service.options[0]?.action
378
370
  ] }) : /* @__PURE__ */ jsxs3("details", { className: "og-connection-catalog-service", children: [
379
371
  /* @__PURE__ */ jsxs3("summary", { className: "og-connection-catalog-row", children: [
380
372
  identity,