Skip to content

Commit 306233b

Browse files
committedJun 11, 2024
Initial commit
Details: - Drafts monorepo structure, based on Lerna (for publishing) and Preconstruct (for building, and linking for dev). The stack is based on sigma.js v3's one. - Drafts packages/storybook, to allow writing stories in there but also in each workspace independently.
0 parents  commit 306233b

19 files changed

+334
-0
lines changed
 

‎.eslintignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**/dist/*
2+
**/build/*
3+
**/node_modules/*
4+
5+
# Doc and examples
6+
**/storybook-static/*

‎.eslintrc

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"env": {
3+
"jest": true,
4+
"browser": true
5+
},
6+
"root": true,
7+
"ignorePatterns": ["*.js", "*.d.ts"],
8+
"parser": "@typescript-eslint/parser",
9+
"plugins": ["import", "@typescript-eslint"],
10+
"extends": [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/recommended",
13+
"plugin:@typescript-eslint/eslint-recommended",
14+
"prettier",
15+
"plugin:storybook/recommended"
16+
],
17+
"rules": {
18+
"no-prototype-builtins": "off",
19+
"no-console": "warn",
20+
"import/extensions": [
21+
"warn",
22+
"never",
23+
{
24+
"json": "always",
25+
"glsl": "always"
26+
}
27+
],
28+
"@typescript-eslint/no-unused-vars": [
29+
"warn",
30+
{
31+
"argsIgnorePattern": "^_",
32+
"varsIgnorePattern": "^_",
33+
"caughtErrorsIgnorePattern": "^_"
34+
}
35+
]
36+
}
37+
}

‎.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
*.tgz
3+
*.log
4+
*.swp
5+
.DS_Store
6+
.idea
7+
.vscode

‎.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**/dist/*
2+
**/build/*
3+
**/node_modules/*
4+
5+
# Doc and examples
6+
**/storybook-static/*

‎.prettierrc.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"trailingComma": "all",
3+
"printWidth": 120,
4+
"importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
5+
"importOrderSeparation": true,
6+
"importOrderSortSpecifiers": true,
7+
"importOrderGroupNamespaceSpecifiers": true,
8+
"plugins": ["@trivago/prettier-plugin-sort-imports"]
9+
}

‎LICENSE.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright (C) 2013-2024, Alexis Jacomy, Guillaume Plique https://www.sigmajs.org
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4+
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5+
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
11+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
12+
IN THE SOFTWARE.

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Gephi TypeScript utils
2+
3+
TODO

‎babel.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ["@babel/preset-env", "@babel/preset-typescript"],
3+
};

‎lerna.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3+
"version": "independent",
4+
"private": false,
5+
"push": false,
6+
"includeMergedTags": true
7+
}

‎package.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "@gephi/root",
3+
"description": "Various TypeScript helper modules used in the web Gephi ecosystem",
4+
"homepage": "https://gephi.org",
5+
"bugs": "http://github.com/gephi/typescript-utils/issues",
6+
"workspaces": [
7+
"packages/*"
8+
],
9+
"scripts": {
10+
"clean": "npm exec --workspaces -- npx rimraf node_modules && npx rimraf node_modules",
11+
"build": "preconstruct build",
12+
"prettify": "prettier --write .",
13+
"lint": "eslint .",
14+
"test": "npm run test --workspaces",
15+
"start": "npm run start --workspace=@gephi/ts-utils-storybook",
16+
"postinstall": "preconstruct dev",
17+
"postpublish": "preconstruct dev",
18+
"prepublishOnly": "npm run lint && npm run test && npm run build"
19+
},
20+
"dependencies": {
21+
"@babel/core": "^7.24.0",
22+
"@babel/preset-typescript": "^7.23.3",
23+
"@preconstruct/cli": "^2.8.3",
24+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
25+
"eslint": "^8.57.0",
26+
"eslint-config-prettier": "^9.1.0",
27+
"eslint-plugin-import": "^2.29.1",
28+
"eslint-plugin-prettier": "^5.1.3",
29+
"eslint-plugin-storybook": "^0.8.0",
30+
"lerna": "^8.1.2",
31+
"prettier": "^3.2.5",
32+
"rimraf": "^5.0.5",
33+
"typescript": "^5.4.2",
34+
"typescript-eslint": "^7.2.0"
35+
},
36+
"preconstruct": {
37+
"packages": [],
38+
"exports": {
39+
"importConditionDefaultExport": "default"
40+
}
41+
}
42+
}

‎packages/storybook/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
storybook-static

‎packages/storybook/.storybook/main.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import type { StorybookConfig } from "@storybook/html-vite";
2+
import { dirname, join } from "path";
3+
import { mergeConfig } from "vite";
4+
5+
/** @type { import('@storybook/html-vite').StorybookConfig } */
6+
const config: StorybookConfig = {
7+
stories: ["../stories/**/stories.ts", "../../**/src/**/*.mdx", "../../**/src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
8+
addons: [
9+
getAbsolutePath("@storybook/addon-links"),
10+
getAbsolutePath("@storybook/addon-essentials"),
11+
getAbsolutePath("@storybook/addon-interactions"),
12+
getAbsolutePath("@storybook/addon-storysource"),
13+
],
14+
framework: getAbsolutePath("@storybook/html-vite"),
15+
typescript: {
16+
check: true,
17+
},
18+
docs: {
19+
autodocs: "tag",
20+
},
21+
core: {
22+
disableTelemetry: true,
23+
},
24+
staticDirs: ["../public"],
25+
logLevel: "debug",
26+
async viteFinal(config) {
27+
return mergeConfig(config, {
28+
resolve: {
29+
preserveSymlinks: false,
30+
},
31+
});
32+
},
33+
};
34+
export default config;
35+
36+
function getAbsolutePath(value: string): any {
37+
return dirname(require.resolve(join(value, "package.json")));
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { addons } from "@storybook/manager-api";
2+
3+
import theme from "./theme";
4+
5+
addons.setConfig({
6+
theme,
7+
});
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Preview } from "@storybook/html";
2+
3+
const forceReloadDecorator: Preview["decorators"] = (storyFn, context) => {
4+
if (context.globals.shouldReload) {
5+
// Change search params of the iframe
6+
const searchParams = new URLSearchParams(window.parent.location.search);
7+
searchParams.set(
8+
"args",
9+
Object.keys(context.args)
10+
.map((k) => `${k}:${context.args[k]}`)
11+
.join(";"),
12+
);
13+
history.pushState(null, "", "?" + searchParams.toString());
14+
15+
// reload iframe
16+
window.location.reload();
17+
18+
// The reload is fired, but the story renderer is already started.
19+
// To avoid blink effect and console error, we return the template inside a full
20+
// invisible div
21+
return `<div style="height:100%;width:100%;visibility:hidden">${storyFn()}</div>`;
22+
}
23+
24+
context.globals.shouldReload = true;
25+
return storyFn();
26+
};
27+
28+
const preview: Preview = {
29+
decorators: [forceReloadDecorator],
30+
parameters: {
31+
actions: { argTypesRegex: "^on[A-Z].*" },
32+
controls: {
33+
matchers: {
34+
color: /(background|color)$/i,
35+
date: /Date$/i,
36+
},
37+
},
38+
},
39+
};
40+
41+
export default preview;
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { create } from "@storybook/theming/create";
2+
3+
export default create({
4+
base: "light",
5+
fontCode: "monospace",
6+
brandTitle: "Gephi TypeScript utils",
7+
brandUrl: "https://gephi.org/",
8+
brandImage: "https://gephi.org/gephi-lite/gephi-logo.svg",
9+
brandTarget: "_self",
10+
colorPrimary: "#000000",
11+
colorSecondary: "#ffffff",
12+
textColor: "#000000",
13+
textInverseColor: "#ffffff",
14+
});

‎packages/storybook/package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@gephi/ts-utils-storybook",
3+
"private": true,
4+
"devDependencies": {
5+
"@storybook/addon-essentials": "^8.0.0",
6+
"@storybook/addon-interactions": "^8.0.0",
7+
"@storybook/addon-links": "^8.0.0",
8+
"@storybook/addon-storysource": "^8.0.0",
9+
"@storybook/html": "^8.0.0",
10+
"@storybook/html-vite": "^8.0.0",
11+
"@storybook/web-components": "^8.0.0",
12+
"storybook": "^8.0.0"
13+
},
14+
"scripts": {
15+
"start": "storybook dev -p 6006",
16+
"build": "storybook build"
17+
}
18+
}

