@rohal12/spindle 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pkg/format.js +1 -1
- package/dist/pkg/macro-registry.json +282 -0
- package/dist/pkg/tooling.js +44 -0
- package/package.json +8 -2
- package/src/components/macros/Button.tsx +1 -0
- package/src/components/macros/Cycle.tsx +1 -0
- package/src/components/macros/Do.tsx +1 -0
- package/src/components/macros/For.tsx +1 -0
- package/src/components/macros/If.tsx +1 -0
- package/src/components/macros/MacroLink.tsx +1 -0
- package/src/components/macros/Nobr.tsx +1 -0
- package/src/components/macros/Repeat.tsx +1 -0
- package/src/components/macros/Span.tsx +1 -0
- package/src/components/macros/Type.tsx +1 -0
- package/src/components/macros/Widget.tsx +1 -0
- package/src/components/macros/WidgetInvocation.tsx +83 -30
- package/src/define-macro.ts +30 -7
- package/src/registry.ts +35 -0
- package/src/story-api.ts +9 -1
package/src/registry.ts
CHANGED
|
@@ -31,3 +31,38 @@ export function registerSubMacro(name: string): void {
|
|
|
31
31
|
export function isSubMacro(name: string): boolean {
|
|
32
32
|
return subMacros.has(name.toLowerCase());
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
export interface ParameterDef {
|
|
36
|
+
name: string;
|
|
37
|
+
required?: boolean;
|
|
38
|
+
description?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface MacroMetadata {
|
|
42
|
+
name: string;
|
|
43
|
+
block: boolean;
|
|
44
|
+
subMacros: string[];
|
|
45
|
+
storeVar?: boolean;
|
|
46
|
+
interpolate?: boolean;
|
|
47
|
+
merged?: boolean;
|
|
48
|
+
source: 'builtin' | 'user';
|
|
49
|
+
description?: string;
|
|
50
|
+
parameters?: ParameterDef[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const metadataRegistry = new Map<string, MacroMetadata>();
|
|
54
|
+
|
|
55
|
+
export function registerMacroMetadata(
|
|
56
|
+
name: string,
|
|
57
|
+
metadata: MacroMetadata,
|
|
58
|
+
): void {
|
|
59
|
+
metadataRegistry.set(name.toLowerCase(), metadata);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getMacroRegistry(): MacroMetadata[] {
|
|
63
|
+
return Array.from(metadataRegistry.values());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function clearMetadataRegistry(): void {
|
|
67
|
+
metadataRegistry.clear();
|
|
68
|
+
}
|
package/src/story-api.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { setTitleGenerator } from './saves/save-manager';
|
|
|
6
6
|
import { registerClass } from './class-registry';
|
|
7
7
|
import { defineMacro } from './define-macro';
|
|
8
8
|
import type { MacroDefinition } from './define-macro';
|
|
9
|
+
import { getMacroRegistry as _getMacroRegistry } from './registry';
|
|
10
|
+
import type { MacroMetadata } from './registry';
|
|
9
11
|
import {
|
|
10
12
|
getActions,
|
|
11
13
|
getAction,
|
|
@@ -33,6 +35,7 @@ import type { WatchOptions } from './triggers';
|
|
|
33
35
|
import type { TransitionConfig } from './transition';
|
|
34
36
|
|
|
35
37
|
export type { StoryAction };
|
|
38
|
+
export type { MacroMetadata };
|
|
36
39
|
|
|
37
40
|
type NavigateCallback = (to: string, from: string) => void;
|
|
38
41
|
type ActionsChangedCallback = () => void;
|
|
@@ -69,6 +72,7 @@ export interface StoryAPI {
|
|
|
69
72
|
readonly settings: typeof settings;
|
|
70
73
|
registerClass(name: string, ctor: new (...args: any[]) => any): void;
|
|
71
74
|
defineMacro(config: MacroDefinition): void;
|
|
75
|
+
getMacroRegistry(): MacroMetadata[];
|
|
72
76
|
readonly saves: {
|
|
73
77
|
setTitleGenerator(fn: (payload: SavePayload) => string): void;
|
|
74
78
|
};
|
|
@@ -229,7 +233,11 @@ function createStoryAPI(): StoryAPI {
|
|
|
229
233
|
},
|
|
230
234
|
|
|
231
235
|
defineMacro(config: MacroDefinition): void {
|
|
232
|
-
defineMacro(config);
|
|
236
|
+
defineMacro(config, 'user');
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
getMacroRegistry(): MacroMetadata[] {
|
|
240
|
+
return _getMacroRegistry();
|
|
233
241
|
},
|
|
234
242
|
|
|
235
243
|
saves: {
|