Skip to content

rewrite #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
"post-commit": "git reset",
"pre-commit": "lint-staged"
}
}
},
"packageManager": "[email protected]+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca"
}
2 changes: 1 addition & 1 deletion packages/@textstat/kernel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"tabWidth": 4
},
"dependencies": {
"@textlint/kernel": "^3.1.4"
"@textlint/kernel": "^14.7.1"
},
"devDependencies": {
"@textlint/textlint-plugin-markdown": "^5.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/@textstat/rule-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"tabWidth": 4
},
"dependencies": {
"@textlint/kernel": "^3.1.4",
"lodash.template": "^4.4.0"
"@textlint/kernel": "^14.7.1",
"lodash.template": "^4.5.0"
},
"devDependencies": {
"@types/lodash.template": "^4.4.4",
Expand Down
8 changes: 4 additions & 4 deletions packages/@textstat/rule-context/src/report-type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TextlintRuleOptions } from "@textlint/kernel";
import RuleContext from "@textlint/kernel/lib/kernel/src/core/rule-context";
import FilterRuleContext from "@textlint/kernel/lib/kernel/src/core/filter-rule-context";
import { TextlintRuleContext } from "@textlint/types";
import { TextlintFilterRuleContext } from "@textlint/types";
import { TxtNode, TxtNodeType } from "@textlint/kernel/lib/ast-node-types/src";
import { LocaleTag, LocalizeMessages } from "./Localize";

Expand Down Expand Up @@ -28,7 +28,7 @@ export type TextstatRuleMeta = {
};

export type TextstatRuleReporter = (
context: Readonly<RuleContext>,
context: Readonly<TextlintRuleContext>,
options: TextlintRuleOptions,
deps: TextstatRuleSharedDependencies
) => { [P in TxtNodeType]?: (node: TxtNode) => void | Promise<any> };
Expand All @@ -43,7 +43,7 @@ export interface TextstatKernelRule {
}

