@elliemae/pui-app-sdk 5.25.0 → 5.26.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.
@@ -24,6 +24,7 @@ __export(functionDecorators_exports, {
24
24
  ImmutableArgs: () => ImmutableArgs,
25
25
  Memoize: () => Memoize,
26
26
  MemoizeAsync: () => MemoizeAsync,
27
+ MemoizeSingleArgPrimitive: () => MemoizeSingleArgPrimitive,
27
28
  QueueTask: () => QueueTask,
28
29
  RetryAsync: () => RetryAsync,
29
30
  Throttle: () => Throttle
@@ -214,3 +215,22 @@ function RetryAsync(retries = 3, interval = 2e3, reThrowException = true) {
214
215
  return descriptor;
215
216
  };
216
217
  }
218
+ function MemoizeSingleArgPrimitive(_target, _propertyKey, descriptor) {
219
+ const originalMethod = descriptor.value;
220
+ const cache = {};
221
+ descriptor.value = function(arg) {
222
+ const type = typeof arg;
223
+ const isPrimitive = arg === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "undefined";
224
+ if (!isPrimitive) {
225
+ return originalMethod.call(this, arg);
226
+ }
227
+ const key = String(arg);
228
+ if (Object.prototype.hasOwnProperty.call(cache, key)) {
229
+ return cache[key];
230
+ }
231
+ const result = originalMethod.call(this, arg);
232
+ cache[key] = result;
233
+ return result;
234
+ };
235
+ return descriptor;
236
+ }
@@ -269,6 +269,9 @@ class CMicroAppGuest {
269
269
  if (useParentHistory && options?.history) {
270
270
  this.props.history = options.history;
271
271
  }
272
+ if (!useParentHistory && options?.initialRoute) {
273
+ this.props.history.push(options.initialRoute);
274
+ }
272
275
  return (0, import_app_bridge.getAppBridge)().then((appBridge) => {
273
276
  this.#appBridge = appBridge;
274
277
  if (this.onInit) this.onInit(this.props);
@@ -50,6 +50,7 @@ const useAppRenderer = (props) => {
50
50
  id,
51
51
  history,
52
52
  homeRoute,
53
+ initialRoute,
53
54
  onLoadComplete,
54
55
  onUnloadComplete,
55
56
  containerId
@@ -72,7 +73,8 @@ const useAppRenderer = (props) => {
72
73
  id,
73
74
  frameOptions: { containerId },
74
75
  history,
75
- homeRoute
76
+ homeRoute,
77
+ initialRoute
76
78
  });
77
79
  setTimeout(() => {
78
80
  try {
@@ -115,6 +117,7 @@ const useAppRenderer = (props) => {
115
117
  dispatch,
116
118
  history,
117
119
  homeRoute,
120
+ initialRoute,
118
121
  id,
119
122
  onLoadComplete,
120
123
  onUnloadComplete
@@ -183,6 +183,25 @@ function RetryAsync(retries = 3, interval = 2e3, reThrowException = true) {
183
183
  return descriptor;
184
184
  };
185
185
  }
186
+ function MemoizeSingleArgPrimitive(_target, _propertyKey, descriptor) {
187
+ const originalMethod = descriptor.value;
188
+ const cache = {};
189
+ descriptor.value = function(arg) {
190
+ const type = typeof arg;
191
+ const isPrimitive = arg === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "undefined";
192
+ if (!isPrimitive) {
193
+ return originalMethod.call(this, arg);
194
+ }
195
+ const key = String(arg);
196
+ if (Object.prototype.hasOwnProperty.call(cache, key)) {
197
+ return cache[key];
198
+ }
199
+ const result = originalMethod.call(this, arg);
200
+ cache[key] = result;
201
+ return result;
202
+ };
203
+ return descriptor;
204
+ }
186
205
  export {
187
206
  AsyncSingleExecution,
188
207
  CacheUntilResolved,
@@ -190,6 +209,7 @@ export {
190
209
  ImmutableArgs,
191
210
  Memoize,
192
211
  MemoizeAsync,
212
+ MemoizeSingleArgPrimitive,
193
213
  QueueTask,
194
214
  RetryAsync,
195
215
  Throttle
@@ -236,6 +236,9 @@ class CMicroAppGuest {
236
236
  if (useParentHistory && options?.history) {
237
237
  this.props.history = options.history;
238
238
  }
239
+ if (!useParentHistory && options?.initialRoute) {
240
+ this.props.history.push(options.initialRoute);
241
+ }
239
242
  return getAppBridge().then((appBridge) => {
240
243
  this.#appBridge = appBridge;
241
244
  if (this.onInit) this.onInit(this.props);
@@ -17,6 +17,7 @@ const useAppRenderer = (props) => {
17
17
  id,
18
18
  history,
19
19
  homeRoute,
20
+ initialRoute,
20
21
  onLoadComplete,
21
22
  onUnloadComplete,
22
23
  containerId
@@ -39,7 +40,8 @@ const useAppRenderer = (props) => {
39
40
  id,
40
41
  frameOptions: { containerId },
41
42
  history,
42
- homeRoute
43
+ homeRoute,
44
+ initialRoute
43
45
  });
44
46
  setTimeout(() => {
45
47
  try {
@@ -82,6 +84,7 @@ const useAppRenderer = (props) => {
82
84
  dispatch,
83
85
  history,
84
86
  homeRoute,
87
+ initialRoute,
85
88
  id,
86
89
  onLoadComplete,
87
90
  onUnloadComplete
@@ -159,3 +159,19 @@ export declare function AsyncSingleExecution(_target: any, _propertyKey: string,
159
159
  * // Error: Fetch failed
160
160
  */
161
161
  export declare function RetryAsync(retries?: number, interval?: number, reThrowException?: boolean): MethodDecorator;
162
+ /**
163
+ * Memoizes the result of a function with a single primitive argument.
164
+ * Only works for functions that take exactly one primitive argument (string, number, boolean, symbol, null, or undefined).
165
+ * Uses a simple object as the cache.
166
+ * @param _target
167
+ * @param _propertyKey
168
+ * @param descriptor
169
+ * @example
170
+ * class Example {
171
+ * @MemoizeSingleArgPrimitive
172
+ * double(x: number) {
173
+ * return x * 2;
174
+ * }
175
+ * }
176
+ */
177
+ export declare function MemoizeSingleArgPrimitive<T extends string | number | boolean | symbol | null | undefined, R>(_target: any, _propertyKey: string, descriptor: TypedPropertyDescriptor<(arg: T) => R>): TypedPropertyDescriptor<(arg: T) => R>;