@cervio/plugin-sdk 2.1.1 → 2.2.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.
package/dist/index.d.ts CHANGED
@@ -269,6 +269,41 @@ type CervioUiLocationResult = {
269
269
  lng: number;
270
270
  accuracy?: number;
271
271
  } | null;
272
+ /** Plain text, or text per UI locale (`{ it: '…', en: '…' }`). */
273
+ type CervioUiHeaderText = string | Record<string, string>;
274
+ /** State of the host section header (`CervioUI.header.get()`). */
275
+ interface CervioUiHeaderState {
276
+ /** Tab on screen; null when the header has no tabs. */
277
+ activeTab: string | null;
278
+ /** Tab ids declared in the manifest `header.tabs`. */
279
+ tabs: string[];
280
+ /** Action ids declared in the manifest `header.actions`. */
281
+ actions: string[];
282
+ }
283
+ interface CervioUiHeaderUpdateOptions {
284
+ /** Breadcrumb title (`Title > Tab` in the app header). */
285
+ title?: CervioUiHeaderText;
286
+ }
287
+ interface CervioUiHeaderActionOptions {
288
+ disabled?: boolean;
289
+ hidden?: boolean;
290
+ }
291
+ type CervioUiHeaderTabEvent = {
292
+ __cervioUI: 1;
293
+ event: 'header.tab.change';
294
+ tabId: string | null;
295
+ /** `init`: the document just loaded; `user`: click in the header. */
296
+ from: 'init' | 'user';
297
+ };
298
+ type CervioUiHeaderActionEvent = {
299
+ __cervioUI: 1;
300
+ event: 'header.action';
301
+ actionId: string;
302
+ };
303
+ interface CervioUiHeaderEventMap {
304
+ tab: CervioUiHeaderTabEvent;
305
+ action: CervioUiHeaderActionEvent;
306
+ }
272
307
  interface CervioUI {
273
308
  apiVersion: typeof CERVIO_UI_API_VERSION;
274
309
  capabilities(): Promise<string[]>;
@@ -454,6 +489,33 @@ interface CervioUI {
454
489
  entityDataId: string;
455
490
  }): Promise<CervioUiTaskListItem[]>;
456
491
  };
492
+ /**
493
+ * Experimental (capability `header`): tab row drawn by the host above a route
494
+ * plugin, like the Admin area pages (tabs and actions on a fixed row, title in
495
+ * the app header breadcrumb), declared in the manifest `header` block. Rejects with
496
+ * `header_unavailable` when the plugin declares no header (or in task plugins),
497
+ * `unknown_id` for a tab / action id not in the manifest. Check
498
+ * `capabilities()` for `header` on older hosts (the namespace is then missing).
499
+ */
500
+ header?: {
501
+ get(): Promise<CervioUiHeaderState>;
502
+ update(opts: CervioUiHeaderUpdateOptions): Promise<{
503
+ ok: true;
504
+ }>;
505
+ /** Selects a tab from code; emits no `tab` event. */
506
+ setTab(tabId: string): Promise<{
507
+ ok: true;
508
+ }>;
509
+ /** Counter on a tab; `null` or `0` removes it (max 9999). */
510
+ setBadge(tabId: string, value: number | null): Promise<{
511
+ ok: true;
512
+ }>;
513
+ setAction(actionId: string, opts: CervioUiHeaderActionOptions): Promise<{
514
+ ok: true;
515
+ }>;
516
+ /** Subscribe to header events; returns the unsubscribe function. */
517
+ on<K extends keyof CervioUiHeaderEventMap>(name: K, listener: (event: CervioUiHeaderEventMap[K]) => void): () => void;
518
+ };
457
519
  }
