@uxland/primary-shell 7.46.2 → 7.46.4

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.
Files changed (27) hide show
  1. package/dist/{component-BE8pBQfD.js → component-BDnhxP4N.js} +2 -2
  2. package/dist/{component-BE8pBQfD.js.map → component-BDnhxP4N.js.map} +1 -1
  3. package/dist/{index-JPNbnLH1.js → index-D9vfVpB7.js} +14958 -22584
  4. package/dist/index-D9vfVpB7.js.map +1 -0
  5. package/dist/index.js +13 -16
  6. package/dist/index.umd.cjs +954 -954
  7. package/dist/index.umd.cjs.map +1 -1
  8. package/dist/plugin-C76XiACG.js +7591 -0
  9. package/dist/plugin-C76XiACG.js.map +1 -0
  10. package/dist/primary/shell/src/UI/components/clinical-pathways-action-menu/clinical-pathways-action-menu.d.ts +1 -1
  11. package/dist/primary/shell/src/UI/components/communication-action-menu/communication-action-menu.d.ts +1 -1
  12. package/dist/primary/shell/src/UI/components/petitioner-action-menu/petitioner-action-menu.d.ts +1 -1
  13. package/dist/primary/shell/src/UI/components/primaria-shell/primaria-shell.d.ts +0 -1
  14. package/dist/primary/shell/src/api/broker/broker-events.d.ts +0 -2
  15. package/dist/primary/shell/src/api/token-manager/token-manager.d.ts +15 -2
  16. package/dist/primary/shell/src/index.d.ts +3 -1
  17. package/package.json +1 -1
  18. package/src/UI/components/clinical-pathways-action-menu/clinical-pathways-action-menu.ts +6 -5
  19. package/src/UI/components/communication-action-menu/communication-action-menu.ts +6 -5
  20. package/src/UI/components/petitioner-action-menu/petitioner-action-menu.ts +6 -5
  21. package/src/UI/components/primaria-shell/primaria-shell.ts +2 -92
  22. package/src/api/broker/broker-events.ts +0 -2
  23. package/src/api/token-manager/token-manager.ts +16 -2
  24. package/src/features/utils.ts +6 -3
  25. package/src/handle-plugins.ts +5 -9
  26. package/src/index.ts +9 -1
  27. package/dist/index-JPNbnLH1.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { PropertyValues } from 'lit';
2
1
  import { IRegion } from '@uxland/regions';
2
+ import { PropertyValues } from 'lit';
3
3
  declare const ClinicalPathwaysActionMenu_base: any;
