@dotcms/uve 0.0.1-beta.5 → 0.0.1-beta.6

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/index.cjs.js CHANGED
@@ -71,11 +71,13 @@ function getUVEState() {
71
71
  */
72
72
  function createUVESubscription(event, callback) {
73
73
  if (!getUVEState()) {
74
- throw new Error('UVE Subscription: Not running inside UVE');
74
+ console.warn('UVE Subscription: Not running inside UVE');
75
+ return internal.__UVE_EVENT_ERROR_FALLBACK__(event);
75
76
  }
76
77
  const eventCallback = internal.__UVE_EVENTS__[event];
77
78
  if (!eventCallback) {
78
- throw new Error(`UVE Subscription: Event ${event} not found`);
79
+ console.error(`UVE Subscription: Event ${event} not found`);
80
+ return internal.__UVE_EVENT_ERROR_FALLBACK__(event);
79
81
  }
80
82
  return eventCallback(callback);
81
83
  }
package/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { UVE_MODE } from './types.esm.js';
2
- import { __UVE_EVENTS__ } from './internal.esm.js';
2
+ import { __UVE_EVENT_ERROR_FALLBACK__, __UVE_EVENTS__ } from './internal.esm.js';
3
3
 
4
4
  /**
5
5
  * Gets the current state of the Universal Visual Editor (UVE).
@@ -69,11 +69,13 @@ function getUVEState() {
69
69
  */
70
70
  function createUVESubscription(event, callback) {
71
71
  if (!getUVEState()) {
72
- throw new Error('UVE Subscription: Not running inside UVE');
72
+ console.warn('UVE Subscription: Not running inside UVE');
73
+ return __UVE_EVENT_ERROR_FALLBACK__(event);
73
74
  }
74
75
  const eventCallback = __UVE_EVENTS__[event];
75
76
  if (!eventCallback) {
76
- throw new Error(`UVE Subscription: Event ${event} not found`);
77
+ console.error(`UVE Subscription: Event ${event} not found`);
78
+ return __UVE_EVENT_ERROR_FALLBACK__(event);
77
79
  }
78
80
  return eventCallback(callback);
79
81
  }
package/internal.cjs.js CHANGED
@@ -57,5 +57,20 @@ const __UVE_EVENTS__ = {
57
57
  };
58
58
  }
59
59
  };
60
+ /**
61
+ * Default UVE event
62
+ *
63
+ * @param {string} event - The event to subscribe to.
64
+ * @internal
65
+ */
66
+ const __UVE_EVENT_ERROR_FALLBACK__ = event => {
67
+ return {
68
+ unsubscribe: () => {
69
+ /* do nothing */
70
+ },
71
+ event
72
+ };
73
+ };
60
74
 
61
75
  exports.__UVE_EVENTS__ = __UVE_EVENTS__;
76
+ exports.__UVE_EVENT_ERROR_FALLBACK__ = __UVE_EVENT_ERROR_FALLBACK__;
package/internal.esm.js CHANGED
@@ -55,5 +55,19 @@ const __UVE_EVENTS__ = {
55
55
  };
56
56
  }
57
57
  };
58
+ /**
59
+ * Default UVE event
60
+ *
61
+ * @param {string} event - The event to subscribe to.
62
+ * @internal
63
+ */
64
+ const __UVE_EVENT_ERROR_FALLBACK__ = event => {
65
+ return {
66
+ unsubscribe: () => {
67
+ /* do nothing */
68
+ },
69
+ event
70
+ };
71
+ };
58
72
 
59
- export { __NOTIFY_CLIENT__, __UVE_EVENTS__ };
73
+ export { __NOTIFY_CLIENT__, __UVE_EVENTS__, __UVE_EVENT_ERROR_FALLBACK__ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/uve",
3
- "version": "0.0.1-beta.5",
3
+ "version": "0.0.1-beta.6",
4
4
  "description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -6,3 +6,13 @@ import { UVEEvent } from '../lib/types';
6
6
  * @type {Record<string, UVEEvent>}
7
7
  */
8
8
  export declare const __UVE_EVENTS__: Record<string, UVEEvent>;
9
+ /**
10
+ * Default UVE event
11
+ *
12
+ * @param {string} event - The event to subscribe to.
13
+ * @internal
14
+ */
15
+ export declare const __UVE_EVENT_ERROR_FALLBACK__: (event: string) => {
16
+ unsubscribe: () => void;
17
+ event: string;
18
+ };