@tldraw/tlschema 5.4.0-next.b120f7febb0f → 5.4.0-next.ebc95cf01337
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/dist-cjs/index.d.ts +119 -100
- package/dist-cjs/index.js +2 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/misc/b64Vecs.js.map +2 -2
- package/dist-cjs/records/TLPage.js +5 -0
- package/dist-cjs/records/TLPage.js.map +2 -2
- package/dist-esm/index.d.mts +119 -100
- package/dist-esm/index.mjs +3 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/misc/b64Vecs.mjs.map +2 -2
- package/dist-esm/records/TLPage.mjs +5 -0
- package/dist-esm/records/TLPage.mjs.map +2 -2
- package/package.json +5 -5
- package/src/index.ts +1 -0
- package/src/misc/b64Vecs.ts +2 -11
- package/src/records/TLPage.ts +23 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/tlschema",
|
|
3
3
|
"description": "tldraw infinite canvas SDK (schema).",
|
|
4
|
-
"version": "5.4.0-next.
|
|
4
|
+
"version": "5.4.0-next.ebc95cf01337",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"vitest": "^4.1.7"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@tldraw/state": "5.4.0-next.
|
|
55
|
-
"@tldraw/store": "5.4.0-next.
|
|
56
|
-
"@tldraw/utils": "5.4.0-next.
|
|
57
|
-
"@tldraw/validate": "5.4.0-next.
|
|
54
|
+
"@tldraw/state": "5.4.0-next.ebc95cf01337",
|
|
55
|
+
"@tldraw/store": "5.4.0-next.ebc95cf01337",
|
|
56
|
+
"@tldraw/utils": "5.4.0-next.ebc95cf01337",
|
|
57
|
+
"@tldraw/validate": "5.4.0-next.ebc95cf01337"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.2.0 || ^19.2.1",
|
package/src/index.ts
CHANGED
package/src/misc/b64Vecs.ts
CHANGED
|
@@ -43,15 +43,6 @@ for (let i = 0; i < 1024; i++) {
|
|
|
43
43
|
MANTISSA[i] = 1 + i / 1024
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
declare global {
|
|
47
|
-
interface Uint8Array {
|
|
48
|
-
toBase64?(): string
|
|
49
|
-
}
|
|
50
|
-
interface Uint8ArrayConstructor {
|
|
51
|
-
fromBase64?(base64: string): Uint8Array
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
46
|
function nativeGetFloat16(dataView: DataView, offset: number): number {
|
|
56
47
|
return (dataView as any).getFloat16(offset, true)
|
|
57
48
|
}
|
|
@@ -77,7 +68,7 @@ const setFloat16 =
|
|
|
77
68
|
: fallbackSetFloat16
|
|
78
69
|
|
|
79
70
|
function nativeBase64ToUint8Array(base64: string): Uint8Array {
|
|
80
|
-
return Uint8Array.fromBase64
|
|
71
|
+
return Uint8Array.fromBase64(base64)
|
|
81
72
|
}
|
|
82
73
|
|
|
83
74
|
/** @internal */
|
|
@@ -132,7 +123,7 @@ export function fallbackBase64ToUint8Array(base64: string): Uint8Array {
|
|
|
132
123
|
}
|
|
133
124
|
|
|
134
125
|
function nativeUint8ArrayToBase64(uint8Array: Uint8Array): string {
|
|
135
|
-
return uint8Array.toBase64
|
|
126
|
+
return uint8Array.toBase64()
|
|
136
127
|
}
|
|
137
128
|
|
|
138
129
|
/** @internal */
|
package/src/records/TLPage.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
createRecordMigrationSequence,
|
|
5
5
|
createRecordType,
|
|
6
6
|
RecordId,
|
|
7
|
+
UnknownRecord,
|
|
7
8
|
} from '@tldraw/store'
|
|
8
9
|
import { IndexKey, JsonObject } from '@tldraw/utils'
|
|
9
10
|
import { T } from '@tldraw/validate'
|
|
@@ -148,6 +149,28 @@ export const PageRecordType = createRecordType<TLPage>('page', {
|
|
|
148
149
|
meta: {},
|
|
149
150
|
}))
|
|
150
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Type guard to check if a record is a page.
|
|
154
|
+
*
|
|
155
|
+
* @param record - The record to check
|
|
156
|
+
* @returns True if the record is a page, false otherwise
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const record = store.get('page:abc123')
|
|
161
|
+
|
|
162
|
+
* if (isPage(record)) {
|
|
163
|
+
* console.log(`Page name: ${record.name}`)
|
|
164
|
+
* }
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
export function isPage(record?: UnknownRecord): record is TLPage {
|
|
170
|
+
if (!record) return false
|
|
171
|
+
return record.typeName === 'page'
|
|
172
|
+
}
|
|
173
|
+
|
|
151
174
|
/**
|
|
152
175
|
* Type guard to check if a string is a valid TLPageId.
|
|
153
176
|
*
|