mirror of
https://github.com/ritz078/transform.git
synced 2026-11-21 00:32:56 +03:00
added accordion for navigation
This commit is contained in:
1 parent
e7aec70db1
commit
88bfa7ab01
12 files changed
+462
-235
No files matched your search
@@ -137,9 +137,13 @@ export default class ConversionPanel extends PureComponent {
|
||||
};
|
||||
|
||||
copyCode = () => {
|
||||
const { rightMode } = this.props
|
||||
const { resultValue } = this.state
|
||||
copy(rightMode !== "rust" ? window.js_beautify(resultValue, { e4x: true }) : resultValue);
|
||||
const { rightMode } = this.props;
|
||||
const { resultValue } = this.state;
|
||||
copy(
|
||||
rightMode !== "rust"
|
||||
? window.js_beautify(resultValue, { e4x: true })
|
||||
: resultValue
|
||||
);
|
||||
this.setState({
|
||||
info: "Code copied to clipboard.",
|
||||
infoType: "success"
|
||||
@@ -348,7 +352,11 @@ export default class ConversionPanel extends PureComponent {
|
||||
theme={theme}
|
||||
name="code"
|
||||
readOnly
|
||||
value={rightMode !== "rust" ? window.js_beautify(resultValue, { e4x: true }) : resultValue}
|
||||
value={
|
||||
rightMode !== "rust"
|
||||
? window.js_beautify(resultValue, { e4x: true })
|
||||
: resultValue
|
||||
}
|
||||
editorProps={{ $blockScrolling: true }}
|
||||
scrollMargin={[20]}
|
||||
fontSize={14}
|
||||
|
||||
+297
-188
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React, { PureComponent } from "react";
|
||||
import isBrowser from "is-in-browser";
|
||||
import Link from "next/link";
|
||||
import Head from "next/head";
|
||||
@@ -6,6 +6,9 @@ import NProgress from "nprogress";
|
||||
import Router from "next/router";
|
||||
import GithubCorner from "react-github-corner";
|
||||
import FuzzyPicker, { FuzzyWrapper } from "react-fuzzy-picker";
|
||||
import Collapse, { Panel } from "rc-collapse";
|
||||
import flatten from "lodash/flatten";
|
||||
import findIndex from "lodash/findIndex";
|
||||
|
||||
NProgress.configure({ showSpinner: false });
|
||||
|
||||
@@ -17,49 +20,75 @@ Router.onRouteChangeStart = url => {
|
||||
Router.onRouteChangeComplete = () => NProgress.done();
|
||||
Router.onRouteChangeError = () => NProgress.done();
|
||||
|
||||
const routes = [
|
||||
const x = [
|
||||
{
|
||||
label: "JSON to React PropTypes",
|
||||
path: "/"
|
||||
category: "React",
|
||||
iconName: "icon-reactjs",
|
||||
content: [
|
||||
{
|
||||
label: "JSON to React PropTypes",
|
||||
path: "/"
|
||||
},
|
||||
{
|
||||
label: "HTML to JSX",
|
||||
path: "/html-to-jsx"
|
||||
},
|
||||
{
|
||||
label: "CSS to JS Objects",
|
||||
path: "/css-to-js"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "JSON to Flow Types",
|
||||
path: "/json-to-flow-types",
|
||||
category: "JavaScript",
|
||||
iconName: "icon-javascript",
|
||||
content: [
|
||||
{
|
||||
label: "JSON to Flow Types",
|
||||
path: "/json-to-flow-types"
|
||||
},
|
||||
{
|
||||
label: "JSON to Typescript Interface",
|
||||
path: "/json-to-ts-interface"
|
||||
},
|
||||
{
|
||||
label: "JSON to MobX-State-Tree Model",
|
||||
path: "/json-to-mobx-state-tree"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "JSON to Typescript Interface",
|
||||
path: "/json-to-ts-interface"
|
||||
category: "Rust",
|
||||
iconName: "icon-rust",
|
||||
content: [
|
||||
{
|
||||
label: "JSON to Rust Serde",
|
||||
path: "/json-to-rust-serde"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "JSON to MobX-State-Tree Model",
|
||||
path: "/json-to-mobx-state-tree"
|
||||
},
|
||||
{
|
||||
label: "CSS to JS Objects",
|
||||
path: "/css-to-js"
|
||||
},
|
||||
{
|
||||
label: "HTML to JSX",
|
||||
path: "/html-to-jsx"
|
||||
},
|
||||
{
|
||||
label: "JSON to Rust Serde",
|
||||
path: "/json-to-rust-serde"
|
||||
},
|
||||
{
|
||||
label: "JSON to Mongoose Schema",
|
||||
path: "/json-to-mongoose"
|
||||
},
|
||||
{
|
||||
label: "JSON to Big Query Schema",
|
||||
path: "/json-to-big-query"
|
||||
},
|
||||
{
|
||||
label: "JSON to MySQL",
|
||||
path: "/json-to-mysql"
|
||||
category: "Databases",
|
||||
iconName: "icon-database",
|
||||
content: [
|
||||
{
|
||||
label: "JSON to Mongoose Schema",
|
||||
path: "/json-to-mongoose"
|
||||
},
|
||||
{
|
||||
label: "JSON to Big Query Schema",
|
||||
path: "/json-to-big-query"
|
||||
},
|
||||
{
|
||||
label: "JSON to MySQL",
|
||||
path: "/json-to-mysql"
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const routes = flatten(x.map(a => a.content));
|
||||
|
||||
function Logo() {
|
||||
return (
|
||||
<svg
|
||||
@@ -119,166 +148,246 @@ function isCorrectKeyPressed(event) {
|
||||
return event.metaKey && event.key === "p";
|
||||
}
|
||||
|
||||
export default function({ children, pathname }) {
|
||||
function getClass(path) {
|
||||
return path === pathname ? "active" : "";
|
||||
export default class Layout extends PureComponent {
|
||||
state = {};
|
||||
|
||||
getClass(path) {
|
||||
return path === this.props.pathname ? "active" : "";
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="main-wrapper">
|
||||
<Head>
|
||||
<title>Transform | All important transforms at one place.</title>
|
||||
<meta
|
||||
rel="description"
|
||||
content="An online utility to convert a JSON object to prop-types, Typescript Interface, Rust serde or flow types. It also converts your CSS into JS and HTML into JSX."
|
||||
componentDidMount() {
|
||||
this.setKey(this.props.pathname);
|
||||
}
|
||||
|
||||
componentWillReceiveProps({ pathname }) {
|
||||
this.setKey(pathname);
|
||||
}
|
||||
|
||||
setKey = pathname => {
|
||||
this.setState({
|
||||
activeKey: `${findIndex(
|
||||
x,
|
||||
o => o.content.filter(a => a.path === pathname).length
|
||||
) + 1}`
|
||||
});
|
||||
};
|
||||
|
||||
onChange = activeKey => {
|
||||
this.setState({
|
||||
activeKey
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="main-wrapper">
|
||||
<Head>
|
||||
<title>Transform | All important transforms at one place.</title>
|
||||
<meta
|
||||
rel="description"
|
||||
content="An online utility to convert a JSON object to prop-types, Typescript Interface, Rust serde or flow types. It also converts your CSS into JS and HTML into JSX."
|
||||
/>
|
||||
<meta
|
||||
name="google-site-verification"
|
||||
content="bjJSOEahdert-7mwVScrwTTUVR3nSe0bEj5YjevUNn0"
|
||||
/>
|
||||
<link rel="icon" type="image/png" href="/static/favicon.png" />
|
||||
<link rel="stylesheet" type="text/css" href="/static/nprogress.css" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-mfizz/2.4.1/font-mfizz.min.css"
|
||||
/>
|
||||
</Head>
|
||||
<style jsx>{`
|
||||
.sidebar {
|
||||
height: 100vh;
|
||||
width: 250px;
|
||||
background-color: #424242;
|
||||
font-size: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
flex-direction: row;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.nav {
|
||||
padding: 20px 0;
|
||||
flex: 1;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.twitter {
|
||||
color: #6dc7ff;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 180px;
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.footer {
|
||||
height: 70px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-family: 'Lato', sans-serif;
|
||||
}
|
||||
|
||||
.footer svg {
|
||||
height: 36px;
|
||||
width: 30px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
margin-top: 6px;
|
||||
margin-left: 6px;
|
||||
background-color: #2196f3;
|
||||
height: 13px;
|
||||
padding: 2px 4px;
|
||||
border-radius: 2px;
|
||||
line-height: 12px;
|
||||
}
|
||||
|
||||
iframe {
|
||||
border: 0;
|
||||
overflow: hidden;
|
||||
display: table;
|
||||
margin: 0 auto;
|
||||
width: 61px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
a.active {
|
||||
background-color: #505050;
|
||||
}
|
||||
|
||||
.info {
|
||||
font-family: 'Lato';
|
||||
color: white;
|
||||
border: 1px solid #7b7b7b;
|
||||
padding: 8px;
|
||||
margin: 0 15px 15px;
|
||||
border-radius: 2px;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
}
|
||||
`}</style>
|
||||
|
||||
<style jsx global>{`
|
||||
.Collapsible__trigger {
|
||||
color: whitesmoke;
|
||||
font-family: 'Lato', sans-serif;
|
||||
line-height: 44px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.Collapsible__trigger a:hover {
|
||||
color: #fff;
|
||||
background-color: #2d2d2d;
|
||||
}
|
||||
|
||||
.Collapsible__trigger a:not(.twitter):not(.github) {
|
||||
display: block;
|
||||
padding-left: 14px;
|
||||
}
|
||||
|
||||
.Collapsible__trigger {
|
||||
padding-left: 14px;
|
||||
color: #fff;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
background-color: #2f2f2f;
|
||||
border-bottom: 1px solid #252525;
|
||||
}
|
||||
|
||||
.rc-collapse-content-box a {
|
||||
display: block;
|
||||
color: #fff;
|
||||
font-family: 'Lato';
|
||||
line-height: 44px;
|
||||
padding-left: 20px;
|
||||
background-color: #3c3c3c;
|
||||
font-size: 14px;
|
||||
}
|
||||
`}</style>
|
||||
|
||||
<FuzzyWrapper
|
||||
isKeyPressed={isCorrectKeyPressed}
|
||||
popup={renderFuzzyPicker}
|
||||
/>
|
||||
<meta
|
||||
name="google-site-verification"
|
||||
content="bjJSOEahdert-7mwVScrwTTUVR3nSe0bEj5YjevUNn0"
|
||||
/>
|
||||
<link rel="icon" type="image/png" href="/static/favicon.png" />
|
||||
<link rel="stylesheet" type="text/css" href="/static/nprogress.css" />
|
||||
</Head>
|
||||
<style jsx>{`
|
||||
.sidebar {
|
||||
height: 100vh;
|
||||
width: 250px;
|
||||
background-color: #424242;
|
||||
font-size: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
<div className="sidebar">
|
||||
<GithubCorner
|
||||
href="https://github.com/ritz078/transform-www"
|
||||
height={80}
|
||||
width={80}
|
||||
direction="left"
|
||||
/>
|
||||
<div className="logo">
|
||||
<Logo />
|
||||
</div>
|
||||
<div className="nav">
|
||||
<div className="info">Use Ctrl/Cmd + P for quick search</div>
|
||||
|
||||
.main-wrapper {
|
||||
flex-direction: row;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
<Collapse
|
||||
onChange={this.onChange}
|
||||
accordion
|
||||
activeKey={this.state.activeKey}
|
||||
>
|
||||
{x.map((route, i) => {
|
||||
return (
|
||||
<Panel
|
||||
key={i + 1}
|
||||
headerClass="Collapsible__trigger"
|
||||
header={
|
||||
<span>
|
||||
<i className={route.iconName} /> {route.category}
|
||||
</span>
|
||||
}
|
||||
>
|
||||
{route.content.map(a =>
|
||||
<Link prefetch href={a.path}>
|
||||
<a className={this.getClass(a.path)}>
|
||||
{a.label}
|
||||
</a>
|
||||
</Link>
|
||||
)}
|
||||
</Panel>
|
||||
);
|
||||
})}
|
||||
</Collapse>
|
||||
</div>
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding: 20px 0;
|
||||
flex: 1;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
li {
|
||||
color: whitesmoke;
|
||||
font-family: 'Lato', sans-serif;
|
||||
line-height: 44px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
li.active {
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
li:hover {
|
||||
color: #fff;
|
||||
background-color: #2d2d2d;
|
||||
}
|
||||
|
||||
a:not(.twitter):not(.github) {
|
||||
display: block;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.twitter {
|
||||
color: #6dc7ff;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 180px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.footer {
|
||||
height: 70px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-family: 'Lato', sans-serif;
|
||||
}
|
||||
|
||||
.footer svg {
|
||||
height: 36px;
|
||||
width: 30px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
margin-top: 6px;
|
||||
margin-left: 6px;
|
||||
background-color: #2196f3;
|
||||
height: 13px;
|
||||
padding: 2px 4px;
|
||||
border-radius: 2px;
|
||||
line-height: 12px;
|
||||
}
|
||||
|
||||
iframe {
|
||||
border: 0;
|
||||
overflow: hidden;
|
||||
display: table;
|
||||
margin: 0 auto;
|
||||
width: 61px;
|
||||
height: 20px;
|
||||
}
|
||||
`}</style>
|
||||
|
||||
<FuzzyWrapper
|
||||
isKeyPressed={isCorrectKeyPressed}
|
||||
popup={renderFuzzyPicker}
|
||||
/>
|
||||
<div className="sidebar">
|
||||
<GithubCorner
|
||||
href="https://github.com/ritz078/transform-www"
|
||||
height={80}
|
||||
width={80}
|
||||
direction="left"
|
||||
/>
|
||||
<div className="logo">
|
||||
<Logo />
|
||||
<div className="footer">
|
||||
<br />Created by{" "}
|
||||
<a
|
||||
target="_blank"
|
||||
className="twitter"
|
||||
href="https://twitter.com/ritz078"
|
||||
>
|
||||
@ritz078
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<ul>
|
||||
{routes.map(route =>
|
||||
<li key={route.path} className={getClass(route.path)}>
|
||||
<Link prefetch href={route.path}>
|
||||
<a>
|
||||
{route.label}
|
||||
</a>
|
||||
</Link>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
|
||||
<div className="footer">
|
||||
<br />Created by{" "}
|
||||
<a
|
||||
target="_blank"
|
||||
className="twitter"
|
||||
href="https://twitter.com/ritz078"
|
||||
>
|
||||
@ritz078
|
||||
</a>
|
||||
<div className="content">
|
||||
{this.props.children}
|
||||
</div>
|
||||
<script>
|
||||
{isBrowser && trackingScript()}
|
||||
</script>
|
||||
</div>
|
||||
<div className="content">
|
||||
{children}
|
||||
</div>
|
||||
<script>
|
||||
{isBrowser && trackingScript()}
|
||||
</script>
|
||||
</div>
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -28,12 +28,15 @@
|
||||
"nprogress": "^0.2.0",
|
||||
"pretty": "^2.0.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"rc-collapse": "^1.7.6",
|
||||
"react": "^15.6.1",
|
||||
"react-ace": "^5.1.2",
|
||||
"react-collapse": "^4.0.3",
|
||||
"react-collapsible": "^2.0.0",
|
||||
"react-dom": "^15.6.1",
|
||||
"react-fuzzy-picker": "^0.5.1",
|
||||
"react-github-corner": "^0.3.0",
|
||||
"react-responsive-accordion": "^1.0.0",
|
||||
"stringify-object": "^3.2.0",
|
||||
"webpack-bundle-analyzer": "^2.9.0"
|
||||
},
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React, { PureComponent } from "react";
|
||||
import { bigquery } from "generate-schema"
|
||||
import stringify from "stringify-object"
|
||||
import { bigquery } from "generate-schema";
|
||||
import stringify from "stringify-object";
|
||||
import Layout from "../components/Layout";
|
||||
import ConversionPanel from "../components/ConversionPanel";
|
||||
import defaultText from "../utils/dummy-object-json";
|
||||
|
||||
export default class Json2Ts extends PureComponent {
|
||||
getTransformedValue = newValue => {
|
||||
const value = JSON.parse(newValue)
|
||||
return stringify(bigquery(value))
|
||||
const value = JSON.parse(newValue);
|
||||
return stringify(bigquery(value));
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React, { PureComponent } from "react";
|
||||
import { mongoose } from "generate-schema"
|
||||
import stringify from "stringify-object"
|
||||
import { mongoose } from "generate-schema";
|
||||
import stringify from "stringify-object";
|
||||
import Layout from "../components/Layout";
|
||||
import ConversionPanel from "../components/ConversionPanel";
|
||||
import defaultText from "../utils/dummy-object-json";
|
||||
|
||||
export default class Json2Ts extends PureComponent {
|
||||
getTransformedValue = newValue => {
|
||||
const value = JSON.parse(newValue)
|
||||
return stringify(mongoose(value))
|
||||
const value = JSON.parse(newValue);
|
||||
return stringify(mongoose(value));
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React, { PureComponent } from "react";
|
||||
import { mysql } from "generate-schema"
|
||||
import stringify from "stringify-object"
|
||||
import { mysql } from "generate-schema";
|
||||
import stringify from "stringify-object";
|
||||
import Layout from "../components/Layout";
|
||||
import ConversionPanel from "../components/ConversionPanel";
|
||||
import defaultText from "../utils/dummy-json";
|
||||
|
||||
export default class Json2Ts extends PureComponent {
|
||||
getTransformedValue = newValue => {
|
||||
const value = JSON.parse(newValue)
|
||||
return mysql(value)
|
||||
const value = JSON.parse(newValue);
|
||||
return mysql(value);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
@@ -1,4 +1,53 @@
|
||||
@import url('https://fonts.googleapis.com/css?family=Lato');
|
||||
.rc-collapse {
|
||||
background-color: #f7f7f7;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.rc-collapse-anim-active {
|
||||
transition: height 0.2s ease-out;
|
||||
}
|
||||
|
||||
.rc-collapse > .rc-collapse-item > .rc-collapse-header {
|
||||
height: 38px;
|
||||
line-height: 38px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.rc-collapse > .rc-collapse-item > .rc-collapse-header .arrow {
|
||||
display: inline-block;
|
||||
content: '\20';
|
||||
width: 0;
|
||||
height: 0;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
border-top: 3px solid transparent;
|
||||
border-bottom: 3px solid transparent;
|
||||
border-left: 4px solid #b3b3b3;
|
||||
vertical-align: middle;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.rc-collapse > .rc-collapse-item-disabled > .rc-collapse-header {
|
||||
cursor: not-allowed;
|
||||
color: #999;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
.rc-collapse-content {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.rc-collapse-content-inactive {
|
||||
display: none;
|
||||
}
|
||||
.rc-collapse-item:last-child > .rc-collapse-content {
|
||||
border-radius: 0 0 3px 3px;
|
||||
}
|
||||
.rc-collapse > .rc-collapse-item-active > .rc-collapse-header .arrow {
|
||||
border-left: 3px solid transparent;
|
||||
border-right: 3px solid transparent;
|
||||
border-top: 4px solid #666;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
|
||||
/* Make clicks pass-through */
|
||||
#nprogress {
|
||||
pointer-events: none;
|
||||
|
||||
@@ -16,10 +16,7 @@ export default function({ types: t }) {
|
||||
if (t.isObjectExpression(uniqueElements[0])) {
|
||||
uniqueElements = [
|
||||
t.callExpression(
|
||||
t.memberExpression(
|
||||
t.identifier("t"),
|
||||
t.identifier("model")
|
||||
),
|
||||
t.memberExpression(t.identifier("t"), t.identifier("model")),
|
||||
uniqueElements
|
||||
)
|
||||
];
|
||||
@@ -31,10 +28,7 @@ export default function({ types: t }) {
|
||||
) {
|
||||
path.replaceWith(
|
||||
t.callExpression(
|
||||
t.memberExpression(
|
||||
t.identifier("t"),
|
||||
t.identifier("array")
|
||||
),
|
||||
t.memberExpression(t.identifier("t"), t.identifier("array")),
|
||||
uniqueElements
|
||||
)
|
||||
);
|
||||
@@ -76,26 +70,20 @@ export default function({ types: t }) {
|
||||
});
|
||||
},
|
||||
|
||||
ObjectProperty(path){
|
||||
if(t.isStringLiteral(path.node.key)){
|
||||
path.node.key = t.identifier(path.node.key.value)
|
||||
}
|
||||
ObjectProperty(path) {
|
||||
if (t.isStringLiteral(path.node.key)) {
|
||||
path.node.key = t.identifier(path.node.key.value);
|
||||
}
|
||||
},
|
||||
|
||||
ObjectExpression(path) {
|
||||
if (
|
||||
t.isCallExpression(path.parent)
|
||||
)
|
||||
return;
|
||||
if (t.isCallExpression(path.parent)) return;
|
||||
|
||||
const elements = [path.node];
|
||||
|
||||
path.replaceWith(
|
||||
t.callExpression(
|
||||
t.memberExpression(
|
||||
t.identifier("t"),
|
||||
t.identifier("model")
|
||||
),
|
||||
t.memberExpression(t.identifier("t"), t.identifier("model")),
|
||||
elements
|
||||
)
|
||||
);
|
||||
|
||||
@@ -16,6 +16,6 @@ const y = `{
|
||||
"index": true,
|
||||
"required": true
|
||||
}
|
||||
}`
|
||||
}`;
|
||||
|
||||
export default y
|
||||
export default y;
|
||||
@@ -21,11 +21,15 @@ var is;
|
||||
}
|
||||
is.string = string;
|
||||
function number(n) {
|
||||
return (typeof n === "number" || n instanceof Number) && !Number.isInteger(n)
|
||||
return (
|
||||
(typeof n === "number" || n instanceof Number) && !Number.isInteger(n)
|
||||
);
|
||||
}
|
||||
is.number = number;
|
||||
function integer(n) {
|
||||
return (typeof n === "number" || n instanceof Number) && Number.isInteger(n)
|
||||
return (
|
||||
(typeof n === "number" || n instanceof Number) && Number.isInteger(n)
|
||||
);
|
||||
}
|
||||
is.integer = integer;
|
||||
function boolean(b) {
|
||||
@@ -277,7 +281,7 @@ var Types = (function() {
|
||||
function Types() {}
|
||||
Types.STRING = "String";
|
||||
Types.NUMBER = "f64";
|
||||
Types.INTEGER = "i64"
|
||||
Types.INTEGER = "i64";
|
||||
Types.BOOLEAN = "boolean";
|
||||
Types.ARRAY = "[]";
|
||||
return Types;
|
||||
@@ -327,9 +331,14 @@ var Json2dts = (function() {
|
||||
var interfaceTab = outputModule ? " " : "";
|
||||
var propertyTab = interfaceTab + " ";
|
||||
Object.keys(this.classes).map(function(clsName) {
|
||||
output = interfaceTab + "#[derive(Serialize, Deserialize)]\nstruct " + clsName + " {\n";
|
||||
output =
|
||||
interfaceTab +
|
||||
"#[derive(Serialize, Deserialize)]\nstruct " +
|
||||
clsName +
|
||||
" {\n";
|
||||
Object.keys(_this.classes[clsName]).map(function(key) {
|
||||
output += propertyTab + key + ": " + _this.classes[clsName][key] + ",\n";
|
||||
output +=
|
||||
propertyTab + key + ": " + _this.classes[clsName][key] + ",\n";
|
||||
});
|
||||
output += interfaceTab + "}\n\n";
|
||||
classes[clsName] = output;
|
||||
@@ -372,7 +381,8 @@ var Json2dts = (function() {
|
||||
type = "Vec<()>";
|
||||
} else {
|
||||
if (is.object(value[0])) {
|
||||
type = "Vec<" + _this.getInterfaceType(key, value[0]).trim() + ">";
|
||||
type =
|
||||
"Vec<" + _this.getInterfaceType(key, value[0]).trim() + ">";
|
||||
_this.analyse_object(value[0], key);
|
||||
} else {
|
||||
type = "Vec<" + _this.getBasicType(value[0]) + ">";
|
||||
|
||||
@@ -326,7 +326,12 @@ var Json2dts = (function() {
|
||||
? interfaceTab + "type " + clsName + " = \n" + interfaceTab + "{\n"
|
||||
: interfaceTab + "interface " + clsName + " \n" + interfaceTab + "{\n";
|
||||
Object.keys(_this.classes[clsName]).map(function(key) {
|
||||
output += propertyTab + key + ":" + _this.classes[clsName][key] + (flow ? ",\n" : ";\n");
|
||||
output +=
|
||||
propertyTab +
|
||||
key +
|
||||
":" +
|
||||
_this.classes[clsName][key] +
|
||||
(flow ? ",\n" : ";\n");
|
||||
});
|
||||
output += interfaceTab + (flow ? "};\n\n" : "}\n\n");
|
||||
classes[clsName] = output;
|
||||
|
||||
@@ -920,6 +920,13 @@ babel-runtime@6.23.0, babel-runtime@^6.18.0, babel-runtime@^6.20.0, babel-runtim
|
||||
core-js "^2.4.0"
|
||||
regenerator-runtime "^0.10.0"
|
||||
|
||||
babel-runtime@6.x:
|
||||
version "6.26.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
|
||||
dependencies:
|
||||
core-js "^2.4.0"
|
||||
regenerator-runtime "^0.11.0"
|
||||
|
||||
babel-standalone@^6.25.0:
|
||||
version "6.25.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-standalone/-/babel-standalone-6.25.0.tgz#759ef04574402b6d1a1b5efa62d18c9a47e4abeb"
|
||||
@@ -1208,7 +1215,7 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3:
|
||||
inherits "^2.0.1"
|
||||
safe-buffer "^5.0.1"
|
||||
|
||||
classnames@^2.2.5:
|
||||
classnames@2.x, classnames@^2.2.5:
|
||||
version "2.2.5"
|
||||
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d"
|
||||
|
||||
@@ -1262,6 +1269,16 @@ commondir@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
|
||||
|
||||
component-classes@^1.2.5:
|
||||
version "1.2.6"
|
||||
resolved "https://registry.yarnpkg.com/component-classes/-/component-classes-1.2.6.tgz#c642394c3618a4d8b0b8919efccbbd930e5cd691"
|
||||
dependencies:
|
||||
component-indexof "0.0.3"
|
||||
|
||||
component-indexof@0.0.3:
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/component-indexof/-/component-indexof-0.0.3.tgz#11d091312239eb8f32c8f25ae9cb002ffe8d3c24"
|
||||
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
@@ -1399,6 +1416,13 @@ crypto-browserify@^3.11.0:
|
||||
public-encrypt "^4.0.0"
|
||||
randombytes "^2.0.0"
|
||||
|
||||
css-animation@1.x, css-animation@^1.3.2:
|
||||
version "1.4.1"
|
||||
resolved "https://registry.yarnpkg.com/css-animation/-/css-animation-1.4.1.tgz#5b8813125de0fbbbb0bbe1b472ae84221469b7a8"
|
||||
dependencies:
|
||||
babel-runtime "6.x"
|
||||
component-classes "^1.2.5"
|
||||
|
||||
css-color-keywords@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/css-color-keywords/-/css-color-keywords-1.0.0.tgz#fea2616dc676b2962686b3af8dbdbe180b244e05"
|
||||
@@ -3271,7 +3295,7 @@ prop-types-exact@^1.1.1:
|
||||
has "^1.0.1"
|
||||
object.assign "^4.0.4"
|
||||
|
||||
prop-types@15.5.10, prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.8:
|
||||
prop-types@15.5.10, prop-types@15.x, prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.6, prop-types@^15.5.8:
|
||||
version "15.5.10"
|
||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
|
||||
dependencies:
|
||||
@@ -3344,6 +3368,23 @@ range-parser@^1.0.3, range-parser@~1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e"
|
||||
|
||||
rc-animate@2.x:
|
||||
version "2.4.1"
|
||||
resolved "https://registry.yarnpkg.com/rc-animate/-/rc-animate-2.4.1.tgz#df3e0f56fe106afe4bf52ff408ced241c5178919"
|
||||
dependencies:
|
||||
babel-runtime "6.x"
|
||||
css-animation "^1.3.2"
|
||||
prop-types "15.x"
|
||||
|
||||
rc-collapse@^1.7.6:
|
||||
version "1.7.6"
|
||||
resolved "https://registry.yarnpkg.com/rc-collapse/-/rc-collapse-1.7.6.tgz#64433512d921f750df61433e675bb9547ba5ef6b"
|
||||
dependencies:
|
||||
classnames "2.x"
|
||||
css-animation "1.x"
|
||||
prop-types "^15.5.6"
|
||||
rc-animate "2.x"
|
||||
|
||||
rc@^1.1.7:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95"
|
||||
@@ -3363,6 +3404,12 @@ react-ace@^5.1.2:
|
||||
opencollective "^1.0.3"
|
||||
prop-types "^15.5.8"
|
||||
|
||||
react-collapse@^4.0.3:
|
||||
version "4.0.3"
|
||||
resolved "https://registry.yarnpkg.com/react-collapse/-/react-collapse-4.0.3.tgz#b96de959ed0092a43534630b599a4753dd76d543"
|
||||
dependencies:
|
||||
prop-types "^15.5.8"
|
||||
|
||||
react-collapsible@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/react-collapsible/-/react-collapsible-2.0.0.tgz#a98113bb26ab55fc5ed95a4835c3fbf8cbf973af"
|
||||
@@ -3420,6 +3467,10 @@ react-proxy@^3.0.0-alpha.0:
|
||||
dependencies:
|
||||
lodash "^4.6.1"
|
||||
|
||||
react-responsive-accordion@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/react-responsive-accordion/-/react-responsive-accordion-1.0.0.tgz#e2c39ee13e18daa40d9d78486beccd27f4988cba"
|
||||
|
||||
react@^15.5.4, react@^15.6.1:
|
||||
version "15.6.1"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-15.6.1.tgz#baa8434ec6780bde997cdc380b79cd33b96393df"
|
||||
@@ -3506,6 +3557,10 @@ regenerator-runtime@^0.10.0:
|
||||
version "0.10.5"
|
||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
|
||||
|
||||
regenerator-runtime@^0.11.0:
|
||||
version "0.11.0"
|
||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz#7e54fe5b5ccd5d6624ea6255c3473be090b802e1"
|
||||
|
||||
regenerator-transform@0.9.11:
|
||||
version "0.9.11"
|
||||
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.9.11.tgz#3a7d067520cb7b7176769eb5ff868691befe1283"
|
||||
|
||||
Reference in new issue
Block a user