chore(system): add polyfill for Promise.withResolvers #5210
This commit is contained in:
@@ -18,7 +18,8 @@ import {
|
||||
type UpdateConnection,
|
||||
type ConnectionState,
|
||||
type NodeOrigin,
|
||||
updateAbsolutePositions
|
||||
updateAbsolutePositions,
|
||||
withResolvers
|
||||
} from '@xyflow/system';
|
||||
|
||||
import type { EdgeTypes, NodeTypes, Node, Edge, FitViewOptions } from '$lib/types';
|
||||
@@ -146,7 +147,7 @@ export function createStore({
|
||||
function fitView(options?: FitViewOptions) {
|
||||
// We either create a new Promise or reuse the existing one
|
||||
// Even if fitView is called multiple times in a row, we only end up with a single Promise
|
||||
const fitViewResolver = get(store.fitViewResolver) ?? Promise.withResolvers<boolean>();
|
||||
const fitViewResolver = get(store.fitViewResolver) ?? withResolvers<boolean>();
|
||||
|
||||
// We schedule a fitView by setting fitViewQueued and triggering a setNodes
|
||||
store.fitViewQueued.set(true);
|
||||
|
||||
@@ -25,7 +25,8 @@ import {
|
||||
type EdgeLookup,
|
||||
type ConnectionState,
|
||||
type ParentLookup,
|
||||
getInternalNodesBounds
|
||||
getInternalNodesBounds,
|
||||
withResolvers
|
||||
} from '@xyflow/system';
|
||||
|
||||
import DefaultNode from '$lib/components/nodes/DefaultNode.svelte';
|
||||
@@ -114,7 +115,7 @@ export const getInitialStore = ({
|
||||
|
||||
const fitViewQueued = writable<boolean>(false);
|
||||
const fitViewOptions = writable<FitViewOptions | undefined>(undefined);
|
||||
const fitViewResolver = writable<PromiseWithResolvers<boolean> | null>(null);
|
||||
const fitViewResolver = writable<ReturnType<typeof withResolvers<boolean>> | null>(null);
|
||||
const panZoom = writable<PanZoomInstance | null>(null);
|
||||
const widthStore = writable<number>(500);
|
||||
const heightStore = writable<number>(500);
|
||||
|
||||
@@ -18,7 +18,8 @@ import {
|
||||
type NodeOrigin,
|
||||
infiniteExtent,
|
||||
type CoordinateExtent,
|
||||
fitViewport
|
||||
fitViewport,
|
||||
withResolvers
|
||||
} from '@xyflow/system';
|
||||
|
||||
import type {
|
||||
@@ -145,7 +146,7 @@ export const createNodesStore = (
|
||||
nodeExtent: CoordinateExtent = infiniteExtent,
|
||||
fitViewQueued: Writable<boolean>,
|
||||
fitViewOptions: Writable<FitViewOptions | undefined>,
|
||||
fitViewResolver: Writable<PromiseWithResolvers<boolean> | null>,
|
||||
fitViewResolver: Writable<ReturnType<typeof withResolvers<boolean>> | null>,
|
||||
panZoom: Writable<PanZoomInstance | null>,
|
||||
width: Writable<number>,
|
||||
height: Writable<number>,
|
||||
|
||||
Reference in New Issue
Block a user