mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 22:04:56 +00:00
config: nextjs,frontends,json (7 files)
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
import type { StorybookConfig } from '@storybook/react-vite'
|
||||
import { mergeConfig } from 'vite'
|
||||
import path from 'path'
|
||||
|
||||
const config: StorybookConfig = {
|
||||
stories: [
|
||||
'../src/**/*.mdx',
|
||||
'../src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
|
||||
// Include Lua package stories
|
||||
'../src/storybook/**/*.stories.@(js|jsx|mjs|ts|tsx)',
|
||||
],
|
||||
addons: [
|
||||
'@storybook/addon-essentials',
|
||||
'@storybook/addon-interactions',
|
||||
],
|
||||
framework: {
|
||||
name: '@storybook/react-vite',
|
||||
options: {},
|
||||
},
|
||||
docs: {},
|
||||
staticDirs: [
|
||||
// Serve package static content
|
||||
{ from: '../../packages', to: '/packages' },
|
||||
],
|
||||
async viteFinal(config) {
|
||||
return mergeConfig(config, {
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, '../src'),
|
||||
},
|
||||
},
|
||||
// Mock Node.js modules that aren't available in browser
|
||||
define: {
|
||||
'process.env': {},
|
||||
},
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
||||
@@ -1,43 +0,0 @@
|
||||
import type { Preview } from '@storybook/react'
|
||||
import React from 'react'
|
||||
|
||||
// Import global styles
|
||||
import '../src/app/globals.scss'
|
||||
|
||||
// Create a mock context provider for Storybook
|
||||
const MockProviders: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
const preview: Preview = {
|
||||
parameters: {
|
||||
controls: {
|
||||
matchers: {
|
||||
color: /(background|color)$/i,
|
||||
date: /Date$/i,
|
||||
},
|
||||
},
|
||||
// Default viewport
|
||||
viewport: {
|
||||
defaultViewport: 'desktop',
|
||||
},
|
||||
// Background options
|
||||
backgrounds: {
|
||||
default: 'light',
|
||||
values: [
|
||||
{ name: 'light', value: '#ffffff' },
|
||||
{ name: 'dark', value: '#1a1a2e' },
|
||||
{ name: 'canvas', value: '#f5f5f5' },
|
||||
],
|
||||
},
|
||||
},
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<MockProviders>
|
||||
<Story />
|
||||
</MockProviders>
|
||||
),
|
||||
],
|
||||
}
|
||||
|
||||
export default preview
|
||||
2614
frontends/nextjs/package-lock.json
generated
2614
frontends/nextjs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -104,11 +104,6 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@playwright/test": "^1.57.0",
|
||||
"@storybook/addon-essentials": "^8.6.14",
|
||||
"@storybook/addon-interactions": "^8.6.14",
|
||||
"@storybook/react": "^8.6.15",
|
||||
"@storybook/react-vite": "^8.6.15",
|
||||
"@storybook/test": "^8.6.14",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/react": "^16.3.1",
|
||||
"@types/node": "^25.0.3",
|
||||
@@ -127,7 +122,6 @@
|
||||
"prettier": "^3.4.2",
|
||||
"prisma": "^7.2.0",
|
||||
"sass": "^1.97.1",
|
||||
"storybook": "^8.6.15",
|
||||
"typescript": "~5.9.3",
|
||||
"typescript-eslint": "^8.50.1",
|
||||
"vite": "^7.3.0",
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
/**
|
||||
* Mock Lua Engine for Storybook
|
||||
*
|
||||
* Since fengari requires a real Lua VM, we mock the execution
|
||||
* by interpreting the JSON-like component trees that Lua packages produce.
|
||||
* This allows Storybook to render Lua packages without running actual Lua code.
|
||||
*/
|
||||
|
||||
import type { LuaUIComponent } from '@/lib/lua/ui/types/lua-ui-package'
|
||||
import type { JsonValue } from '@/types/utility-types'
|
||||
|
||||
export interface MockLuaContext {
|
||||
user?: {
|
||||
id: string
|
||||
username: string
|
||||
level: number
|
||||
email?: string
|
||||
}
|
||||
nerdMode?: boolean
|
||||
theme?: 'light' | 'dark'
|
||||
[key: string]: JsonValue | undefined
|
||||
}
|
||||
|
||||
export interface MockLuaScript {
|
||||
id: string
|
||||
name: string
|
||||
code: string
|
||||
/**
|
||||
* Pre-computed output for this script given specific contexts.
|
||||
* Keys are JSON-stringified context objects.
|
||||
*/
|
||||
mockOutputs?: Record<string, LuaUIComponent>
|
||||
/**
|
||||
* Default output to use when no matching mock is found
|
||||
*/
|
||||
defaultOutput?: LuaUIComponent
|
||||
}
|
||||
|
||||
export interface MockPackageManifest {
|
||||
id: string
|
||||
name: string
|
||||
version: string
|
||||
description: string
|
||||
category: string
|
||||
minLevel: number
|
||||
scripts: MockLuaScript[]
|
||||
/**
|
||||
* Pre-rendered component trees for different contexts
|
||||
*/
|
||||
renderedPages?: Record<string, LuaUIComponent>
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a mock user context for Storybook stories
|
||||
*/
|
||||
export function createMockUser(overrides?: Partial<MockLuaContext['user']>): MockLuaContext['user'] {
|
||||
return {
|
||||
id: 'mock-user-1',
|
||||
username: 'storybook_user',
|
||||
level: 4,
|
||||
email: 'user@example.com',
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a full mock context for Lua package rendering
|
||||
*/
|
||||
export function createMockContext(overrides?: Partial<MockLuaContext>): MockLuaContext {
|
||||
return {
|
||||
user: createMockUser(overrides?.user),
|
||||
nerdMode: false,
|
||||
theme: 'light',
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mock Lua execution result
|
||||
*/
|
||||
export interface MockLuaResult {
|
||||
success: boolean
|
||||
result?: LuaUIComponent
|
||||
error?: string
|
||||
logs: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a mock Lua script with the given context
|
||||
* Returns pre-computed output based on the context
|
||||
*/
|
||||
export function executeMockLuaScript(
|
||||
script: MockLuaScript,
|
||||
context: MockLuaContext
|
||||
): MockLuaResult {
|
||||
const contextKey = JSON.stringify(context)
|
||||
|
||||
// Check for exact context match
|
||||
if (script.mockOutputs && script.mockOutputs[contextKey]) {
|
||||
return {
|
||||
success: true,
|
||||
result: script.mockOutputs[contextKey],
|
||||
logs: [],
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to default output
|
||||
if (script.defaultOutput) {
|
||||
return {
|
||||
success: true,
|
||||
result: script.defaultOutput,
|
||||
logs: [],
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: `No mock output defined for script: ${script.id}`,
|
||||
logs: [`Mock script ${script.id} has no output for context`],
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registry of mock package outputs
|
||||
* This is populated by individual package mock files
|
||||
*/
|
||||
export const mockPackageRegistry: Map<string, MockPackageManifest> = new Map()
|
||||
|
||||
/**
|
||||
* Register a mock package for Storybook rendering
|
||||
*/
|
||||
export function registerMockPackage(manifest: MockPackageManifest): void {
|
||||
mockPackageRegistry.set(manifest.id, manifest)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registered mock package
|
||||
*/
|
||||
export function getMockPackage(packageId: string): MockPackageManifest | undefined {
|
||||
return mockPackageRegistry.get(packageId)
|
||||
}
|
||||
|
||||
/**
|
||||
* List all registered mock packages
|
||||
*/
|
||||
export function listMockPackages(): MockPackageManifest[] {
|
||||
return Array.from(mockPackageRegistry.values())
|
||||
}
|
||||
33
storybook/package.json
Normal file
33
storybook/package.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@metabuilder/storybook",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Storybook for rendering Lua packages and UI components",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "storybook dev -p 6006",
|
||||
"build": "storybook build",
|
||||
"preview": "npx serve storybook-static"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"fengari-web": "^0.1.4",
|
||||
"fengari-interop": "^0.1.4",
|
||||
"clsx": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/addon-essentials": "^8.6.15",
|
||||
"@storybook/addon-interactions": "^8.6.15",
|
||||
"@storybook/react": "^8.6.15",
|
||||
"@storybook/react-vite": "^8.6.15",
|
||||
"@storybook/test": "^8.6.15",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"@vitejs/plugin-react": "^4.5.2",
|
||||
"sass": "^1.97.1",
|
||||
"storybook": "^8.6.15",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^6.3.5"
|
||||
}
|
||||
}
|
||||
26
storybook/tsconfig.json
Normal file
26
storybook/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"],
|
||||
"@packages/*": ["../packages/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src", ".storybook"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
Reference in New Issue
Block a user