2023-04-25 11:01:25 +00:00
|
|
|
import { writeFileSync } from 'fs'
|
|
|
|
import { join, resolve } from 'path'
|
|
|
|
import { exec } from './lib/exec'
|
|
|
|
import { readFileIfExists } from './lib/file'
|
2023-06-01 18:01:49 +00:00
|
|
|
import { nicelog } from './lib/nicelog'
|
2023-04-25 11:01:25 +00:00
|
|
|
import { getAllWorkspacePackages } from './lib/workspace'
|
|
|
|
|
|
|
|
const packagesOurTypesCanDependOn = [
|
2024-06-11 13:59:25 +00:00
|
|
|
'@types/lodash.throttle',
|
|
|
|
'@types/lodash.uniq',
|
2023-04-25 11:01:25 +00:00
|
|
|
'@types/react',
|
|
|
|
'@types/react-dom',
|
|
|
|
'eventemitter3',
|
2024-07-15 16:08:42 +00:00
|
|
|
'nanoevents',
|
2023-04-25 11:01:25 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const tsconfig: any = {
|
|
|
|
compilerOptions: {
|
|
|
|
lib: ['es2015', 'dom'],
|
|
|
|
strict: true,
|
|
|
|
rootDir: '.',
|
|
|
|
paths: {},
|
|
|
|
esModuleInterop: true,
|
|
|
|
},
|
|
|
|
files: [],
|
|
|
|
}
|
|
|
|
|
|
|
|
const tempDir = (await exec('mktemp', ['-d'])).trim()
|
2023-06-01 18:01:49 +00:00
|
|
|
nicelog(`Working in ${tempDir}`)
|
2023-04-25 11:01:25 +00:00
|
|
|
|
|
|
|
const packages = (await getAllWorkspacePackages()).filter(
|
|
|
|
({ packageJson }) => !packageJson.private
|
|
|
|
)
|
|
|
|
|
2023-06-01 18:01:49 +00:00
|
|
|
nicelog(
|
2023-04-25 11:01:25 +00:00
|
|
|
'Checking packages:',
|
|
|
|
packages.map(({ packageJson }) => packageJson.name)
|
|
|
|
)
|
|
|
|
|
|
|
|
for (const { name, relativePath } of packages) {
|
|
|
|
const unprefixedName = name.replace('@tldraw/', '')
|
|
|
|
const dtsFile = await readFileIfExists(join(relativePath, 'api', 'public.d.ts'))
|
|
|
|
if (!dtsFile) {
|
2023-06-01 18:01:49 +00:00
|
|
|
nicelog(`No public.d.ts for ${name}, skipping`)
|
2023-04-25 11:01:25 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
writeFileSync(join(tempDir, `${unprefixedName}.d.ts`), dtsFile, 'utf8')
|
|
|
|
tsconfig.compilerOptions.paths[name] = [`./${unprefixedName}.d.ts`]
|
|
|
|
tsconfig.files.push(`./${unprefixedName}.d.ts`)
|
|
|
|
}
|
|
|
|
|
2023-06-01 18:01:49 +00:00
|
|
|
nicelog('Checking with tsconfig:', tsconfig)
|
2023-04-25 11:01:25 +00:00
|
|
|
writeFileSync(`${tempDir}/tsconfig.json`, JSON.stringify(tsconfig, null, '\t'), 'utf8')
|
|
|
|
writeFileSync(`${tempDir}/package.json`, JSON.stringify({ dependencies: {} }, null, '\t'), 'utf8')
|
|
|
|
|
derived presence state (#1204)
This PR adds
- A new `TLInstancePresence` record type, to collect info about the
presence state in a particular instance of the editor. This will
eventually be used to sync presence data instead of sending
instance-only state across the wire.
- **Record Scopes**
`RecordType` now has a `scope` property which can be one of three
things:
- `document`: the record belongs to the document and should be synced
and persisted freely. Currently: `TLDocument`, `TLPage`, `TLShape`, and
`TLAsset`
- `instance`: the record belongs to a single instance of the store and
should not be synced at all. It should not be persisted directly in most
cases, but rather compiled into a kind of 'instance configuration' to
store alongside the local document data so that when reopening the
associated document it can remember some of the previous instance state.
Currently: `TLInstance`, `TLInstancePageState`, `TLCamera`, `TLUser`,
`TLUserDocument`, `TLUserPresence`
- `presence`: the record belongs to a single instance of the store and
should not be persisted, but may be synced using the special presence
sync protocol. Currently just `TLInstancePresence`
This sets us up for the following changes, which are gonna be pretty
high-impact in terms of integrating tldraw into existing systems:
- Removing `instanceId` as a config option. Each instance gets a
randomly generated ID.
- We'd replace it with an `instanceConfig` option that has stuff like
selectedIds, camera positions, and so on. Then it's up to library users
to get and reinstate the instance config at persistence boundaries.
- Removing `userId` as config option, and removing the `TLUser` type
altogether.
- We might need to revisit when doing auth-enabled features like locking
shapes, but I suspect that will be separate.
2023-04-27 18:03:19 +00:00
|
|
|
await exec('npm', ['install', ...packagesOurTypesCanDependOn], { pwd: tempDir })
|
2023-04-25 11:01:25 +00:00
|
|
|
await exec(resolve('./node_modules/.bin/tsc'), [], { pwd: tempDir })
|
|
|
|
|
|
|
|
await exec('rm', ['-rf', tempDir])
|
|
|
|
}
|