Vue's provide/inject is a lightweight DI system that lets ancestor components share values with any descendant without prop drilling.
// Parent
const root = createContext();
setCurrentContext(root);
provide('theme', 'dark');
provide('locale', 'en');
// Grandchild (3 levels deep)
const grandchild = createContext(child);
setCurrentContext(grandchild);
inject('theme'); // → 'dark' (inherited from root)
inject('locale'); // → 'en' (inherited from root)
// Child overrides
setCurrentContext(child);
provide('theme', 'light');
setCurrentContext(grandchild);
inject('theme'); // → 'light' (nearest ancestor wins)1. inject(key) walks up the context chain — the nearest ancestor that provide()d the key wins.
2. A sibling context does not inherit from another sibling's provide().
3. inject(key) returns undefined when the key is not found.
Implement createContext(parent?), provide(key, value), inject(key), and setCurrentContext(ctx).
The solve(op, ...args) harness is provided — do not modify it.
Sample tests