From d27f5ee8e22a54ad7648b9adcefa41b2f6bb59b2 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 12 Nov 2018 12:37:22 -0500 Subject: [PATCH] wip: remove outdated files --- packages/scheduler/src/index.ts | 2 - packages/scheduler/src/patchNodeOps.ts | 51 ------------------- packages/scheduler/src/sync.ts | 69 -------------------------- 3 files changed, 122 deletions(-) delete mode 100644 packages/scheduler/src/index.ts delete mode 100644 packages/scheduler/src/patchNodeOps.ts delete mode 100644 packages/scheduler/src/sync.ts diff --git a/packages/scheduler/src/index.ts b/packages/scheduler/src/index.ts deleted file mode 100644 index d07e7c3e..00000000 --- a/packages/scheduler/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './experimental' -// export * from './sync' diff --git a/packages/scheduler/src/patchNodeOps.ts b/packages/scheduler/src/patchNodeOps.ts deleted file mode 100644 index e99239af..00000000 --- a/packages/scheduler/src/patchNodeOps.ts +++ /dev/null @@ -1,51 +0,0 @@ -// temporary hack to wrap nodeOps so it works with time-slicing -import { NodeOps } from '@vue/runtime-core' -import { nodeOps } from '../../runtime-dom/src/nodeOps' -import { nodeOps as testNodeOps } from '../../runtime-test/src/nodeOps' - -export type Op = [Function, ...any[]] - -let currentOps: Op[] | null = null - -export function setCurrentOps(ops: Op[] | null) { - currentOps = ops -} - -const evaluate = (v: any) => { - return typeof v === 'function' ? v() : v -} - -// patch nodeOps to record operations without touching the DOM -function patchOps(nodeOps: NodeOps) { - Object.keys(nodeOps).forEach((key: keyof NodeOps) => { - const original = nodeOps[key] as Function - if (key === 'querySelector') { - return - } - if (/create/.test(key)) { - nodeOps[key] = (...args: any[]) => { - let res: any - if (currentOps) { - return () => res || (res = original(...args)) - } else { - return original(...args) - } - } - } else if (!/parent|next|query/.test(key)) { - nodeOps[key] = (...args: any[]) => { - if (currentOps) { - currentOps.push([original, ...args.map(evaluate)]) - } else { - return original(...args) - } - } - } else { - nodeOps[key] = (node: any) => { - return original(evaluate(node)) - } - } - }) -} - -patchOps(nodeOps) -patchOps(testNodeOps) diff --git a/packages/scheduler/src/sync.ts b/packages/scheduler/src/sync.ts deleted file mode 100644 index 0ab693c4..00000000 --- a/packages/scheduler/src/sync.ts +++ /dev/null @@ -1,69 +0,0 @@ -const queue: Array<() => void> = [] -const postFlushCbs: Array<() => void> = [] -const p = Promise.resolve() - -let isFlushing = false - -export function nextTick(fn?: () => void): Promise { - return p.then(fn) -} - -export function queueJob( - job: () => void, - postFlushCb?: () => void, - onError?: (err: Error) => void -) { - if (queue.indexOf(job) === -1) { - queue.push(job) - if (!isFlushing) { - isFlushing = true - const p = nextTick(flushJobs) - if (onError) p.catch(onError) - } - } - if (postFlushCb && postFlushCbs.indexOf(postFlushCb) === -1) { - postFlushCbs.push(postFlushCb) - } -} - -const RECURSION_LIMIT = 100 -type JobCountMap = Map - -function flushJobs(seenJobs?: JobCountMap) { - let job - if (__DEV__) { - seenJobs = seenJobs || new Map() - } - while ((job = queue.shift())) { - if (__DEV__) { - const seen = seenJobs as JobCountMap - if (!seen.has(job)) { - seen.set(job, 1) - } else { - const count = seen.get(job) as number - if (count > RECURSION_LIMIT) { - throw new Error( - 'Maximum recursive updates exceeded. ' + - "You may have code that is mutating state in your component's " + - 'render function or updated hook.' - ) - } else { - seen.set(job, count + 1) - } - } - } - job() - } - const cbs = postFlushCbs.slice() - postFlushCbs.length = 0 - for (let i = 0; i < cbs.length; i++) { - cbs[i]() - } - // some postFlushCb queued jobs! - // keep flushing until it drains. - if (queue.length) { - flushJobs(seenJobs) - } else { - isFlushing = false - } -}