@tldraw/utils 3.16.0-next.eafb52d15064 → 3.16.0-next.fe14f1b4181f

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.
@@ -9,7 +9,7 @@ import { default as uniq } from 'lodash.uniq';
9
9
 
10
10
  /* Excluded from this release type: areObjectsShallowEqual */
11
11
 
12
- /* Excluded from this release type: assert */
12
+ /* Excluded from this release type: assert_2 */
13
13
 
14
14
  /* Excluded from this release type: assertExists */
15
15
 
package/dist-cjs/index.js CHANGED
@@ -167,7 +167,7 @@ var import_version2 = require("./lib/version");
167
167
  var import_warn = require("./lib/warn");
168
168
  (0, import_version.registerTldrawLibraryVersion)(
169
169
  "@tldraw/utils",
170
- "3.16.0-next.eafb52d15064",
170
+ "3.16.0-next.fe14f1b4181f",
171
171
  "cjs"
172
172
  );
173
173
  //# sourceMappingURL=index.js.map
@@ -9,7 +9,7 @@ import { default as uniq } from 'lodash.uniq';
9
9
 
10
10
  /* Excluded from this release type: areObjectsShallowEqual */
11
11
 
12
- /* Excluded from this release type: assert */
12
+ /* Excluded from this release type: assert_2 */
13
13
 
14
14
  /* Excluded from this release type: assertExists */
15
15
 
@@ -100,7 +100,7 @@ import { registerTldrawLibraryVersion as registerTldrawLibraryVersion2 } from ".
100
100
  import { warnDeprecatedGetter, warnOnce } from "./lib/warn.mjs";
101
101
  registerTldrawLibraryVersion(
102
102
  "@tldraw/utils",
103
- "3.16.0-next.eafb52d15064",
103
+ "3.16.0-next.fe14f1b4181f",
104
104
  "esm"
105
105
  );
106
106
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tldraw/utils",
3
3
  "description": "tldraw infinite canvas SDK (private utilities).",
4
- "version": "3.16.0-next.eafb52d15064",
4
+ "version": "3.16.0-next.fe14f1b4181f",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
@@ -32,24 +32,16 @@
32
32
  "src"
33
33
  ],
34
34
  "scripts": {
35
- "test-ci": "lazy inherit",
36
- "test": "yarn run -T jest",
37
- "test-coverage": "lazy inherit",
35
+ "test-ci": "yarn run -T vitest run --passWithNoTests",
36
+ "test": "yarn run -T vitest --passWithNoTests",
37
+ "test-coverage": "yarn run -T vitest run --coverage --passWithNoTests",
38
38
  "build": "yarn run -T tsx ../../internal/scripts/build-package.ts",
39
39
  "build-api": "yarn run -T tsx ../../internal/scripts/build-api.ts",
40
40
  "prepack": "yarn run -T tsx ../../internal/scripts/prepack.ts",
41
41
  "postpack": "../../internal/scripts/postpack.sh",
42
42
  "pack-tarball": "yarn pack",
43
- "lint": "yarn run -T tsx ../../internal/scripts/lint.ts"
44
- },
45
- "jest": {
46
- "preset": "../../internal/config/jest/node/jest-preset.js",
47
- "setupFiles": [
48
- "raf/polyfill"
49
- ],
50
- "moduleNameMapper": {
51
- "^~(.*)": "<rootDir>/src/$1"
52
- }
43
+ "lint": "yarn run -T tsx ../../internal/scripts/lint.ts",
44
+ "context": "yarn run -T tsx ../../internal/scripts/context.ts"
53
45
  },
54
46
  "dependencies": {
55
47
  "fractional-indexing-jittered": "^1.0.0",
@@ -63,8 +55,8 @@
63
55
  "@types/lodash.isequalwith": "^4.4.9",
64
56
  "@types/lodash.throttle": "^4.1.9",
65
57
  "@types/lodash.uniq": "^4.5.9",
66
- "jest-environment-jsdom": "^29.7.0",
67
- "lazyrepo": "0.0.0-alpha.27"
58
+ "lazyrepo": "0.0.0-alpha.27",
59
+ "vitest": "^3.2.4"
68
60
  },
69
61
  "module": "dist-esm/index.mjs",
70
62
  "source": "src/index.ts",
@@ -1,43 +1,44 @@
1
+ import { vi } from 'vitest'
1
2
  import { debounce } from './debounce'
2
3
 
3
- jest.useFakeTimers()
4
+ vi.useFakeTimers()
4
5
 
