generator-bitloops 0.3.31 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-bitloops",
3
- "version": "0.3.31",
3
+ "version": "0.3.33",
4
4
  "description": "Next.js with TypeScript, Tailwind, Storybook and Cypress generator by Bitloops",
5
5
  "license": "MIT",
6
6
  "author": "Bitloops S.A.",
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(
@@ -23,7 +23,7 @@ const config: StorybookConfig = {
23
23
  if (config.resolve) {
24
24
  config.resolve.alias = {
25
25
  ...config.resolve.alias,
26
- '@/primitives': path.resolve(__dirname, '../platform-vite/src'),
26
+ '@primitives': path.resolve(__dirname, '../platform-vite/src'),
27
27
  };
28
28
  }
29
29
  return config;
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export { useRouter } from "./useRouter";
@@ -0,0 +1,5 @@
1
+ export interface Router {
2
+ push: (url: string) => void;
3
+ replace: (url: string) => void;
4
+ back: () => void;
5
+ }
@@ -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,5 @@
1
+ export interface ImageProperties {
2
+ src: string;
3
+ width: number;
4
+ height: number;
5
+ }
@@ -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 };
@@ -0,0 +1,4 @@
1
+ declare module "*.svg" {
2
+ const content: string;
3
+ export default content;
4
+ }
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2022",
4
- "lib": ["dom", "dom.iterable", "esnext"],
4
+ "lib": [
5
+ "dom",
6
+ "dom.iterable",
7
+ "esnext"
8
+ ],
5
9
  "allowJs": true,
6
10
  "skipLibCheck": true,
7
11
  "strict": true,
@@ -20,17 +24,42 @@
20
24
  ],
21
25
  "baseUrl": ".",
22
26
  "paths": {
23
- "@/*": ["src/*"],
24
- "@/components/*": ["src/components/*"],
25
- "@/assets/*": ["src/assets/*"],
26
- "@/primitives": ["platform-next/src"],
27
- "@/primitives/*": ["platform-next/src/*"],
28
- "@/hooks/*": ["src/hooks/*"],
29
- "@/lib/*": ["src/lib/*"],
30
- "@/types/*": ["src/types/*"],
31
- "@/utils/*": ["src/utils/*"]
27
+ "@/*": [
28
+ "src/*"
29
+ ],
30
+ "@/components/*": [
31
+ "src/components/*"
32
+ ],
33
+ "@/assets/*": [
34
+ "src/assets/*"
35
+ ],
36
+ "@primitives": [
37
+ "platform-next/src"
38
+ ],
39
+ "@primitives/*": [
40
+ "platform-next/src/*"
41
+ ],
42
+ "@/hooks/*": [
43
+ "src/hooks/*"
44
+ ],
45
+ "@/lib/*": [
46
+ "src/lib/*"
47
+ ],
48
+ "@/types/*": [
49
+ "src/types/*"
50
+ ],
51
+ "@/utils/*": [
52
+ "src/utils/*"
53
+ ]
32
54
  }
33
55
  },
34
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
35
- "exclude": ["node_modules"]
36
- }
56
+ "include": [
57
+ "next-env.d.ts",
58
+ "**/*.ts",
59
+ "**/*.tsx",
60
+ ".next/types/**/*.ts"
61
+ ],
62
+ "exclude": [
63
+ "node_modules"
64
+ ]
65
+ }
@@ -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]);