export type TextstatFilterRuleReporter = (
context: Readonly<FilterRuleContext>,
context: Readonly<TextlintFilterRuleContext>,
options: TextlintRuleOptions,
deps: TextstatRuleSharedDependencies
) => { [P in TxtNodeType]?: (node: TxtNode) => void | Promise<any> };
Expand Down
2 changes: 2 additions & 0 deletions packages/@textstat/rule-context/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": { "*": ["types/*"] },
"outDir": "./lib/"
},
"include": [
Expand Down
6 changes: 3 additions & 3 deletions packages/@textstat/textstat-rule-tateishi-level/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"tabWidth": 4
},
"dependencies": {
"@textlint/ast-node-types": "^4.2.1",
"@textlint/ast-node-types": "^14.7.1",
"@textstat/rule-context": "^0.8.0",
"sentence-splitter": "^3.0.11",
"textlint-rule-helper": "^2.0.1"
"sentence-splitter": "^5.0.0",
"textlint-rule-helper": "^2.3.1"
},
"devDependencies": {
"@textstat/textstat-tester": "^0.8.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { splitAST, Syntax } from "sentence-splitter";
import { TxtParentNode } from "@textlint/ast-node-types";

export const getSentences = (node: TxtParentNode) => {
export const getSentences = (node: TxtParentNode): import("sentence-splitter").SentenceNode[] => {
return splitAST(node).children.filter(node => {
return node.type === Syntax.Sentence;
});
}) as import("sentence-splitter").SentenceNode[];
};
2 changes: 1 addition & 1 deletion packages/@textstat/textstat-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"tabWidth": 4
},
"dependencies": {
"@textlint/textlint-plugin-markdown": "^5.1.4",
"@textlint/textlint-plugin-markdown": "^14.7.1",
"@textstat/kernel": "^0.8.0",
"@textstat/rule-context": "^0.8.0"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/@textstat/textstat-view/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
.next/

# misc
.DS_Store
Expand Down Expand Up @@ -104,5 +105,6 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

next-env.d.ts

/lib
8 changes: 8 additions & 0 deletions packages/@textstat/textstat-view/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NextConfig } from "next";

const nextConfig: NextConfig = {
output: "export", // Outputs a Single-Page Application (SPA)
distDir: "build" // Changes the build output directory to `build`
};

export default nextConfig;
35 changes: 16 additions & 19 deletions packages/@textstat/textstat-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"version": "0.8.0",
"private": true,
"scripts": {
"build": "react-scripts build",
"build:navi": "cross-env REACT_APP_NAVI=true navi-scripts build",
"eject": "react-scripts eject",
"start": "react-scripts start",
"test": "react-scripts test",
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"export": "next export",
"serve": "npx serve@latest ./build",
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\""
},
"prettier": {
Expand All @@ -21,28 +22,24 @@
"dependencies": {
"@textstat/to-non-cyclic": "^0.8.0",
"@types/classnames": "^2.2.6",
"@types/jest": "23.3.10",
"@types/node": "10.12.12",
"@types/react": "16.7.13",
"@types/react-dom": "16.0.11",
"@types/react": "19.1.4",
"@types/react-dom": "19.1.5",
"classnames": "^2.2.6",
"common-path-prefix": "^1.0.0",
"navi": "^0.8.0",
"plotly.js": "^1.45.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-navi": "^0.8.4",
"react-plotly.js": "^2.3.0",
"react-scripts": "2.1.1",
"typescript": "3.3.3333"
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-plotly.js": "^2.6.0",
"typescript": "^5.8.3",
"next": "^15.3.2"
},
"devDependencies": {
"@types/react-plotly.js": "^2.2.2",
"cross-env": "^5.2.0",
"husky": "^1.3.1",
"lint-staged": "^8.1.4",
"navi-scripts": "^0.8.0",
"prettier": "^1.16.4"
"prettier": "^1.16.4",
"eslint": "^8",
"eslint-config-next": "^15.3.2"
},
"browserslist": [
">0.2%",
Expand Down
1 change: 0 additions & 1 deletion packages/@textstat/textstat-view/public/_redirects

This file was deleted.

Binary file removed packages/@textstat/textstat-view/public/favicon.ico
Binary file not shown.
40 changes: 0 additions & 40 deletions packages/@textstat/textstat-view/public/index.html

This file was deleted.

104 changes: 53 additions & 51 deletions packages/@textstat/textstat-view/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
// App.js
"use client";
import * as React from "react";
import * as url from "url";
import { ChangeEvent } from "react";
import { NavLoading, NavProvider, NavRoute } from "react-navi";
import { BrowserNavigation } from "navi";
import { StatContext } from "./context/StatContext";
import { ChangeEvent, useEffect, useState } from "react"; // useEffectとuseStateをインポート
// import { NavLoading, NavProvider, NavRoute } from "react-navi"; // react-navi関連を削除
// import { BrowserNavigation } from "navi"; // react-navi関連を削除
import { Result, StatProvider } from "./context/StatContext"; // Result型をインポート
import { getStore, saveStore } from "./context/LocalStore";
import { AppMenu } from "./AppMenu";
import "./App.css";
import { fetchGistContent } from "./context/GistStore";

export interface AppProps {
navigation: BrowserNavigation<any>;
}
// AppPropsからnavigationを削除
// export interface AppProps {
// navigation: BrowserNavigation<any>;
// }

class App extends React.Component<AppProps> {
state = getStore({
input: "[]",
results: []
});
// クラスコンポーネントを関数コンポーネントに変換
const App = () => {
// AppPropsを削除
const [state, setState] = useState(
getStore({
input: "[]",
results: [] as Result[] // resultsの型を明示
})
);

private onChangeTextarea = (event: ChangeEvent<HTMLTextAreaElement>) => {
const onChangeTextarea = (event: ChangeEvent<HTMLTextAreaElement>) => {
const input = event.currentTarget.value;
let results = this.state.results;
let results = state.results;
try {
results = JSON.parse(input);
} catch (error) {
Expand All @@ -32,20 +37,20 @@ class App extends React.Component<AppProps> {
input: input,
results: results
};
this.setState(newState);
setState(newState);
saveStore(newState);
};

componentDidMount(): void {
useEffect(() => {
const urlObject = url.parse(location.href, true);
if (urlObject.query && typeof urlObject.query.gist === "string") {
fetchGistContent(urlObject.query.gist)
.then(content => {
try {
const state = JSON.parse(content);
this.setState({
const parsedResults = JSON.parse(content); // 変数名を変更
setState({
input: content,
results: state
results: parsedResults
});
} catch (error) {
console.error("parse error ?gist", error);
Expand All @@ -55,37 +60,34 @@ class App extends React.Component<AppProps> {
console.error("Gist Fetch Error", error);
});
}
}
}, []); // componentDidMountの代わりにuseEffectを使用

render() {
return (
<NavProvider navigation={this.props.navigation}>
<div className="App">
<header className="App-header">
<label>
State:
<textarea
className={"App-input"}
value={this.state.input}
onChange={this.onChangeTextarea}
/>
</label>
<AppMenu />
</header>
<main className="App-main">
<NavLoading>
{isLoading => {
return isLoading ? <p className={"App-mainLoading"}>Loading</p> : null;
}}
</NavLoading>
<StatContext.Provider value={this.state}>
<NavRoute />
</StatContext.Provider>
</main>
</div>
</NavProvider>
);
}
}
return (
// <NavProvider navigation={props.navigation}> // react-navi関連を削除
<div className="App">
<header className="App-header">
<label>
State:
<textarea className={"App-input"} value={state.input} onChange={onChangeTextarea} />
</label>
<AppMenu />
</header>
<main className="App-main">
{/* <NavLoading> // react-navi関連を削除
{isLoading => {
return isLoading ? <p className={"App-mainLoading"}>Loading</p> : null;
}}
</NavLoading> */}
<StatProvider value={state}>
{/* <NavRoute /> // react-navi関連を削除。代わりにchildrenや具体的なコンポーネントを配置 */}
{/* Next.jsのルーティングでは、ページコンポーネントがここに表示されることを期待します。 */}
{/* この部分は、Appコンポーネントがどのようにページコンテンツを表示するかに依存します。 */}
{/* 今回はAppがレイアウトの役割を担い、ページ内容はNext.jsがsrc/app以下のpage.tsxで制御すると仮定 */}
</StatProvider>
</main>
</div>
// </NavProvider> // react-navi関連を削除
);
};

export default App;
11 changes: 11 additions & 0 deletions packages/@textstat/textstat-view/src/app/client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use client";

import dynamic from "next/dynamic";

// Appコンポーネントを動的にインポートし、SSRを無効にします。
// パスはプロジェクト構造に合わせて調整してください。
const App = dynamic(() => import("../App"), { ssr: false });

export function ClientOnly() {
return <App />;
}
17 changes: 17 additions & 0 deletions packages/@textstat/textstat-view/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import "../index.css";
import { Metadata } from "next";

export const metadata: Metadata = {
title: "textstat-viewer",
description: "Web site created with Next.js."
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<div id="root">{children}</div>
</body>
</html>
);
}
Loading