@arsedizioni/ars-utils 20.3.46 → 20.3.48

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.
@@ -1033,7 +1033,7 @@ declare class ClipperDocumentMenuComponent implements OnInit, OnDestroy {
1033
1033
  private changeDetector;
1034
1034
  private clipperService;
1035
1035
  readonly useSelections: _angular_core.InputSignal<boolean>;
1036
- readonly selectionSource: _angular_core.InputSignal<"selection" | "bag" | "none">;
1036
+ readonly selectionSource: _angular_core.InputSignal<"none" | "selection" | "bag">;
1037
1037
  protected selection: () => ClipperDocumentInfo[];
1038
1038
  readonly parent: _angular_core.InputSignal<ClipperSearchResultManager>;
1039
1039
  readonly item: _angular_core.InputSignal<ClipperDocumentInfo>;
package/core/index.d.ts CHANGED
@@ -715,12 +715,98 @@ declare class SelectableModel<T, V> {
715
715
  hasValue(): boolean;
716
716
  }
717
717
 
718
+ /**
719
+ * Standard Broadcast Messages Manager
720
+ * https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
721
+ */
722
+ /**
723
+ * The message bag sent as a message
724
+ */
725
+ interface BroadcastChannelMessageBag<T> {
726
+ messageId: string;
727
+ sender: string;
728
+ data?: T;
729
+ }
730
+ /**
731
+ * Message subscription params
732
+ */
733
+ interface BroadcastChannelSubscriberInfo<T> {
734
+ messageId: string;
735
+ action: (bag: BroadcastChannelMessageBag<T>) => void;
736
+ }
737
+ /**
738
+ * Web Standard Broadcast Messages Manager
739
+ * https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
740
+ */
741
+ declare class BroadcastChannelManager {
742
+ private channel?;
743
+ private subscriptions;
744
+ /**
745
+ * Get the current channel registration
746
+ */
747
+ get currentBus(): string | undefined;
748
+ constructor(bus: string);
749
+ dispose(): void;
750
+ /**
751
+ * Send a message
752
+ * @param bag The message, see also {@link BroadcastChannelMessageBag}
753
+ *
754
+ * @example
755
+ * channel.sendMessage({ messageId: 'my-broadcast-message', sender: 'the-sender', data: value });
756
+ */
757
+ sendMessage<T>(bag: BroadcastChannelMessageBag<T>): void;
758
+ /**
759
+ * Send a message
760
+ * @param bag The message, see also {@link BroadcastChannelMessageBag}
761
+ * @param delay The number of milliseconds to wait before sending the message, see also {@link setTimeout}
762
+ *
763
+ * @example
764
+ * channel.sendMessage({ messageId: 'my-broadcast-message', sender: 'the-sender', data: value }, 250);
765
+ */
766
+ sendMessage<T>(bag: BroadcastChannelMessageBag<T>, delay?: number): void;
767
+ /**
768
+ * Send a message
769
+ * @param messageId The message id
770
+ * @param data The data to send
771
+ *
772
+ * @example
773
+ * channel.sendMessage('my-broadcast-message', value);
774
+ */
775
+ sendMessage<T>(messageId: string, data?: T): void;
776
+ /**
777
+ * Send a message
778
+ * @param messageId The message id
779
+ * @param data The data to send
780
+ * @param delay The number of milliseconds to wait before sending the message
781
+ *
782
+ * @example
783
+ * channel.sendMessage('my-broadcast-message', value, 250);
784
+ */
785
+ sendMessage<T>(messageId: string, data?: T, delay?: number): void;
786
+ /**
787
+ * Subscribe to a message
788
+ * @param args The subscription info, see also {@link BroadcastChannelSubscriberInfo}
789
+ */
790
+ subscribe<T>(args: BroadcastChannelSubscriberInfo<T>): void;
791
+ /**
792
+ * Remove a message subscription
793
+ * @param messageId The message id
794
+ */
795
+ unsubscribe(messageId: string): void;
796
+ /**
797
+ * Remove all the current subscriptions
798
+ */
799
+ unsubscribeAll(): void;
800
+ }
801
+
718
802
  interface BroadcastMessageInfo {
719
803
  id: string;
720
804
  data?: any;
721
805
  }
722
- declare class BroadcastService {
806
+ declare class BroadcastService implements OnDestroy {
723
807
  private subject;
808
+ private channel;
809
+ ngOnDestroy(): void;
724
810
  /**
725
811
  * Send a message
726
812
  * @param id : the message id
@@ -728,6 +814,18 @@ declare class BroadcastService {
728
814
  * @param delay : the number of milliseconds to wait before sending the message
729
815
  */
730
816
  sendMessage(id: string, data?: any, delay?: number): void;
817
+ /**
818
+ * Send a channel message
819
+ * @param bag : the message bag
820
+ * @param delay : the number of milliseconds to wait before sending the message
821
+ */
822
+ sendChannelMessage<T>(bag: BroadcastChannelMessageBag<T>, delay?: number): void;
823
+ /**
824
+ * Subscribe channel message
825
+ * @param messageId : the message id
826
+ * @param action : the actionto perform
827
+ */
828
+ subscribeChannelMessage(messageId: string, action: (bag: BroadcastChannelMessageBag<any>) => void): void;
731
829
  /**
732
830
  * Get the next message as observable
733
831
  * @returns : the observable object
@@ -904,89 +1002,5 @@ declare class FormatMarkdownPipe implements PipeTransform {
904
1002
  static ɵprov: i0.ɵɵInjectableDeclaration<FormatMarkdownPipe>;
905
1003
  }
906
1004
 
907
- /**
908
- * Standard Broadcast Messages Manager
909
- * https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
910
- */
911
- /**
912
- * The message bag sent as a message
913
- */
914
- interface BroadcastChannelMessageBag<T> {
915
- messageId: string;
916
- sender: string;
917
- data?: T;
918
- }
919
- /**
920
- * Message subscription params
921
- */
922
- interface BroadcastChannelSubscriberInfo<T> {
923
- messageId: string;
924
- action: (bag: BroadcastChannelMessageBag<T>) => void;
925
- }
926
- /**
927
- * Web Standard Broadcast Messages Manager
928
- * https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
929
- */
930
- declare class BroadcastChannelManager {
931
- private channel?;
932
- private subscriptions;
933
- /**
934
- * Get the current channel registration
935
- */
936
- get currentBus(): string | undefined;
937
- constructor(bus: string);
938
- dispose(): void;
939
- /**
940
- * Send a message
941
- * @param bag The message, see also {@link BroadcastChannelMessageBag}
942
- *
943
- * @example
944
- * channel.sendMessage({ messageId: 'my-broadcast-message', sender: 'the-sender', data: value });
945
- */
946
- sendMessage<T>(bag: BroadcastChannelMessageBag<T>): void;
947
- /**
948
- * Send a message
949
- * @param bag The message, see also {@link BroadcastChannelMessageBag}
950
- * @param delay The number of milliseconds to wait before sending the message, see also {@link setTimeout}
951
- *
952
- * @example
953
- * channel.sendMessage({ messageId: 'my-broadcast-message', sender: 'the-sender', data: value }, 250);
954
- */
955
- sendMessage<T>(bag: BroadcastChannelMessageBag<T>, delay?: number): void;
956
- /**
957
- * Send a message
958
- * @param messageId The message id
959
- * @param data The data to send
960
- *
961
- * @example
962
- * channel.sendMessage('my-broadcast-message', value);
963
- */
964
- sendMessage<T>(messageId: string, data?: T): void;
965
- /**
966
- * Send a message
967
- * @param messageId The message id
968
- * @param data The data to send
969
- * @param delay The number of milliseconds to wait before sending the message
970
- *
971
- * @example
972
- * channel.sendMessage('my-broadcast-message', value, 250);
973
- */
974
- sendMessage<T>(messageId: string, data?: T, delay?: number): void;
975
- /**
976
- * Subscribe to a message
977
- * @param args The subscription info, see also {@link BroadcastChannelSubscriberInfo}
978
- */
979
- subscribe<T>(args: BroadcastChannelSubscriberInfo<T>): void;
980
- /**
981
- * Remove a message subscription
982
- * @param messageId The message id
983
- */
984
- unsubscribe(messageId: string): void;
985
- /**
986
- * Remove all the current subscriptions
987
- */
988
- unsubscribeAll(): void;
989
- }
990
-
991
1005
  export { ArsCoreModule, ArsDateFnsModule, AutoFocusDirective, BroadcastChannelManager, BroadcastService, CopyClipboardDirective, DateFnsAdapter, DateFormat, DateInterval, DateIntervalChangeDirective, DeleteModel, EmailsValidatorDirective, EnvironmentService, EqualsValidatorDirective, FileInfo, FileSizeValidatorDirective, FormatHtmlPipe, FormatMarkdownPipe, FormatPipe, GroupModel, GuidValidatorDirective, IDModel, ImportModel, MAT_DATE_FNS_FORMATS, MaxTermsValidatorDirective, NotEmptyValidatorDirective, NotEqualValidatorDirective, NotFutureValidatorDirective, PasswordValidatorDirective, QueryModel, RelationModel, RemoveFocusDirective, ReplacePipe, SafeHtmlPipe, SafeUrlPipe, ScreenService, SearchCallbackPipe, SearchFilterPipe, SelectableModel, SqlDateValidatorDirective, SystemUtils, ThemeService, TimeValidatorDirective, UpdateRelationsModel, UrlValidatorDirective, UtilsMessages, ValidIfDirective, ValidatorDirective, ValueModel };
992
1006
  export type { AddModel, AddResultModel, ApiResponse, ApiResult, BroadcastChannelMessageBag, BroadcastChannelSubscriberInfo, BroadcastMessageInfo, Checkable, DeleteResultModel, DoneResult, EnableDisableModel, ErrorInfo, File, Folder, FolderTree, INode, LoginResult, NameValueItem, PasswordStrength, QueryResultModel, SearchBag, SearchFilterMetadata, Searchable, SendToModel, ThemeType, UpdateModel, UpdateResultModel, Validated };
@@ -2028,9 +2028,93 @@ class SelectableModel {
2028
2028
  }
2029
2029
  }
2030
2030
 
2031
+ /**
2032
+ * Standard Broadcast Messages Manager
2033
+ * https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
2034
+ */
2035
+ /**
2036
+ * Web Standard Broadcast Messages Manager
2037
+ * https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
2038
+ */
2039
+ class BroadcastChannelManager {
2040
+ /**
2041
+ * Get the current channel registration
2042
+ */
2043
+ get currentBus() {
2044
+ return this.channel?.name;
2045
+ }
2046
+ constructor(bus) {
2047
+ this.subscriptions = [];
2048
+ this.channel = new BroadcastChannel(bus);
2049
+ this.channel.onmessageerror = (e) => {
2050
+ console.error('[BroadcastChannelManager] Errore di ricezione del messaggio', e);
2051
+ };
2052
+ this.channel.onmessage = (e) => {
2053
+ const bag = e.data;
2054
+ if (bag) {
2055
+ const bagInfo = this.subscriptions.find(m => m.messageId === bag.messageId);
2056
+ bagInfo?.action(bag);
2057
+ }
2058
+ };
2059
+ }
2060
+ dispose() {
2061
+ setTimeout(() => {
2062
+ this.subscriptions = [];
2063
+ this.channel?.close();
2064
+ this.channel = undefined;
2065
+ }, 1000);
2066
+ }
2067
+ /**
2068
+ * overloads
2069
+ */
2070
+ sendMessage(messageIdorBag, dataOrDelay, delay) {
2071
+ setTimeout(() => {
2072
+ if (typeof messageIdorBag === 'string') {
2073
+ this.channel?.postMessage({ messageId: messageIdorBag, data: dataOrDelay });
2074
+ }
2075
+ else {
2076
+ this.channel?.postMessage(messageIdorBag);
2077
+ }
2078
+ }, (typeof dataOrDelay === 'number' ? dataOrDelay : delay) ?? 0);
2079
+ }
2080
+ /**
2081
+ * Subscribe to a message
2082
+ * @param args The subscription info, see also {@link BroadcastChannelSubscriberInfo}
2083
+ */
2084
+ subscribe(args) {
2085
+ const i = this.subscriptions.findIndex(m => m.messageId === args.messageId);
2086
+ if (i === -1) {
2087
+ this.subscriptions.push(args);
2088
+ }
2089
+ else {
2090
+ this.subscriptions[i].action = args.action;
2091
+ }
2092
+ }
2093
+ /**
2094
+ * Remove a message subscription
2095
+ * @param messageId The message id
2096
+ */
2097
+ unsubscribe(messageId) {
2098
+ const i = this.subscriptions.findIndex(m => m.messageId === messageId);
2099
+ if (i !== -1) {
2100
+ this.subscriptions.splice(i, 1);
2101
+ }
2102
+ }
2103
+ /**
2104
+ * Remove all the current subscriptions
2105
+ */
2106
+ unsubscribeAll() {
2107
+ this.subscriptions = [];
2108
+ }
2109
+ }
2110
+
2031
2111
  class BroadcastService {
2032
2112
  constructor() {
2033
2113
  this.subject = new Subject();
2114
+ this.channel = new BroadcastChannelManager("ARS-CHANNEL");
2115
+ }
2116
+ ngOnDestroy() {
2117
+ this.channel?.dispose();
2034
2118
  }
2035
2119
  /**
2036
2120
  * Send a message
@@ -2038,11 +2122,29 @@ class BroadcastService {
2038
2122
  * @param data : the data to send
2039
2123
  * @param delay : the number of milliseconds to wait before sending the message
2040
2124
  */
2041
- sendMessage(id, data = null, delay = 0) {
2125
+ sendMessage(id, data = undefined, delay = 0) {
2042
2126
  setTimeout(() => {
2043
2127
  this.subject.next({ id: id, data: data });
2044
2128
  }, delay);
2045
2129
  }
2130
+ /**
2131
+ * Send a channel message
2132
+ * @param bag : the message bag
2133
+ * @param delay : the number of milliseconds to wait before sending the message
2134
+ */
2135
+ sendChannelMessage(bag, delay) {
2136
+ setTimeout(() => {
2137
+ this.channel.sendMessage(bag, delay);
2138
+ }, delay);
2139
+ }
2140
+ /**
2141
+ * Subscribe channel message
2142
+ * @param messageId : the message id
2143
+ * @param action : the actionto perform
2144
+ */
2145
+ subscribeChannelMessage(messageId, action) {
2146
+ this.channel.subscribe({ messageId: messageId, action: action });
2147
+ }
2046
2148
  /**
2047
2149
  * Get the next message as observable
2048
2150
  * @returns : the observable object
@@ -2121,84 +2223,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImpor
2121
2223
  }]
2122
2224
  }] });
2123
2225
 
2124
- /**
2125
- * Standard Broadcast Messages Manager
2126
- * https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
2127
- */
2128
- /**
2129
- * Web Standard Broadcast Messages Manager
2130
- * https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
2131
- */
2132
- class BroadcastChannelManager {
2133
- /**
2134
- * Get the current channel registration
2135
- */
2136
- get currentBus() {
2137
- return this.channel?.name;
2138
- }
2139
- constructor(bus) {
2140
- this.subscriptions = [];
2141
- this.channel = new BroadcastChannel(bus);
2142
- this.channel.onmessageerror = (e) => {
2143
- console.error('[BroadcastChannelManager] Errore di ricezione del messaggio', e);
2144
- };
2145
- this.channel.onmessage = (e) => {
2146
- const bag = e.data;
2147
- if (bag) {
2148
- const bagInfo = this.subscriptions.find(m => m.messageId === bag.messageId);
2149
- bagInfo?.action(bag);
2150
- }
2151
- };
2152
- }
2153
- dispose() {
2154
- this.subscriptions = [];
2155
- this.channel?.close();
2156
- this.channel = undefined;
2157
- }
2158
- /**
2159
- * overloads
2160
- */
2161
- sendMessage(messageIdorBag, dataOrDelay, delay) {
2162
- setTimeout(() => {
2163
- if (typeof messageIdorBag === 'string') {
2164
- this.channel?.postMessage({ messageId: messageIdorBag, data: dataOrDelay });
2165
- }
2166
- else {
2167
- this.channel?.postMessage(messageIdorBag);
2168
- }
2169
- }, (typeof dataOrDelay === 'number' ? dataOrDelay : delay) ?? 0);
2170
- }
2171
- /**
2172
- * Subscribe to a message
2173
- * @param args The subscription info, see also {@link BroadcastChannelSubscriberInfo}
2174
- */
2175
- subscribe(args) {
2176
- const i = this.subscriptions.findIndex(m => m.messageId === args.messageId);
2177
- if (i === -1) {
2178
- this.subscriptions.push(args);
2179
- }
2180
- else {
2181
- this.subscriptions[i].action = args.action;
2182
- }
2183
- }
2184
- /**
2185
- * Remove a message subscription
2186
- * @param messageId The message id
2187
- */
2188
- unsubscribe(messageId) {
2189
- const i = this.subscriptions.findIndex(m => m.messageId === messageId);
2190
- if (i !== -1) {
2191
- this.subscriptions.splice(i, 1);
2192
- }
2193
- }
2194
- /**
2195
- * Remove all the current subscriptions
2196
- */
2197
- unsubscribeAll() {
2198
- this.subscriptions = [];
2199
- }
2200
- }
2201
-
2202
2226
  class ThemeService {
2203
2227
  constructor() {
2204
2228
  // messaggi broadcast