Wykres commitów

158 Commity (a4fff303bf5c8ba4f63117e58b7f2dfe49a8abf1)

Autor SHA1 Wiadomość Data
David Sheldrick a4fff303bf update lazyrepo 2023-06-05 18:32:32 +01:00
David Sheldrick f15a8797f0
Independent instance state persistence (#1493)
This PR 

- Removes UserDocumentRecordType
  - moving isSnapMode to user preferences
  - moving isGridMode and isPenMode to InstanceRecordType
  - deleting the other properties which are no longer needed.
 
- Creates a separate pipeline for persisting instance state.
  
Previously the instance state records were stored alongside the document
state records, and in order to load the state for a particular instance
(in our case, a particular tab) you needed to pass the 'instanceId'
prop. This prop ended up totally pervading the public API and people ran
into all kinds of issues with it, e.g. using the same instance id in
multiple editor instances.

There was also an issue whereby it was hard for us to clean up old
instance state so the idb table ended up bloating over time.
  
This PR makes it so that rather than passing an instanceId, you load the
instance state yourself while creating the store. It provides tools to
make that easy.

- Undoes the assumption that we might have more than one instance's
state in the store.

- Like `document`, `instance` now has a singleton id
`instance:instance`.
- Page state ids and camera ids are no longer random, but rather derive
from the page they belong to. This is like having a foreign primary key
in SQL databases. It's something i'd love to support fully as part of
the RecordType/Store api.

Tests to do

- [x] Test Migrations
- [x] Test Store.listen filtering
- [x] Make type sets in Store public and readonly
- [x] Test RecordType.createId
- [x] Test Instance state snapshot loading/exporting
- [x] Manual test File I/O
- [x] Manual test Vscode extension with multiple tabs
- [x] Audit usages of store.query
- [x] Audit usages of changed types: InstanceRecordType, 'instance',
InstancePageStateRecordType, 'instance_page_state', 'user_document',
'camera', CameraRecordType, InstancePresenceRecordType,
'instance_presence'
- [x] Test user preferences
- [x] Manual test isSnapMode and isGridMode and isPenMode
- [ ] Test indexedDb functions
- [x] Add instanceId stuff back


### Change Type

- [x] `major` — Breaking Change


### Test Plan

1. Add a step-by-step description of how to test your PR here.
2.

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Add a brief release note for your PR here.
2023-06-05 14:11:07 +00:00
Steve Ruiz c1b84bf246
Rename tlstore to store (#1507)
This PR renames the `@tldraw/tlstore` package to `@tldraw/store`, mainly
to avoid confusion between `TLStore`. Will be doing the same with other
packages.

### Change Type

- [x] `major` — Breaking Change

### Release Notes

- Replace @tldraw/tlstore with @tldraw/store
2023-06-03 08:59:04 +00:00
Steve Ruiz a5e653b225
Cleanup @tldraw/ui types / exports (#1504)
This PR cleans up exports from TldrawUi, unifying types under `TLUi` and
removing many items from exports / marking others as internal.

### Change Type

- [x] `major` — Breaking Change

### Release Notes

- [editor] clean up / unify types
2023-06-02 21:16:09 +00:00
Steve Ruiz 735f1c41b7
rename app to editor (#1503)
This PR renames `App`, `app` and all appy names to `Editor`, `editor`,
and editorry names.

### Change Type

- [x] `major` — Breaking Change

### Release Notes

- Rename `App` to `Editor` and many other things that reference `app` to
`editor`.
2023-06-02 15:21:45 +00:00
alex 640bc9de24
Revert 09c36781 & tweak linting (#1501)
This diff reverts 09c36781 and tweaks how some of our linting was
working.

I'm not actually sure what caused the regression that 09c36781 was
fixing - it was something to do with typescript being used to transpile
eslintrc.js, but that being excluded from the tsconfig for those
projects. I fixed that by removing `rootDir` from those, but that
revealed some other issues with files not getting ignored correctly.

I fixed the ignoring issue with a change I've wanted to make to these
scripts for a while: only running them on files that are actually
tracked by git, instead of on everything with a relevant extension. A
side effect of that is that we have to re-implement .eslintignore
support ourselves, but that's very straight forward: the `ignore`
package that eslint uses is very easy to include.

### Change Type
- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Test Plan
-

### Release Notes
[internal-only]
2023-06-02 10:45:51 +00:00
Steve Ruiz 09c367811d
[fix] eslint from brivate (#1498)
This PR updates the `lint` scripts for the vs code extension in order to
solve a very weird bug with our submodules setup.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-06-02 08:47:34 +00:00
Mitja Bezenšek 941647fd1b
VS Code version bump, changelog. (#1497)
Bump VS code version, update changelog.

### Change Type

- [x] `patch` — Bug Fix
2023-06-01 18:14:35 +00:00
Steve Ruiz a3c39cde4b
replace console.log with nicelog (#1496)
This PR replaces our `console.log` with `nicelog` so that I can more
easily grep for errant console.logs.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-06-01 18:01:49 +00:00
Steve Ruiz 0c4174c0b8
[refactor] User-facing APIs (#1478)
This PR updates our user-facing APIs for the Tldraw and TldrawEditor
components, as well as the Editor (App). It mainly incorporates surface
changes from #1450 without any changes to validators or migrators,
incorporating feedback / discussion with @SomeHats and @ds300.

Here we:
- remove the TldrawEditorConfig
- bring back a loose version of shape definitions
- make a separation between "core" shapes and "default" shapes
- do not allow custom shapes, migrators or validators to overwrite core
shapes
- but _do_ allow new shapes

## `<Tldraw>` component

In this PR, the `Tldraw` component wraps both the `TldrawEditor`
component and our `TldrawUi` component. It accepts a union of props for
both components. Previously, this component also added local syncing via
a `useLocalSyncClient` hook call, however that has been pushed down to
the `TldrawEditor` component.

## `<TldrawEditor>` component

The `TldrawEditor` component now more neatly wraps up the different ways
that the editor can be configured.

## The store prop (`TldrawEditorProps.store`)

There are three main ways for the `TldrawEditor` component to be run:
1. with an externally defined store
2. with an externally defined syncing store (local or remote)
3. with an internally defined store
4. with an internally defined locally syncing store

The `store` prop allows for these configurations.

If the `store` prop is defined, it may be defined either as a `TLStore`
or as a `SyncedStore`. If the store is a `TLStore`, then the Editor will
assume that the store is ready to go; if it is defined as a SyncedStore,
then the component will display the loading / error screens as needed,
or the final editor once the store's status is "synced".

When the store is left undefined, then the `TldrawEditor` will create
its own internal store using the optional `instanceId`, `initialData`,
or `shapes` props to define the store / store schema.

If the `persistenceKey` prop is left undefined, then the store will not
be synced. If the `persistenceKey` is defined, then the store will be
synced locally. In the future, we may also here accept the API key /
roomId / etc for creating a remotely synced store.

The `SyncedStore` type has been expanded to also include types used for
remote syncing, e.g. with `ConnectionStatus`.

## Tools

By default, the App has two "baked-in" tools: the select tool and the
zoom tool. These cannot (for now) be replaced or removed. The default
tools are used by default, but may be replaced by other tools if
provided.

## Shapes

By default, the App has a set of "core" shapes:
- group
- embed
- bookmark
- image
- video
- text

That cannot by overwritten because they're created by the app at
different moments, such as when double clicking on the canvas or via a
copy and paste event. In follow up PRs, we'll split these out so that
users can replace parts of the code where these shapes are created.

### Change Type

- [x] `major` — Breaking Change

### Test Plan

- [x] Unit Tests
2023-06-01 15:47:34 +00:00
David Sheldrick 356a0d1e73
[chore] refactor user preferences (#1435)
- Remove TLUser, TLUserPresence
- Add first-class support for user preferences that persists across
rooms and tabs

### Change Type

<!-- 💡 Indicate the type of change your pull request is. -->
<!-- 🤷‍♀️ If you're not sure, don't select anything -->
<!-- ✂️ Feel free to delete unselected options -->

<!-- To select one, put an x in the box: [x] -->

- [ ] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [x] `major` — Breaking Change
- [ ] `dependencies` — Dependency Update (publishes a `patch` release,
for devDependencies use `internal`)
- [ ] `documentation` — Changes to the documentation only (will not
publish a new version)
- [ ] `tests` — Changes to any testing-related code only (will not
publish a new version)
- [ ] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Test Plan

1. Add a step-by-step description of how to test your PR here.
2.

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Add a brief release note for your PR here.
2023-05-25 09:54:29 +00:00
alex 0375b5d86d
Stricter ID types (#1439)
We noticed that when inferring the type of a shape from its ID, it was
getting inferred as `any` which was hiding some issues. This diff
switches `BaseRecord`'s automatic ID to an explicit one, which lets us
pass in our correct `TLShapeId` definition and still have it play nicely
with other places.

### Change Type

- [x] `patch` — Bug Fix

### Release Notes

[internal only, covered by #1432 changelog]

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-05-24 11:25:41 +00:00
Steve Ruiz eb26964130
[refactor] restore createTLSchema (#1444)
This PR restores `createTLSchema`. 

It also:
- removes `TldrawEditorConfig.default`
- makes `config` a required property of `<TldrawEditor>`, though it's
created automatically in `<Tldraw>`.
- makes `config` a required property of `App`
- removes `TLShapeType` and replaces the rare usage with
`TLShape["type"]`
- adds `TLDefaultShape` for a union of our default shapes
- makes `TLShape` a union of `TLDefaultShape` and `TLUnknownShape`

### Change Type

- [x] `major` — Breaking Change

### Release Notes

- [editor] Simplifies custom shape definition
- [tldraw] Updates props for <TldrawEditor> component to require a
`TldrawEditorConfig`.
2023-05-24 10:48:31 +00:00
Mitja Bezenšek 0375dbf8c0
Bump version. (#1421)
Bump vs code version. I build the extension from the
`release-2023-05-16` branch, but didn't push the changes there as we
never pull them back to main. So I'm making this change here.

### Change Type

- [x] `patch` — Bug Fix
2023-05-19 11:43:41 +00:00
alex 0bd6410d9f
avoid lazy race conditions (#1364)
We had a few issues with lazy race conditions failing CI. This came from
scripts configured to invoke lazy again, rather than through expressing
dependencies between scripts.

This diff reconfigures lazy to articulate these sorts of things as
dependencies instead of through self-invocation. Instead of having lots
of separate `build-package`, `build-docs`, etc commands, we now just
have a build command with package overrides to express more specific
options

### Change Type
- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Release Notes
[internal only]
2023-05-12 15:41:40 +00:00
David Sheldrick 5061240912
[chore] Bump nanoid (#1349)
I need to mock nanoid for the ephemeral state fuzz tests, to create
repeatable test runs. In order to do that properly it needs to have a
consistent version among all our packages.

At the same time I'm removing some old unused params in AppOptions

### Change Type

<!-- 💡 Indicate the type of change your pull request is. -->
<!-- 🤷‍♀️ If you're not sure, don't select anything -->
<!-- ✂️ Feel free to delete unselected options -->

<!-- To select one, put an x in the box: [x] -->

- [ ] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [x] `major` — Breaking Change

- [ ] `dependencies` — Dependency Update (publishes a `patch` release,
for devDependencies use `internal`)

- [ ] `documentation` — Changes to the documentation only (will not
publish a new version)
- [ ] `tests` — Changes to any testing-related code only (will not
publish a new version)
- [ ] `internal` — Any other changes that don't affect the published
package (will not publish a new version)


### Release Notes

- Remove unused userId and instanceId props from AppOptions
2023-05-11 11:55:00 +00:00
alex 71aef1764d
Rework the assets package for strategy-specific imports (#1341)
The assets package now only exports esm-formatted .js files. There's one
for each strategy - import-based, and meta.url-based. These are directly
generated as .js and .d.ts files rather than generated as .ts and
converted to js/dts through other means.

As this package depends on esm-specific stuff to function, we don't
publish a cjs version any more.

### Change Type

<!-- 💡 Indicate the type of change your pull request is. -->
<!-- 🤷‍♀️ If you're not sure, don't select anything -->
<!-- ✂️ Feel free to delete unselected options -->

<!-- To select one, put an x in the box: [x] -->

- [ ] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [x] `major` — Breaking Change

- [ ] `dependencies` — Dependency Update (publishes a `patch` release,
for devDependencies use `internal`)

- [ ] `documentation` — Changes to the documentation only (will not
publish a new version)
- [ ] `tests` — Changes to any testing-related code only (will not
publish a new version)
- [ ] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Release Notes

- [dev] If you're using the `@tldraw/assets` package, you need to update
your code to `import { getAssetUrlsByImport } from
'@tldraw/assets/imports'` instead of `import { getBundlerAssetUrls }
from '@tldraw/assets`
2023-05-09 16:08:38 +00:00
alex 880f82e658
New vite-based examples app (#1226)
Right now this examples app looks exactly the same as our old examples
app, but there are a couple of tiny differences:
- We use `vite` instead of our own esbuild setup for development and
bundling
- We use `@tldraw/assets` for smart asset hashing instead of copying the
assets to a public folder

You can use `@tldraw/assets` with vite with a bunch of extra config, but
it (plus a bunch of other bundlers) also support a special syntax for
specifying asset urls: `new URL('./my/asset.svg',
import.meta.url).href`. This approach is more standards-complient, but
doesn't work with every bundler just yet. This diff also adds a
url-based version of `@tldraw/assets`, although I'd like to tweak the
entry point - right now you need to import from
`@tldraw/assets/lib/urls`, but i'd like to find a way to get this to
`@tldraw/assets/urls` or something at some point.

There are a couple other extra fixes in here:
- vscode builds were broken, they're fixed now!
- there's also a little tweak to the `getBundlerAssetUrls` API to allow
passing in a function instead of an object for URL formatting
- there are new internal-only functions for injecting asset urls
globally instead of passing them in via react props. this means we can
get the benefits of cacheable URLs without having to clutter our
examples by passing them in
2023-05-05 13:10:36 +00:00
David Sheldrick f5c5b05dc7
[chore] update lazyrepo (#1211) 2023-05-02 12:25:26 +00:00
David Sheldrick 4c65cb8db4
[lite] upgrade lazyrepo (#1198)
* upgrade lazyrepo

* update lockfile + lazy.config
2023-04-25 14:32:17 +01:00
alex 29ed921c67 transfer-out: transfer out 2023-04-25 12:01:25 +01:00
alex ec84f64e63 lite: delete all 2023-04-21 16:53:31 +01:00
Steve Ruiz 325d494a8a 1.29.2 2023-04-01 07:09:12 +01:00
Steve Ruiz fd9200c200 1.29 2023-03-10 11:42:43 +00:00
Steve Ruiz 8b8b823012 v1.28.2 2023-03-10 11:37:43 +00:00
Steve Ruiz 3d1d329b6f 1.28.0 2023-02-06 14:26:40 +00:00
Steve Ruiz 55a8831a6b 1.27.0 2023-01-15 11:22:09 +00:00
Daniel Molkentin 065c3ddc4a
serve fonts locally via fontsource (#1091)
* [fix] serve fonts locally via fontsource (#1077)

* fix vscode extension build

Co-authored-by: zfgrnzfsberire <noreply@github.com>
2022-12-30 17:56:33 -06:00
Steve Ruiz c5ff2da775 1.25.2 2022-11-14 15:53:12 +00:00
Steve Ruiz 0f2abaf286 1.26.1 2022-11-09 16:35:43 +00:00
Steve Ruiz 6e275f09ef 1.26.0 2022-10-26 14:06:20 +01:00
Steve Ruiz 0eebdddb5b 1.24.0 2022-10-04 13:08:31 +01:00
Steve Ruiz 8e55e263bf 1.24.5 2022-09-09 09:54:48 +01:00
Steve Ruiz 5e24e5a4cb 1.24.4 2022-09-08 13:36:08 +01:00
Steve Ruiz 0549660244 1.24.3 2022-09-08 11:33:57 +01:00
Steve Ruiz b56a3a6982 1.24.1 2022-09-08 10:58:42 +01:00
Steve Ruiz 760f6494e3 1.24.0 2022-09-08 09:48:50 +01:00
Steve Ruiz 34ce1ed68c 1.22.0 2022-09-07 15:25:47 +01:00
Steve Ruiz 9dab372b81 1.22.1 2022-09-01 17:24:33 +01:00
Steve Ruiz f98310e5bf 1.22.0 2022-09-01 10:13:32 +01:00
Steve Ruiz 7b3c6ed808
Update vscode extension (#942) 2022-09-01 09:49:01 +01:00
Steve Ruiz a22124b3a7 1.21.1 2022-08-28 08:19:11 +01:00
Gwenaël Gallon 25f39a65fc
Chore: update and optimize turbo (#885)
* Update turbo to latest

* Update turbo.json

* The --stream flag has been deprecated

* Remove unused start:all

* build:packages -> use new --filter

* build:apps -> use new --filter

* build:www -> use new --filter

* build:core -> use new --filter

* build -> fix tldraw-example dependencies

* Optimize test* and lint

* start & start:core -> use new --filter

* start:electron -> use new --filter

* Remove unused start:apps

* Update turbo.json

* Caching ESLint

See Pro Tip : https://turborepo.org/docs/core-concepts/caching#configuring-cache-outputs

* Optimize test:watch

* start:www -> use new filter

* start:vscode -> use new filter

* Update build:core

* Optimize start and start:core

* Clean build:core

* Remove unused command

* Revert "Merge branch 'main' into chore/update-turbo"

This reverts commit a481c24205, reversing
changes made to a0f2f337b3.

* Update start:electron

* Remove unused deploy in turbo.json

* Add start:extension

* Add package:electron and package:vscode

* Add publish:vscode

* Revet Revert: revert "Merge branch 'main' into chore/update-turbo"

* Update vscode extension build

* Clean tldraw-example tsconfig.json

* Uniform script commands

* Fix start for www

* remove mention of removed packages

* add build:core

* Add force to build step

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-08-11 07:08:32 +01:00
Steve Ruiz d5639f696a update yarn.lock, clean some deps 2022-08-10 01:00:42 +01:00
Steve Ruiz a0007142e0
[chore] epic purge (#893)
* remove extension / electron app

* switch examples to vite

* Update licenses

* Add script

* fix titles
2022-08-10 00:18:59 +01:00
Gwenaël Gallon 2567cedcd2
Add clean script to apps and examples (#869) 2022-08-02 14:57:00 +01:00
Gwenaël Gallon e0e1373468
Chore: clean up sort imports with prettier (#870)
* Update prettier to latest

* Add format command

* Create .prettierignore

* Add prettier plugin sort imports

* Update prettier config

* Update prettier config

* Update .prettierignore

* Fix @babel/parser conflict

https://github.com/trivago/prettier-plugin-sort-imports/issues/156

* Revert "Update .prettierignore"

This reverts commit 282e5b8383.

* Revert change for apps/www/pages/v/[id].tsx

* Sort imports

Moves the third party imports to the top, "~" imports in middle, and "./" at last

* Sorting of the specifiers

in an import declarations

* [www] use path vs  "../"

* [core] use path "~" vs "../"

* [tldraw] use path "~" vs "../.../"

* [tldraw] use path "~" vs "../"

* [tldraw] Cleanup

* Update prettier config

* Last use path "~" vs "../.../"

* [www] Fix order of the third party imports

* Clean prettier config
2022-08-02 14:56:12 +01:00
Gwenaël Gallon 3c2c26c11e
Fix: workflow failure with missing lint command and added lint for apps/examples (#866)
* Add turbo run lint

* Add lint to all apps and examples

* Update eslint with monorepo configuration

see: https://typescript-eslint.io/docs/linting/typed-linting/monorepos#one-tsconfigjson-per-package-and-an-optional-one-in-the-root

* Remove unused rules

* Exclude @tldraw/www from global eslint config

* Remove duplicated eslint

* Fix eslint prefer-const errors

* Fix eslint no-unused-vars warning

* Update package.json

* Fix eslint no-unused-vars warning

* bump eslint@^8.20.0

* Correct "Fix eslint no-unused-vars warning"

This reverts commit 0158a2585a.
2022-07-30 08:27:54 +01:00
with-heart 82f9278976
chore: remove typedoc and docs scripts (#864) 2022-07-29 15:22:08 +01:00
with-heart 2e36dadfec
chore: clean up local dev tooling (#856)
* chore: clean up husky + lint-staged

* chore: format all files with prettier
2022-07-28 08:19:53 +01:00