Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
|
Amateur-hour question. Not asked skeptically. |
|
@decepulis |
95ba375 to
a434413
Compare
|
|
@mihar-22 I had trouble grokking the top of Seems to me like a high-level dev building their own volume slider would be accessing Meanwhile, feature developers will use |
- Merge feature-accessor-design.md content into player-api/ - Add primitives.md for library author API (hasFeature, types) - Replace STORE_SYMBOL with getStore() function - Update package export locations (store exports utils, core/dom exports types) - Update all cross-references
a434413 to
81aee0b
Compare
- Update architecture.md examples to use getFeature(target.media, f) pattern - Add StoreHost contract documentation to decisions.md - Document overloaded hasFeature/getFeature for stores vs proxies - Update primitives.md with StoreHost contract and implementation details
…tore Key changes: - StoreProxy<T> interface replaces StoreHost (generic preserves store type) - UnknownPlayer/UnknownMedia are interfaces extending StoreProxy - PlayerTarget.media is now UnknownMedia (flat proxy, not store) - Remove hasFeature/getFeature store overloads (only work with proxies) - Remove getStore() from public API (internal only) - Add createProxy(store) factory for store → proxy conversion - Feature authors use same flat API as component authors
- Remove verbose type signatures from primitives.md Implementation section - Consolidate 4 examples into 1 focused example - Convert Package Exports to table - Condense Reactive System to bullet points - Convert File Structure and Player Features to tables - Remove duplicate Fullscreen feature example (already shown in Cross-Store Access) - Trim hasFeature/getFeature rationale to essentials - Remove verbose code examples from decisions.md Net: -306 lines
- Restore StoreProxy<T> interface definition in decisions.md - Add hasFeature/getFeature usage examples - Add both React and Lit examples to primitives.md for cross-framework clarity
- Add throwMissingFeature(feature, componentName) to surface misconfiguration - Update examples to show throw pattern for critical features (PlayButton) - Update examples to show getFeature for optional features - Add to package exports table
Change from throwMissingFeature(feature, 'Name') to
throwMissingFeature(feature, { displayName: 'Name' }) for extensibility
Critical components like PlayButton should throw on missing feature, not silently return null which hides misconfiguration
- Update 'Two functions' → 'Three utilities' in primitives.md - Add throwMissingFeature to solution table and cross-framework table - Rename 'Optional Feature' section to 'Mixing Required and Optional' - Add throwMissingFeature to architecture.md constraints - Fix stale 'navigate two stores' trade-off in decisions.md - Add store type definitions to StoreProxy example in decisions.md
- Remove duplicate PlayButton examples from primitives.md - Replace verbose Primitives API section in decisions.md with rationale-only + link - Replace Two Stores rationale in decisions.md with link to architecture.md - Condense Feature Registry in architecture.md to one line with link Canonical locations: - Types & examples → primitives.md - Rationale & decisions → decisions.md - How it works → architecture.md Net: -120 lines
|
Thanks @luwes and @decepulis! Both of you calling it out made me go back to the drawing board and simplify the design. I hope both of you are happy with this design! I'm merging to keep us moving but please feel free to leave more comments for us to discuss. Happy to update any time. API surfacePrimitives (component authors): function PlayButton() {
const player = usePlayer(); // UnknownPlayer
// Type guard
if (!hasFeature(player, features.playback)) {
throwMissingFeature(features.playback, { displayName: 'PlayButton' });
}
// Typed here now
return <button onClick={player.play}>{player.paused ? '▶' : '⏸'}</button>;
}
// Optional features
const volume = getFeature(player, features.volume);
volume.setVolume?.(0.5); // safe if missingFeature authors — same flat API: const fullscreen = createPlayerFeature({
request: {
enterFullscreen: (_, { target }) => {
const mediaFS = getFeature(target.media, media.fullscreen);
mediaFS.enterFullscreen?.(); // flat, not mediaFS.request.enterFullscreen()
},
},
});Key changes
|
Closes #306
Summary
Folded feature accessor design into the player-api RFC as
primitives.md.