@pitcher/js-api 1.22.0-alpha.4 → 1.22.0-alpha.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/js-api.esm.js +361 -102
- package/js-api.esm.js.map +1 -1
- package/js-api.umd.min.js +10 -10
- package/js-api.umd.min.js.map +1 -1
- package/lib/api/canvases/canvases.queries.d.ts +1 -1
- package/lib/apps/browser/stores/api.d.ts +53 -53
- package/lib/apps/browser/stores/app.d.ts +18 -15
- package/lib/apps/browser/stores/upload.d.ts +29 -29
- package/lib/apps/canvas-builder/composables/useCanvas.d.ts +607 -621
- package/lib/apps/canvas-builder/composables/useCanvasDnd.d.ts +12 -0
- package/lib/apps/canvas-builder/composables/useCanvasHistory.d.ts +93 -95
- package/lib/apps/canvas-builder/composables/useCanvasPages.d.ts +1 -0
- package/lib/apps/canvas-builder/composables/useCanvasSectionOverrides.d.ts +8 -7
- package/lib/apps/canvas-builder/composables/useCanvasTheme.d.ts +11 -11
- package/lib/apps/canvas-builder/composables/useCanvasVisibility.d.ts +5 -4
- package/lib/apps/canvas-builder/composables/useCollapsibles.d.ts +2 -2
- package/lib/apps/canvas-builder/composables/useContentSelector.d.ts +9 -9
- package/lib/apps/canvas-builder/composables/useRecommendations.d.ts +13 -10
- package/lib/apps/canvas-builder/types/canvas.d.ts +4 -3
- package/lib/apps/canvas-builder/util/tree.d.ts +1 -0
- package/lib/apps/content-selector/stores/app.d.ts +16 -15
- package/lib/components/CFileViewer/CFileViewer.use.d.ts +1 -1
- package/lib/composables/bulkActions.use.d.ts +4 -4
- package/lib/composables/recentFiles.use.d.ts +1 -1
- package/lib/composables/useDetailsView.d.ts +1 -1
- package/lib/composables/useLocation.d.ts +1 -1
- package/lib/composables/useLocationAPI.d.ts +2 -2
- package/lib/composables/useLocationManipulation.d.ts +1 -1
- package/lib/composables/useWindowEvents.d.ts +1 -1
- package/lib/custom-naive-locales/el.d.ts +1 -1
- package/lib/sdk/api/HighLevelApi.d.ts +31 -31
- package/lib/sdk/api/modules/ui/canvas.ui.d.ts +6 -1
- package/lib/sdk/api/modules/ui/index.d.ts +7 -2
- package/lib/sdk/api/modules/ui/post-call.ui.d.ts +4 -1
- package/lib/sdk/api/modules/ui/types.ui.d.ts +56 -2
- package/lib/sdk/api/onlineRestApiHandlers.d.ts +4 -0
- package/lib/sdk/interfaces.d.ts +2 -0
- package/lib/sdk/main.d.ts +134 -95
- package/lib/sdk/utils/httpFetch.d.ts +15 -0
- package/lib/theme/light.d.ts +5 -315
- package/lib/types/instanceSettings.d.ts +1 -0
- package/lib/types/launchDarkly.types.d.ts +1 -1
- package/lib/util/network.d.ts +1 -1
- package/package.json +1 -1
package/js-api.esm.js
CHANGED
|
@@ -2599,43 +2599,42 @@ class EventEmitter {
|
|
|
2599
2599
|
}
|
|
2600
2600
|
}
|
|
2601
2601
|
|
|
2602
|
+
/**
|
|
2603
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
2604
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
2605
|
+
*/
|
|
2606
|
+
var byteToHex = [];
|
|
2607
|
+
for (var i = 0; i < 256; ++i) {
|
|
2608
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
2609
|
+
}
|
|
2610
|
+
function unsafeStringify(arr, offset = 0) {
|
|
2611
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
2612
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
2613
|
+
//
|
|
2614
|
+
// Note to future-self: No, you can't remove the `toLowerCase()` call.
|
|
2615
|
+
// REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
|
|
2616
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2602
2619
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
2603
2620
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
2604
2621
|
// generators (like Math.random()).
|
|
2605
|
-
|
|
2606
|
-
|
|
2622
|
+
|
|
2623
|
+
var getRandomValues;
|
|
2624
|
+
var rnds8 = new Uint8Array(16);
|
|
2607
2625
|
function rng() {
|
|
2608
2626
|
// lazy load so that environments that need to polyfill have a chance to do so
|
|
2609
2627
|
if (!getRandomValues) {
|
|
2610
2628
|
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
2611
2629
|
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
2612
|
-
|
|
2613
2630
|
if (!getRandomValues) {
|
|
2614
2631
|
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
2615
2632
|
}
|
|
2616
2633
|
}
|
|
2617
|
-
|
|
2618
2634
|
return getRandomValues(rnds8);
|
|
2619
2635
|
}
|
|
2620
2636
|
|
|
2621
|
-
|
|
2622
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
2623
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
2624
|
-
*/
|
|
2625
|
-
|
|
2626
|
-
const byteToHex = [];
|
|
2627
|
-
|
|
2628
|
-
for (let i = 0; i < 256; ++i) {
|
|
2629
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
2630
|
-
}
|
|
2631
|
-
|
|
2632
|
-
function unsafeStringify(arr, offset = 0) {
|
|
2633
|
-
// Note: Be careful editing this code! It's been tuned for performance
|
|
2634
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
2635
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
2636
|
-
}
|
|
2637
|
-
|
|
2638
|
-
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
2637
|
+
var randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
2639
2638
|
const native = {
|
|
2640
2639
|
randomUUID
|
|
2641
2640
|
};
|
|
@@ -2644,26 +2643,69 @@ function v4(options, buf, offset) {
|
|
|
2644
2643
|
if (native.randomUUID && !buf && !options) {
|
|
2645
2644
|
return native.randomUUID();
|
|
2646
2645
|
}
|
|
2647
|
-
|
|
2648
2646
|
options = options || {};
|
|
2649
|
-
|
|
2647
|
+
var rnds = options.random || (options.rng || rng)();
|
|
2650
2648
|
|
|
2649
|
+
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
2651
2650
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
2652
|
-
rnds[8] = rnds[8] & 0x3f | 0x80;
|
|
2651
|
+
rnds[8] = rnds[8] & 0x3f | 0x80;
|
|
2653
2652
|
|
|
2653
|
+
// Copy bytes to buffer, if provided
|
|
2654
2654
|
if (buf) {
|
|
2655
2655
|
offset = offset || 0;
|
|
2656
|
-
|
|
2657
|
-
for (let i = 0; i < 16; ++i) {
|
|
2656
|
+
for (var i = 0; i < 16; ++i) {
|
|
2658
2657
|
buf[offset + i] = rnds[i];
|
|
2659
2658
|
}
|
|
2660
|
-
|
|
2661
2659
|
return buf;
|
|
2662
2660
|
}
|
|
2663
|
-
|
|
2664
2661
|
return unsafeStringify(rnds);
|
|
2665
2662
|
}
|
|
2666
2663
|
|
|
2664
|
+
const PITCHER_EVENT = "PITCHER_EVENT";
|
|
2665
|
+
var PitcherMessageType = /* @__PURE__ */ ((PitcherMessageType2) => {
|
|
2666
|
+
PitcherMessageType2["REQUEST"] = "PITCHER_REQUEST";
|
|
2667
|
+
PitcherMessageType2["RESPONSE"] = "PITCHER_RESPONSE";
|
|
2668
|
+
return PitcherMessageType2;
|
|
2669
|
+
})(PitcherMessageType || {});
|
|
2670
|
+
var PitcherResponseStatus = /* @__PURE__ */ ((PitcherResponseStatus2) => {
|
|
2671
|
+
PitcherResponseStatus2["OK"] = "ok";
|
|
2672
|
+
PitcherResponseStatus2["ERROR"] = "error";
|
|
2673
|
+
return PitcherResponseStatus2;
|
|
2674
|
+
})(PitcherResponseStatus || {});
|
|
2675
|
+
var PitcherEventName = /* @__PURE__ */ ((PitcherEventName2) => {
|
|
2676
|
+
PitcherEventName2["ENV_CHANGED"] = "env_changed";
|
|
2677
|
+
PitcherEventName2["PHOTOS_CAPTURED"] = "photos_captured";
|
|
2678
|
+
PitcherEventName2["FILE_DOWNLOADED"] = "file_downloaded";
|
|
2679
|
+
PitcherEventName2["FILE_UPLOAD_PROGRESS"] = "file_upload_progress";
|
|
2680
|
+
PitcherEventName2["UPDATE_LOCATION"] = "update_location";
|
|
2681
|
+
PitcherEventName2["CANVAS_UPDATED"] = "canvas_updated";
|
|
2682
|
+
PitcherEventName2["CANVAS_UPDATED_SUCCESS"] = "canvas_updated_success";
|
|
2683
|
+
PitcherEventName2["FILE_CLOSED"] = "file_closed";
|
|
2684
|
+
PitcherEventName2["APP_BACKGROUNDED"] = "app_backgrounded";
|
|
2685
|
+
PitcherEventName2["APP_FOREGROUNDED"] = "app_foregrounded";
|
|
2686
|
+
PitcherEventName2["NON_FILES_SYNC_FINISHED"] = "non_files_sync_finished";
|
|
2687
|
+
PitcherEventName2["CONTENT_LIST_REFRESH_REQUESTED"] = "content_list_refresh_requested";
|
|
2688
|
+
PitcherEventName2["NETWORK_CONNECTION_ESTABLISHED"] = "network_connection_established";
|
|
2689
|
+
PitcherEventName2["NETWORK_CONNECTION_LOST"] = "network_connection_lost";
|
|
2690
|
+
PitcherEventName2["ENTERED_FULLSCREEN"] = "entered_fullscreen";
|
|
2691
|
+
PitcherEventName2["EXITED_FULLSCREEN"] = "exited_fullscreen";
|
|
2692
|
+
PitcherEventName2["SUBMIT_POSTCALL_CLICKED"] = "submit_postcall_clicked";
|
|
2693
|
+
return PitcherEventName2;
|
|
2694
|
+
})(PitcherEventName || {});
|
|
2695
|
+
var PitcherBroadcastedEventName = /* @__PURE__ */ ((PitcherBroadcastedEventName2) => {
|
|
2696
|
+
PitcherBroadcastedEventName2["UI_SHOW_MODAL"] = "ui:show-modal";
|
|
2697
|
+
PitcherBroadcastedEventName2["UI_HIDE_MODAL"] = "ui:hide-modal";
|
|
2698
|
+
PitcherBroadcastedEventName2["FAVORITES_CHANGED"] = "favorites:changed";
|
|
2699
|
+
PitcherBroadcastedEventName2["FILE_DOWNLOAD"] = "file:download";
|
|
2700
|
+
return PitcherBroadcastedEventName2;
|
|
2701
|
+
})(PitcherBroadcastedEventName || {});
|
|
2702
|
+
var PitcherExternalEventName = /* @__PURE__ */ ((PitcherExternalEventName2) => {
|
|
2703
|
+
PitcherExternalEventName2["CREATE_AND_OPEN_CANVAS"] = "create_and_open_canvas";
|
|
2704
|
+
PitcherExternalEventName2["OPEN_CANVAS"] = "open_canvas";
|
|
2705
|
+
PitcherExternalEventName2["START_CALL"] = "start_call";
|
|
2706
|
+
return PitcherExternalEventName2;
|
|
2707
|
+
})(PitcherExternalEventName || {});
|
|
2708
|
+
|
|
2667
2709
|
class AssertionError extends Error {
|
|
2668
2710
|
}
|
|
2669
2711
|
function assert(exp, message) {
|
|
@@ -2736,16 +2778,167 @@ function isOriginValid(event, allowedOrigins = [], isDev = ["development", "test
|
|
|
2736
2778
|
return isValid;
|
|
2737
2779
|
}
|
|
2738
2780
|
|
|
2781
|
+
const MAX_RETRIES = 5;
|
|
2782
|
+
const BASE_DELAY = 1e3;
|
|
2783
|
+
function paramsSerializer(params) {
|
|
2784
|
+
const searchParams = new URLSearchParams();
|
|
2785
|
+
for (const key in params) {
|
|
2786
|
+
if (Array.isArray(params[key])) {
|
|
2787
|
+
params[key].forEach((val) => searchParams.append(key, val));
|
|
2788
|
+
} else {
|
|
2789
|
+
searchParams.append(key, params[key]);
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
return searchParams.toString();
|
|
2793
|
+
}
|
|
2794
|
+
async function fetchWithRetry(url, options, remainingRetries = MAX_RETRIES) {
|
|
2795
|
+
try {
|
|
2796
|
+
const response = await fetch(url, options);
|
|
2797
|
+
if (!response.ok) {
|
|
2798
|
+
if (response.status >= 500 && response.status < 600 && remainingRetries > 0) {
|
|
2799
|
+
const delay = BASE_DELAY * Math.pow(2, MAX_RETRIES - remainingRetries);
|
|
2800
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2801
|
+
return fetchWithRetry(url, options, remainingRetries - 1);
|
|
2802
|
+
}
|
|
2803
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
2804
|
+
}
|
|
2805
|
+
return response.json();
|
|
2806
|
+
} catch (error) {
|
|
2807
|
+
if (remainingRetries > 0) {
|
|
2808
|
+
const delay = BASE_DELAY * Math.pow(2, MAX_RETRIES - remainingRetries);
|
|
2809
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2810
|
+
return fetchWithRetry(url, options, remainingRetries - 1);
|
|
2811
|
+
}
|
|
2812
|
+
throw error;
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
function createHttpClient(origin, token) {
|
|
2816
|
+
const headers = {
|
|
2817
|
+
"Content-Type": "application/json",
|
|
2818
|
+
Authorization: `Bearer ${token}`
|
|
2819
|
+
};
|
|
2820
|
+
const basePath = origin + "/api/v1";
|
|
2821
|
+
const baseCommon = { credentials: "include" };
|
|
2822
|
+
return {
|
|
2823
|
+
get: async (endpoint, options = {}) => {
|
|
2824
|
+
const url = new URL(`${basePath}${endpoint}`);
|
|
2825
|
+
if (options.params) {
|
|
2826
|
+
url.search = paramsSerializer(options.params);
|
|
2827
|
+
}
|
|
2828
|
+
const data = await fetchWithRetry(url.toString(), {
|
|
2829
|
+
...baseCommon,
|
|
2830
|
+
...options,
|
|
2831
|
+
method: "GET",
|
|
2832
|
+
headers
|
|
2833
|
+
});
|
|
2834
|
+
return data;
|
|
2835
|
+
},
|
|
2836
|
+
post: async (endpoint, body, options = {}) => {
|
|
2837
|
+
const url = new URL(`${basePath}${endpoint}`);
|
|
2838
|
+
if (options.params) {
|
|
2839
|
+
url.search = paramsSerializer(options.params);
|
|
2840
|
+
}
|
|
2841
|
+
const data = await fetchWithRetry(url.toString(), {
|
|
2842
|
+
...baseCommon,
|
|
2843
|
+
...options,
|
|
2844
|
+
method: "POST",
|
|
2845
|
+
headers,
|
|
2846
|
+
body: JSON.stringify(body)
|
|
2847
|
+
});
|
|
2848
|
+
return data;
|
|
2849
|
+
},
|
|
2850
|
+
put: async (endpoint, body, options = {}) => {
|
|
2851
|
+
const url = new URL(`${basePath}${endpoint}`);
|
|
2852
|
+
if (options.params) {
|
|
2853
|
+
url.search = paramsSerializer(options.params);
|
|
2854
|
+
}
|
|
2855
|
+
const data = await fetchWithRetry(url.toString(), {
|
|
2856
|
+
...baseCommon,
|
|
2857
|
+
...options,
|
|
2858
|
+
method: "PUT",
|
|
2859
|
+
headers,
|
|
2860
|
+
body: JSON.stringify(body)
|
|
2861
|
+
});
|
|
2862
|
+
return data;
|
|
2863
|
+
},
|
|
2864
|
+
delete: async (endpoint, options = {}) => {
|
|
2865
|
+
const url = new URL(`${basePath}${endpoint}`);
|
|
2866
|
+
if (options.params) {
|
|
2867
|
+
url.search = paramsSerializer(options.params);
|
|
2868
|
+
}
|
|
2869
|
+
const data = await fetchWithRetry(url.toString(), {
|
|
2870
|
+
...baseCommon,
|
|
2871
|
+
...options,
|
|
2872
|
+
method: "DELETE",
|
|
2873
|
+
headers
|
|
2874
|
+
});
|
|
2875
|
+
return data;
|
|
2876
|
+
},
|
|
2877
|
+
patch: async (endpoint, body, options = {}) => {
|
|
2878
|
+
const url = new URL(`${basePath}${endpoint}`);
|
|
2879
|
+
if (options.params) {
|
|
2880
|
+
url.search = paramsSerializer(options.params);
|
|
2881
|
+
}
|
|
2882
|
+
const data = await fetchWithRetry(url.toString(), {
|
|
2883
|
+
...baseCommon,
|
|
2884
|
+
...options,
|
|
2885
|
+
method: "PATCH",
|
|
2886
|
+
headers,
|
|
2887
|
+
body: JSON.stringify(body)
|
|
2888
|
+
});
|
|
2889
|
+
return data;
|
|
2890
|
+
}
|
|
2891
|
+
};
|
|
2892
|
+
}
|
|
2893
|
+
|
|
2894
|
+
let env;
|
|
2895
|
+
let http;
|
|
2896
|
+
const logInfo = (msg, ...rest) => console.info(`[online handlers]: ${msg}`, ...rest);
|
|
2897
|
+
const check = () => {
|
|
2898
|
+
if (!env) throw new Error("Missing env");
|
|
2899
|
+
if (!http) throw new Error("Missing http");
|
|
2900
|
+
};
|
|
2901
|
+
const setEnv = (e) => {
|
|
2902
|
+
env = e;
|
|
2903
|
+
http = createHttpClient(
|
|
2904
|
+
env.pitcher.token_claims["https://pitcher.com/claims/urls"].custom_domain,
|
|
2905
|
+
env.pitcher.access_token
|
|
2906
|
+
);
|
|
2907
|
+
};
|
|
2908
|
+
const onlineRestApiHandlers = {
|
|
2909
|
+
get_canvases: async (params) => {
|
|
2910
|
+
logInfo("online handler get_canvases called with:", params);
|
|
2911
|
+
check();
|
|
2912
|
+
const { api_base_url, ...restParams } = params;
|
|
2913
|
+
const res = await http.get("/canvases", { params: { ...restParams, instance_id: env.pitcher.instance.id } });
|
|
2914
|
+
return res;
|
|
2915
|
+
},
|
|
2916
|
+
get_canvas: async (params) => {
|
|
2917
|
+
logInfo("online handler get_canvas called with:", params);
|
|
2918
|
+
check();
|
|
2919
|
+
const { id, ...restParams } = params;
|
|
2920
|
+
const res = await http.get(`/canvases/${params.id}`, { params: restParams });
|
|
2921
|
+
return res;
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2924
|
+
|
|
2925
|
+
function updateOnlineHandlersEnv(env) {
|
|
2926
|
+
env && setEnv(env);
|
|
2927
|
+
}
|
|
2739
2928
|
class LowLevelApi extends EventEmitter {
|
|
2740
2929
|
constructor(options) {
|
|
2741
2930
|
super();
|
|
2742
2931
|
this.callbacks = {};
|
|
2743
|
-
this.options = options ?? {
|
|
2744
|
-
|
|
2932
|
+
this.options = options ?? {
|
|
2933
|
+
casing: "snake",
|
|
2934
|
+
logLevel: "off",
|
|
2935
|
+
errorLogger: () => {
|
|
2936
|
+
},
|
|
2937
|
+
fetchMode: "postmessage"
|
|
2938
|
+
};
|
|
2745
2939
|
if (typeof window !== "undefined") {
|
|
2746
2940
|
window.addEventListener("message", (event) => {
|
|
2747
|
-
if (!isOriginValid(event))
|
|
2748
|
-
return;
|
|
2941
|
+
if (!isOriginValid(event)) return;
|
|
2749
2942
|
this.options.logLevel === "debug" && console.log("message received", event);
|
|
2750
2943
|
if (event.data.type === "PITCHER_RESPONSE") {
|
|
2751
2944
|
assert(event.data.request.id, "event id is required");
|
|
@@ -2772,6 +2965,7 @@ class LowLevelApi extends EventEmitter {
|
|
|
2772
2965
|
this.emit("event", event);
|
|
2773
2966
|
}
|
|
2774
2967
|
request(type, body = null) {
|
|
2968
|
+
const fetchMode = this.options.fetchMode ?? "prefer-online";
|
|
2775
2969
|
return new Promise((resolve, reject) => {
|
|
2776
2970
|
const id = v4();
|
|
2777
2971
|
const callback = (res) => {
|
|
@@ -2780,6 +2974,7 @@ class LowLevelApi extends EventEmitter {
|
|
|
2780
2974
|
resolve(
|
|
2781
2975
|
this.options.casing === "camel" ? camelCaseKeys(res.response.body) : res.response.body
|
|
2782
2976
|
);
|
|
2977
|
+
if (type === "get_env") updateOnlineHandlersEnv(res.response.body);
|
|
2783
2978
|
} else if (res.response.status === "error") {
|
|
2784
2979
|
this.options.errorLogger?.({
|
|
2785
2980
|
message: `Pitcher JS API call failure: ${res.request.type}`,
|
|
@@ -2797,18 +2992,40 @@ class LowLevelApi extends EventEmitter {
|
|
|
2797
2992
|
payload: payload ?? {},
|
|
2798
2993
|
callback
|
|
2799
2994
|
};
|
|
2800
|
-
if (
|
|
2801
|
-
|
|
2802
|
-
{
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
type,
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
}
|
|
2810
|
-
|
|
2811
|
-
|
|
2995
|
+
if (fetchMode === "prefer-online" && type && onlineRestApiHandlers[type]) {
|
|
2996
|
+
onlineRestApiHandlers[type](payload).then((data) => {
|
|
2997
|
+
if (this.callbacks[id]) {
|
|
2998
|
+
this.callbacks[id].callback({
|
|
2999
|
+
type: PitcherMessageType.RESPONSE,
|
|
3000
|
+
request: { id, type },
|
|
3001
|
+
response: { status: PitcherResponseStatus.OK, body: data }
|
|
3002
|
+
});
|
|
3003
|
+
delete this.callbacks[id];
|
|
3004
|
+
}
|
|
3005
|
+
}).catch((error) => {
|
|
3006
|
+
if (this.callbacks[id]) {
|
|
3007
|
+
this.callbacks[id].callback({
|
|
3008
|
+
type: PitcherMessageType.RESPONSE,
|
|
3009
|
+
request: { id, type },
|
|
3010
|
+
response: { status: PitcherResponseStatus.ERROR, body: error }
|
|
3011
|
+
});
|
|
3012
|
+
delete this.callbacks[id];
|
|
3013
|
+
}
|
|
3014
|
+
});
|
|
3015
|
+
} else {
|
|
3016
|
+
if (typeof window !== "undefined" && window.top) {
|
|
3017
|
+
window.top.postMessage(
|
|
3018
|
+
{
|
|
3019
|
+
type: "PITCHER_REQUEST",
|
|
3020
|
+
request: {
|
|
3021
|
+
type,
|
|
3022
|
+
id,
|
|
3023
|
+
body: payload
|
|
3024
|
+
}
|
|
3025
|
+
},
|
|
3026
|
+
"*"
|
|
3027
|
+
);
|
|
3028
|
+
}
|
|
2812
3029
|
}
|
|
2813
3030
|
});
|
|
2814
3031
|
}
|
|
@@ -2837,8 +3054,7 @@ function createHighLevelApi(options) {
|
|
|
2837
3054
|
}
|
|
2838
3055
|
|
|
2839
3056
|
function usePostRobot() {
|
|
2840
|
-
if (window.postRobot)
|
|
2841
|
-
return window.postRobot;
|
|
3057
|
+
if (window.postRobot) return window.postRobot;
|
|
2842
3058
|
return Promise.resolve().then(() => index).then((m) => m.default || m);
|
|
2843
3059
|
}
|
|
2844
3060
|
|
|
@@ -2853,11 +3069,28 @@ const UI_API_METHOD_TYPES = {
|
|
|
2853
3069
|
UI_UPDATE_CANVAS: "ui_update_canvas",
|
|
2854
3070
|
UI_UPDATE_LOCATION: "ui_update_location",
|
|
2855
3071
|
UI_PRESELECT_SFDC_MEETING_ID: "ui_preselect_sfdc_meeting_id",
|
|
2856
|
-
|
|
3072
|
+
UI_SET_POSTCALL_STYLE: "ui_set_postcall_style",
|
|
3073
|
+
UI_ENABLE_POSTCALL_SUBMIT: "ui_enable_postcall_submit",
|
|
3074
|
+
UI_DISABLE_POSTCALL_SUBMIT: "ui_disable_postcall_submit",
|
|
3075
|
+
UI_COMPLETE_POSTCALL: "ui_complete_postcall",
|
|
3076
|
+
UI_CANVAS_NAVIGATE_NEXT_PAGE: "ui_canvas_navigate_next_page",
|
|
3077
|
+
UI_CANVAS_NAVIGATE_PREVIOUS_PAGE: "ui_canvas_navigate_previous_page",
|
|
3078
|
+
UI_CANVAS_NAVIGATE_PAGE: "ui_canvas_navigate_page",
|
|
3079
|
+
UI_APP_LOADED: "ui_app_loaded",
|
|
3080
|
+
UI_APP_RESIZE: "ui_app_resize"
|
|
2857
3081
|
};
|
|
2858
3082
|
const UI_MESSAGE_TYPES = {
|
|
2859
|
-
UI_MEETING_CANCELED: "ui_meeting_canceled"
|
|
3083
|
+
UI_MEETING_CANCELED: "ui_meeting_canceled",
|
|
3084
|
+
UI_CANVAS_UPDATED: "ui_canvas_updated",
|
|
3085
|
+
UI_SECTION_LIST_UPDATED: "ui_section_list_updated",
|
|
3086
|
+
UI_APP_SET_DATA: "ui_app_set_data",
|
|
3087
|
+
UI_APP_UPDATE_DATA: "ui_app_update_data"
|
|
2860
3088
|
};
|
|
3089
|
+
const UI_NATIVE_MESSAGE_TYPES = [
|
|
3090
|
+
UI_MESSAGE_TYPES.UI_APP_SET_DATA,
|
|
3091
|
+
UI_MESSAGE_TYPES.UI_APP_UPDATE_DATA,
|
|
3092
|
+
UI_MESSAGE_TYPES.UI_CANVAS_UPDATED
|
|
3093
|
+
];
|
|
2861
3094
|
|
|
2862
3095
|
async function ui_select_content(payload = {}) {
|
|
2863
3096
|
const pr = await usePostRobot();
|
|
@@ -2905,17 +3138,78 @@ async function update_canvas(payload) {
|
|
|
2905
3138
|
const pr = await usePostRobot();
|
|
2906
3139
|
return pr.send(window.parent, UI_API_METHOD_TYPES.UI_UPDATE_CANVAS, payload).then((response) => response.data);
|
|
2907
3140
|
}
|
|
3141
|
+
async function app_loaded() {
|
|
3142
|
+
window.parent.postMessage({ type: UI_API_METHOD_TYPES.UI_APP_LOADED, body: {} }, "*");
|
|
3143
|
+
}
|
|
3144
|
+
async function app_resize(payload) {
|
|
3145
|
+
window.parent.postMessage({ type: UI_API_METHOD_TYPES.UI_APP_RESIZE, body: payload }, "*");
|
|
3146
|
+
}
|
|
3147
|
+
async function canvas_navigate_next_page() {
|
|
3148
|
+
const pr = await usePostRobot();
|
|
3149
|
+
pr.send(window.parent, UI_API_METHOD_TYPES.UI_CANVAS_NAVIGATE_NEXT_PAGE);
|
|
3150
|
+
}
|
|
3151
|
+
async function canvas_navigate_previous_page() {
|
|
3152
|
+
const pr = await usePostRobot();
|
|
3153
|
+
pr.send(window.parent, UI_API_METHOD_TYPES.UI_CANVAS_NAVIGATE_PREVIOUS_PAGE);
|
|
3154
|
+
}
|
|
3155
|
+
async function canvas_navigate_page(payload) {
|
|
3156
|
+
const pr = await usePostRobot();
|
|
3157
|
+
pr.send(window.parent, UI_API_METHOD_TYPES.UI_CANVAS_NAVIGATE_PAGE, payload);
|
|
3158
|
+
}
|
|
2908
3159
|
|
|
2909
3160
|
async function complete_postcall(payload) {
|
|
2910
3161
|
const pr = await usePostRobot();
|
|
2911
3162
|
pr.send(window.parent, UI_API_METHOD_TYPES.UI_COMPLETE_POSTCALL, payload);
|
|
2912
3163
|
}
|
|
3164
|
+
async function enable_postcall_submit() {
|
|
3165
|
+
const pr = await usePostRobot();
|
|
3166
|
+
pr.send(window.parent, UI_API_METHOD_TYPES.UI_ENABLE_POSTCALL_SUBMIT);
|
|
3167
|
+
}
|
|
3168
|
+
async function disable_postcall_submit() {
|
|
3169
|
+
const pr = await usePostRobot();
|
|
3170
|
+
pr.send(window.parent, UI_API_METHOD_TYPES.UI_DISABLE_POSTCALL_SUBMIT);
|
|
3171
|
+
}
|
|
3172
|
+
async function set_postcall_style(payload) {
|
|
3173
|
+
const pr = await usePostRobot();
|
|
3174
|
+
pr.send(window.parent, UI_API_METHOD_TYPES.UI_SET_POSTCALL_STYLE, payload);
|
|
3175
|
+
}
|
|
2913
3176
|
|
|
2914
|
-
async function
|
|
3177
|
+
async function on_native(type, handler) {
|
|
3178
|
+
console.log("attaching native handler for type", type);
|
|
3179
|
+
const messageListener = (event) => {
|
|
3180
|
+
if (event.data.type === type) {
|
|
3181
|
+
handler(event.data.body);
|
|
3182
|
+
}
|
|
3183
|
+
};
|
|
3184
|
+
window.addEventListener("message", messageListener);
|
|
3185
|
+
return () => window.removeEventListener("message", messageListener);
|
|
3186
|
+
}
|
|
3187
|
+
async function on_post_robot(type, handler) {
|
|
2915
3188
|
const pr = await usePostRobot();
|
|
2916
3189
|
const listener = pr.on(type, (e) => handler(e.data));
|
|
2917
3190
|
return listener.cancel;
|
|
2918
3191
|
}
|
|
3192
|
+
function on$2(type, handler) {
|
|
3193
|
+
if (UI_NATIVE_MESSAGE_TYPES.includes(type)) {
|
|
3194
|
+
return on_native(type, handler);
|
|
3195
|
+
}
|
|
3196
|
+
return on_post_robot(type, handler);
|
|
3197
|
+
}
|
|
3198
|
+
function on_meeting_canceled(handler) {
|
|
3199
|
+
return on$2(UI_MESSAGE_TYPES.UI_MEETING_CANCELED, handler);
|
|
3200
|
+
}
|
|
3201
|
+
function on_canvas_updated(handler) {
|
|
3202
|
+
return on$2(UI_MESSAGE_TYPES.UI_CANVAS_UPDATED, handler);
|
|
3203
|
+
}
|
|
3204
|
+
function on_section_list_updated(handler) {
|
|
3205
|
+
return on$2(UI_MESSAGE_TYPES.UI_SECTION_LIST_UPDATED, handler);
|
|
3206
|
+
}
|
|
3207
|
+
function on_app_set_data(handler) {
|
|
3208
|
+
return on$2(UI_MESSAGE_TYPES.UI_APP_SET_DATA, handler);
|
|
3209
|
+
}
|
|
3210
|
+
function on_app_update_data(handler) {
|
|
3211
|
+
return on$2(UI_MESSAGE_TYPES.UI_APP_UPDATE_DATA, handler);
|
|
3212
|
+
}
|
|
2919
3213
|
async function ui_broadcast(payload) {
|
|
2920
3214
|
const pr = await usePostRobot();
|
|
2921
3215
|
pr.send(window.parent, UI_API_METHOD_TYPES.UI_BROADCAST, payload);
|
|
@@ -2923,13 +3217,26 @@ async function ui_broadcast(payload) {
|
|
|
2923
3217
|
|
|
2924
3218
|
const ui = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
2925
3219
|
__proto__: null,
|
|
3220
|
+
app_loaded,
|
|
3221
|
+
app_resize,
|
|
3222
|
+
canvas_navigate_next_page,
|
|
3223
|
+
canvas_navigate_page,
|
|
3224
|
+
canvas_navigate_previous_page,
|
|
2926
3225
|
capture_app_error,
|
|
2927
3226
|
complete_postcall,
|
|
3227
|
+
disable_postcall_submit,
|
|
2928
3228
|
embeddable_ready: embeddable_ready$1,
|
|
3229
|
+
enable_postcall_submit,
|
|
2929
3230
|
on: on$2,
|
|
3231
|
+
on_app_set_data,
|
|
3232
|
+
on_app_update_data,
|
|
3233
|
+
on_canvas_updated,
|
|
3234
|
+
on_meeting_canceled,
|
|
3235
|
+
on_section_list_updated,
|
|
2930
3236
|
open,
|
|
2931
3237
|
preselect_sfdc_meeting_id,
|
|
2932
3238
|
select_content,
|
|
3239
|
+
set_postcall_style,
|
|
2933
3240
|
toast,
|
|
2934
3241
|
ui_broadcast,
|
|
2935
3242
|
ui_select_content,
|
|
@@ -3042,55 +3349,9 @@ const dsr = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
3042
3349
|
on
|
|
3043
3350
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
3044
3351
|
|
|
3045
|
-
const PITCHER_EVENT = "PITCHER_EVENT";
|
|
3046
|
-
var PitcherMessageType = /* @__PURE__ */ ((PitcherMessageType2) => {
|
|
3047
|
-
PitcherMessageType2["REQUEST"] = "PITCHER_REQUEST";
|
|
3048
|
-
PitcherMessageType2["RESPONSE"] = "PITCHER_RESPONSE";
|
|
3049
|
-
return PitcherMessageType2;
|
|
3050
|
-
})(PitcherMessageType || {});
|
|
3051
|
-
var PitcherResponseStatus = /* @__PURE__ */ ((PitcherResponseStatus2) => {
|
|
3052
|
-
PitcherResponseStatus2["OK"] = "ok";
|
|
3053
|
-
PitcherResponseStatus2["ERROR"] = "error";
|
|
3054
|
-
return PitcherResponseStatus2;
|
|
3055
|
-
})(PitcherResponseStatus || {});
|
|
3056
|
-
var PitcherEventName = /* @__PURE__ */ ((PitcherEventName2) => {
|
|
3057
|
-
PitcherEventName2["ENV_CHANGED"] = "env_changed";
|
|
3058
|
-
PitcherEventName2["PHOTOS_CAPTURED"] = "photos_captured";
|
|
3059
|
-
PitcherEventName2["FILE_DOWNLOADED"] = "file_downloaded";
|
|
3060
|
-
PitcherEventName2["FILE_UPLOAD_PROGRESS"] = "file_upload_progress";
|
|
3061
|
-
PitcherEventName2["UPDATE_LOCATION"] = "update_location";
|
|
3062
|
-
PitcherEventName2["CANVAS_UPDATED"] = "canvas_updated";
|
|
3063
|
-
PitcherEventName2["CANVAS_UPDATED_SUCCESS"] = "canvas_updated_success";
|
|
3064
|
-
PitcherEventName2["FILE_CLOSED"] = "file_closed";
|
|
3065
|
-
PitcherEventName2["APP_BACKGROUNDED"] = "app_backgrounded";
|
|
3066
|
-
PitcherEventName2["APP_FOREGROUNDED"] = "app_foregrounded";
|
|
3067
|
-
PitcherEventName2["NON_FILES_SYNC_FINISHED"] = "non_files_sync_finished";
|
|
3068
|
-
PitcherEventName2["CONTENT_LIST_REFRESH_REQUESTED"] = "content_list_refresh_requested";
|
|
3069
|
-
PitcherEventName2["NETWORK_CONNECTION_ESTABLISHED"] = "network_connection_established";
|
|
3070
|
-
PitcherEventName2["NETWORK_CONNECTION_LOST"] = "network_connection_lost";
|
|
3071
|
-
PitcherEventName2["ENTERED_FULLSCREEN"] = "entered_fullscreen";
|
|
3072
|
-
PitcherEventName2["EXITED_FULLSCREEN"] = "exited_fullscreen";
|
|
3073
|
-
PitcherEventName2["SUBMIT_POSTCALL_CLICKED"] = "submit_postcall_clicked";
|
|
3074
|
-
return PitcherEventName2;
|
|
3075
|
-
})(PitcherEventName || {});
|
|
3076
|
-
var PitcherBroadcastedEventName = /* @__PURE__ */ ((PitcherBroadcastedEventName2) => {
|
|
3077
|
-
PitcherBroadcastedEventName2["UI_SHOW_MODAL"] = "ui:show-modal";
|
|
3078
|
-
PitcherBroadcastedEventName2["UI_HIDE_MODAL"] = "ui:hide-modal";
|
|
3079
|
-
PitcherBroadcastedEventName2["FAVORITES_CHANGED"] = "favorites:changed";
|
|
3080
|
-
PitcherBroadcastedEventName2["FILE_DOWNLOAD"] = "file:download";
|
|
3081
|
-
return PitcherBroadcastedEventName2;
|
|
3082
|
-
})(PitcherBroadcastedEventName || {});
|
|
3083
|
-
var PitcherExternalEventName = /* @__PURE__ */ ((PitcherExternalEventName2) => {
|
|
3084
|
-
PitcherExternalEventName2["CREATE_AND_OPEN_CANVAS"] = "create_and_open_canvas";
|
|
3085
|
-
PitcherExternalEventName2["OPEN_CANVAS"] = "open_canvas";
|
|
3086
|
-
PitcherExternalEventName2["START_CALL"] = "start_call";
|
|
3087
|
-
return PitcherExternalEventName2;
|
|
3088
|
-
})(PitcherExternalEventName || {});
|
|
3089
|
-
|
|
3090
3352
|
let highLevelApi;
|
|
3091
3353
|
function usePitcherApi(options) {
|
|
3092
|
-
if (!highLevelApi)
|
|
3093
|
-
highLevelApi = createHighLevelApi(options);
|
|
3354
|
+
if (!highLevelApi) highLevelApi = createHighLevelApi(options);
|
|
3094
3355
|
return highLevelApi;
|
|
3095
3356
|
}
|
|
3096
3357
|
const uiApi = Object.entries(
|
|
@@ -3129,14 +3390,12 @@ function useDsr() {
|
|
|
3129
3390
|
return dsrApi;
|
|
3130
3391
|
}
|
|
3131
3392
|
function getAvailableApis() {
|
|
3132
|
-
if (typeof window === "undefined")
|
|
3133
|
-
throw new Error("getAvailableApis: window is not defined");
|
|
3393
|
+
if (typeof window === "undefined") throw new Error("getAvailableApis: window is not defined");
|
|
3134
3394
|
const location = window.parent.jsApiLocation;
|
|
3135
3395
|
return location === "ui" ? ["ui", "impact"] : [location ?? "impact"];
|
|
3136
3396
|
}
|
|
3137
3397
|
function useApi() {
|
|
3138
|
-
if (typeof window === "undefined")
|
|
3139
|
-
throw new Error("useApi: window is not defined");
|
|
3398
|
+
if (typeof window === "undefined") throw new Error("useApi: window is not defined");
|
|
3140
3399
|
const location = window.parent.jsApiLocation;
|
|
3141
3400
|
switch (location) {
|
|
3142
3401
|
case "ui":
|
|
@@ -3154,5 +3413,5 @@ function useApi() {
|
|
|
3154
3413
|
|
|
3155
3414
|
window.postRobot = pr;
|
|
3156
3415
|
|
|
3157
|
-
export { ADMIN_API_METHOD_TYPES, ADMIN_API_TYPES, ADMIN_MESSAGE, ADMIN_MESSAGE_TYPES, DSR_API_METHOD_TYPES, DSR_API_TYPES, DSR_MESSAGE, DSR_MESSAGE_TYPES, PITCHER_EVENT, PitcherBroadcastedEventName, PitcherEventName, PitcherExternalEventName, PitcherMessageType, PitcherResponseStatus, UI_API_METHOD_TYPES, UI_MESSAGE, UI_MESSAGE_TYPES, getAvailableApis, highLevelApi, useAdmin, useApi, useDsr, usePitcherApi, useUi };
|
|
3416
|
+
export { ADMIN_API_METHOD_TYPES, ADMIN_API_TYPES, ADMIN_MESSAGE, ADMIN_MESSAGE_TYPES, DSR_API_METHOD_TYPES, DSR_API_TYPES, DSR_MESSAGE, DSR_MESSAGE_TYPES, PITCHER_EVENT, PitcherBroadcastedEventName, PitcherEventName, PitcherExternalEventName, PitcherMessageType, PitcherResponseStatus, UI_API_METHOD_TYPES, UI_MESSAGE, UI_MESSAGE_TYPES, UI_NATIVE_MESSAGE_TYPES, getAvailableApis, highLevelApi, useAdmin, useApi, useDsr, usePitcherApi, useUi };
|
|
3158
3417
|
//# sourceMappingURL=js-api.esm.js.map
|