generator-bitloops 0.3.32 → 0.3.33
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/package.json +1 -1
- package/setup/index.js +33 -4
- package/setup/templates/lib/router/index.ts +2 -0
- package/setup/templates/lib/router/types.ts +5 -0
- package/setup/templates/lib/router/useRouter.ts +18 -0
- package/setup/templates/lib/types/image.types.ts +5 -0
- package/setup/templates/lib/types/primitives.types.ts +64 -0
- package/setup/templates/lib/types/types.d.ts +4 -0
- package/setup/templates/.storybook/vitest.setup.ts +0 -7
package/package.json
CHANGED
package/setup/index.js
CHANGED
|
@@ -17,6 +17,8 @@ const PLATFORM_NEXT_FOLDER = 'platform-next';
|
|
|
17
17
|
const PLATFORM_NEXT_SRC_FOLDER = `${PLATFORM_NEXT_FOLDER}/src`;
|
|
18
18
|
const PLATFORM_VITE_FOLDER = 'platform-vite';
|
|
19
19
|
const PLATFORM_VITE_SRC_FOLDER = `${PLATFORM_VITE_FOLDER}/src`;
|
|
20
|
+
const LIB_TYPES_FOLDER = 'lib/types';
|
|
21
|
+
const LIB_ROUTER_FOLDER = 'lib/router';
|
|
20
22
|
|
|
21
23
|
function isKebabCase(str) {
|
|
22
24
|
// Check if the string is empty
|
|
@@ -507,6 +509,36 @@ export default class extends Generator {
|
|
|
507
509
|
);
|
|
508
510
|
});
|
|
509
511
|
|
|
512
|
+
// Lib types files
|
|
513
|
+
const libTypesFiles = [
|
|
514
|
+
`${LIB_TYPES_FOLDER}/primitives.types.ts`,
|
|
515
|
+
`${LIB_TYPES_FOLDER}/image.types.ts`,
|
|
516
|
+
`${LIB_TYPES_FOLDER}/types.d.ts`,
|
|
517
|
+
];
|
|
518
|
+
|
|
519
|
+
libTypesFiles.forEach((filePath) => {
|
|
520
|
+
deleteFileIfExists(this.destinationPath(filePath));
|
|
521
|
+
this.fs.copyTpl(
|
|
522
|
+
this.templatePath(filePath),
|
|
523
|
+
this.destinationPath(filePath),
|
|
524
|
+
);
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
// Lib router files
|
|
528
|
+
const libRouterFiles = [
|
|
529
|
+
`${LIB_ROUTER_FOLDER}/index.ts`,
|
|
530
|
+
`${LIB_ROUTER_FOLDER}/types.ts`,
|
|
531
|
+
`${LIB_ROUTER_FOLDER}/useRouter.ts`,
|
|
532
|
+
];
|
|
533
|
+
|
|
534
|
+
libRouterFiles.forEach((filePath) => {
|
|
535
|
+
deleteFileIfExists(this.destinationPath(filePath));
|
|
536
|
+
this.fs.copyTpl(
|
|
537
|
+
this.templatePath(filePath),
|
|
538
|
+
this.destinationPath(filePath),
|
|
539
|
+
);
|
|
540
|
+
});
|
|
541
|
+
|
|
510
542
|
this.log('Primitives installed!');
|
|
511
543
|
}
|
|
512
544
|
};
|
|
@@ -517,10 +549,7 @@ export default class extends Generator {
|
|
|
517
549
|
this.log('Making Storybook changes...');
|
|
518
550
|
|
|
519
551
|
// Copy .storybook template files
|
|
520
|
-
const storybookFiles = [
|
|
521
|
-
`${STORYBOOK_FOLDER}/main.ts`,
|
|
522
|
-
`${STORYBOOK_FOLDER}/vitest.setup.ts`,
|
|
523
|
-
];
|
|
552
|
+
const storybookFiles = [`${STORYBOOK_FOLDER}/main.ts`];
|
|
524
553
|
|
|
525
554
|
// Delete .storybook/preview.ts if it exists (generated by storybook init)
|
|
526
555
|
deleteFileIfExists(
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Router } from './types';
|
|
2
|
+
|
|
3
|
+
// This will be implemented by platform-specific code
|
|
4
|
+
// The implementation will be injected at build time
|
|
5
|
+
let routerImplementation: (() => Router) | null = null;
|
|
6
|
+
|
|
7
|
+
export function setRouterImplementation(implementation: () => Router) {
|
|
8
|
+
routerImplementation = implementation;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function useRouter(): Router {
|
|
12
|
+
if (!routerImplementation) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
'Router implementation not set. Make sure to call setRouterImplementation in your platform setup.'
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return routerImplementation();
|
|
18
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// shared types (export them from both adapters)
|
|
2
|
+
export type ImgProps = {
|
|
3
|
+
src: string;
|
|
4
|
+
alt: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
fill?: boolean;
|
|
8
|
+
sizes?: string;
|
|
9
|
+
priority?: boolean;
|
|
10
|
+
quality?: number;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
loading?: "eager" | "lazy";
|
|
14
|
+
decoding?: "auto" | "sync" | "async";
|
|
15
|
+
responsive?: { sources: Array<{ media: string; srcSet: string }> }; // optional <picture>
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type LinkProps = {
|
|
19
|
+
href: string;
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
prefetch?: boolean;
|
|
22
|
+
replace?: boolean;
|
|
23
|
+
scroll?: boolean;
|
|
24
|
+
target?: React.HTMLAttributeAnchorTarget;
|
|
25
|
+
rel?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: React.CSSProperties;
|
|
28
|
+
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
29
|
+
"aria-label"?: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type ButtonProps = {
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
onClick?: () => void;
|
|
35
|
+
type?: "button" | "submit" | "reset";
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
className?: string;
|
|
38
|
+
style?: React.CSSProperties;
|
|
39
|
+
"aria-label"?: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type MetaProps = {
|
|
43
|
+
title?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
lang?: string;
|
|
46
|
+
openGraph?: {
|
|
47
|
+
title?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
image?: string;
|
|
50
|
+
url?: string;
|
|
51
|
+
type?: string;
|
|
52
|
+
};
|
|
53
|
+
twitter?: {
|
|
54
|
+
card?: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
image?: string;
|
|
58
|
+
};
|
|
59
|
+
icons?: { icon?: string; apple?: string };
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type FontSpec =
|
|
63
|
+
| { kind: "next"; fonts: Array<{ variable: string; loader: () => unknown }> } // Next native loaders
|
|
64
|
+
| { kind: "css"; hrefs: string[]; className?: string };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
|
|
2
|
-
import { setProjectAnnotations } from '@storybook/nextjs-vite';
|
|
3
|
-
import * as projectAnnotations from './preview';
|
|
4
|
-
|
|
5
|
-
// This is an important step to apply the right configuration when testing your stories.
|
|
6
|
-
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
|
|
7
|
-
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
|