Repository navigation
Conversation
Benchmarks: Patchwork with this PR against main
Nothing changed by more than the runs vary. every benchmark: the median of 3 runs of main and 3 runs of the PR, their range in brackets
|
✅ Patchwork glance readyhttps://patchwork-preview-465.patchwork.inkandswitch.comA peek at |
accidental commit
There was a problem hiding this comment.
🟡 Changes recommended
Fallback ranking mishandles equally close supertypes, and datatype registration can fail to mount the appropriate tool.
3 open issues
What changed in this PR
Adds datatype conformance so Patchwork documents can use tools for their parent types, including transitive relationships.
Changes:
- Introduces
conformsTometadata andgetSupertypes. - Extends tool matching and fallback selection to include supertypes.
- Updates legacy views to react to datatype registration, with integration tests and a changeset.
| File | Description |
|---|---|
core/plugins/src/tools.ts |
Adds supertype-aware tool matching and fallback ranking. |
core/plugins/src/datatypes.ts |
Defines conformance metadata and cycle-safe supertype traversal. |
core/elements/test/patchwork-view.test.ts |
Tests supertype selection and late datatype registration. |
core/elements/src/legacy-impl.ts |
Updates fallback handling for conformance and registration events. |
.changeset/datatype-conforms-to.md |
Records patch releases and describes the new behavior. |
Review effort: Balanced
| if (!type) return; | ||
| if (added.id != type && !getSupertypes(type).includes(added.id)) return; | ||
| const fallback = getFallbackTool(this.#handle.doc()); | ||
| if (!fallback || fallback.id == this.#fallbackId) return; |
| this.#fallbackId = fallback.id; | ||
| if (!fallback.module) { | ||
| // The "loaded" listener mounts it once it's in. | ||
| if (isLoadablePlugin(fallback)) toolRegistry.load(fallback.id); |
| const index = types.findIndex((type) => datatypes.includes(type)); | ||
| if (index >= 0) return index; |

similar to https://developer.apple.com/documentation/uniformtypeidentifiers
we could declare, like
or