@ensera/plugin-frontend 1.0.1 → 1.1.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
@@ -89,6 +89,14 @@ type PluginThemeMessage = {
89
89
  theme: PluginThemeSnapshot;
90
90
  };
91
91
  };
92
+ type WorkspaceMemberRole = "OWNER" | "ADMIN" | "MEMBER" | "GUEST";
93
+ type PluginWorkspaceMember = {
94
+ userId: string;
95
+ name: string | null;
96
+ email: string;
97
+ image: string | null;
98
+ role: WorkspaceMemberRole;
99
+ };
92
100
  /**
93
101
  * Launch modes for plugin instances
94
102
  */
@@ -587,6 +595,15 @@ declare function getFeatureColorTokens(hex: string, mode: PluginThemeMode): {
587
595
  };
588
596
  declare function syncAdaptiveFeatureColors(root: ParentNode | null | undefined, mode: PluginThemeMode): void;
589
597
 
598
+ declare function getWorkspaceMembers(options?: {
599
+ includeGuests?: boolean;
600
+ }): PluginWorkspaceMember[];
601
+ declare function getUser(userId: string): PluginWorkspaceMember | null;
602
+ declare function isMembersReady(): boolean;
603
+ declare function useWorkspaceMembers(options?: {
604
+ includeGuests?: boolean;
605
+ }): PluginWorkspaceMember[];
606
+
590
607
  declare const tokens: {
591
608
  readonly spacing: {
592
609
  readonly xs: 4;
@@ -788,4 +805,4 @@ declare function setupContextMenuRelay(ctx: {
788
805
  instanceId: string;
789
806
  }): () => void;
790
807
 
791
- export { Button, type ButtonProps, type ButtonSize, type ButtonVariant, ContextMenuShell, ContextRow, type ContextRowProps, IconButton, type IconButtonProps, type IconButtonSize, type IconButtonVariant, Input, type InputProps, type InputSize, type InputVariant, type JsonObject, type JsonValue, type NotificationAction, type NotificationCapabilities, type NotificationTypeConfig, type PluginActionHandler, type PluginActionHandlerArgs, type PluginActionId, type PluginActionsMap, PluginAuthError, type PluginCtx, type PluginDispatchFn, type PluginDispatchRequest, type PluginDispatchResult, type PluginErrorPayload, PluginFetchError, type PluginFetchExpect, PluginFetchInputError, type PluginFetchOptions, type PluginFetchResponse, type PluginFetchRetry, PluginForbiddenError, type PluginLaunch, type PluginLogLevel, type PluginLogger, PluginNetworkError, PluginNotFoundError, type PluginNotification, type PluginNotificationBulkResponse, type PluginNotificationOptions, type PluginNotificationRequest, type PluginNotificationResponse, type PluginNotificationResultMessage, type PluginNotify, type PluginOpenOverlayMessage, PluginRateLimitError, PluginResponseError, type PluginRuntime, PluginServerError, type PluginStorage, type PluginStorageBackend, PluginStorageError, type PluginStorageIndexedDB, PluginStorageQuotaError, type PluginThemeColorRole, type PluginThemeMessage, type PluginThemeMode, type PluginThemeSnapshot, PluginUnknownActionError, PluginValidationError, Row, type RowAlign, type RowHeight, type RowJustify, type RowProps, type SyncCallback, type SyncEventType, type SyncMessage, type SyncPayload, type SyncedState, type Tokens, adaptFeatureColor, applyPluginTheme, attachActionDispatcher, broadcast, createPluginFetch, createPluginLogger, createPluginNotify, createPluginRuntime, createPluginStorage, createPluginStorageIndexedDB, createSyncedState, defineActions, dispatchPluginThemeChange, getFeatureColorTokens, getPluginThemeSnapshot, getReadableFeatureTextColor, initBroadcast, initializePluginTheme, makeStorageNamespace, normalizePluginThemeMode, normalizePluginThemeSnapshot, onBroadcast, openOverlay, runActionSafe, setupContextMenuRelay, subscribePluginTheme, syncAdaptiveFeatureColors, tokens, useBroadcastListener, usePluginTheme, useSyncedState };
808
+ export { Button, type ButtonProps, type ButtonSize, type ButtonVariant, ContextMenuShell, ContextRow, type ContextRowProps, IconButton, type IconButtonProps, type IconButtonSize, type IconButtonVariant, Input, type InputProps, type InputSize, type InputVariant, type JsonObject, type JsonValue, type NotificationAction, type NotificationCapabilities, type NotificationTypeConfig, type PluginActionHandler, type PluginActionHandlerArgs, type PluginActionId, type PluginActionsMap, PluginAuthError, type PluginCtx, type PluginDispatchFn, type PluginDispatchRequest, type PluginDispatchResult, type PluginErrorPayload, PluginFetchError, type PluginFetchExpect, PluginFetchInputError, type PluginFetchOptions, type PluginFetchResponse, type PluginFetchRetry, PluginForbiddenError, type PluginLaunch, type PluginLogLevel, type PluginLogger, PluginNetworkError, PluginNotFoundError, type PluginNotification, type PluginNotificationBulkResponse, type PluginNotificationOptions, type PluginNotificationRequest, type PluginNotificationResponse, type PluginNotificationResultMessage, type PluginNotify, type PluginOpenOverlayMessage, PluginRateLimitError, PluginResponseError, type PluginRuntime, PluginServerError, type PluginStorage, type PluginStorageBackend, PluginStorageError, type PluginStorageIndexedDB, PluginStorageQuotaError, type PluginThemeColorRole, type PluginThemeMessage, type PluginThemeMode, type PluginThemeSnapshot, PluginUnknownActionError, PluginValidationError, type PluginWorkspaceMember, Row, type RowAlign, type RowHeight, type RowJustify, type RowProps, type SyncCallback, type SyncEventType, type SyncMessage, type SyncPayload, type SyncedState, type Tokens, type WorkspaceMemberRole, adaptFeatureColor, applyPluginTheme, attachActionDispatcher, broadcast, createPluginFetch, createPluginLogger, createPluginNotify, createPluginRuntime, createPluginStorage, createPluginStorageIndexedDB, createSyncedState, defineActions, dispatchPluginThemeChange, getFeatureColorTokens, getPluginThemeSnapshot, getReadableFeatureTextColor, getUser, getWorkspaceMembers, initBroadcast, initializePluginTheme, isMembersReady, makeStorageNamespace, normalizePluginThemeMode, normalizePluginThemeSnapshot, onBroadcast, openOverlay, runActionSafe, setupContextMenuRelay, subscribePluginTheme, syncAdaptiveFeatureColors, tokens, useBroadcastListener, usePluginTheme, useSyncedState, useWorkspaceMembers };
package/dist/index.js CHANGED
@@ -1581,6 +1581,92 @@ function syncAdaptiveFeatureColors(root, mode) {
1581
1581
  }
1582
1582
  bindWindowThemeListeners();
1583
1583
 
1584
+ // src/members.ts
1585
+ import { useSyncExternalStore as useSyncExternalStore2 } from "react";
1586
+ var membersStore = [];
1587
+ var membersInitialized = false;
1588
+ var boundWindowListeners2 = false;
1589
+ var listeners2 = /* @__PURE__ */ new Set();
1590
+ function notifyListeners() {
1591
+ for (const listener of listeners2) {
1592
+ listener();
1593
+ }
1594
+ }
1595
+ function getMembersSnapshot() {
1596
+ return membersStore;
1597
+ }
1598
+ function subscribeMembersStore(listener) {
1599
+ listeners2.add(listener);
1600
+ return () => listeners2.delete(listener);
1601
+ }
1602
+ function bindMembersMessageListeners() {
1603
+ if (boundWindowListeners2 || typeof window === "undefined") {
1604
+ return;
1605
+ }
1606
+ window.addEventListener("message", (event) => {
1607
+ const message = event.data;
1608
+ if (!message || typeof message !== "object") {
1609
+ return;
1610
+ }
1611
+ switch (message.type) {
1612
+ case "ENSERA_INIT": {
1613
+ const members = message.payload?.members;
1614
+ if (Array.isArray(members)) {
1615
+ setWorkspaceMembers(members);
1616
+ } else {
1617
+ setWorkspaceMembers([]);
1618
+ }
1619
+ break;
1620
+ }
1621
+ case "ENSERA_MEMBERS_UPDATE": {
1622
+ const members = message.payload?.members;
1623
+ if (Array.isArray(members)) {
1624
+ updateWorkspaceMembers(members);
1625
+ }
1626
+ break;
1627
+ }
1628
+ }
1629
+ });
1630
+ boundWindowListeners2 = true;
1631
+ }
1632
+ function setWorkspaceMembers(members) {
1633
+ membersStore = Array.isArray(members) ? members : [];
1634
+ membersInitialized = true;
1635
+ notifyListeners();
1636
+ }
1637
+ function updateWorkspaceMembers(members) {
1638
+ membersStore = Array.isArray(members) ? members : [];
1639
+ notifyListeners();
1640
+ }
1641
+ function getWorkspaceMembers(options) {
1642
+ bindMembersMessageListeners();
1643
+ if (!options?.includeGuests) {
1644
+ return membersStore.filter((member) => member.role !== "GUEST");
1645
+ }
1646
+ return [...membersStore];
1647
+ }
1648
+ function getUser(userId) {
1649
+ bindMembersMessageListeners();
1650
+ return membersStore.find((member) => member.userId === userId) ?? null;
1651
+ }
1652
+ function isMembersReady() {
1653
+ bindMembersMessageListeners();
1654
+ return membersInitialized;
1655
+ }
1656
+ function useWorkspaceMembers(options) {
1657
+ bindMembersMessageListeners();
1658
+ const all = useSyncExternalStore2(
1659
+ subscribeMembersStore,
1660
+ getMembersSnapshot,
1661
+ getMembersSnapshot
1662
+ );
1663
+ if (!options?.includeGuests) {
1664
+ return all.filter((member) => member.role !== "GUEST");
1665
+ }
1666
+ return all;
1667
+ }
1668
+ bindMembersMessageListeners();
1669
+
1584
1670
  // src/ui/tokens.ts
1585
1671
  var tokens = {
1586
1672
  // Spacing scale (in pixels)
@@ -2336,8 +2422,11 @@ export {
2336
2422
  getFeatureColorTokens,
2337
2423
  getPluginThemeSnapshot,
2338
2424
  getReadableFeatureTextColor,
2425
+ getUser,
2426
+ getWorkspaceMembers,
2339
2427
  initBroadcast,
2340
2428
  initializePluginTheme,
2429
+ isMembersReady,
2341
2430
  makeStorageNamespace,
2342
2431
  normalizePluginThemeMode,
2343
2432
  normalizePluginThemeSnapshot,
@@ -2350,5 +2439,6 @@ export {
2350
2439
  tokens,
2351
2440
  useBroadcastListener,
2352
2441
  usePluginTheme,
2353
- useSyncedState
2442
+ useSyncedState,
2443
+ useWorkspaceMembers
2354
2444
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ensera/plugin-frontend",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Runtime frontend SDK for Ensera plugins.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",