Skip to content

Commit bdbbb92

Browse files
committed
build(#10336): impl SatisfiesExpression
1 parent 2eecb8e commit bdbbb92

File tree

431 files changed

+1414
-1383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

431 files changed

+1414
-1383
lines changed

packages/frontend/.storybook/generate.tsx

+125-96
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,26 @@ import { existsSync, readFileSync } from 'node:fs';
22
import { writeFile } from 'node:fs/promises';
33
import { basename, dirname } from 'node:path/posix';
44
import { promisify } from 'node:util';
5-
import { generate } from 'astring';
5+
import { GENERATOR, type State, generate } from 'astring';
66
import type * as estree from 'estree';
77
import * as glob from 'glob';
88
import { format } from 'prettier';
99

10+
interface SatisfiesExpression extends estree.BaseExpression {
11+
type: 'SatisfiesExpression';
12+
expression: estree.Expression;
13+
reference: estree.Identifier;
14+
}
15+
16+
const generator = {
17+
...GENERATOR,
18+
SatisfiesExpression(node: SatisfiesExpression, state: State) {
19+
this[node.expression.type](node.expression, state);
20+
state.write(' satisfies ');
21+
this[node.reference.type](node.reference, state);
22+
},
23+
}
24+
1025
function h<T extends estree.Node>(component: T['type'], props: Omit<T, 'type'>): T {
1126
const type = component.replace(/(?:^|-)([a-z])/g, (_, c) => c.toUpperCase());
1227
return Object.assign(props, { type }) as T;
@@ -56,10 +71,14 @@ function toStories(component: string): string {
5671
local={<identifier name="Meta" />}
5772
imported={<identifier name="Meta" />}
5873
/>,
59-
<import-specifier
60-
local={<identifier name="Story" />}
61-
imported={<identifier name="Story" />}
62-
/>,
74+
...hasImplStories
75+
? []
76+
: [
77+
<import-specifier
78+
local={<identifier name="StoryObj" />}
79+
imported={<identifier name="StoryObj" />}
80+
/>,
81+
],
6382
]}
6483
/>,
6584
...hasMsw
@@ -93,19 +112,24 @@ function toStories(component: string): string {
93112
<variable-declarator
94113
id={<identifier name="meta" />}
95114
init={
96-
<object-expression
97-
properties={[
98-
<property
99-
key={<identifier name="title" />}
100-
value={literal}
101-
kind="init"
102-
/>,
103-
<property
104-
key={<identifier name="component" />}
105-
value={identifier}
106-
kind="init"
107-
/>,
108-
]}
115+
<satisfies-expression
116+
expression={
117+
<object-expression
118+
properties={[
119+
<property
120+
key={<identifier name="title" />}
121+
value={literal}
122+
kind="init"
123+
/>,
124+
<property
125+
key={<identifier name="component" />}
126+
value={identifier}
127+
kind="init"
128+
/>,
129+
]}
130+
/>
131+
}
132+
reference={<identifier name={`Meta<typeof ${identifier.name}>`} />}
109133
/>
110134
}
111135
/>,
@@ -123,89 +147,94 @@ function toStories(component: string): string {
123147
<variable-declarator
124148
id={<identifier name="Default" />}
125149
init={
126-
<object-expression
127-
properties={[
128-
<property
129-
key={<identifier name="render" />}
130-
value={
131-
<function-expression
132-
id={<identifier name="render" />}
133-
params={[
134-
<identifier name="args" />,
135-
<object-pattern
136-
properties={[
137-
<property
138-
key={<identifier name="argTypes" />}
139-
value={<identifier name="argTypes" />}
140-
kind="init"
141-
shorthand
150+
<satisfies-expression
151+
expression={
152+
<object-expression
153+
properties={[
154+
<property
155+
key={<identifier name="render" />}
156+
value={
157+
<function-expression
158+
id={<identifier name="render" />}
159+
params={[
160+
<identifier name="args" />,
161+
<object-pattern
162+
properties={[
163+
<property
164+
key={<identifier name="argTypes" />}
165+
value={<identifier name="argTypes" />}
166+
kind="init"
167+
shorthand
168+
/>,
169+
]}
142170
/>,
143171
]}
144-
/>,
145-
]}
146-
body={
147-
<block-statement
148-
body={[
149-
<return-statement
150-
argument={
151-
<object-expression
152-
properties={[
153-
<property
154-
key={<identifier name="components" />}
155-
value={
156-
<object-expression
157-
properties={[
158-
<property
159-
key={identifier}
160-
value={identifier}
161-
kind="init"
162-
shorthand
163-
/>,
164-
]}
165-
/>
166-
}
167-
kind="init"
168-
/>,
169-
<property
170-
key={<identifier name="props" />}
171-
value={
172-
<call-expression
173-
callee={
174-
<member-expression
175-
object={<identifier name="Object" />}
176-
property={<identifier name="keys" />}
172+
body={
173+
<block-statement
174+
body={[
175+
<return-statement
176+
argument={
177+
<object-expression
178+
properties={[
179+
<property
180+
key={<identifier name="components" />}
181+
value={
182+
<object-expression
183+
properties={[
184+
<property
185+
key={identifier}
186+
value={identifier}
187+
kind="init"
188+
shorthand
189+
/>,
190+
]}
177191
/>
178192
}
179-
arguments={[
180-
<identifier name="argTypes" />,
181-
]}
182-
/>
183-
}
184-
kind="init"
185-
/>,
186-
<property
187-
key={<identifier name="template" />}
188-
value={<literal value={`<${identifier.name} v-bind="$props" />`} />}
189-
kind="init"
190-
/>,
191-
]}
192-
/>
193-
}
194-
/>,
195-
]}
193+
kind="init"
194+
/>,
195+
<property
196+
key={<identifier name="props" />}
197+
value={
198+
<call-expression
199+
callee={
200+
<member-expression
201+
object={<identifier name="Object" />}
202+
property={<identifier name="keys" />}
203+
/>
204+
}
205+
arguments={[
206+
<identifier name="argTypes" />,
207+
]}
208+
/>
209+
}
210+
kind="init"
211+
/>,
212+
<property
213+
key={<identifier name="template" />}
214+
value={<literal value={`<${identifier.name} v-bind="$props" />`} />}
215+
kind="init"
216+
/>,
217+
]}
218+
/>
219+
}
220+
/>,
221+
]}
222+
/>
223+
}
196224
/>
197225
}
198-
/>
199-
}
200-
method
201-
kind="init"
202-
/>,
203-
<property
204-
key={<identifier name="parameters" />}
205-
value={parameters}
206-
kind="init"
207-
/>,
208-
]}
226+
method
227+
kind="init"
228+
/>,
229+
<property
230+
key={<identifier name="parameters" />}
231+
value={parameters}
232+
kind="init"
233+
/>,
234+
]}
235+
/>
236+
}
237+
reference={<identifier name={`StoryObj<typeof ${identifier.name}>`} />}
209238
/>
210239
}
211240
/>,
@@ -221,7 +250,7 @@ function toStories(component: string): string {
221250
/>
222251
) as unknown as estree.Program;
223252
return format(
224-
generate(program) + (hasImplStories ? readFileSync(`${implStories}.ts`, 'utf-8') : ''),
253+
generate(program, { generator }) + (hasImplStories ? readFileSync(`${implStories}.ts`, 'utf-8') : ''),
225254
{
226255
parser: 'babel-ts',
227256
singleQuote: true,

packages/frontend/src/components/MkAbuseReport.stories.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Meta, Story } from '@storybook/vue3';
1+
import { Meta, StoryObj } from '@storybook/vue3';
22
import MkAbuseReport from './MkAbuseReport.vue';
33
const meta = {
44
title: 'components/MkAbuseReport',
55
component: MkAbuseReport,
6-
};
6+
} satisfies Meta<typeof MkAbuseReport>;
77
export const Default = {
88
render(args, { argTypes }) {
99
return {
@@ -17,5 +17,5 @@ export const Default = {
1717
parameters: {
1818
layout: 'centered',
1919
},
20-
};
20+
} satisfies StoryObj<typeof MkAbuseReport>;
2121
export default meta;

packages/frontend/src/components/MkAbuseReportWindow.stories.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Meta, Story } from '@storybook/vue3';
1+
import { Meta, StoryObj } from '@storybook/vue3';
22
import MkAbuseReportWindow from './MkAbuseReportWindow.vue';
33
const meta = {
44
title: 'components/MkAbuseReportWindow',
55
component: MkAbuseReportWindow,
6-
};
6+
} satisfies Meta<typeof MkAbuseReportWindow>;
77
export const Default = {
88
render(args, { argTypes }) {
99
return {
@@ -17,5 +17,5 @@ export const Default = {
1717
parameters: {
1818
layout: 'centered',
1919
},
20-
};
20+
} satisfies StoryObj<typeof MkAbuseReportWindow>;
2121
export default meta;

packages/frontend/src/components/MkAchievements.stories.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Meta, Story } from '@storybook/vue3';
1+
import { Meta, StoryObj } from '@storybook/vue3';
22
import MkAchievements from './MkAchievements.vue';
33
const meta = {
44
title: 'components/MkAchievements',
55
component: MkAchievements,
6-
};
6+
} satisfies Meta<typeof MkAchievements>;
77
export const Default = {
88
render(args, { argTypes }) {
99
return {
@@ -17,5 +17,5 @@ export const Default = {
1717
parameters: {
1818
layout: 'centered',
1919
},
20-
};
20+
} satisfies StoryObj<typeof MkAchievements>;
2121
export default meta;

packages/frontend/src/components/MkAnalogClock.stories.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Meta, Story } from '@storybook/vue3';
1+
import { Meta } from '@storybook/vue3';
22
const meta = {
33
title: 'components/MkAnalogClock',
44
component: MkAnalogClock,
5-
};
5+
} satisfies Meta<typeof MkAnalogClock>;
66
export default meta;
77
import MkAnalogClock from './MkAnalogClock.vue';
88
export const Default = {

packages/frontend/src/components/MkAsUi.stories.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Meta, Story } from '@storybook/vue3';
1+
import { Meta, StoryObj } from '@storybook/vue3';
22
import MkAsUi from './MkAsUi.vue';
33
const meta = {
44
title: 'components/MkAsUi',
55
component: MkAsUi,
6-
};
6+
} satisfies Meta<typeof MkAsUi>;
77
export const Default = {
88
render(args, { argTypes }) {
99
return {
@@ -17,5 +17,5 @@ export const Default = {
1717
parameters: {
1818
layout: 'centered',
1919
},
20-
};
20+
} satisfies StoryObj<typeof MkAsUi>;
2121
export default meta;

packages/frontend/src/components/MkAutocomplete.stories.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Meta, Story } from '@storybook/vue3';
1+
import { Meta, StoryObj } from '@storybook/vue3';
22
import MkAutocomplete from './MkAutocomplete.vue';
33
const meta = {
44
title: 'components/MkAutocomplete',
55
component: MkAutocomplete,
6-
};
6+
} satisfies Meta<typeof MkAutocomplete>;
77
export const Default = {
88
render(args, { argTypes }) {
99
return {
@@ -17,5 +17,5 @@ export const Default = {
1717
parameters: {
1818
layout: 'centered',
1919
},
20-
};
20+
} satisfies StoryObj<typeof MkAutocomplete>;
2121
export default meta;

packages/frontend/src/components/MkAvatars.stories.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Meta, Story } from '@storybook/vue3';
1+
import { Meta, StoryObj } from '@storybook/vue3';
22
import MkAvatars from './MkAvatars.vue';
33
const meta = {
44
title: 'components/MkAvatars',
55
component: MkAvatars,
6-
};
6+
} satisfies Meta<typeof MkAvatars>;
77
export const Default = {
88
render(args, { argTypes }) {
99
return {
@@ -17,5 +17,5 @@ export const Default = {
1717
parameters: {
1818
layout: 'centered',
1919
},
20-
};
20+
} satisfies StoryObj<typeof MkAvatars>;
2121
export default meta;

0 commit comments

Comments
 (0)