this.gui 1.3.40 → 1.3.41

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.
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "thisgui-demo",
3
+ "private": true,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "react": "^19.1.1",
13
+ "react-dom": "^19.1.1",
14
+ "react-router-dom": "^6.30.1",
15
+ "this.gui": "^1.2.18"
16
+ },
17
+ "devDependencies": {
18
+ "@types/react": "^19.0.0",
19
+ "@types/react-dom": "^19.0.0",
20
+ "@vitejs/plugin-react": "^5.0.0",
21
+ "typescript": "^5.9.0",
22
+ "vite": "^6.0.0"
23
+ }
24
+ }
@@ -0,0 +1,40 @@
1
+ //Include this.GUI components as a showviewcase
2
+ import "./index.css";
3
+ import { useState } from "react";
4
+ export default function App() {
5
+ const defaultText = "Generation powered by AI.";
6
+ const [text, setText] = useState(defaultText);
7
+ const handleFocus = () => {
8
+ if (text === defaultText) setText("");
9
+ };
10
+ const handleBlur = () => {
11
+ if (text.trim() === "") setText(defaultText);
12
+ };
13
+
14
+ return (
15
+ <div style={{ textAlign: "center", padding: "2rem" }}>
16
+ <p style={{ textAlign: "center" }}>
17
+ <img src="https://res.cloudinary.com/dkwnxf6gm/image/upload/v1760629119/this.gui.neurons.me_mkapde.png" alt=".GUI logo" width="244" />
18
+ </p>
19
+ <h1>.GUI</h1>
20
+ <input
21
+ type="text"
22
+ value={text}
23
+ onChange={(e) => setText(e.target.value)}
24
+ onFocus={handleFocus}
25
+ onBlur={handleBlur}
26
+ style={{
27
+ textAlign: "center",
28
+ border: "none",
29
+ fontSize: "1.2rem",
30
+ background: "transparent",
31
+ outline: "none",
32
+ width: "80%",
33
+ opacity: text === defaultText ? 0.4 : 1,
34
+ transition: "opacity 0.3s ease"
35
+ }}
36
+ />
37
+ <hr style={{ margin: "2rem auto", width: "60%" }} />
38
+ </div>
39
+ );
40
+ }
@@ -0,0 +1,16 @@
1
+ :root {
2
+ font-family: 'Inter', system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ color: #1f2933;
4
+ background-color: #f5f7fb;
5
+ }
6
+
7
+ body {
8
+ margin: 0;
9
+ min-height: 100vh;
10
+ }
11
+
12
+ .app-container {
13
+ max-width: 960px;
14
+ margin: 96px auto;
15
+ padding: 0 24px;
16
+ }
@@ -0,0 +1,13 @@
1
+ // init/src/main.tsx
2
+ import React from "react";
3
+ import ReactDOM from "react-dom/client";
4
+ import App from "./App";
5
+ import "./index.css";
6
+ import { GuiProvider } from "this.gui";
7
+ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
8
+ <React.StrictMode>
9
+ <GuiProvider>
10
+ <App />
11
+ </GuiProvider>
12
+ </React.StrictMode>
13
+ );
@@ -0,0 +1,36 @@
1
+ import React, { createContext, useContext, useState, useEffect } from 'react';
2
+ import { BrowserRouter, useLocation, useNavigate } from 'react-router-dom';
3
+ type DerivableRouterContextType = {
4
+ currentPath: string;
5
+ navigate: (path: string) => void;
6
+ };
7
+
8
+ const DerivableRouterContext = createContext<DerivableRouterContextType | undefined>(undefined);
9
+ export const DerivableRouterProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => {
10
+ const location = useLocation();
11
+ const navigate = useNavigate();
12
+ const [currentPath, setCurrentPath] = useState<string>(location.pathname);
13
+ useEffect(() => {
14
+ setCurrentPath(location.pathname);
15
+ }, [location.pathname]);
16
+ return (
17
+ <DerivableRouterContext.Provider value={{ currentPath, navigate }}>
18
+ {children}
19
+ </DerivableRouterContext.Provider>
20
+ );
21
+ };
22
+
23
+ export const useDerivableRouter = (): DerivableRouterContextType => {
24
+ const ctx = useContext(DerivableRouterContext);
25
+ if (!ctx) {
26
+ throw new Error('useDerivableRouter must be used within a DerivableRouterProvider');
27
+ }
28
+ return ctx;
29
+ };
30
+
31
+ // Wrapper to ensure routing context
32
+ export const DerivableRouterRoot: React.FC<{ children?: React.ReactNode }> = ({ children }) => (
33
+ <BrowserRouter>
34
+ <DerivableRouterProvider>{children}</DerivableRouterProvider>
35
+ </BrowserRouter>
36
+ );
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "node",
7
+ "strict": true,
8
+ "jsx": "react-jsx",
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "types": ["vite/client", "node"]
15
+ },
16
+ "include": ["src"]
17
+ }
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ resolve: {
7
+ alias: {
8
+ '@': '/src'
9
+ }
10
+ }
11
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "this.gui",
3
3
  "private": false,
4
- "version": "1.3.40",
4
+ "version": "1.3.41",
5
5
  "type": "module",
6
6
  "main": "./dist/this.gui.cjs",
7
7
  "module": "./dist/this.gui.es.js",
@@ -28,8 +28,9 @@
28
28
  "gui": "./dist/bin/cli.js"
29
29
  },
30
30
  "scripts": {
31
- "build": "vite build && npm run build:cli",
31
+ "build": "vite build && npm run build:cli && npm run build:copy-init",
32
32
  "build:cli": "tsc --project tsconfig.cli.json",
33
+ "build:copy-init": "node -e \"const fs=require('fs-extra'); if(!fs.existsSync('init')){throw new Error('init directory missing at project root');} fs.removeSync('dist/init'); fs.copySync('init','dist/init');\"",
33
34
  "pack:local": "npm run build && npm pack",
34
35
  "prepublishOnly": "npm run build",
35
36
  "dev": "vite",