Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const moduleGraphServiceDef = defineService({
input: noInputSchema,
output: moduleGraphStatusSchema,
load: async (_input, ctx) => {
await ctx.self.commands.waitForSettledEngine(undefined);
await ctx.self.commands._waitForSettledEngine(undefined);
},
handler: (_input, ctx) => ctx.self.state.status,
},
Expand Down Expand Up @@ -192,9 +192,10 @@ export const moduleGraphServiceDef = defineService({
},
},
commands: {
applyGraphSnapshot: {
_applyGraphSnapshot: {
internal: true,
description:
'Internal use only: replaces the reverse index after the initial graph build. Called by the graph engine, not by external consumers.',
'Replaces the reverse index after the initial graph build. Called by the graph engine, not by external consumers.',
input: v.object({
storiesByFile: v.pipe(
storiesByFileSchema,
Expand All @@ -221,9 +222,10 @@ export const moduleGraphServiceDef = defineService({
});
},
},
applyGraphUpdate: {
_applyGraphUpdate: {
internal: true,
description:
'Internal use only: replaces the reverse index after an incremental patch and bumps versions for affected story files. Called by the graph engine, not by external consumers.',
'Replaces the reverse index after an incremental patch and bumps versions for affected story files. Called by the graph engine, not by external consumers.',
input: v.object({
storiesByFile: v.pipe(
storiesByFileSchema,
Expand Down Expand Up @@ -255,9 +257,10 @@ export const moduleGraphServiceDef = defineService({
});
},
},
bumpGraphRevision: {
_bumpGraphRevision: {
internal: true,
description:
'Internal use only: bumps the graph revision when the story index invalidates without an immediate graph snapshot/update.',
'Bumps the graph revision when the story index invalidates without an immediate graph snapshot/update.',
input: noInputSchema,
output: v.void(),
handler: async (_input, ctx) => {
Expand All @@ -267,9 +270,10 @@ export const moduleGraphServiceDef = defineService({
});
},
},
setStatus: {
_setStatus: {
internal: true,
description:
'Internal use only: sets the module graph lifecycle status after engine startup, failure, or adapter availability changes.',
'Sets the module graph lifecycle status after engine startup, failure, or adapter availability changes.',
input: moduleGraphStatusSchema,
output: v.void(),
handler: async (input, ctx) => {
Expand All @@ -278,9 +282,10 @@ export const moduleGraphServiceDef = defineService({
});
},
},
waitForSettledEngine: {
_waitForSettledEngine: {
internal: true,
description:
'Internal use only: waits for the module graph engine to finish its current build or patch cycle. Handler is supplied at server registration.',
'Waits for the module graph engine to finish its current build or patch cycle. Handler is supplied at server registration.',
input: noInputSchema,
output: v.void(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function registerTestModuleGraphService(workingDir = process.cwd()) {
},
{
commands: {
waitForSettledEngine: {
_waitForSettledEngine: {
handler: async () => undefined,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ describe('module-graph open service', () => {
});
});

describe('applyGraphSnapshot command', () => {
describe('_applyGraphSnapshot command', () => {
it('marks the service ready and stores the reverse index without advancing the revision', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: {
'./src/Button.tsx': { './src/Button.stories.tsx': 1 },
},
Expand All @@ -65,7 +65,7 @@ describe('module-graph open service', () => {
it('seeds every known story to revision 0 for scoped reads', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: {
'./src/Button.tsx': { './src/Button.stories.tsx': 1 },
'./src/Card.tsx': { './src/Card.stories.tsx': 1 },
Expand All @@ -81,10 +81,10 @@ describe('module-graph open service', () => {
it('replaces (not merges) the reverse index on a subsequent snapshot', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/A.tsx': { './src/A.stories.tsx': 0 } },
});
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/B.tsx': { './src/B.stories.tsx': 0 } },
});

Expand All @@ -100,7 +100,7 @@ describe('module-graph open service', () => {
it('marks the graph failed with a serializable error', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.setStatus({
await runtime.commands._setStatus({
value: 'error',
error: { message: 'graph build blew up', name: 'ModuleGraphFailureError' },
});
Expand All @@ -114,7 +114,7 @@ describe('module-graph open service', () => {
it('marks the graph unavailable with a reason and optional error', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.setStatus({
await runtime.commands._setStatus({
value: 'unavailable',
reason: 'builder does not support change detection',
error: { message: 'adapter missing' },
Expand All @@ -131,7 +131,7 @@ describe('module-graph open service', () => {
describe('getStoriesForFiles query', () => {
it('returns one result array per input file, positionally', async () => {
const runtime = registerBareModuleGraph();
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: {
'./src/Button.tsx': { './src/Button.stories.tsx': 1 },
'./src/Card.tsx': {
Expand All @@ -157,7 +157,7 @@ describe('module-graph open service', () => {

it('accepts absolute, relative-with-dot, and relative-without-dot input paths', async () => {
const runtime = registerBareModuleGraph();
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
});

Expand All @@ -174,7 +174,7 @@ describe('module-graph open service', () => {

it('accepts Windows-style absolute and relative input paths', async () => {
const runtime = registerBareModuleGraph('C:\\repo');
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
});

Expand All @@ -195,14 +195,14 @@ describe('module-graph open service', () => {
});
});

describe('applyGraphUpdate command', () => {
describe('_applyGraphUpdate command', () => {
it('replaces the reverse index, bumps the revision, and records latest changed stories', async () => {
const runtime = registerBareModuleGraph();
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
});

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {
'./src/Button.tsx': { './src/Button.stories.tsx': 1 },
'./src/Icon.tsx': { './src/Button.stories.tsx': 2 },
Expand All @@ -223,14 +223,14 @@ describe('module-graph open service', () => {

it('stamps each bumped story with the new revision and leaves untouched stories at 0', async () => {
const runtime = registerBareModuleGraph();
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: {
'./src/Button.tsx': { './src/Button.stories.tsx': 1 },
'./src/Card.tsx': { './src/Card.stories.tsx': 1 },
},
});

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {
'./src/Button.tsx': { './src/Button.stories.tsx': 1 },
'./src/Card.tsx': { './src/Card.stories.tsx': 1 },
Expand All @@ -248,11 +248,11 @@ describe('module-graph open service', () => {
it('replaces latest story changes with the newest revision payload', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./a.stories.tsx', './b.stories.tsx'],
});
await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./a.stories.tsx'],
});
Expand All @@ -266,11 +266,11 @@ describe('module-graph open service', () => {

it('does not advance the revision for an out-of-graph change (no bumped stories)', async () => {
const runtime = registerBareModuleGraph();
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
});

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
bumpedStoryFiles: [],
});
Expand All @@ -292,7 +292,7 @@ describe('module-graph open service', () => {
storyFiles: [],
});

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./src/Button.stories.tsx', './src/Card.stories.tsx'],
});
Expand All @@ -306,11 +306,11 @@ describe('module-graph open service', () => {
it('replaces the previous change set when a newer update bumps different stories', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./a.stories.tsx', './b.stories.tsx'],
});
await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./c.stories.tsx'],
});
Expand All @@ -324,11 +324,11 @@ describe('module-graph open service', () => {
it('preserves the prior change set when an update bumps no stories', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./src/Button.stories.tsx'],
});
await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
bumpedStoryFiles: [],
});
Expand All @@ -342,11 +342,11 @@ describe('module-graph open service', () => {
it('clears story files after a snapshot without resetting the graph revision', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./src/Button.stories.tsx'],
});
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
});

Expand All @@ -356,14 +356,14 @@ describe('module-graph open service', () => {
});
});

it('clears story files but keeps the current revision after bumpGraphRevision', async () => {
it('clears story files but keeps the current revision after _bumpGraphRevision', async () => {
const runtime = registerBareModuleGraph();

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./src/Button.stories.tsx'],
});
await runtime.commands.bumpGraphRevision(undefined);
await runtime.commands._bumpGraphRevision(undefined);

expect(runtime.queries.getLatestStoryChanges(undefined)).toEqual({
revision: 2,
Expand All @@ -378,11 +378,11 @@ describe('module-graph open service', () => {
seen.push(value);
});

await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./a.stories.tsx'],
});
await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./b.stories.tsx'],
});
Expand All @@ -397,10 +397,10 @@ describe('module-graph open service', () => {
describe('getGraphRevision query scopes', () => {
it('returns 0 for an empty watch list and ignores unknown stories', async () => {
const runtime = registerBareModuleGraph();
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
});
await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
bumpedStoryFiles: ['./src/Button.stories.tsx'],
});
Expand All @@ -417,10 +417,10 @@ describe('module-graph open service', () => {

it('accepts absolute and relative scope paths', async () => {
const runtime = registerBareModuleGraph();
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
});
await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
bumpedStoryFiles: ['./src/Button.stories.tsx'],
});
Expand All @@ -436,11 +436,11 @@ describe('module-graph open service', () => {

it('advances watch-all but not scoped reads on a bare revision bump', async () => {
const runtime = registerBareModuleGraph();
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: { './src/Button.tsx': { './src/Button.stories.tsx': 1 } },
});

await runtime.commands.bumpGraphRevision(undefined);
await runtime.commands._bumpGraphRevision(undefined);

// Index reconciliation advances the global (watch-all) revision...
expect(runtime.queries.getGraphRevision(undefined)).toBe(1);
Expand All @@ -459,8 +459,8 @@ describe('module-graph open service', () => {
seen.push(revision);
});

await runtime.commands.applyGraphSnapshot({ storiesByFile: {} });
await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphSnapshot({ storiesByFile: {} });
await runtime.commands._applyGraphUpdate({
storiesByFile: {},
bumpedStoryFiles: ['./a.stories.tsx'],
});
Expand All @@ -471,7 +471,7 @@ describe('module-graph open service', () => {

it('notifies a scoped subscriber only when its story is bumped', async () => {
const runtime = registerBareModuleGraph();
await runtime.commands.applyGraphSnapshot({
await runtime.commands._applyGraphSnapshot({
storiesByFile: {
'./src/Button.tsx': { './src/Button.stories.tsx': 1 },
'./src/Card.tsx': { './src/Card.stories.tsx': 1 },
Expand All @@ -487,15 +487,15 @@ describe('module-graph open service', () => {
);

// Bump an unrelated story: the Button-scoped subscriber must not advance.
await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {
'./src/Button.tsx': { './src/Button.stories.tsx': 1 },
'./src/Card.tsx': { './src/Card.stories.tsx': 1 },
},
bumpedStoryFiles: ['./src/Card.stories.tsx'],
});
// Now bump Button itself.
await runtime.commands.applyGraphUpdate({
await runtime.commands._applyGraphUpdate({
storiesByFile: {
'./src/Button.tsx': { './src/Button.stories.tsx': 1 },
'./src/Card.tsx': { './src/Card.stories.tsx': 1 },
Expand Down
Loading
Loading