@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/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.b120f7febb0f",
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.b120f7febb0f",
55
- "@tldraw/store": "5.4.0-next.b120f7febb0f",
56
- "@tldraw/utils": "5.4.0-next.b120f7febb0f",
57
- "@tldraw/validate": "5.4.0-next.b120f7febb0f"
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
@@ -159,6 +159,7 @@ export {
159
159
  type TLInstanceId,
160
160
  } from './records/TLInstance'
161
161
  export {
162
+ isPage,
162
163
  isPageId,
163
164
  pageIdValidator,
164
165
  PageRecordType,
@@ -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!(base64)
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 */
@@ -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
  *