‎packages/storybook/tsconfig.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"include": ["./types/raw.d.ts", ".storybook/*.tsx", "stories"]
4+
}

‎tsconfig.base.json

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"allowJs": false,
5+
"allowSyntheticDefaultImports": true,
6+
"allowUnreachableCode": false,
7+
"allowUnusedLabels": false,
8+
"alwaysStrict": true,
9+
"baseUrl": ".",
10+
"declaration": true,
11+
"diagnostics": false,
12+
"emitBOM": false,
13+
"emitDecoratorMetadata": false,
14+
"esModuleInterop": true,
15+
"experimentalDecorators": false,
16+
"forceConsistentCasingInFileNames": true,
17+
"importHelpers": true,
18+
"importsNotUsedAsValues": "remove",
19+
"inlineSourceMap": false,
20+
"inlineSources": false,
21+
"isolatedModules": false,
22+
"jsx": "react",
23+
"lib": ["dom", "dom.iterable", "esnext"],
24+
"listEmittedFiles": false,
25+
"listFiles": false,
26+
"module": "commonjs",
27+
"moduleResolution": "node",
28+
"noEmit": false,
29+
"noEmitHelpers": false,
30+
"noEmitOnError": false,
31+
"noFallthroughCasesInSwitch": true,
32+
"noImplicitAny": true,
33+
"noImplicitReturns": true,
34+
"noImplicitThis": true,
35+
"noImplicitUseStrict": false,
36+
"noUnusedLocals": true,
37+
"noUnusedParameters": true,
38+
"paths": {
39+
"*": ["@types/*"]
40+
},
41+
"preserveConstEnums": true,
42+
"pretty": true,
43+
"removeComments": true,
44+
"resolveJsonModule": true,
45+
"skipDefaultLibCheck": true,
46+
"skipLibCheck": true,
47+
"sourceMap": true,
48+
"strict": true,
49+
"strictBindCallApply": true,
50+
"strictFunctionTypes": true,
51+
"strictNullChecks": true,
52+
"strictPropertyInitialization": true,
53+
"stripInternal": true,
54+
"suppressExcessPropertyErrors": false,
55+
"suppressImplicitAnyIndexErrors": false,
56+
"target": "es6"
57+
}
58+
}

‎tsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"files": [],
4+
"references": [
5+
{ "path": "./packages/demo" },
6+
{ "path": "./packages/test" },
7+
{ "path": "./packages/storybook" },
8+
{ "path": "./packages/sigma" },
9+
{ "path": "./packages/node-border" },
10+
{ "path": "./packages/node-image" },
11+
{ "path": "./packages/node-piechart" },
12+
{ "path": "./packages/edge-curve" }
13+
],
14+
"watchOptions": {
15+
"excludeDirectories": ["**/node_modules"]
16+
},
17+
"compilerOptions": {
18+
"noFallthroughCasesInSwitch": false
19+
}
20+
}

0 commit comments

Comments
 (0)
Please sign in to comment.