dce-reactkit 3.10.3 → 3.11.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.
@@ -19,6 +19,12 @@ type SendRequestFunction = (opts: {
19
19
  [x: string]: any;
20
20
  };
21
21
  }>;
22
+ declare let noServer: boolean;
23
+ /**
24
+ * Check if there is no server for this app
25
+ * @author Gabe Abrams
26
+ */
27
+ export declare const appHasNoServer: () => boolean;
22
28
  /**
23
29
  * Get the send request function
24
30
  * @author Gabe Abrams
@@ -44,10 +50,18 @@ export declare const isDarkModeOn: () => boolean;
44
50
  * @param opts object containing all arguments
45
51
  * @param opts.sendRequest caccl send request functions
46
52
  * @param [opts.sessionExpiredMessage] a custom session expired message
53
+ * @param [opts.darkModeOn] if true, dark mode is enabled
54
+ * @param [opts.noServer] if true, there is no server for this app
47
55
  */
48
- declare const initClient: (opts: {
56
+ declare const initClient: (opts: ({
49
57
  sendRequest: SendRequestFunction;
50
58
  sessionExpiredMessage?: string;
51
59
  darkModeOn?: boolean;
52
- }) => void;
60
+ noServer?: false;
61
+ } | {
62
+ darkModeOn?: boolean;
63
+ noServer: true;
64
+ sendRequest?: undefined;
65
+ sessionExpiredMessage?: undefined;
66
+ })) => void;
53
67
  export default initClient;
package/dist/esm/index.js CHANGED
@@ -289,11 +289,23 @@ const isDarkModeOn = () => {
289
289
  * @param opts object containing all arguments
290
290
  * @param opts.sendRequest caccl send request functions
291
291
  * @param [opts.sessionExpiredMessage] a custom session expired message
292
+ * @param [opts.darkModeOn] if true, dark mode is enabled
293
+ * @param [opts.noServer] if true, there is no server for this app
292
294
  */
293
295
  const initClient = (opts) => {
294
- // Store values
295
- storedSendRequest = opts.sendRequest;
296
- sessionExpiredMessage = opts.sessionExpiredMessage;
296
+ // Handle separately if there is no server
297
+ if (opts.noServer) {
298
+ // Store values
299
+ storedSendRequest = () => __awaiter(void 0, void 0, void 0, function* () {
300
+ throw new Error('Cannot send requests because there is no server');
301
+ });
302
+ }
303
+ else {
304
+ // Store values
305
+ storedSendRequest = opts.sendRequest;
306
+ sessionExpiredMessage = opts.sessionExpiredMessage;
307
+ }
308
+ // Handle universal parts
297
309
  darkModeOn = !!opts.darkModeOn;
298
310
  // Mark as initialized
299
311
  onInitialized(null);
@@ -757,6 +769,7 @@ const _setStubResponse = (opts) => {
757
769
  */
758
770
  const visitServerEndpoint = (opts) => __awaiter(void 0, void 0, void 0, function* () {
759
771
  var _a, _b, _c;
772
+ // Set default method
760
773
  const method = ((_a = opts.method) !== null && _a !== void 0 ? _a : 'GET');
761
774
  // Handle stubs
762
775
  const stubResponse = (_b = stubResponses[method]) === null || _b === void 0 ? void 0 : _b[opts.path];