Socket
Book a DemoInstallSign in
Socket

@tldraw/utils

Package Overview
Dependencies
Maintainers
4
Versions
3045
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tldraw/utils - npm Package Compare versions

Comparing version

to
3.16.0-canary.1e59e27864bb

6

dist-cjs/index.d.ts

@@ -12,3 +12,3 @@ import { default as isEqual } from 'lodash.isequal';

/* Excluded from this release type: assert */
/* Excluded from this release type: assert_2 */

@@ -108,6 +108,2 @@ /* Excluded from this release type: assertExists */

/**
* @deprecated Use `urlToArrayBuffer` instead.
*/
static dataUrlToArrayBuffer(dataURL: string): Promise<ArrayBuffer>;
/**
* @param url - The url of the file.

@@ -114,0 +110,0 @@ */

2

dist-cjs/index.js

@@ -170,5 +170,5 @@ "use strict";

"@tldraw/utils",
"3.16.0-canary.1b74ce1c7283",
"3.16.0-canary.1e59e27864bb",
"cjs"
);
//# sourceMappingURL=index.js.map

@@ -27,10 +27,2 @@ "use strict";

/**
* @deprecated Use `urlToArrayBuffer` instead.
*/
static async dataUrlToArrayBuffer(dataURL) {
return (0, import_network.fetch)(dataURL).then(function(result) {
return result.arrayBuffer();
});
}
/**
* @param url - The url of the file.

@@ -37,0 +29,0 @@ */

@@ -191,3 +191,3 @@ "use strict";

const physData = import_png.PngHelpers.parsePhys(view, physChunk.dataOffset);
if (physData.unit === 0 && physData.ppux === physData.ppuy) {
if (physData.unit === 1 && physData.ppux === physData.ppuy) {
const pixelsPerMeter = 72 / 0.0254;

@@ -194,0 +194,0 @@ const pixelRatio = Math.max(physData.ppux / pixelsPerMeter, 1);

@@ -345,3 +345,3 @@ "use strict";

ppuy: view.getUint32(offset + 4),
unit: view.getUint8(offset + 4)
unit: view.getUint8(offset + 8)
};

@@ -373,5 +373,5 @@ }

pHYsDataView.setUint8(7, "s".charCodeAt(0));
const DPI_96 = 2835.5;
pHYsDataView.setInt32(8, DPI_96 * dpr);
pHYsDataView.setInt32(12, DPI_96 * dpr);
const DPI_72 = 2835.5;
pHYsDataView.setInt32(8, DPI_72 * dpr);
pHYsDataView.setInt32(12, DPI_72 * dpr);
pHYsDataView.setInt8(16, 1);

@@ -378,0 +378,0 @@ const crcBit = new Uint8Array(pHYsData.slice(4, 17));

@@ -33,8 +33,11 @@ "use strict";