458
520
  declare global {
459
521
  interface Window {
@@ -497,7 +559,7 @@ type CervioUiSurfaceClosedEvent = {
497
559
  event: 'dialog.surface.closed';
498
560
  reason: 'host' | 'plugin' | 'escape';
499
561
  };
500
- type CervioUiHostEvent = CervioUiFrameMetricsEvent | CervioUiFrameClosedEvent | CervioUiSurfaceOpenedEvent | CervioUiSurfaceMessageEvent | CervioUiSurfaceClosedEvent;
562
+ type CervioUiHostEvent = CervioUiHeaderTabEvent | CervioUiHeaderActionEvent | CervioUiFrameMetricsEvent | CervioUiFrameClosedEvent | CervioUiSurfaceOpenedEvent | CervioUiSurfaceMessageEvent | CervioUiSurfaceClosedEvent;
501
563
 
502
564
  /**
503
565
  * Typed access to `window.__CERVIO_PLUGIN_CONTEXT__`, the boot payload the
@@ -927,4 +989,4 @@ interface CervioI18n {
927
989
  declare function createI18n(opts: CreateI18nOptions): CervioI18n;
928
990
 
929
991
  export { CERVIO_UI_API_VERSION, CervioApiError, createCervioClient, createCervioSessionClient, createI18n, ensureExternalConnection, findEntityByName, getCervioUI, getCurrentTheme, getPluginContext, getTaskPluginContext, isCervioUIAvailable, isInsideCervioSandbox, markReady, onThemeChange, openExternalAuth, resolveApiBaseUrl, resolvePluginLocale, setTaskDraft, submitTaskOutcome };
930
- export type { CervioClient, CervioClientOptions, CervioColorScheme, CervioHostThemeMessage, CervioI18n, CervioI18nCatalog, CervioI18nMessages, CervioPluginContext, CervioPluginRuntimeSettings, CervioSessionClient, CervioSessionClientOptions, CervioTaskDraftResult, CervioTaskOutcome, CervioTaskPluginBoot, CervioTaskPluginContextData, CervioTaskSubmitResult, CervioThemeChangeHandler, CervioThemeSnapshot, CervioUI, CervioUiActionSheetAction, CervioUiActionSheetOpenOptions, CervioUiAlertOptions, CervioUiBarcodeScanOptions, CervioUiBarcodeScanResult, CervioUiCameraOpenOptions, CervioUiConfirmOptions, CervioUiDateOpenOptions, CervioUiDialogVariant, CervioUiDomainPickOption, CervioUiEntityPickOptions, CervioUiExportDownloadOptions, CervioUiFileMeta, CervioUiFilesCaptureOptions, CervioUiFilesPickOptions, CervioUiFilesPickResult, CervioUiFilesUploadOptions, CervioUiFilesUploadResult, CervioUiFormatSnapshot, CervioUiFrameClosedEvent, CervioUiFrameMetricsEvent, CervioUiFrameOpenOptions, CervioUiFrameSize, CervioUiFrameSlot, CervioUiGroupPickOptions, CervioUiHostEvent, CervioUiLocationPickOptions, CervioUiLocationResult, CervioUiNavConfirmLeaveOptions, CervioUiPrintOpenOptions, CervioUiProgressShowOptions, CervioUiProgressUpdateOptions, CervioUiRecordPickOptions, CervioUiSelectOpenOptions, CervioUiSelectOption, CervioUiShareOpenOptions, CervioUiShareResult, CervioUiSheetAction, CervioUiSheetOpenOptions, CervioUiSurfaceClosedEvent, CervioUiSurfaceMessageEvent, CervioUiSurfaceOpenOptions, CervioUiSurfaceOpenedEvent, CervioUiTaskCompleteOptions, CervioUiTaskCompleteResult, CervioUiTaskListItem, CervioUiTaskOpenResult, CervioUiTaskOutcome, CervioUiTaskSummary, CervioUiThemeSnapshot, CervioUiToastOptions, CervioUiToastType, CervioUiUserPickOptions, CreateI18nOptions, Entity, EntityCapabilities, EntityRecord, ExternalConnectionStatus, ExternalProxyInput, Identity, ListViewRecordsOptions, RecordWriteOptions, ResolvePluginLocaleOptions, UpdateRecordOptions, ViewRecordsPage };
992
+ export type { CervioClient, CervioClientOptions, CervioColorScheme, CervioHostThemeMessage, CervioI18n, CervioI18nCatalog, CervioI18nMessages, CervioPluginContext, CervioPluginRuntimeSettings, CervioSessionClient, CervioSessionClientOptions, CervioTaskDraftResult, CervioTaskOutcome, CervioTaskPluginBoot, CervioTaskPluginContextData, CervioTaskSubmitResult, CervioThemeChangeHandler, CervioThemeSnapshot, CervioUI, CervioUiActionSheetAction, CervioUiActionSheetOpenOptions, CervioUiAlertOptions, CervioUiBarcodeScanOptions, CervioUiBarcodeScanResult, CervioUiCameraOpenOptions, CervioUiConfirmOptions, CervioUiDateOpenOptions, CervioUiDialogVariant, CervioUiDomainPickOption, CervioUiEntityPickOptions, CervioUiExportDownloadOptions, CervioUiFileMeta, CervioUiFilesCaptureOptions, CervioUiFilesPickOptions, CervioUiFilesPickResult, CervioUiFilesUploadOptions, CervioUiFilesUploadResult, CervioUiFormatSnapshot, CervioUiFrameClosedEvent, CervioUiFrameMetricsEvent, CervioUiFrameOpenOptions, CervioUiFrameSize, CervioUiFrameSlot, CervioUiGroupPickOptions, CervioUiHeaderActionEvent, CervioUiHeaderActionOptions, CervioUiHeaderEventMap, CervioUiHeaderState, CervioUiHeaderTabEvent, CervioUiHeaderText, CervioUiHeaderUpdateOptions, CervioUiHostEvent, CervioUiLocationPickOptions, CervioUiLocationResult, CervioUiNavConfirmLeaveOptions, CervioUiPrintOpenOptions, CervioUiProgressShowOptions, CervioUiProgressUpdateOptions, CervioUiRecordPickOptions, CervioUiSelectOpenOptions, CervioUiSelectOption, CervioUiShareOpenOptions, CervioUiShareResult, CervioUiSheetAction, CervioUiSheetOpenOptions, CervioUiSurfaceClosedEvent, CervioUiSurfaceMessageEvent, CervioUiSurfaceOpenOptions, CervioUiSurfaceOpenedEvent, CervioUiTaskCompleteOptions, CervioUiTaskCompleteResult, CervioUiTaskListItem, CervioUiTaskOpenResult, CervioUiTaskOutcome, CervioUiTaskSummary, CervioUiThemeSnapshot, CervioUiToastOptions, CervioUiToastType, CervioUiUserPickOptions, CreateI18nOptions, Entity, EntityCapabilities, EntityRecord, ExternalConnectionStatus, ExternalProxyInput, Identity, ListViewRecordsOptions, RecordWriteOptions, ResolvePluginLocaleOptions, UpdateRecordOptions, ViewRecordsPage };
package/dist/pdf/index.js CHANGED
@@ -236,13 +236,18 @@ function PdfViewer({ url, activePage, onPageChange, renderPageOverlay, locale =
236
236
  setPageSize({ width: viewport.width, height: viewport.height });
237
237
  const canvas = canvasRef.current;
238
238
  if (!canvas) return;
239
- canvas.width = viewport.width;
240
- canvas.height = viewport.height;
239
+ const dpr = typeof window !== "undefined" ? Math.min(window.devicePixelRatio || 1, 3) : 1;
240
+ canvas.width = Math.floor(viewport.width * dpr);
241
+ canvas.height = Math.floor(viewport.height * dpr);
241
242
  canvas.style.width = `${viewport.width}px`;
242
243
  canvas.style.height = `${viewport.height}px`;
243
244
  const ctx = canvas.getContext("2d");
244
245
  if (!ctx) return;
245
- await p.render({ canvasContext: ctx, viewport }).promise;
246
+ await p.render({
247
+ canvasContext: ctx,
248
+ viewport,
249
+ ...dpr !== 1 ? { transform: [dpr, 0, 0, dpr, 0, 0] } : {}
250
+ }).promise;
246
251
  if (cancelled) return;
247
252
  textLayerInstanceRef.current?.cancel();
248
253
  const textLayerDiv = textLayerRef.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cervio/plugin-sdk",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "SDK for Cervio plugins: CervioUI client, plugin context, /api/v1 client, theme sync, i18n, PDF viewer (./pdf) and write-gate helpers (./policy).",
5
5
  "keywords": [
6
6
  "cervio",
@@ -63,7 +63,7 @@
63
63
  "tsup": "^9.0.0",
64
64
  "typescript": "^5.8.3",
65
65
  "vitest": "^5.0.5",
66
- "@cervio/plugin-core": "^1.2.0"
66
+ "@cervio/plugin-core": "^1.5.0"
67
67
  },
68
68
  "publishConfig": {
69
69
  "access": "public"