5
6
  describe(debounce, () => {
6
7
  it('should debounce a function', async () => {
7
- const fn = jest.fn()
8
+ const fn = vi.fn()
8
9
  const debounced = debounce(fn, 100)
9
10
  debounced()
10
11
  debounced()
11
12
  debounced()
12
13
  expect(fn).not.toHaveBeenCalled()
13
- jest.advanceTimersByTime(200)
14
+ vi.advanceTimersByTime(200)
14
15
  expect(fn).toHaveBeenCalledTimes(1)
15
- jest.advanceTimersByTime(200)
16
+ vi.advanceTimersByTime(200)
16
17
  expect(fn).toHaveBeenCalledTimes(1)
17
- jest.advanceTimersByTime(200)
18
+ vi.advanceTimersByTime(200)
18
19
  expect(fn).toHaveBeenCalledTimes(1)
19
20
  })
20
21
 
21
22
  it('should debounce a function with arguments', async () => {
22
- const fn = jest.fn()
23
+ const fn = vi.fn()
23
24
  const debounced = debounce(fn, 100)
24
25
  debounced('a', 'b')
25
26
  debounced('a', 'b')
26
27
  debounced('a', 'b')
27
28
  expect(fn).not.toHaveBeenCalled()
28
- jest.advanceTimersByTime(200)
29
+ vi.advanceTimersByTime(200)
29
30
  expect(fn).toHaveBeenCalledTimes(1)
30
31
  expect(fn).toHaveBeenCalledWith('a', 'b')
31
32
  })
32
33
 
33
34
  it('should debounce a function with arguments and return a promise', async () => {
34
- const fn = jest.fn((a, b) => a + b)
35
+ const fn = vi.fn((a, b) => a + b)
35
36
  const debounced = debounce(fn, 100)
36
37
  const promiseA = debounced('a', 'b')
37
38
  const promiseB = debounced('c', 'd')
38
39
  const promiseC = debounced('e', 'f')
39
40
  expect(fn).not.toHaveBeenCalled()
40
- jest.advanceTimersByTime(200)
41
+ vi.advanceTimersByTime(200)
41
42
  expect(fn).toHaveBeenCalledTimes(1)
42
43
  const results = await Promise.all([promiseA, promiseB, promiseC])
43
44
 
@@ -45,12 +46,12 @@ describe(debounce, () => {
45
46
  })
46
47
 
47
48
  it('can be called across multiple debounce windows', async () => {
48
- const fn = jest.fn((a, b) => a + b)
49
+ const fn = vi.fn((a, b) => a + b)
49
50
  const debounced = debounce(fn, 100)
50
51
  const promiseA = debounced('a', 'b')
51
52
  const promiseB = debounced('c', 'd')
52
53
  expect(fn).not.toHaveBeenCalled()
53
- jest.advanceTimersByTime(200)
54
+ vi.advanceTimersByTime(200)
54
55
  expect(fn).toHaveBeenCalledTimes(1)
55
56
 
56
57
  expect(await Promise.all([promiseA, promiseB])).toEqual(['cd', 'cd'])
@@ -59,7 +60,7 @@ describe(debounce, () => {
59
60
  const promiseD = debounced('g', 'h')
60
61
  expect(fn).toHaveBeenCalledTimes(1)
61
62
 
62
- jest.advanceTimersByTime(200)
63
+ vi.advanceTimersByTime(200)
63
64
 
64
65
  expect(fn).toHaveBeenCalledTimes(2)
65
66
  expect(await Promise.all([promiseC, promiseD])).toEqual(['gh', 'gh'])
@@ -1,28 +1,29 @@
1
+ import { vi } from 'vitest'
1
2
  import { clearRegisteredVersionsForTests, registerTldrawLibraryVersion } from './version'
2
3
 
3
- jest.useFakeTimers()
4
+ vi.useFakeTimers()
4
5
 
5
6
  describe('registerTldrawLibraryVersion', () => {
6
7
  afterEach(() => {
7
8
  clearRegisteredVersionsForTests()
8
- jest.restoreAllMocks()
9
+ vi.restoreAllMocks()
9
10
  })
10
11
 
11
12
  it('doesnt log anything if all versions are the same', () => {
12
- const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
13
+ const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
13
14
 
14
15
  registerTldrawLibraryVersion('tldraw', '1.0.0', 'esm')
15
16
  registerTldrawLibraryVersion('@tldraw/editor', '1.0.0', 'esm')
16
17
  registerTldrawLibraryVersion('@tldraw/utils', '1.0.0', 'esm')
17
18
  registerTldrawLibraryVersion('@tldraw/tlschema', '1.0.0', 'esm')
18
19
 
19
- jest.runAllTimers()
20
+ vi.runAllTimers()
20
21
 
21
22
  expect(consoleLogSpy).toHaveBeenCalledTimes(0)
22
23
  })
23
24
 
24
25
  it('logs if not all versions match', () => {
25
- const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
26
+ const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
26
27
 
27
28
  registerTldrawLibraryVersion('tldraw', '1.0.0', 'esm')
28
29
  registerTldrawLibraryVersion('@tldraw/editor', '1.1.0', 'esm')
@@ -30,7 +31,7 @@ describe('registerTldrawLibraryVersion', () => {
30
31
  registerTldrawLibraryVersion('@tldraw/utils', '1.2.0', 'esm')
31
32
  registerTldrawLibraryVersion('@tldraw/tlschema', '1.2.0', 'esm')
32
33
 
33
- jest.runAllTimers()
34
+ vi.runAllTimers()
34
35
 
35
36
  expect(consoleLogSpy).toHaveBeenCalledTimes(1)
36
37
  expect(consoleLogSpy.mock.lastCall).toMatchInlineSnapshot(`
@@ -49,7 +50,7 @@ describe('registerTldrawLibraryVersion', () => {
49
50
  })
50
51
 
51
52
  it('logs if multiple versions of te same library are installed', () => {
52
- const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
53
+ const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
53
54
 
54
55
  registerTldrawLibraryVersion('tldraw', '1.1.0', 'esm')
55
56
  registerTldrawLibraryVersion('@tldraw/editor', '1.1.0', 'esm')
@@ -58,7 +59,7 @@ describe('registerTldrawLibraryVersion', () => {
58
59
  registerTldrawLibraryVersion('@tldraw/utils', '1.1.0', 'cjs')
59
60
  registerTldrawLibraryVersion('@tldraw/tlschema', '1.1.0', 'esm')
60
61
 
61
- jest.runAllTimers()
62
+ vi.runAllTimers()
62
63
 
63
64
  expect(consoleLogSpy).toHaveBeenCalledTimes(1)
64
65
  expect(consoleLogSpy.mock.lastCall).toMatchInlineSnapshot(`