module.exports = __toCommonJS(reordering_exports);
var import_fractional_indexing_jittered = require("fractional-indexing-jittered");
const generateKeysFn = process.env.NODE_ENV === "test" ? import_fractional_indexing_jittered.generateNKeysBetween : import_fractional_indexing_jittered.generateNJitteredKeysBetween;
var import_jittered_fractional_indexing = require("jittered-fractional-indexing");
const generateNKeysBetweenWithNoJitter = (a, b, n) => {
return (0, import_jittered_fractional_indexing.generateNKeysBetween)(a, b, n, { jitterBits: 0 });
};
const generateKeysFn = process.env.NODE_ENV === "test" ? generateNKeysBetweenWithNoJitter : import_jittered_fractional_indexing.generateNKeysBetween;
const ZERO_INDEX_KEY = "a0";
function validateIndexKey(index) {
try {
(0, import_fractional_indexing_jittered.generateJitteredKeyBetween)(index, null);
(0, import_jittered_fractional_indexing.generateKeyBetween)(index, null);
} catch {

@@ -41,0 +44,0 @@ throw new Error("invalid index: " + index);

{
"name": "@tldraw/utils",
"description": "tldraw infinite canvas SDK (private utilities).",
"version": "3.16.0-canary.1b74ce1c7283",
"version": "3.16.0-canary.1e59e27864bb",
"author": {

@@ -35,5 +35,5 @@ "name": "tldraw Inc.",

"scripts": {
"test-ci": "lazy inherit",
"test": "yarn run -T jest",
"test-coverage": "lazy inherit",
"test-ci": "yarn run -T vitest run --passWithNoTests",
"test": "yarn run -T vitest --passWithNoTests",
"test-coverage": "yarn run -T vitest run --coverage --passWithNoTests",
"build": "yarn run -T tsx ../../internal/scripts/build-package.ts",

@@ -44,15 +44,7 @@ "build-api": "yarn run -T tsx ../../internal/scripts/build-api.ts",

"pack-tarball": "yarn pack",
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts"
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts",
"context": "yarn run -T tsx ../../internal/scripts/context.ts"
},
"jest": {
"preset": "../../internal/config/jest/node/jest-preset.js",
"setupFiles": [
"raf/polyfill"
],
"moduleNameMapper": {
"^~(.*)": "<rootDir>/src/$1"
}
},
"dependencies": {
"fractional-indexing-jittered": "^1.0.0",
"jittered-fractional-indexing": "^1.0.0",
"lodash.isequal": "^4.5.0",

@@ -68,4 +60,4 @@ "lodash.isequalwith": "^4.4.0",

"@types/lodash.uniq": "^4.5.9",
"jest-environment-jsdom": "^29.7.0",
"lazyrepo": "0.0.0-alpha.27"
"lazyrepo": "0.0.0-alpha.27",
"vitest": "^3.2.4"
},

@@ -72,0 +64,0 @@ "module": "dist-esm/index.mjs",

@@ -0,8 +1,9 @@

import { vi } from 'vitest'
import { debounce } from './debounce'
jest.useFakeTimers()
vi.useFakeTimers()
describe(debounce, () => {
it('should debounce a function', async () => {
const fn = jest.fn()
const fn = vi.fn()
const debounced = debounce(fn, 100)

@@ -13,7 +14,7 @@ debounced()

expect(fn).not.toHaveBeenCalled()
jest.advanceTimersByTime(200)
vi.advanceTimersByTime(200)
expect(fn).toHaveBeenCalledTimes(1)
jest.advanceTimersByTime(200)
vi.advanceTimersByTime(200)
expect(fn).toHaveBeenCalledTimes(1)
jest.advanceTimersByTime(200)
vi.advanceTimersByTime(200)
expect(fn).toHaveBeenCalledTimes(1)

@@ -23,3 +24,3 @@ })

it('should debounce a function with arguments', async () => {
const fn = jest.fn()
const fn = vi.fn()
const debounced = debounce(fn, 100)

@@ -30,3 +31,3 @@ debounced('a', 'b')

expect(fn).not.toHaveBeenCalled()
jest.advanceTimersByTime(200)
vi.advanceTimersByTime(200)
expect(fn).toHaveBeenCalledTimes(1)

@@ -37,3 +38,3 @@ expect(fn).toHaveBeenCalledWith('a', 'b')

it('should debounce a function with arguments and return a promise', async () => {
const fn = jest.fn((a, b) => a + b)
const fn = vi.fn((a, b) => a + b)
const debounced = debounce(fn, 100)

@@ -44,3 +45,3 @@ const promiseA = debounced('a', 'b')

expect(fn).not.toHaveBeenCalled()
jest.advanceTimersByTime(200)
vi.advanceTimersByTime(200)
expect(fn).toHaveBeenCalledTimes(1)

@@ -53,3 +54,3 @@ const results = await Promise.all([promiseA, promiseB, promiseC])

it('can be called across multiple debounce windows', async () => {
const fn = jest.fn((a, b) => a + b)
const fn = vi.fn((a, b) => a + b)
const debounced = debounce(fn, 100)

@@ -59,3 +60,3 @@ const promiseA = debounced('a', 'b')

expect(fn).not.toHaveBeenCalled()
jest.advanceTimersByTime(200)
vi.advanceTimersByTime(200)
expect(fn).toHaveBeenCalledTimes(1)

@@ -69,3 +70,3 @@

jest.advanceTimersByTime(200)
vi.advanceTimersByTime(200)

@@ -72,0 +73,0 @@ expect(fn).toHaveBeenCalledTimes(2)

@@ -10,11 +10,2 @@ import { fetch } from './network'

/**
* @deprecated Use `urlToArrayBuffer` instead.
*/
static async dataUrlToArrayBuffer(dataURL: string) {
return fetch(dataURL).then(function (result) {
return result.arrayBuffer()
})
}
/**
* @param url - The url of the file.

@@ -21,0 +12,0 @@ */

@@ -191,3 +191,3 @@ import { promiseWithResolve } from '../control'

const physData = PngHelpers.parsePhys(view, physChunk.dataOffset)
if (physData.unit === 0 && physData.ppux === physData.ppuy) {
if (physData.unit === 1 && physData.ppux === physData.ppuy) {
// Calculate pixels per meter:

@@ -194,0 +194,0 @@ // - 1 inch = 0.0254 meters

@@ -129,3 +129,3 @@ /*!

ppuy: view.getUint32(offset + 4),
unit: view.getUint8(offset + 4),
unit: view.getUint8(offset + 8),
}

@@ -164,6 +164,6 @@ }

const DPI_96 = 2835.5
const DPI_72 = 2835.5
pHYsDataView.setInt32(8, DPI_96 * dpr)
pHYsDataView.setInt32(12, DPI_96 * dpr)
pHYsDataView.setInt32(8, DPI_72 * dpr)
pHYsDataView.setInt32(12, DPI_72 * dpr)
pHYsDataView.setInt8(16, 1)

@@ -170,0 +170,0 @@

@@ -1,9 +0,9 @@

import {
generateJitteredKeyBetween,
generateNJitteredKeysBetween,
generateNKeysBetween,
} from 'fractional-indexing-jittered'
import { generateKeyBetween, generateNKeysBetween } from 'jittered-fractional-indexing'
const generateNKeysBetweenWithNoJitter = (a: string | null, b: string | null, n: number) => {
return generateNKeysBetween(a, b, n, { jitterBits: 0 })
}
const generateKeysFn =
process.env.NODE_ENV === 'test' ? generateNKeysBetween : generateNJitteredKeysBetween
process.env.NODE_ENV === 'test' ? generateNKeysBetweenWithNoJitter : generateNKeysBetween

@@ -28,3 +28,3 @@ /**

try {
generateJitteredKeyBetween(index, null)
generateKeyBetween(index, null)
} catch {

@@ -31,0 +31,0 @@ throw new Error('invalid index: ' + index)

@@ -0,4 +1,5 @@

import { vi } from 'vitest'
import { clearRegisteredVersionsForTests, registerTldrawLibraryVersion } from './version'
jest.useFakeTimers()
vi.useFakeTimers()

@@ -8,7 +9,7 @@ describe('registerTldrawLibraryVersion', () => {

clearRegisteredVersionsForTests()
jest.restoreAllMocks()
vi.restoreAllMocks()
})
it('doesnt log anything if all versions are the same', () => {
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {})

@@ -20,3 +21,3 @@ registerTldrawLibraryVersion('tldraw', '1.0.0', 'esm')

jest.runAllTimers()
vi.runAllTimers()

@@ -27,3 +28,3 @@ expect(consoleLogSpy).toHaveBeenCalledTimes(0)

it('logs if not all versions match', () => {
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {})

@@ -36,3 +37,3 @@ registerTldrawLibraryVersion('tldraw', '1.0.0', 'esm')

jest.runAllTimers()
vi.runAllTimers()

@@ -56,3 +57,3 @@ expect(consoleLogSpy).toHaveBeenCalledTimes(1)

it('logs if multiple versions of te same library are installed', () => {
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {})

@@ -66,3 +67,3 @@ registerTldrawLibraryVersion('tldraw', '1.1.0', 'esm')

jest.runAllTimers()
vi.runAllTimers()

@@ -69,0 +70,0 @@ expect(consoleLogSpy).toHaveBeenCalledTimes(1)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet