switching web boilerplate

This commit is contained in:
balzack 2024-07-11 15:31:20 -07:00
parent 313b69dd36
commit 54ad228b4d
39 changed files with 3979 additions and 39852 deletions

View File

@ -935,6 +935,8 @@ PODS:
- React-Mapbuffer (0.74.3):
- glog
- React-debug
- react-native-sqlite-storage (6.0.1):
- React-Core
- React-nativeconfig (0.74.3)
- React-NativeModulesApple (0.74.3):
- glog
@ -1200,6 +1202,7 @@ DEPENDENCIES:
- React-jsitracing (from `../node_modules/react-native/ReactCommon/hermes/executor/`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
- react-native-sqlite-storage (from `../node_modules/react-native-sqlite-storage`)
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
@ -1291,6 +1294,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/logger"
React-Mapbuffer:
:path: "../node_modules/react-native/ReactCommon"
react-native-sqlite-storage:
:path: "../node_modules/react-native-sqlite-storage"
React-nativeconfig:
:path: "../node_modules/react-native/ReactCommon"
React-NativeModulesApple:
@ -1371,6 +1376,7 @@ SPEC CHECKSUMS:
React-jsitracing: 6b3c8c98313642140530f93c46f5a6ca4530b446
React-logger: fa92ba4d3a5d39ac450f59be2a3cec7b099f0304
React-Mapbuffer: 9f68550e7c6839d01411ac8896aea5c868eff63a
react-native-sqlite-storage: f6d515e1c446d1e6d026aa5352908a25d4de3261
React-nativeconfig: fa5de9d8f4dbd5917358f8ad3ad1e08762f01dcb
React-NativeModulesApple: 585d1b78e0597de364d259cb56007052d0bda5e5
React-perflogger: 7bb9ba49435ff66b666e7966ee10082508a203e8

View File

@ -10,9 +10,10 @@
"test": "jest"
},
"dependencies": {
"databag-client-sdk": "^0.0.18",
"databag-client-sdk": "^0.0.21",
"react": "18.2.0",
"react-native": "0.74.3"
"react-native": "0.74.3",
"react-native-sqlite-storage": "^6.0.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",

View File

@ -1,18 +1,44 @@
import { useState, useEffect } from 'react';
import { DatabagSDK, SqlStore, Session } from 'databag-client-sdk';
import SQLite from "react-native-sqlite-storage";
const DATABAG_DB = 'db_v200.db';
class Store implements SqlStore {
set(stmt: string, params: (string | number)[]): Promise<void> {
console.log("store set");
private db: any = null;
constructor() {
SQLite.DEBUG(false);
SQLite.enablePromise(true);
}
get(stmt: string, params: (string | number)[]): Promise<any[]> {
console.log("store get");
public async open(path: string) {
this.db = await SQLite.openDatabase({ name: path, location: "default" });
}
public async set(stmt: string, params: (string | number | null)[]): Promise<void> {
await this.db.executeSql(stmt, params);
}
public async get(stmt: string, params: (string | number | null)[]): Promise<any[]> {
const res = await this.db.executeSql(stmt, params);
const rows = [];
if (res[0] && res[0].rows && res[0].rows > 1) {
for (let i = 0; i < res[0].rows.length; i++) {
rows.push(res[0].rows.item(i));
}
}
return rows;
}
};
export function useAppContext() {
const [state, setState] = useState({});
const [state, setState] = useState({
accountMfa: boolean = false,
accountSet: boolean = false,
adminMfa: boolean = false,
adminSet: boolean = false,
});
const updateState = (value: any) => {
setState((s) => ({ ...s, ...value }))
@ -23,11 +49,25 @@ export function useAppContext() {
const init = async () => {
const sdk = new DatabagSDK(null);
const store = new Store();
await store.open(DATABAG_DB);
const session = await sdk.initOfflineStore(store);
updateState('databag sdk');
const accountSet = (session != null);
updateState({ accountSet, sdk, session });
};
const actions = {
loginAccount: async (handle: string, password: string, url: string, mfaCode: string | null) => {
},
accessAccount: async (url: string, token: string) => {
},
createAccount: async (handle: string, password: string, url: string, token: string | null) => {
},
logoutAccount: async () => {
},
loginAdmin: async (token: string, url: string, mfaCode: string | null) => {
},
logoutAdmin: async () => {
},
}
return { state, actions }

View File

@ -3010,12 +3010,13 @@ __metadata:
"@types/react": ^18.2.6
"@types/react-test-renderer": ^18.0.0
babel-jest: ^29.6.3
databag-client-sdk: ^0.0.18
databag-client-sdk: ^0.0.21
eslint: ^8.19.0
jest: ^29.6.3
prettier: 2.8.8
react: 18.2.0
react-native: 0.74.3
react-native-sqlite-storage: ^6.0.1
react-test-renderer: 18.2.0
typescript: 5.0.4
languageName: unknown
@ -4034,12 +4035,12 @@ __metadata:
languageName: node
linkType: hard
"databag-client-sdk@npm:^0.0.18":
version: 0.0.18
resolution: "databag-client-sdk@npm:0.0.18"
"databag-client-sdk@npm:^0.0.21":
version: 0.0.21
resolution: "databag-client-sdk@npm:0.0.21"
dependencies:
eventemitter3: ^5.0.1
checksum: d7afa318a9f0b4474d3d9df247f9ee8ed3f473d2163560b93d62716069650306286413b2d83cb4946fc3cf07575291e45c025475aec7a9e428c4a6318f4c29ec
checksum: 5046d90531119554a8787e7f0e79c2dc420372bfe15edd8e6dfcf49e134aac328c84e2f990dcf448e8832e198d2340b7f2e7fdab5cf3b35b79e1e919dc05e0d5
languageName: node
linkType: hard
@ -7969,6 +7970,15 @@ __metadata:
languageName: node
linkType: hard
"react-native-sqlite-storage@npm:^6.0.1":
version: 6.0.1
resolution: "react-native-sqlite-storage@npm:6.0.1"
peerDependencies:
react-native: ">=0.14.0"
checksum: 79bd454682beb22cdfb5a234b9d52b454d0451dccf03a3c15b70b9c331b32cf0066703652b0d23707bda9b9b4c8063e92d31084171af3ea647855b5d727746e0
languageName: node
linkType: hard
"react-native@npm:0.74.3":
version: 0.74.3
resolution: "react-native@npm:0.74.3"

View File

@ -0,0 +1,31 @@
{
"extends": [
"react-app",
"react-app/jest",
"standard",
"standard-jsx",
"standard-react"
],
"plugins": [
"jsx-a11y"
],
"rules": {
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline"
}
],
"no-undef": "off",
"react/react-in-jsx-scope": "off",
"react/jsx-pascal-case": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["off", {
"ignoreRestSiblings": true
}]
}
}

View File

@ -1,23 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
node_modules
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
dist
dist-ssr
*.local
coverage
tsconfig.tsbuildinfo

13
app/client/web/index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Databag</title>
</head>
<body>
<div data-js="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@ -0,0 +1,205 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/
const assetsKey = '\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|css)$'
const config = {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after `n` failures
// bail: 0,
// The directory where Jest should store its cached dependency information
// cacheDirectory: "/tmp/jest_rs",
// Automatically clear mock calls, instances and results before every test
clearMocks: true,
// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,
// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,
// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',
// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: [
'/node_modules/',
'config/tests',
],
// Indicates which provider should be used to instrument code for coverage
// coverageProvider: "babel",
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,
// A path to a custom dependency extractor
// dependencyExtractor: undefined,
// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],
// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,
// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,
// A set of global variables that need to be available in all test environments
// globals: {},
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "jsx",
// "ts",
// "tsx",
// "json",
// "node"
// ],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
'@/(.*)': '<rootDir>/src/$1',
'\\.svg$': '<rootDir>/src/config/tests/mocks/svg.ts',
[assetsKey]: 'ts-jest',
},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
// Activates notifications for test results
// notify: false,
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration
// preset: undefined,
// Run tests from one or more projects
// projects: undefined,
// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
// Automatically reset mock state before every test
// resetMocks: false,
// Reset the module registry before running each individual test
// resetModules: false,
// A path to a custom resolver
// resolver: undefined,
// Automatically restore mock state and implementation before every test
// restoreMocks: false,
// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,
// A list of paths to directories that Jest should use to search for files in
roots: ['<rootDir>'],
// Allows you to use a custom runner instead of Jest's default test runner
// runner: 'jest-runner',
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
// The test environment that will be used for testing
testEnvironment: 'jsdom',
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
// Adds a location field to test results
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
// This option allows the use of a custom results processor
// testResultsProcessor: undefined,
// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",
// A map from regular expressions to paths to transformers
transform: {
'^.+\\.tsx?$': 'ts-jest',
[assetsKey]: 'ts-jest',
'\\.svg$': 'ts-jest',
},
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
// Indicates whether each individual test should be reported during the run
// verbose: undefined,
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
// Whether to use watchman for file crawling
// watchman: true,
}
export default config

View File

@ -0,0 +1 @@
import '@testing-library/jest-dom'

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +1,48 @@
{
"name": "databag",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.101",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"databag-client-sdk": "^0.0.18",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
"version": "0.2.0",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"test": "jest",
"test:watch": "yarn test --watch",
"lint": "eslint src --ext ts,tsx",
"lint:fix": "yarn lint --fix",
"type-check": "tsc --project tsconfig.json --pretty --noEmit",
"prepare": "husky install",
"update-deps": "node ./src/config/update-deps.mjs"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"dependencies": {
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "13.4.0",
"@types/jest": "29.0.3",
"@types/react": "18.0.21",
"@types/react-dom": "18.0.6",
"@vitejs/plugin-react": "2.1.0",
"babel-eslint": "10.1.0",
"databag-client-sdk": "^0.0.21",
"eslint": "8.24.0",
"eslint-config-react-app": "7.0.1",
"eslint-config-standard": "17.0.0",
"eslint-config-standard-jsx": "11.0.0",
"eslint-config-standard-react": "11.0.1",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-n": "15.3.0",
"eslint-plugin-promise": "6.0.1",
"eslint-plugin-react": "7.31.8",
"husky": "8.0.1",
"jest": "29.1.1",
"jest-runner-eslint": "1.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-test-renderer": "18.2.0",
"ts-jest": "29.0.2",
"ts-node": "10.9.1",
"typescript": "4.8.4",
"vite": "3.1.4",
"vite-plugin-linter": "1.2.0",
"vite-plugin-svgr": "2.2.1",
"vite-tsconfig-paths": "3.5.1"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -1,25 +0,0 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

9
app/client/web/src/@types/svg.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
// https://github.com/facebook/create-react-app/blob/0ee4765c39f820e5f4820abf4bf2e47b3324da7f/packages/react-scripts/lib/react-app.d.ts#L47-L56
declare module '*.svg' {
import * as React from 'react'
export const ReactComponent: React.FunctionComponent<
React.SVGProps<SVGSVGElement> & { title?: string }
>
}

View File

@ -36,3 +36,7 @@
transform: rotate(360deg);
}
}
button {
font-size: calc(10px + 2vmin);
}

View File

@ -1,9 +0,0 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@ -1,29 +1,48 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import { AppContextProvider } from './context/AppContext';
import { useState } from 'react'
import { ReactComponent as Logo } from './logo.svg'
import './app.css'
import { AppContextProvider } from './context/AppContext'
export function App () {
const [count, setCount] = useState(0)
function App() {
return (
<AppContextProvider>
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<div className='App'>
<header className='App-header'>
<Logo className='App-logo' title='logo' />
<p>Hello Vite + React!</p>
<p>
Edit <code>src/App.tsx</code> and save to reload.
<button type='button' onClick={() => setCount((count) => count + 1)}>
count is: {count}
</button>
</p>
<p>
Edit <code>App.tsx</code> and save to test HMR updates.
</p>
<p>
<a
className='App-link'
href='https://reactjs.org'
target='_blank'
rel='noopener noreferrer'
>
Learn React
</a>
{' | '}
<a
className='App-link'
href='https://vitejs.dev/guide/features.html'
target='_blank'
rel='noopener noreferrer'
>
Vite Docs
</a>
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
</AppContextProvider>
);
)
}
export default App;

View File

@ -0,0 +1,9 @@
import { App } from '@/app'
import { render, screen } from '@testing-library/react'
it('Test', () => {
render(<App />)
const button = screen.getByRole('button')
expect(button).toBeEnabled()
})

View File

@ -0,0 +1,4 @@
const svgUrl = 'svgUrl'
export default svgUrl
export const ReactComponent = 'svg'

View File

@ -0,0 +1,24 @@
import { spawn } from 'child_process'
import { readFile } from 'fs/promises'
import { fileURLToPath } from 'url'
import path from 'path'
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const pkg = JSON.parse(await readFile(path.join(dirname, '../../', 'package.json')))
const dependencies = Object.keys(pkg.dependencies)
const devDependencies = Object.keys(pkg.devDependencies || [])
const add = (args) => {
return spawn('yarn', ['add', '--exact'].concat(args), { stdio: 'inherit' })
}
add(dependencies).on('close', () => {
if(devDependencies.length > 0) {
add(['--dev'].concat(devDependencies))
.on('close', (code) => process.exit(Number(code)))
}
})

View File

@ -1,14 +0,0 @@
import { createContext } from 'react';
import { useAppContext } from './useAppContext.hook';
export const AppContext = createContext({});
export function AppContextProvider({ children }) {
const { state, actions } = useAppContext();
return (
<AppContext.Provider value={{ state, actions }}>
{children}
</AppContext.Provider>
);
}

View File

@ -0,0 +1,13 @@
import { ReactNode, createContext } from 'react'
import { useAppContext } from './useAppContext.hook'
export const AppContext = createContext({})
export function AppContextProvider ({ children }: { children: ReactNode }) {
const { state, actions } = useAppContext()
return (
<AppContext.Provider value={{ state, actions }}>
{children}
</AppContext.Provider>
)
}

View File

@ -1,41 +1,51 @@
import { useState, useEffect } from 'react';
import { DatabagSDK, WebStore, Session } from 'databag-client-sdk';
import { useState, useEffect } from 'react'
import { DatabagSDK, WebStore, Session } from 'databag-client-sdk'
class Store implements WebStore {
public async getValue(key: string): Promise<string> {
return '';
public async getValue (key: string): Promise<any> {
console.log('web store get: ', key)
const value = localStorage.getItem(key)
if (!value) {
return null
}
return JSON.parse(value)
}
public async setValue(key: string, value: string): Promise<void> {
public async setValue (key: string, value: any): Promise<void> {
localStorage.setItem(key, JSON.stringify(value))
}
public async clearValue(key: string): Promise<void> {
public async clearValue (key: string): Promise<void> {
localStorage.removeItem(key)
}
public async clearAll(): Promise<void> {
public async clearAll (): Promise<void> {
localStorage.clear()
}
};
export function useAppContext() {
const [state, setState] = useState({});
export function useAppContext () {
const [state, setState] = useState({})
const updateState = (value: any) => {
setState((s) => ({ ...s, ...value }))
}
useEffect(() => { init() }, []);
useEffect(() => {
init()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
const init = async () => {
const sdk = new DatabagSDK(null);
const store = new Store();
const session: Session | null = await sdk.initOnlineStore(store);
console.log(session);
updateState({ sdk, session });
};
const sdk = new DatabagSDK(null, null)
const store = new Store()
const session: Session | null = await sdk.initOnlineStore(store)
console.log(session)
updateState({ sdk, session })
}
const actions = {
}
return { state, actions }
}

View File

@ -0,0 +1,15 @@
<svg width="410" height="404" viewBox="0 0 410 404" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M399.641 59.5246L215.643 388.545C211.844 395.338 202.084 395.378 198.228 388.618L10.5817 59.5563C6.38087 52.1896 12.6802 43.2665 21.0281 44.7586L205.223 77.6824C206.398 77.8924 207.601 77.8904 208.776 77.6763L389.119 44.8058C397.439 43.2894 403.768 52.1434 399.641 59.5246Z" fill="url(#paint0_linear)"/>
<path d="M292.965 1.5744L156.801 28.2552C154.563 28.6937 152.906 30.5903 152.771 32.8664L144.395 174.33C144.198 177.662 147.258 180.248 150.51 179.498L188.42 170.749C191.967 169.931 195.172 173.055 194.443 176.622L183.18 231.775C182.422 235.487 185.907 238.661 189.532 237.56L212.947 230.446C216.577 229.344 220.065 232.527 219.297 236.242L201.398 322.875C200.278 328.294 207.486 331.249 210.492 326.603L212.5 323.5L323.454 102.072C325.312 98.3645 322.108 94.137 318.036 94.9228L279.014 102.454C275.347 103.161 272.227 99.746 273.262 96.1583L298.731 7.86689C299.767 4.27314 296.636 0.855181 292.965 1.5744Z" fill="url(#paint1_linear)"/>
<defs>
<linearGradient id="paint0_linear" x1="6.00017" y1="32.9999" x2="235" y2="344" gradientUnits="userSpaceOnUse">
<stop stop-color="#41D1FF"/>
<stop offset="1" stop-color="#BD34FE"/>
</linearGradient>
<linearGradient id="paint1_linear" x1="194.651" y1="8.81818" x2="236.076" y2="292.989" gradientUnits="userSpaceOnUse">
<stop stop-color="#FFEA83"/>
<stop offset="0.0833333" stop-color="#FFDD35"/>
<stop offset="1" stop-color="#FFA800"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1,19 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

View File

@ -1 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
<g fill="#61DAFB">
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
<circle cx="420.9" cy="296.5" r="45.7"/>
<path d="M520.5 78.1z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,17 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { App } from '@/app'
import './index.css'
const rootElement = document.querySelector('[data-js="root"]')
if (!rootElement) {
throw new Error('Failed to find the root element')
}
const root = createRoot(rootElement)
root.render(
<StrictMode>
<App />
</StrictMode>,
)

View File

@ -1 +0,0 @@
/// <reference types="react-scripts" />

View File

@ -1,15 +0,0 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@ -1,5 +0,0 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

1
app/client/web/src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

View File

@ -1,26 +1,29 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"incremental": true,
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"isolatedModules": false,
"noEmit": true,
"jsx": "react-jsx"
"typeRoots": [
"./node_modules/@types",
"./src/@types"
],
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": [
"src"
]
"include": ["./src"]
}

View File

@ -0,0 +1,24 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tsConfigPaths from 'vite-tsconfig-paths'
import { EsLinter, linterPlugin } from 'vite-plugin-linter'
import svgrPlugin from 'vite-plugin-svgr'
// https://vitejs.dev/config/
export default defineConfig(configEnv => ({
plugins: [
react(),
tsConfigPaths(),
linterPlugin({
include: ['./src/**/*.{ts,tsx}'],
linters: [new EsLinter({ configEnv })],
}),
svgrPlugin(),
],
server: {
port: 3000,
},
preview: {
port: 8080,
},
}))

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "databag-client-sdk",
"version": "0.0.20",
"version": "0.0.21",
"description": "an SDK for developing Databag applications",
"main": "./dist/index.js",
"module": "./dist/index.mjs",