4
4
  export declare class ClinicalPathwaysActionMenu extends ClinicalPathwaysActionMenu_base {
5
5
  constructor(icon: string, label: string);
@@ -1,5 +1,5 @@
1
- import { PropertyValues } from 'lit';
2
1
  import { IRegion } from '@uxland/regions';
2
+ import { PropertyValues } from 'lit';
3
3
  declare const CommunicationActionMenu_base: any;
4
4
  export declare class CommunicationActionMenu extends CommunicationActionMenu_base {
5
5
  constructor(icon: string, label: string);
@@ -1,5 +1,5 @@
1
- import { PropertyValues } from 'lit';
2
1
  import { IRegion } from '@uxland/regions';
2
+ import { PropertyValues } from 'lit';
3
3
  declare const PetitionerActionMenu_base: any;
4
4
  export declare class PetitionerActionMenu extends PetitionerActionMenu_base {
5
5
  constructor(icon: string, label: string);
@@ -24,6 +24,5 @@ export declare class PrimariaShell extends PrimariaShell_base {
24
24
  message: string;
25
25
  }): void;
26
26
  _unsubscribeEvents(): void;
27
- _scrollToNavItem(navItemMenuKey: string): Promise<void>;
28
27
  }
29
28
  export {};
@@ -21,8 +21,6 @@ export declare const BROKER_EVENTS: {
21
21
  readonly refreshTokenFailed: "refreshTokenFailed";
22
22
  readonly mpidHeaderInvalid: "mpidHeaderInvalid";
23
23
  readonly quickActionBusyChanged: "quickActionBusyChanged";
24
- readonly scrollToNavItemRequested: "scrollToNavItemRequested";
25
- readonly scrollToNavItemCompleted: "scrollToNavItemCompleted";
26
24
  };
27
25
  readonly administrativeManagement: {
28
26
  readonly tabSelected: "administrative_management_tab_selected";
@@ -1,10 +1,23 @@
1
1
  import { PrimariaBroker } from '../broker/primaria-broker';
2
+ /**
3
+ * API pública de tokens disponible per als plugins via `api.tokenManager`.
4
+ * Els plugins poden llegir el token actual o forçar-ne el refresc; NO han de
5
+ * fixar els tokens inicials (això és una responsabilitat del host de bootstrap
6
+ * — vegeu {@link InternalTokenManager}).
7
+ */
2
8
  export interface TokenManager {
3
- setInitialTokens: (access_token: string, refresh_token: string) => void;
4
9
  getToken: () => string;
5
10
  refreshToken: () => Promise<string>;
6
11
  }
7
- export declare class TokenManagerImpl implements TokenManager {
12
+ /**
13
+ * Extensió host-only de {@link TokenManager}. Només el host del shell
14
+ * (`primary/app`) usa `setInitialTokens` durant el bootstrap; és deliberadament
15
+ * absent del tipus `TokenManager` que veuen els plugins.
16
+ */
17
+ export interface InternalTokenManager extends TokenManager {
18
+ setInitialTokens: (access_token: string, refresh_token: string) => void;
19
+ }
20
+ export declare class TokenManagerImpl implements InternalTokenManager {
8
21
  private readonly broker;
9
22
  constructor(broker: PrimariaBroker);
10
23
  getUrlParams: () => URLSearchParams;
@@ -2,7 +2,9 @@ export * from './bootstrapper';
2
2
  export * from './disposer';
3
3
  export * from './api/region-manager/regions';
4
4
  export * from './handle-plugins';
5
- export * from './api/api';
5
+ export type { PrimariaApi } from './api/api';
6
+ export { PrimariaRegionHost, shellApi } from './api/api';
7
+ export type { TokenManager, InternalTokenManager } from './api/token-manager/token-manager';
6
8
  export * from './api/broker/primaria-broker';
7
9
  export type { PrimariaContextManager, EcapContext } from './api/context-manager/context-manager';
8
10
  export * from './UI/index';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "7.46.2",
3
+ "version": "7.46.4",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -1,9 +1,10 @@
1
- import { LitElement, html, css, unsafeCSS, PropertyValues } from "lit";
2
- import { template } from "./template";
3
- import { property, state } from "lit/decorators.js";
4
1
  import { IRegion, region } from "@uxland/regions";
5
- import { PrimariaRegionHost, shellApi } from "../../../api/api";
2
+ import { LitElement, PropertyValues, css, html, unsafeCSS } from "lit";
3
+ import { property, state } from "lit/decorators.js";
4
+ import { PrimariaRegionHost } from "../../../api/api";
5
+ import { shellRegions } from "../../../api/region-manager/regions";
6
6
  import styles from "./styles.css?inline";
7
+ import { template } from "./template";
7
8
 
8
9
  export class ClinicalPathwaysActionMenu extends PrimariaRegionHost(LitElement) {
9
10
  constructor(icon: string, label: string) {
@@ -14,7 +15,7 @@ export class ClinicalPathwaysActionMenu extends PrimariaRegionHost(LitElement) {
14
15
 
15
16
  @state() showText = false;
16
17
 
17
- @region({ targetId: "clinical-pathways-sidenav-region-container", name: shellApi.regionManager.regions.shell.clinicalPathwaysSidenav })
18
+ @region({ targetId: "clinical-pathways-sidenav-region-container", name: shellRegions.clinicalPathwaysSidenav })
18
19
  clinicalPathwaysSidenavRegion: IRegion | undefined;
19
20
 
20
21
  static styles = css`
@@ -1,9 +1,10 @@
1
- import { LitElement, html, css, unsafeCSS, PropertyValues } from "lit";
2
- import { template } from "./template";
3
- import { property, state } from "lit/decorators.js";
4
1
  import { IRegion, region } from "@uxland/regions";
5
- import { PrimariaRegionHost, shellApi } from "../../../api/api";
2
+ import { LitElement, PropertyValues, css, html, unsafeCSS } from "lit";
3
+ import { property, state } from "lit/decorators.js";
4
+ import { PrimariaRegionHost } from "../../../api/api";
5
+ import { shellRegions } from "../../../api/region-manager/regions";
6
6
  import styles from "./styles.css?inline";
7
+ import { template } from "./template";
7
8
 
8
9
  export class CommunicationActionMenu extends PrimariaRegionHost(LitElement) {
9
10
  constructor(icon: string, label: string) {
@@ -14,7 +15,7 @@ export class CommunicationActionMenu extends PrimariaRegionHost(LitElement) {
14
15
 
15
16
  @state() showText = false;
16
17
 
17
- @region({ targetId: "communication-sidenav-region-container", name: shellApi.regionManager.regions.shell.communicationSidenav })
18
+ @region({ targetId: "communication-sidenav-region-container", name: shellRegions.communicationSidenav })
18
19
  comminucationSidenavRegion: IRegion | undefined;
19
20
 
20
21
  static styles = css`
@@ -1,9 +1,10 @@
1
- import { LitElement, html, css, unsafeCSS, PropertyValues } from "lit";
2
- import { template } from "./template";
3
- import { property, state } from "lit/decorators.js";
4
1
  import { IRegion, region } from "@uxland/regions";
5
- import { PrimariaRegionHost, shellApi } from "../../../api/api";
2
+ import { LitElement, PropertyValues, css, html, unsafeCSS } from "lit";
3
+ import { property, state } from "lit/decorators.js";
4
+ import { PrimariaRegionHost } from "../../../api/api";
5
+ import { shellRegions } from "../../../api/region-manager/regions";
6
6
  import styles from "./styles.css?inline";
7
+ import { template } from "./template";
7
8
 
8
9
  export class PetitionerActionMenu extends PrimariaRegionHost(LitElement) {
9
10
  constructor(icon: string, label: string) {
@@ -14,7 +15,7 @@ export class PetitionerActionMenu extends PrimariaRegionHost(LitElement) {
14
15
 
15
16
  @state() showText = false;
16
17
 
17
- @region({ targetId: "petitioner-sidenav-region-container", name: shellApi.regionManager.regions.shell.petitionerSidenav })
18
+ @region({ targetId: "petitioner-sidenav-region-container", name: shellRegions.petitionerSidenav })
18
19
  petitionerSidenavRegion: IRegion | undefined;
19
20
 
20
21
  static styles = css`
@@ -1,14 +1,14 @@
1
+ import { BrokerDisposableHandler } from "@uxland/harmonix";
1
2
  import { IRegion, region } from "@uxland/regions";
2
3
  import { LitElement, css, html, unsafeCSS } from "lit";
3
4
  import { state } from "lit/decorators.js";
4
5
  import { PrimariaRegionHost, shellApi } from "../../../api/api";
5
- import { disposeShell } from "../../../disposer";
6
6
  import { BROKER_EVENTS } from "../../../api/broker/broker-events";
7
+ import { disposeShell } from "../../../disposer";
7
8
  import { translate } from "../../../locales";
8
9
  import { shellViews } from "./constants";
9
10
  import styles from "./styles.css?inline";
10
11
  import { template } from "./template";
11
- import { BrokerDisposableHandler } from "@uxland/harmonix";
12
12
 
13
13
  export class PrimariaShell extends PrimariaRegionHost(LitElement) {
14
14
  render() {
@@ -89,12 +89,6 @@ export class PrimariaShell extends PrimariaRegionHost(LitElement) {
89
89
  this.quickActionBusy = detail.busy;
90
90
  }),
91
91
  );
92
-
93
- this.subscriptions.push(
94
- shellApi.broker.subscribe(BROKER_EVENTS.shell.scrollToNavItemRequested, (navItemMenuKey: string) => {
95
- this._scrollToNavItem(navItemMenuKey);
96
- }),
97
- );
98
92
  }
99
93
 
100
94
  _handleError(error: { message: string }) {
@@ -106,88 +100,4 @@ export class PrimariaShell extends PrimariaRegionHost(LitElement) {
106
100
  _unsubscribeEvents() {
107
101
  this.subscriptions.forEach((s) => s.dispose());
108
102
  }
109
-
110
- async _scrollToNavItem(navItemMenuKey: string) {
111
- const region = await shellApi.regionManager.getRegion(shellApi.regionManager.regions.shell.navigationMenu);
112
-
113
- const allViews = region.currentActiveViews;
114
-
115
- // Extract the actual view id from the key (remove plugin prefix)
116
- // navItemMenuKey comes as "primaria-shell::pdf-viewer", we need just "pdf-viewer"
117
- const viewId = navItemMenuKey.includes("::") ? navItemMenuKey.split("::")[1] : navItemMenuKey;
118
-
119
- const targetView = allViews.find((view: any) => view.id === viewId);
120
-
121
- if (!targetView) {
122
- shellApi.broker.publish(BROKER_EVENTS.shell.scrollToNavItemCompleted, {
123
- scrollTop: 0,
124
- containerTop: 0,
125
- itemIndex: -1,
126
- });
127
- return;
128
- }
129
-
130
- // Sort views by sortHint to find the correct position
131
- const sortedViews = [...allViews].sort((a: any, b: any) => {
132
- const sortHintA = a.sortHint || "999";
133
- const sortHintB = b.sortHint || "999";
134
- return sortHintA.localeCompare(sortHintB);
135
- });
136
-
137
- const targetIndex = sortedViews.findIndex((view: any) => view.id === viewId);
138
-
139
- if (targetIndex === -1) {
140
- shellApi.broker.publish(BROKER_EVENTS.shell.scrollToNavItemCompleted, {
141
- scrollTop: 0,
142
- containerTop: 0,
143
- itemIndex: -1,
144
- });
145
- return;
146
- }
147
-
148
- const menuContainer = this.shadowRoot?.querySelector("#menu-region-container") as HTMLElement;
149
- if (!menuContainer) {
150
- shellApi.broker.publish(BROKER_EVENTS.shell.scrollToNavItemCompleted, {
151
- scrollTop: 0,
152
- containerTop: 0,
153
- itemIndex: targetIndex,
154
- });
155
- return;
156
- }
157
-
158
- const itemHeight = 51;
159
- const targetPosition = itemHeight * targetIndex;
160
- const containerHeight = menuContainer.clientHeight;
161
-
162
- // Scroll to position the item in the middle of the container
163
- const scrollPosition = targetPosition - containerHeight / 2 + itemHeight / 2;
164
- menuContainer.scrollTo({
165
- top: Math.max(0, scrollPosition),
166
- behavior: "smooth",
167
- });
168
-
169
- // Wait for scroll to complete and then publish the completed event
170
- setTimeout(() => {
171
- const containerRect = menuContainer.getBoundingClientRect();
172
-
173
- // Get all nav items from the container
174
- const navItems = Array.from(menuContainer.children) as HTMLElement[];
175
-
176
- // Find the actual DOM element for the target item
177
- let itemAbsoluteY = window.innerHeight / 2; // default fallback
178
-
179
- if (navItems[targetIndex]) {
180
- const itemRect = navItems[targetIndex].getBoundingClientRect();
181
- itemAbsoluteY = itemRect.top;
182
- }
183
-
184
- const data = {
185
- scrollTop: menuContainer.scrollTop,
186
- containerTop: containerRect.top,
187
- itemIndex: targetIndex,
188
- itemAbsoluteY: itemAbsoluteY,
189
- };
190
- shellApi.broker.publish(BROKER_EVENTS.shell.scrollToNavItemCompleted, data);
191
- }, 300);
192
- }
193
103
  }
@@ -21,8 +21,6 @@ export const BROKER_EVENTS = {
21
21
  refreshTokenFailed: "refreshTokenFailed",
22
22
  mpidHeaderInvalid: "mpidHeaderInvalid",
23
23
  quickActionBusyChanged: "quickActionBusyChanged",
24
- scrollToNavItemRequested: "scrollToNavItemRequested",
25
- scrollToNavItemCompleted: "scrollToNavItemCompleted",
26
24
  },
27
25
  administrativeManagement: {
28
26
  tabSelected: "administrative_management_tab_selected",
@@ -2,17 +2,31 @@ import axios from "axios";
2
2
  import { BROKER_EVENTS } from "../broker/broker-events";
3
3
  import { PrimariaBroker } from "../broker/primaria-broker";
4
4
 
5
+ /**
6
+ * API pública de tokens disponible per als plugins via `api.tokenManager`.
7
+ * Els plugins poden llegir el token actual o forçar-ne el refresc; NO han de
8
+ * fixar els tokens inicials (això és una responsabilitat del host de bootstrap
9
+ * — vegeu {@link InternalTokenManager}).
10
+ */
5
11
  export interface TokenManager {
6
- setInitialTokens: (access_token: string, refresh_token: string) => void;
7
12
  getToken: () => string;
8
13
  refreshToken: () => Promise<string>;
9
14
  }
10
15
 
16
+ /**
17
+ * Extensió host-only de {@link TokenManager}. Només el host del shell
18
+ * (`primary/app`) usa `setInitialTokens` durant el bootstrap; és deliberadament
19
+ * absent del tipus `TokenManager` que veuen els plugins.
20
+ */
21
+ export interface InternalTokenManager extends TokenManager {
22
+ setInitialTokens: (access_token: string, refresh_token: string) => void;
23
+ }
24
+
11
25
  let token: string;
12
26
  let refreshToken: string;
13
27
  let tokenInitialized = false;
14
28
 
15
- export class TokenManagerImpl implements TokenManager {
29
+ export class TokenManagerImpl implements InternalTokenManager {
16
30
  constructor(private readonly broker: PrimariaBroker) {}
17
31
 
18
32
  getUrlParams = (): URLSearchParams => {
@@ -3,10 +3,13 @@ import type { interfaces } from "inversify";
3
3
  import { IRequest, IRequestClass } from "..";
4
4
  import { PrimariaApi } from "../api/api";
5
5
 
6
- //TODO aixo ho fan ja les Broker extensions de plugins/core. Veure si s'ha de canviar
6
+ // Helper intern del shell: registra una request al broker i binda el seu handler
7
+ // al container d'Inversify. És el bessó del `registerRequest` de
8
+ // `@primaria/plugins-core` (brokerExtensions), però es manté aquí a propòsit:
9
+ // `plugins-core` depèn del shell (no al revés), i exposar aquest helper a l'API
10
+ // pública del shell la bloataria innecessàriament.
7
11
  export const registerRequest =
8
- (api: PrimariaApi, container: Container) =>
9
- (command: IRequestClass<any>, handler: interfaces.Newable<any>) => {
12
+ (api: PrimariaApi, container: Container) => (command: IRequestClass<any>, handler: interfaces.Newable<any>) => {
10
13
  container.bind(handler).to(handler).inTransientScope();
11
14
  injectable()(handler);
12
15
  const disposable = api.broker.registerRequest(command, (cmd: IRequest<any>) => {
@@ -1,9 +1,5 @@
1
1
  import type { BootstrappedPlugin, PluginDefinition, Plugin as PluginType } from "@uxland/harmonix";
2
2
  import { bootstrapPlugins as pluginBootstrapper } from "@uxland/harmonix";
3
- import {
4
- dispose as activityHistoryDispose,
5
- initialize as activityHistoryInitialize,
6
- } from "../../../plugins/activity-history/src/plugin";
7
3
  import { PrimariaApi, primariaApiFactory } from "./api/api";
8
4
  export type { PluginDefinition, PluginInfo } from "@uxland/harmonix";
9
5
 
@@ -29,13 +25,13 @@ const CORE_FIRST_ID = "activity-history";
29
25
  // from the plugin store (versioned/uploadable) like any other plugin; this
30
26
  // bundled copy is the fallback used when the caller does not provide it — e.g.
31
27
  // third-party sandboxes that install primary-shell without a plugin store.
28
+ //
29
+ // The import stays inside the importer on purpose: importing it statically would
30
+ // evaluate the plugin's modules on shell load and register its custom elements,
31
+ // so the copy coming from the store would fail to define them again.
32
32
  const bundledActivityHistory: PluginDefinition = {
33
33
  pluginId: CORE_FIRST_ID,
34
- importer: () =>
35
- Promise.resolve({
36
- initialize: activityHistoryInitialize,
37
- dispose: activityHistoryDispose,
38
- }),
34
+ importer: () => import("../../../plugins/activity-history/src/plugin"),
39
35
  };
40
36
 
41
37
  export const bootstrapPlugins = async (plugins: PluginDefinition[], startup?: PrimariaStartupPlugin) => {
package/src/index.ts CHANGED
@@ -12,7 +12,15 @@ export * from "./bootstrapper";
12
12
  export * from "./disposer";
13
13
  export * from "./api/region-manager/regions";
14
14
  export * from "./handle-plugins";
15
- export * from "./api/api";
15
+ // Superfície pública explícita: `primariaApiFactory`, `activityMonitor` i
16
+ // `sessionRefreshTimer` són singletons interns del shell i no s'exposen.
17
+ // `shellApi` es manté només perquè els hosts (app/sandbox) l'usen per arrencar;
18
+ // els plugins han d'usar l'`api` que reben a `initialize(api)`.
19
+ export type { PrimariaApi } from "./api/api";
20
+ export { PrimariaRegionHost, shellApi } from "./api/api";
21
+ // `TokenManager` és el tipus públic per a plugins; `InternalTokenManager`
22
+ // (amb `setInitialTokens`) és host-only, per al bootstrap de `primary/app`.
23
+ export type { TokenManager, InternalTokenManager } from "./api/token-manager/token-manager";
16
24
  export * from "./api/broker/primaria-broker";
17
25
  export type { PrimariaContextManager, EcapContext } from "./api/context-manager/context-manager";
18
26
  export * from "./UI/index";