一些变动,添加了vaultwarden

main
zengwei 2 years ago
parent 1b7e1af96e
commit b20740f56a

@ -0,0 +1,14 @@
# Ignore node modules as they will be installed in the Dockerfile
node_modules/
# Ignore local configuration and cache files
.cache/
.config/
.DS_Store
# Ignore logs
*.log
# Ignore test and development files
*.md
*.test.js

@ -0,0 +1,5 @@
NEXT_PUBLIC_BASE_URL=http://localhost:3000
NEXT_PUBLIC_PAYMENT_URL=https://herowand.lemonsqueezy.com/checkout/buy/ce30521f-c7cc-44f3-9435-995d3260ba22
NEXT_PUBLIC_GA_ID=G-JKZEHMJBMH
NEXT_PUBLIC_SUPABASE_URL=https://bxkgqurwqjmvrqekcbws.supabase.co
NEXT_PUBLIC_SUPABASE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJ4a2dxdXJ3cWptdnJxZWtjYndzIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTA2NDU0MjUsImV4cCI6MjAwNjIyMTQyNX0.3nZ0yhuFjnI3yHbAL8S9UtK-Ny-6F5AylNHgo1tymTU

@ -0,0 +1,5 @@
NEXT_PUBLIC_BASE_URL=https://jsoncrack.com
NEXT_PUBLIC_PAYMENT_URL=https://herowand.lemonsqueezy.com/checkout/buy/ce30521f-c7cc-44f3-9435-995d3260ba22
NEXT_PUBLIC_GA_ID=G-JKZEHMJBMH
NEXT_PUBLIC_SUPABASE_URL=https://bxkgqurwqjmvrqekcbws.supabase.co
NEXT_PUBLIC_SUPABASE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJ4a2dxdXJ3cWptdnJxZWtjYndzIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTA2NDU0MjUsImV4cCI6MjAwNjIyMTQyNX0.3nZ0yhuFjnI3yHbAL8S9UtK-Ny-6F5AylNHgo1tymTU

@ -0,0 +1,27 @@
{
"rules": {
"@next/next/no-img-element": "off",
"unused-imports/no-unused-imports": "error",
"prettier/prettier": "error",
"space-in-parens": "error",
"no-empty": "error",
"no-multiple-empty-lines": "error",
"no-irregular-whitespace": "error",
"strict": ["error", "never"],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double", { "avoidEscape": true }],
"semi": ["error", "always"],
"prefer-const": "error",
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}
]
},
"extends": ["next/core-web-vitals", "prettier"],
"plugins": ["prettier", "unused-imports"],
"ignorePatterns": ["src/enums"]
}

@ -0,0 +1,13 @@
# These are supported funding model platforms
github: AykutSarac
patreon: # patreon name
open_collective: # opencollective name
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

@ -0,0 +1,48 @@
name: Bug report
description: Create a report to help us improve
title: "[BUG]: <Context of the issue>"
labels: bug
assignees: AykutSarac
body:
- type: textarea
id: description
attributes:
label: Issue description
description: |
Describe the issue in as much detail as possible.
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files into it.
placeholder: |
Steps to reproduce with below code sample:
1. do thing
2. click...
3. observe behavior
4. see error logs below
validations:
required: true
- type: textarea
id: media
attributes:
label: Media & Screenshots
description: Include screenshots or video of reproduction as much as possible
- type: textarea
id: os
attributes:
label: Operating system
description: Which OS does your application run on?
value: |
- OS: [e.g. iOS]:
- Browser [e.g. chrome, safari]:
- Any other details...
- type: dropdown
id: priority
attributes:
label: Priority this issue should have
description: Please be realistic. If you need to elaborate on your reasoning, please use the Issue description field above.
options:
- Low (slightly annoying)
- Medium (should be fixed soon)
- High (immediate attention needed)
validations:
required: true

@ -0,0 +1,22 @@
name: Feature request
description: Request a new feature
labels: [feature]
body:
- type: textarea
id: description
attributes:
label: Feature
description: A clear and concise description of what the problem is, or what feature you want to be implemented.
placeholder: I'm always frustrated when..., Discord has recently released..., A good addition would be...
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternative solutions or implementations
description: A clear and concise description of any alternative solutions or features you have considered.
- type: textarea
id: additional-context
attributes:
label: Other context
description: Any other context, screenshots, or file uploads that help us understand your feature request.

@ -0,0 +1,128 @@
name: Deploy Next.js site to Pages
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup Pages
uses: actions/configure-pages@v3
with:
static_site_generator: next
- name: Restore cache
uses: actions/cache@v3
with:
path: |
.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/pnpm-lock.yaml') }}-
- name: Install dependencies
run: pnpm install
- name: Build with Next.js
run: pnpm next build
- name: Upload Build Artifacts
uses: actions/upload-artifact@v2
with:
name: build-files
path: ./out/_next/static/chunks
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: './out'
# Sentry job
sentry:
needs: build
runs-on: ubuntu-latest
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_RELEASE: ${{ github.sha }}
SENTRY_SOURCEMAP_PATH: "./"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v2
with:
name: build-files
- name: Download sentry-cli
run: curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION="2.20.0" sh
- name: Create Release
run: sentry-cli releases new $SENTRY_RELEASE
- name: Inject Debug IDs to source files
run: sentry-cli sourcemaps inject $SENTRY_SOURCEMAP_PATH
- name: Upload Source Files
run: sentry-cli sourcemaps upload --validate -r=$SENTRY_RELEASE $SENTRY_SOURCEMAP_PATH
- name: Set Release Commits
run: sentry-cli releases set-commits $SENTRY_RELEASE --auto
- name: Deploy to Sentry
run: sentry-cli releases deploys $SENTRY_RELEASE new -e production
- name: Finalize Sentry Release
run: sentry-cli releases finalize $SENTRY_RELEASE
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1

@ -0,0 +1,48 @@
name: Verify Pull Request
on:
pull_request:
branches: [ "main" ]
jobs:
cache-and-install:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Lint
run: pnpm run lint
- name: Build
run: pnpm run build

@ -0,0 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel
# typescript
*.tsbuildinfo
# PWA workers
**/public/workbox-*.js
**/public/sw.js
**/public/fallback-*.js
# Sentry Auth Token
.sentryclirc
/src/migration

@ -0,0 +1,7 @@
.github
.next
node_modules/
out
public
*-lock.json
tsconfig.json

@ -0,0 +1,19 @@
{
"trailingComma": "es5",
"singleQuote": false,
"semi": true,
"printWidth": 100,
"arrowParens": "avoid",
"importOrder": [
"^(react/(.*)$)|^(react$)",
"^(next/(.*)$)|^(next$)",
"^@mantine/core",
"^@mantine",
"styled",
"<THIRD_PARTY_MODULES>",
"^src/(.*)$",
"^[./]"
],
"importOrderParserPlugins": ["typescript", "jsx", "decorators-legacy"],
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}

@ -0,0 +1,133 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
opensource@github.com.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of
actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the
community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

@ -0,0 +1,62 @@
# Welcome to the JSON Crack Contributing Guide <!-- omit in toc -->
Thank you for investing your time in contributing to our project! Any contribution you make will be reflected at [jsoncrack.com](https://jsoncrack.com).
Read our [Code of Conduct](./CODE_OF_CONDUCT.md) to keep our community approachable and respectable.
In this guide you will get an overview of the contribution workflow from opening an issue, creating a PR, reviewing, and merging the PR.
## Getting Started
JSON Crack is built with React, Reaflow for visualization, Mantine UI for components, Zustand for state management, and Supabase for backend integration. If you are not familiar with these technologies, we recommend you to read their documentation to get started. You can find the links to the respective documentations below:
* [React](https://reactjs.org/docs/getting-started.html)
* [Reaflow](https://github.com/reaviz/reaflow)
* [Mantine UI](https://mantine.dev/)
* [Zustand](https://github.com/pmndrs/zustand)
Once you are familiar with these technologies, you can clone the JSON Crack repository by running the following command:
```bash
git clone https://github.com/AykutSarac/jsoncrack.com.git
```
After cloning the repository, you can install the required dependencies by running the following command:
```bash
pnpm install
```
To run the development server, you can run the following command:
```bash
pnpm dev
```
## Contributing Guidelines
Before submitting a pull request, please make sure to follow these guidelines:
### 1. Performance
Performance is an important criteria for JSON Crack. Any new contributions should not affect the re-rendering of the application. Therefore, when making changes to the code, please keep performance in mind.
If you're having trouble with re-rendering issues in React, you can use the React Devtools Profiler to debug it. You can also check out this up-to-date guide on debugging re-renders with React Devtools to learn more.
### 2. Code Style
We follow the [Google TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html) for our code. Please make sure to follow this guide when writing new code or modifying existing code.
### 3. Testing
While we do not currently have a comprehensive testing suite in place, we encourage contributors to thoroughly test their changes and ensure that they do not break any existing functionality. Please include a description of how you tested your changes in your pull request, so that we can review them more effectively.
### 4. Commit Messages
Please use descriptive commit messages that explain the changes you have made. This will help us understand your changes and make it easier to review your pull request.
### 5. Pull Requests
Please create a new branch for your changes and submit a pull request to the main branch. Please provide a detailed explanation of the changes you have made and any necessary context in the pull request description.
## Conclusion
We appreciate any contributions to JSON Crack, big or small. If you have any questions or need any help, please do not hesitate to reach out to us. Thank you for contributing!
### Your PR is merged!
Congratulations :tada::tada: The JSON Crack team thanks you :sparkles:.
Once your PR is merged, your contributions will become part of the next JSON Crack release, and will be visible in the [JSON Crack app](https://jsoncrack.com).

@ -0,0 +1,17 @@
# Builder
FROM node:18-alpine as builder
RUN corepack enable
WORKDIR /src
# Cache dependencies first
COPY package.json pnpm-lock.yaml ./
RUN pnpm install
# Copy other files and build
COPY . /src/
RUN pnpm build
# App
FROM nginxinc/nginx-unprivileged
COPY --chown=nginx:nginx --from=builder /src/out /app
COPY default.conf /etc/nginx/conf.d/default.conf

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
JSON Crack
Copyright (C) 2023 Aykut Saraç
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
JSON Crack Copyright (C) 2023 Aykut Saraç
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

@ -0,0 +1,92 @@
<a href="https://jsoncrack.com/" target="_blank" rel="noopener">
<img alt="JSON Crack" w src="https://user-images.githubusercontent.com/47941171/236689277-0fa9e50a-3106-4854-a2d4-bb5722f16d48.png" />
</a>
<h4 align="center">
<a href="https://jsoncrack.com">JSON Crack</a> |
<a href="https://marketplace.visualstudio.com/items?itemName=AykutSarac.jsoncrack-vscode">VS Code Extension</a> |
<a href="https://jsoncrack.com/docs">Documentation</a>
</h4>
<div align="center">
<h2>
An innovative, open source data visualization app.
<br />
Brings data to life through captivating graphs.
</h2>
</div>
<br />
<p align="center">
<a href="https://www.producthunt.com/posts/json-crack?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-json&#0045;crack" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=332281&theme=light" alt="JSON&#0032;Crack - Simple&#0032;visualization&#0032;tool&#0032;for&#0032;your&#0032;JSON&#0032;data&#0046; | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
<a href="https://discord.gg/yVyTtCRueq" target="_blank"><img src="https://user-images.githubusercontent.com/47941171/206397224-94da03a4-59d0-48cd-aafc-512624a768d6.png" "style=" height: 54px;" height="54" /></a>
</br>
<a href="https://github.com/sponsors/AykutSarac" target="_blank"><img src="https://user-images.githubusercontent.com/47941171/206397875-a4e73f02-5d8f-4db0-902b-9a4bc2b22d90.png" "style=" height: 54px;" height="54" /></a>
</p>
<p align="center">
<img src="./public/assets/jsoncrack-screenshot.jpeg" alt="Product Preview" />
</p>
# JSON Crack (jsoncrack.com)
JSON Crack is a free, open-source data visualization app capable of visualizing data formats such as JSON, YAML, XML, CSV and more, into interactive graphs. With its intuitive and user-friendly interface, JSON Crack makes it easy to explore, analyze, and understand even the most complex data structures. Whether you're a developer working on a large-scale project or a data enthusiast looking to uncover hidden insights, JSON Crack has the tools and features you need to unlock the full potential of your data.
## Features
- 💯 Free & open-source.
- 🌓 Dark mode.
- 🖼️ Export to PNG, SVG, JPEG & clipboard.
- 🔍 Zoom and panning support with touch gestures.
- 🛠 Wide range of tools - search, json path, node contents, expand/toggle, auto format...
- 🔗 Share/Import/Fetch
- 🧱 Embeddable iframe widgets.
## Contributing
- Missing something or found a bug? [Report here](https://github.com/AykutSarac/jsoncrack.com/issues).
- Want to contribute? Check out our [contribution guide](https://github.com/AykutSarac/jsoncrack.com/blob/main/CONTRIBUTING.md) or let us know on [Discord](https://discord.gg/yVyTtCRueq).
## Sponsors & support
If you like the project, you can become a sponsor at [GitHub Sponsors](https://github.com/sponsors/AykutSarac) or use [Premium](https://jsoncrack.com/pricing).
## Running Locally
### Local
After cloning the repository, run the following commands:
```console
# Install the packages
pnpm install
# Start development server
# Then the development server will run at http://localhost:3000
pnpm dev
```
### Docker
🐳 A [`Dockerfile`](Dockerfile) is provided in the root of the repository.
If you want to run JSON Crack locally:
```console
# Build a Docker image with:
docker build -t jsoncrack .
# Run locally with `docker run`
docker run -p 8888:8080 jsoncrack
# Run locally with `docker-compose`
docker-compose up -d
# Go to http://localhost:8888
```
## Thank you for supporting JSON Crack
Last but not least, we're thankful to these companies for offering their services for free:
<a href="https://sentry.io">
<img height="30" src="https://user-images.githubusercontent.com/47941171/236691121-717c7975-809f-4508-b58e-5ada2f7e8c7c.png" alt="Sentry" />
</a>

@ -0,0 +1,38 @@
server {
listen 8080;
root /app;
include /etc/nginx/mime.types;
location /editor {
try_files $uri /editor.html;
}
location /widget {
try_files $uri /widget.html;
}
location /embed {
try_files $uri /embed.html;
}
location /docs {
try_files $uri /docs.html;
}
location /oss {
try_files $uri /oss.html;
}
location /pricing {
try_files $uri /pricing.html;
}
location /forgot-password {
try_files $uri /forgot-password.html;
}
location /sign-in {
try_files $uri /sign-in.html;
}
}

@ -0,0 +1,10 @@
version: '3.9'
services:
jsoncrack:
image: jsoncrack
container_name: jsoncrack
build:
context: .
dockerfile: Dockerfile
ports:
- "8888:8080"

@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

@ -0,0 +1,46 @@
const million = require("million/compiler");
const { withSentryConfig } = require("@sentry/nextjs");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
/**
* @type {import('next').NextConfig}
*/
const config = {
output: "export",
reactStrictMode: false,
productionBrowserSourceMaps: true,
compiler: {
styledComponents: true,
},
webpack: config => {
config.resolve.fallback = { fs: false };
config.output.webassemblyModuleFilename = "static/wasm/[modulehash].wasm";
config.experiments = { asyncWebAssembly: true };
return config;
},
};
const bundleAnalyzerConfig = withBundleAnalyzer(config);
const sentryConfig = withSentryConfig(
config,
{
silent: true,
org: "aykut-sarac",
project: "json-crack",
},
{
widenClientFileUpload: true,
hideSourceMaps: true,
disableLogger: true,
disableServerWebpackPlugin: true,
}
);
module.exports = million.next(
process.env.ANALYZE === "true" ? bundleAnalyzerConfig : sentryConfig,
{ auto: true }
);

@ -0,0 +1,87 @@
{
"name": "json-crack",
"private": true,
"version": "v3.2.0",
"license": "GPL-3.0",
"author": "https://github.com/AykutSarac",
"homepage": "https://jsoncrack.com",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "tsc --project tsconfig.json && eslint src && prettier --check src",
"lint:fix": "eslint --fix src & prettier --write src",
"analyze": "ANALYZE=true npm run build"
},
"dependencies": {
"@mantine/code-highlight": "^7.4.2",
"@mantine/core": "^7.4.2",
"@mantine/hooks": "^7.4.2",
"@monaco-editor/react": "^4.6.0",
"@sentry/nextjs": "^7.94.1",
"@supabase/auth-helpers-nextjs": "^0.8.7",
"@supabase/auth-helpers-react": "^0.4.2",
"@supabase/supabase-js": "^2.39.3",
"@tanstack/react-query": "^4.36.1",
"allotment": "^1.20.0",
"axios": "^1.6.5",
"dayjs": "^1.11.10",
"gofmt.js": "^0.0.2",
"html-to-image": "^1.11.11",
"jq-in-the-browser": "^0.7.2",
"jq-web": "^0.5.1",
"js-yaml": "^4.1.0",
"json-2-csv": "^5.0.1",
"json_typegen_wasm": "^0.7.0",
"jsonc-parser": "^3.2.0",
"jsonwebtoken": "^9.0.2",
"jxon": "^2.0.0-beta.5",
"lodash.debounce": "^4.0.8",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
"lodash.unset": "^4.5.2",
"lodash.update": "^4.10.2",
"maketypes": "^1.1.2",
"million": "^2.6.4",
"next": "14.1.0",
"pako": "^2.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-ga4": "^2.1.0",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.0.1",
"react-json-tree": "^0.18.0",
"react-linkify-it": "^1.0.8",
"react-simple-typewriter": "^5.0.1",
"react-zoomable-ui": "^0.11.0",
"reaflow": "5.2.8",
"styled-components": "^6.1.8",
"toml": "^3.0.0",
"use-long-press": "^3.2.0",
"zustand": "^4.5.0"
},
"devDependencies": {
"@next/bundle-analyzer": "^14.1.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/js-yaml": "^4.0.9",
"@types/jsonwebtoken": "^9.0.5",
"@types/jxon": "^2.0.5",
"@types/lodash.debounce": "^4.0.9",
"@types/lodash.get": "^4.4.9",
"@types/lodash.set": "^4.3.9",
"@types/lodash.unset": "^4.5.9",
"@types/lodash.update": "^4.10.9",
"@types/node": "^20.11.5",
"@types/pako": "^2.0.3",
"@types/react": "18.2.48",
"@types/react-dom": "^18.2.18",
"eslint": "8.56.0",
"eslint-config-next": "14.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unused-imports": "^3.0.0",
"prettier": "^3.2.4",
"ts-node": "^10.9.2",
"typescript": "5.3.3"
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

@ -0,0 +1,10 @@
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="shadow" x="0" y="0" width="150%" height="150%">
<feOffset result="offOut" in="SourceAlpha" dx="1" dy="1" />
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="1" />
<feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
</filter>
</defs>
<path d="M5.65376 12.3673H5.46026L5.31717 12.4976L0.500002 16.8829L0.500002 1.19841L11.7841 12.3673H5.65376Z" fill="#000000" stroke="#E2E2E2" stroke-width="1" filter="url(#shadow)" />
</svg>

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@ -0,0 +1,229 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg id="ab01b6ca-fda4-4c55-a447-43113c79b51e" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="865.76" height="682.89" viewBox="0 0 865.76 682.89">
<defs>
<style xmlns="http://www.w3.org/1999/xhtml">*, ::after, ::before { box-sizing: border-box; }
img, svg { vertical-align: middle; }
</style>
<style xmlns="http://www.w3.org/1999/xhtml">*, body, html { -webkit-font-smoothing: antialiased; }
img, svg { max-width: 100%; }
</style>
</defs>
<g id="aacbc6a0-2124-4f6c-b34d-11346ed3b501" data-name="freepik--background-simple--inject-2">
<path d="M732.32,286.81s19.57-46.27,1.78-119.22S634.47,91.07,565,82.18,490.32,28.8,415.6,23.46s-138.76,40.93-151.24,89,1.78,72.95-51.58,110.32-105,69.39-83.65,138.79,74.73,69.39,83.63,115.65,71.17,103.15,144.13,126.34,122.77-41,190.38-37.37S679,564.37,711,512.78s-14.24-101.43-5.34-137S725.29,320.6,732.32,286.81Z" fill="#014D4E" data-primary="true"/>
<path d="M732.32,286.81s19.57-46.27,1.78-119.22S634.47,91.07,565,82.18,490.32,28.8,415.6,23.46s-138.76,40.93-151.24,89,1.78,72.95-51.58,110.32-105,69.39-83.65,138.79,74.73,69.39,83.63,115.65,71.17,103.15,144.13,126.34,122.77-41,190.38-37.37S679,564.37,711,512.78s-14.24-101.43-5.34-137S725.29,320.6,732.32,286.81Z" fill="#fff" opacity="0.7" style="isolation:isolate"/>
</g>
<g id="a4889a5a-1504-4c3e-a144-1f84ee95c415" data-name="freepik--Mountains--inject-2">
<path d="M711,512.78c14.33-23.14,13-45.85,7.89-67.2-2.62-.2-5.53-.34-8.85-.34-21.25,0-26.25,36.26-38.68,37.51S640.07,464,618.82,464s-48.71,86.25-58.74,92.51-17.51-5-38.76-13.75-48.71,18.75-73.75,27.49-52.5-6.24-61.25-22.49S357.56,484,340.07,485.24s-35,13.75-45,2.51S251.31,385.24,238.82,384c-8.16-.82-45.56,21.78-70.59,37.58,19.78,17.77,39.44,29.23,44.53,55.62,8.89,46.26,71.17,103.15,144.13,126.34s122.77-41,190.38-37.37S679,564.37,711,512.78Z" fill="#014D4E" data-primary="true"/>
<path d="M711,512.78c14.33-23.14,13-45.85,7.89-67.2-2.62-.2-5.53-.34-8.85-.34-21.25,0-26.25,36.26-38.68,37.51S640.07,464,618.82,464s-48.71,86.25-58.74,92.51-17.51-5-38.76-13.75-48.71,18.75-73.75,27.49-52.5-6.24-61.25-22.49S357.56,484,340.07,485.24s-35,13.75-45,2.51S251.31,385.24,238.82,384c-8.16-.82-45.56,21.78-70.59,37.58,19.78,17.77,39.44,29.23,44.53,55.62,8.89,46.26,71.17,103.15,144.13,126.34s122.77-41,190.38-37.37S679,564.37,711,512.78Z" fill="#fff" opacity="0.5" style="isolation:isolate"/>
</g>
<g id="b373a570-594e-4f19-bd18-202c80330dc7" data-name="freepik--Stars--inject-2">
<path d="M661.74,264.26a6.53,6.53,0,1,0,6.52,6.54h0A6.52,6.52,0,0,0,661.74,264.26Z" fill="#014D4E" data-primary="true"/>
<path d="M606.89,271.38a3.27,3.27,0,1,0,3.25,3.28v0A3.26,3.26,0,0,0,606.89,271.38Z" fill="#014D4E" data-primary="true"/>
<path d="M673.91,211.17a3.27,3.27,0,1,0,3.25,3.28h0A3.27,3.27,0,0,0,673.91,211.17Z" fill="#014D4E" data-primary="true"/>
<path d="M713.35,266.05a3.27,3.27,0,1,0,3.25,3.28v0A3.26,3.26,0,0,0,713.35,266.05Z" fill="#014D4E" data-primary="true"/>
<path d="M614.32,344.57a6.52,6.52,0,1,0,9,2.25,6.52,6.52,0,0,0-9-2.25Z" fill="#014D4E" data-primary="true"/>
<path d="M584.51,302.29a3.25,3.25,0,1,0,4.47,1.12A3.26,3.26,0,0,0,584.51,302.29Z" fill="#014D4E" data-primary="true"/>
<path d="M670.58,328.86a3.25,3.25,0,1,0,4.47,1.12,3.25,3.25,0,0,0-4.47-1.12Z" fill="#014D4E" data-primary="true"/>
<path d="M643.79,390.88a3.27,3.27,0,1,0,4.48,1.13h0A3.27,3.27,0,0,0,643.79,390.88Z" fill="#014D4E" data-primary="true"/>
<path d="M243.6,284.43a6.52,6.52,0,1,0,9,2.25A6.52,6.52,0,0,0,243.6,284.43Z" fill="#014D4E" data-primary="true"/>
<path d="M213.8,242.13a3.27,3.27,0,1,0,4.48,1.15h0A3.28,3.28,0,0,0,213.8,242.13Z" fill="#014D4E" data-primary="true"/>
<path d="M299.87,268.7a3.27,3.27,0,1,0,4.47,1.14h0A3.26,3.26,0,0,0,299.87,268.7Z" fill="#014D4E" data-primary="true"/>
<path d="M273.06,330.73a3.25,3.25,0,1,0,4.48,1.12,3.25,3.25,0,0,0-4.48-1.12Z" fill="#014D4E" data-primary="true"/>
<path d="M182.8,344.37a6.52,6.52,0,1,0,8.95,2.25,6.53,6.53,0,0,0-8.95-2.25Z" fill="#014D4E" data-primary="true"/>
<path d="M153,302.09a3.26,3.26,0,1,0,4.47,1.12,3.27,3.27,0,0,0-4.47-1.12Z" fill="#014D4E" data-primary="true"/>
<path d="M239.06,328.66a3.25,3.25,0,1,0,4.48,1.11,3.26,3.26,0,0,0-4.48-1.11Z" fill="#014D4E" data-primary="true"/>
<path d="M212.27,390.62a3.26,3.26,0,1,0,4.48,1.13h0A3.27,3.27,0,0,0,212.27,390.62Z" fill="#014D4E" data-primary="true"/>
<path d="M330.41,52.07a6.52,6.52,0,1,0,8.72,3h0A6.53,6.53,0,0,0,330.41,52.07Z" fill="#014D4E" data-primary="true"/>
<path d="M379.45,27.47A3.25,3.25,0,1,0,383.79,29a.36.36,0,0,0,0-.09A3.26,3.26,0,0,0,379.45,27.47Z" fill="#014D4E" data-primary="true"/>
<path d="M345.61,96.73a3.16,3.16,0,1,0,.11-.06Z" fill="#014D4E" data-primary="true"/>
<path d="M286.11,79a3.27,3.27,0,1,0,4.38,1.46v0A3.27,3.27,0,0,0,286.11,79Z" fill="#014D4E" data-primary="true"/>
<path d="M625.1,135.32a6.52,6.52,0,1,0,2.47,8.89v0A6.53,6.53,0,0,0,625.1,135.32Z" fill="#014D4E" data-primary="true"/>
<path d="M573.83,114.55a3.25,3.25,0,1,0,1.23,4.44,3.25,3.25,0,0,0-1.23-4.44Z" fill="#014D4E" data-primary="true"/>
<path d="M650.07,103.16a3.25,3.25,0,1,0,1.23,4.44,3.25,3.25,0,0,0-1.23-4.44Z" fill="#014D4E" data-primary="true"/>
<path d="M665.94,167.93a3.27,3.27,0,1,0-1.22-4.45h0A3.29,3.29,0,0,0,665.94,167.93Z" fill="#014D4E" data-primary="true"/>
<g opacity="0.3">
<path d="M661.74,264.26a6.53,6.53,0,1,0,6.52,6.54h0A6.52,6.52,0,0,0,661.74,264.26Z" fill="#fff"/>
<path d="M606.89,271.38a3.27,3.27,0,1,0,3.25,3.28v0A3.26,3.26,0,0,0,606.89,271.38Z" fill="#fff"/>
<path d="M673.91,211.17a3.27,3.27,0,1,0,3.25,3.28h0A3.27,3.27,0,0,0,673.91,211.17Z" fill="#fff"/>
<path d="M713.35,266.05a3.27,3.27,0,1,0,3.25,3.28v0A3.26,3.26,0,0,0,713.35,266.05Z" fill="#fff"/>
<path d="M614.32,344.57a6.52,6.52,0,1,0,9,2.25,6.52,6.52,0,0,0-9-2.25Z" fill="#fff"/>
<path d="M584.51,302.29a3.25,3.25,0,1,0,4.47,1.12A3.26,3.26,0,0,0,584.51,302.29Z" fill="#fff"/>
<path d="M670.58,328.86a3.25,3.25,0,1,0,4.47,1.12,3.25,3.25,0,0,0-4.47-1.12Z" fill="#fff"/>
<path d="M643.79,390.88a3.27,3.27,0,1,0,4.48,1.13h0A3.27,3.27,0,0,0,643.79,390.88Z" fill="#fff"/>
<path d="M243.6,284.43a6.52,6.52,0,1,0,9,2.25A6.52,6.52,0,0,0,243.6,284.43Z" fill="#fff"/>
<path d="M213.8,242.13a3.27,3.27,0,1,0,4.48,1.15h0A3.28,3.28,0,0,0,213.8,242.13Z" fill="#fff"/>
<path d="M299.87,268.7a3.27,3.27,0,1,0,4.47,1.14h0A3.26,3.26,0,0,0,299.87,268.7Z" fill="#fff"/>
<path d="M273.06,330.73a3.25,3.25,0,1,0,4.48,1.12,3.25,3.25,0,0,0-4.48-1.12Z" fill="#fff"/>
<path d="M182.8,344.37a6.52,6.52,0,1,0,8.95,2.25,6.53,6.53,0,0,0-8.95-2.25Z" fill="#fff"/>
<path d="M153,302.09a3.26,3.26,0,1,0,4.47,1.12,3.27,3.27,0,0,0-4.47-1.12Z" fill="#fff"/>
<path d="M239.06,328.66a3.25,3.25,0,1,0,4.48,1.11,3.26,3.26,0,0,0-4.48-1.11Z" fill="#fff"/>
<path d="M212.27,390.62a3.26,3.26,0,1,0,4.48,1.13h0A3.27,3.27,0,0,0,212.27,390.62Z" fill="#fff"/>
<path d="M330.41,52.07a6.52,6.52,0,1,0,8.72,3h0A6.53,6.53,0,0,0,330.41,52.07Z" fill="#fff"/>
<path d="M379.45,27.47A3.25,3.25,0,1,0,383.79,29a.36.36,0,0,0,0-.09A3.26,3.26,0,0,0,379.45,27.47Z" fill="#fff"/>
<path d="M345.61,96.73a3.16,3.16,0,1,0,.11-.06Z" fill="#fff"/>
<path d="M286.11,79a3.27,3.27,0,1,0,4.38,1.46v0A3.27,3.27,0,0,0,286.11,79Z" fill="#fff"/>
<path d="M625.1,135.32a6.52,6.52,0,1,0,2.47,8.89v0A6.53,6.53,0,0,0,625.1,135.32Z" fill="#fff"/>
<path d="M573.83,114.55a3.25,3.25,0,1,0,1.23,4.44,3.25,3.25,0,0,0-1.23-4.44Z" fill="#fff"/>
<path d="M650.07,103.16a3.25,3.25,0,1,0,1.23,4.44,3.25,3.25,0,0,0-1.23-4.44Z" fill="#fff"/>
<path d="M665.94,167.93a3.27,3.27,0,1,0-1.22-4.45h0A3.29,3.29,0,0,0,665.94,167.93Z" fill="#fff"/>
</g>
</g>
<ellipse cx="441.92" cy="141.46" rx="82.81" ry="64.64" fill="#2f2e41" data-secondary="true"/>
<path d="M500.35,100.85c12.32,10.79,19.81,25,19.81,40.61,0,33.72-35,61.06-78.21,61.06s-78.21-27.34-78.21-61.06c0-21.08,13.68-39.65,34.48-50.62" fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.24"/>
<path d="M408,86.42a94.3,94.3,0,0,1,19.5-5" fill="#263238" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.24"/>
<ellipse cx="441.92" cy="156.71" rx="133.93" ry="44.44" fill="#014D4E" data-primary="true"/>
<ellipse cx="441.92" cy="172.73" rx="190.83" ry="44.44" fill="#014D4E" data-primary="true"/>
<ellipse cx="441.92" cy="172.73" rx="190.83" ry="44.44" opacity="0.2"/>
<ellipse cx="441.92" cy="184.58" rx="220.45" ry="44.44" fill="#2f2e41" data-secondary="true"/>
<ellipse cx="442.04" cy="184.57" rx="165.11" ry="31.06" fill="#014D4E" data-primary="true"/>
<ellipse cx="441.92" cy="184.58" rx="73.48" ry="14.81" fill="#263238" stroke="#263238" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.24"/>
<ellipse cx="442.04" cy="151.03" rx="17.51" ry="3.84" fill="#fff"/>
<path d="M279.81,184.31c0,1.43-5.36,2.64-12,2.64s-12-1.19-12-2.64,5.37-2.64,12-2.64S279.81,182.88,279.81,184.31Z" fill="#fff"/>
<path d="M631.73,184.31c0,1.43-5.37,2.64-12,2.64s-11.94-1.21-11.94-2.64,5.36-2.64,12-2.64S631.73,182.88,631.73,184.31Z" fill="#fff"/>
<ellipse cx="550.15" cy="163.31" rx="16.36" ry="3.6" fill="#fff"/>
<ellipse cx="346.72" cy="163.31" rx="16.36" ry="3.6" fill="#fff"/>
<ellipse cx="550.15" cy="205.4" rx="11.98" ry="2.64" fill="#fff"/>
<ellipse cx="346.72" cy="205.4" rx="11.98" ry="2.64" fill="#fff"/>
<path d="M305.25,397.67l-.15,0a.54.54,0,0,1-.37-.67l4-14a.55.55,0,0,1,.68-.37.54.54,0,0,1,.37.67l-4.06,14A.53.53,0,0,1,305.25,397.67Z" fill="#2f2e41" data-secondary="true"/>
<path d="M313.51,369.3a.41.41,0,0,1-.16,0,.54.54,0,0,1-.37-.67l32-110a.54.54,0,1,1,1,.3L314,368.91A.54.54,0,0,1,313.51,369.3Z" fill="#2f2e41" data-secondary="true"/>
<path d="M349,247.28l-.15,0a.55.55,0,0,1-.37-.68L364.56,191a.53.53,0,0,1,.67-.37.55.55,0,0,1,.38.67l-16.14,55.57A.55.55,0,0,1,349,247.28Z" fill="#2f2e41" data-secondary="true"/>
<path d="M584.64,390.55a.55.55,0,0,1-.52-.37L514.89,184.76a.54.54,0,0,1,1-.35l69.23,205.42a.54.54,0,0,1-.34.69Z" fill="#2f2e41" data-secondary="true"/>
<path d="M382.35,293h-.1a.55.55,0,0,1-.44-.63l16.11-89.75a.54.54,0,0,1,1.07.19l-16.11,89.75A.54.54,0,0,1,382.35,293Z" fill="#2f2e41" data-secondary="true"/>
<path d="M523.87,363.16a.54.54,0,0,1-.53-.45L494.57,202.77a.54.54,0,0,1,.44-.63.54.54,0,0,1,.63.44l28.77,159.94a.55.55,0,0,1-.44.63Z" fill="#2f2e41" data-secondary="true"/>
<line x1="441.92" y1="391.38" x2="441.92" y2="409.79" fill="none" stroke="#263238" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.24"/>
<path d="M441.92,169.77a309.57,309.57,0,0,0-42.05,2.66c4.05,8.4,21.78,14.73,43,14.73s38.6-6.2,42.88-14.47A302.76,302.76,0,0,0,441.92,169.77Z" fill="#fff" stroke="#263238" stroke-miterlimit="10" stroke-width="1.24"/>
<path d="M448,618.07l-7.66,8.64s-3,4,2,9.59L458,651.7s12.62,12.12,18.68,6.82c0,0,3-1.52-2.77-9.6,0,0-10.22-9.17-6.5-19.7C467.44,629.22,460.49,626.6,448,618.07Z" fill="#014D4E" data-primary="true"/>
<path d="M411.28,602.79s-11.3,8.78-8,14.08l9.34,9.34a34,34,0,0,0,11.11,9.84s9.08,6.56,11.86,7.32c0,0,4-.23,2.27-4.4,0,0-9.95-20.16-8.55-26.21C429.29,612.76,421.57,611.69,411.28,602.79Z" fill="#014D4E" data-primary="true"/>
<path d="M442.09,332.82a10.72,10.72,0,0,0,1,7.14l2.95,5.72-5.83,8.42-20.54,4.41-1.6-6.55,5.6-16.27,15.74-2.87Z" fill="#f9b499"/>
<path d="M442.09,332.82a7.52,7.52,0,0,1-4.79,2.87s1.92,3.22,5.24,3.11C442.54,338.8,441.22,335.22,442.09,332.82Z" fill="#f7a48b"/>
<path d="M424.71,416.6c-1.32.2-4.39,6.69-7.83,15.11-6.57,16-14.53,39.06-14.53,39.06-2.11,5.15-11.46,0-11.46,0-3-.47-2.81-1.87-2.81-1.87l4-14.5c4.91-23.16,8.65-31.34,8.65-31.34,2.57-5.62,4.92-21.76,4.92-21.76-.1-3.19.07-7.37.31-11.24.34-5.78.85-10.85.85-10.85l.14,1.16a18.23,18.23,0,0,0,.73,3S417.68,408.76,424.71,416.6Z" fill="#014D4E" data-primary="true"/>
<path d="M390.89,470.77s-5.14,8.65-1.4,16.37c0,0,2.85,8.44,10.44,7a1.42,1.42,0,0,0,.49-2.59,15.68,15.68,0,0,0-2.75-1.34,4.83,4.83,0,0,1-1.78-4.82.81.81,0,0,1,1.13-.57,2.13,2.13,0,0,0,2.23-.33.87.87,0,0,0,.23-1.25,6.34,6.34,0,0,1-1.34-5l.24-5.14S393.7,472.64,390.89,470.77Z" fill="#f9b499"/>
<path d="M442,452.86a221,221,0,0,0,2.77,31.62s-2.12,30.88-2.77,37.74c0,0-3.15,3.12-2.84,10,0,0-14.18,11.16-20.58,51a6.47,6.47,0,0,1-1.19,2.86,8.73,8.73,0,0,0-1.56,4.27,3.13,3.13,0,0,1-1,2c-.45.38-.91,1.43-1,4.11a9.69,9.69,0,0,1-2.59,6.34h0s9.81,9,16.82,9.71c0,0,3.83,2.68,2.59-5.78,0,0,4.33-3.93,1-10.74,0,0-.21-3.1,2.48-4.13,0,0,2.61-.75,3.22-9.88a12.2,12.2,0,0,1,.59-3.05,181.91,181.91,0,0,1,8.11-20.57,37.34,37.34,0,0,1,9.12-12c2.91-2.51,7.59-8.29,9.51-20.4,0,0,3.72,9.5-3.92,27.87A154.37,154.37,0,0,0,453,599.93a10.82,10.82,0,0,1-1.35,5.16c-1.09,2-2.3,5.06-1.23,7.68,0,0,2.38.76-2.37,5.3,0,0,11.36,8,19.41,11.15,0,0,2.06,3.1,1.24-4.33,0,0,.2-5,2.47-6.2,0,0,3.51-4.54,0-10.53,0,0-1.21-4.95,1.56-7.64,0,0,1.52-.18,1.56-5.21a6.28,6.28,0,0,1,.44-2.31c1.86-4.58,8.65-22,8.83-32.74,0,0,2.89-.62,1.65-5,0,0,3.51-2.69,3.51-9.71,0,0,2.37-5.16,2.94-19.4,0,0,5.26-10.13,10.24-43.67,0,0,2.58-19.84-2.41-37.64l-5.81-7.47L450.4,450.63l-6.29-4.13Z" fill="#2f2e41" data-secondary="true"/>
<path d="M437.3,335.69l-13.75-.83-6.77-.4s-8.57-15.58-7.76-15.84,5.4-3.24,5.4-3.24.66-.12,1.63-.25c1.94-.24,5.16-.48,7.11.25,0,0,4-3.43,6.67,2.17,0,0,11.2,2.93,13.07,9.07C442.9,326.62,444.77,334.62,437.3,335.69Z" fill="#f9b499"/>
<path d="M431.7,340a7.87,7.87,0,0,1,1.22,3.94,2.47,2.47,0,0,0,2.38,2.32,32.39,32.39,0,0,0,6-.55l-13.58,10.2-6.66-.31s-.77-8.37,0-8.52,5.62-9.42,5.62-9.42S427.75,339.69,431.7,340Z" fill="#f7a48b"/>
<path d="M424.71,416.6c-1.32.2-4.39,6.69-7.83,15.11-2.16-2.71-6.67-10-5.6-22.68,0,0,.41-12.48-5.34-18.94v0c.34-5.78.85-10.85.85-10.85l.14,1.16a18.23,18.23,0,0,0,.73,3S417.68,408.76,424.71,416.6Z" opacity="0.3"/>
<path d="M456.91,459.58a12,12,0,0,0-1.54,8,13,13,0,0,0,4.06,7.05c1,.95,2.15,1.7,3.21,2.72a10.58,10.58,0,0,1,2.41,3.57,10.15,10.15,0,0,1,.76,4.24,16.34,16.34,0,0,1-.62,4.24c-1.53,5.35-1.44,11.06-.7,16.57.11.68.21,1.38.34,2.06l.39,2.07a8.46,8.46,0,0,1-.4,4.24,12.89,12.89,0,0,0,.14,8.21,12.76,12.76,0,0,1-.48-8.3,8.18,8.18,0,0,0,.29-4.07l-.44-2c-.14-.69-.26-1.39-.39-2.08a47.61,47.61,0,0,1-.61-8.44,33.63,33.63,0,0,1,1.16-8.4,15.62,15.62,0,0,0,.63-4.06,9.32,9.32,0,0,0-.68-4,10,10,0,0,0-2.24-3.38c-1-.93-2.15-1.77-3.16-2.77a13.52,13.52,0,0,1-4-7.38A12,12,0,0,1,456.91,459.58Z" opacity="0.3"/>
<path d="M496.4,446.63c-14.61,5.14-54.37,6.23-54.37,6.23-1.8-9.49-1.43-15.71-.85-19.15a3,3,0,0,0-2.3-3.36c-7.33-1.73-14.17-13.75-14.17-13.75-7-7.84-17-33.27-17-33.27a17.31,17.31,0,0,1-.74-3c-1.87-11.82,9.93-19.22,9.93-19.22-.8-2.17,1.63-4.33,1.63-4.33,2.1-1.11,4.16-2.08,5.86-2.84a42,42,0,0,0,7-4.08c6.66-4.65,12.25-4.45,12.25-4.45,1.9-1.62,6.75,4.06,6.75,4.06a26.25,26.25,0,0,1,14.08,7.31c13.8,15.15,18.4,36.52,18.4,36.52,9.19,16.77,18.12,43.55,18.12,43.55C504.52,443.93,496.4,446.63,496.4,446.63Z" fill="#014D4E" data-primary="true"/>
<path d="M466.65,472.49s1.35,12.29,8.92,16.35a22.62,22.62,0,0,0,12,4.78,3.79,3.79,0,0,0,3.93-2.45,3.57,3.57,0,0,0-1.16-3.84s-9.21-7.25-9.24-15.07a.42.42,0,0,1,.81-.16c1.24,3.35,4.23,10.14,8,9.86,0,0,2.48-.36.93-3,0,0-3.25-3.87-3.72-7.59,0,0-1.37-5.57-5.8-8.51C481.25,462.87,469.78,461.21,466.65,472.49Z" fill="#f9b499"/>
<path d="M489,493.46a23.68,23.68,0,0,1-4-2.45,28.5,28.5,0,0,1-3.55-3.13c-.56-.56-1.07-1.17-1.59-1.76s-1-1.23-1.4-1.91a22.14,22.14,0,0,1-2.25-4.14c.46.63.83,1.32,1.31,1.94l.67.95c.23.32.48.62.72.92a40.77,40.77,0,0,0,3.06,3.5,44.38,44.38,0,0,0,3.38,3.19c.58.51,1.19,1,1.81,1.48S488.38,493,489,493.46Z" fill="#f7a48b"/>
<path d="M471.74,451s11.44-1,17.28-2.41c0,0-14.68-31.27-16.44-49.54L459,409.92Z" opacity="0.2"/>
<path d="M426.09,332.76l-2.54,2.1-6.77-.4s-8.57-15.58-7.76-15.84,5.4-3.24,5.4-3.24.66-.12,1.63-.25c0,0,1.9,3.88,2,6C418.09,321.16,428.88,317.44,426.09,332.76Z" fill="#f7a48b"/>
<path d="M403.49,315.2c-3.31,4.85-13.15,21.44-2.74,34.1,0,0,8.54,8.11,17.74,7.52l5.86-2.84,5.29-8.19a3.71,3.71,0,0,0-.22-4.33c-1.86-2.29-4.38-6.07-3.33-8.71,0,0,1.34-14.67-9.6-9.6,0,0-1.84-16.34-10-11A10.78,10.78,0,0,0,403.49,315.2Z" fill="#2f2e41" data-secondary="true"/>
<ellipse cx="431.04" cy="335.69" rx="5.6" ry="4.27" fill="#f9b499"/>
<ellipse cx="431.04" cy="335.69" rx="1.94" ry="1.39" fill="#f7a48b"/>
<path d="M466.65,472.49c.84-2.95,4-10.27,14.6-9.62a138.92,138.92,0,0,1-7.44-30.57s-1.21-25.63-1.48-45.45c0,0,2.3-24.6-9.43-28a8.69,8.69,0,0,0-5.77.42c-4.46,1.88-13.15,7.62-10.61,23.53a41.72,41.72,0,0,1,.57,7c-.08,9.08.43,32.93,7.22,50.13,0,0,6.83,23.77,11.45,32.7A.48.48,0,0,0,466.65,472.49Z" fill="#014D4E" data-primary="true"/>
<path d="M466.65,472.49c.84-2.95,4-10.27,14.6-9.62a138.92,138.92,0,0,1-7.44-30.57s-1.21-25.63-1.48-45.45c0,0,2.3-24.6-9.43-28a8.69,8.69,0,0,0-5.77.42c-4.46,1.88-13.15,7.62-10.61,23.53a41.72,41.72,0,0,1,.57,7c-.08,9.08.43,32.93,7.22,50.13,0,0,6.83,23.77,11.45,32.7A.48.48,0,0,0,466.65,472.49Z" opacity="0.3"/>
<path d="M397.49,493.63a9.79,9.79,0,0,1-2.74-1.91,11.9,11.9,0,0,1-2.06-2.67,12.74,12.74,0,0,1-.73-1.54,9.53,9.53,0,0,1-.46-1.64,8.94,8.94,0,0,1-.05-3.34,25.66,25.66,0,0,0,.85,3.13,16.84,16.84,0,0,0,1.3,2.87A26,26,0,0,0,397.49,493.63Z" fill="#f7a48b"/>
</svg>

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

@ -0,0 +1,24 @@
{
"name": "JSON Crack",
"short_name": "JSON Crack",
"description": "JSON Crack Editor is a tool for visualizing into graphs, analyzing, editing, formatting, querying, transforming and validating JSON, CSV, YAML, XML, and more.",
"theme_color": "#36393e",
"background_color": "#36393e",
"display": "standalone",
"orientation": "landscape",
"scope": "/editor",
"start_url": "/editor",
"icons": [
{
"src": "assets/192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "assets/512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

@ -0,0 +1,10 @@
# Allow all crawlers
User-agent: *
Allow: /
# Block all crawlers for /accounts
User-agent: *
Disallow: /*?*
Disallow: /forgot-password
Disallow: /widget

@ -0,0 +1,6 @@
https://jsoncrack.com
https://jsoncrack.com/sign-in
https://jsoncrack.com/editor
https://jsoncrack.com/docs
https://jsoncrack.com/legal/terms
https://jsoncrack.com/legal/privacy

@ -0,0 +1,21 @@
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from "@sentry/nextjs";
if (process.env.NODE_ENV === "production") {
Sentry.init({
dsn: "https://d3345591295d4dd1b8c579b62003d939@o1284435.ingest.sentry.io/6495191",
tracesSampleRate: 0.2,
debug: false,
release: `${process.env.SENTRY_RELEASE || "production"}`,
allowUrls: ["https://jsoncrack.com/editor"],
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
integrations: [
new Sentry.BrowserTracing(),
new Sentry.Replay({
maskAllText: true,
blockAllMedia: true,
}),
],
});
}

@ -0,0 +1,80 @@
import React from "react";
import styled from "styled-components";
const StyledInputWrapper = styled.div`
background: ${({ theme }) => theme.BACKGROUND_TERTIARY};
width: 100%;
border-radius: 4px;
`;
const StyledForm = styled.div`
display: flex;
flex: 1;
`;
const StyledInput = styled.input`
background: ${({ theme }) => theme.BACKGROUND_TERTIARY};
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
outline: none;
border: none;
border-radius: 4px;
line-height: 32px;
padding: 10px;
width: 100%;
height: 40px;
`;
const StyledButton = styled.button`
display: flex;
align-items: center;
background: none;
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
padding: 0 10px;
min-height: unset;
text-transform: uppercase;
&:hover {
box-shadow: none;
}
&.active {
background: ${({ theme }) => theme.PRIMARY};
color: white;
outline: 3px solid ${({ theme }) => theme.BACKGROUND_TERTIARY};
border-radius: 10px;
}
`;
export interface InputProps {
value: string | number | string[];
extensions: string[];
activeExtension: number;
onChange?: React.ChangeEventHandler<HTMLInputElement>;
setExtension: (value: number) => void;
}
export const FileInput: React.FC<InputProps> = ({
setExtension,
activeExtension,
onChange,
extensions,
value,
}) => {
return (
<StyledInputWrapper>
<StyledForm>
<StyledInput type="text" onChange={onChange} value={value} placeholder="File Name" />
{extensions.map((ext, key) => (
<StyledButton
className={`${activeExtension === key && "active"}`}
key={key}
aria-label="search"
onClick={() => setExtension(key)}
>
{ext}
</StyledButton>
))}
</StyledForm>
</StyledInputWrapper>
);
};

@ -0,0 +1,88 @@
import React from "react";
import styled from "styled-components";
import Editor, { loader, useMonaco } from "@monaco-editor/react";
import { Loading } from "src/layout/Loading";
import useConfig from "src/store/useConfig";
import useFile from "src/store/useFile";
loader.config({
paths: {
vs: "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.0/min/vs",
},
});
const editorOptions = {
formatOnPaste: true,
formatOnType: true,
minimap: {
enabled: false,
},
};
const StyledWrapper = styled.div`
display: grid;
height: calc(100vh - 67px);
grid-template-columns: 100%;
grid-template-rows: minmax(0, 1fr);
`;
export const MonacoEditor = () => {
const monaco = useMonaco();
const contents = useFile(state => state.contents);
const setContents = useFile(state => state.setContents);
const setError = useFile(state => state.setError);
const jsonSchema = useFile(state => state.jsonSchema);
const getHasChanges = useFile(state => state.getHasChanges);
const theme = useConfig(state => (state.darkmodeEnabled ? "vs-dark" : "light"));
const fileType = useFile(state => state.format);
React.useEffect(() => {
monaco?.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
allowComments: true,
enableSchemaRequest: true,
...(jsonSchema && {
schemas: [
{
uri: "http://myserver/foo-schema.json",
fileMatch: ["*"],
schema: jsonSchema,
},
],
}),
});
}, [jsonSchema, monaco?.languages.json.jsonDefaults]);
React.useEffect(() => {
const beforeunload = (e: BeforeUnloadEvent) => {
if (getHasChanges()) {
const confirmationMessage =
"Unsaved changes, if you leave before saving your changes will be lost";
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage;
}
};
window.addEventListener("beforeunload", beforeunload);
return () => {
window.removeEventListener("beforeunload", beforeunload);
};
}, [getHasChanges]);
return (
<StyledWrapper>
<Editor
height="100%"
language={fileType}
theme={theme}
value={contents}
options={editorOptions}
onValidate={errors => setError(errors[0]?.message)}
onChange={contents => setContents({ contents, skipUpdate: true })}
loading={<Loading message="Loading Monaco Editor..." loading />}
/>
</StyledWrapper>
);
};

@ -0,0 +1,182 @@
import React from "react";
import {
ActionIcon,
TextInput,
Text,
Loader,
Tooltip,
HoverCard,
Flex,
Badge,
} from "@mantine/core";
import { getHotkeyHandler } from "@mantine/hooks";
import styled from "styled-components";
import { FunctionsHttpError } from "@supabase/supabase-js";
import toast from "react-hot-toast";
import { GoDependabot } from "react-icons/go";
import { VscClose, VscQuestion } from "react-icons/vsc";
import useJsonQuery from "src/hooks/useJsonQuery";
import { supabase } from "src/lib/api/supabase";
import useConfig from "src/store/useConfig";
import useUser from "src/store/useUser";
const StyledPromptInput = styled(TextInput)`
.mantine-TextInput-wrapper {
margin-bottom: 0;
}
.mantine-TextInput-input {
font-weight: 500;
background: ${({ theme }) => theme.PROMPT_BG};
color: ${({ theme }) => theme.PROMPT_TEXT_COLOR};
border: none;
border-bottom: 1px solid
${({ theme, error }) => (error ? theme.DANGER : theme.PROMPT_BORDER_COLOR)};
:focus-within {
border-color: #15593a;
}
}
.mantine-TextInput-error {
padding: 4px;
border-bottom: 1px solid ${({ theme }) => theme.DANGER};
background: #280000;
}
svg {
color: ${({ theme }) => theme.PROMPT_TEXT_COLOR};
}
::placeholder {
color: ${({ theme }) => theme.PROMPT_PLACEHOLDER_COLOR};
}
`;
export const PromptInput = () => {
const { updateJson, getJsonType } = useJsonQuery();
const premium = useUser(state => state.premium);
const [completing, setCompleting] = React.useState(false);
const [prompt, setPrompt] = React.useState("");
const promptVisible = useConfig(state => state.aiEnabled);
const [promptError, setPromptError] = React.useState<string | null>(null);
const onSubmit = async () => {
try {
setPromptError(null);
setCompleting(true);
const jsonModel = await getJsonType();
const { data, error } = await supabase.functions.invoke("jq", {
body: { query: prompt, jsonModel },
});
if (error instanceof FunctionsHttpError) {
const errorMessage = await error.context.json();
throw Error(errorMessage.error);
}
// extract jq command
const jqOutput = data.command;
const regex = /'([^']*)'/;
const match = jqOutput.match(regex);
if (match && match[1]) {
const extractedString = match[1];
updateJson(extractedString);
toast.success(`${data.credits} credits left for today.`);
} else {
throw Error("An error occured while parsing result.");
}
} catch (error: any) {
console.error(error);
if (error instanceof Error) setPromptError(error.message);
} finally {
setCompleting(false);
}
};
if (!promptVisible) return null;
return (
<Tooltip
disabled={premium}
w={400}
multiline
position="right"
label={
<Text fz="xs">
<Badge size="xs" radius={2}>
Alpha
</Badge>{" "}
JSON Crack AI is currently only available to premium users to test out. You may close this
from the settings.
</Text>
}
fz="xs"
withinPortal
withArrow
>
<div>
<StyledPromptInput
placeholder="Ask JSON Crack AI to transform the data"
value={prompt}
onChange={e => setPrompt(e.currentTarget.value)}
maxLength={200}
disabled={!premium || completing}
onKeyDown={getHotkeyHandler([["Enter", onSubmit]])}
onSubmit={onSubmit}
error={
promptError && (
<Flex align="center" justify="space-between">
{promptError}
<ActionIcon
size="xs"
variant="transparent"
title="Close Error"
onClick={() => setPromptError(null)}
>
<VscClose color="red" />
</ActionIcon>
</Flex>
)
}
rightSection={
<>
<HoverCard withArrow withinPortal>
<HoverCard.Target>
<ActionIcon variant="transparent">
<VscQuestion />
</ActionIcon>
</HoverCard.Target>
<HoverCard.Dropdown maw={300} fz="xs">
This feature is in the{" "}
<Badge size="xs" radius={2} variant="light">
alpha
</Badge>{" "}
phase, and its results may not always be accurate. Be cautious, as invalid actions
still consume a credit. We only process the schema of your data and DO NOT process
values.
<br />
<br />
You receive <b>10 credits</b> daily, and you have the option to deactivate this
feature in the settings located at the upper right corner of the editor.
<br />
<br />
Examples:
<li>
<code>Retrieve members whose names begin with &quot;M&quot;</code>
</li>
<li>
<code>Retrieve members with age older than 30</code>
</li>
</HoverCard.Dropdown>
</HoverCard>
</>
}
leftSection={completing ? <Loader size="xs" /> : <GoDependabot strokeWidth={1} />}
radius={0}
/>
</div>
</Tooltip>
);
};

@ -0,0 +1,34 @@
import React from "react";
import { Flex, Text, TextInput } from "@mantine/core";
import { getHotkeyHandler } from "@mantine/hooks";
import ReactGA from "react-ga4";
import { AiOutlineSearch } from "react-icons/ai";
import { useFocusNode } from "src/hooks/useFocusNode";
export const SearchInput: React.FC = () => {
const [searchValue, setValue, skip, nodeCount, currentNode] = useFocusNode();
return (
<TextInput
type="search"
size="xs"
id="search-node"
w={180}
value={searchValue}
onChange={e => setValue(e.currentTarget.value)}
onFocus={() => ReactGA.event({ action: "focus_node_search", category: "User" })}
placeholder="Search Node"
onKeyDown={getHotkeyHandler([["Enter", skip]])}
leftSection={<AiOutlineSearch />}
rightSection={
searchValue && (
<Flex h={30} align="center">
<Text size="xs" c="dimmed" pr="md">
{searchValue && `${nodeCount}/${nodeCount > 0 ? currentNode + 1 : "0"}`}
</Text>
</Flex>
)
}
/>
);
};

@ -0,0 +1,28 @@
import React from "react";
interface SeoTagsProps {
title: string;
description: string;
image: string;
}
export const SeoTags: React.FC<SeoTagsProps> = ({ description, title, image }) => (
<>
<meta name="description" content={description} />
{/* <!-- Facebook Meta Tags --> */}
<meta property="og:url" content="https://jsoncrack.com" />
<meta property="og:type" content="website" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={image} />
{/* <!-- Twitter Meta Tags --> */}
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="https://jsoncrack.com" />
<meta property="twitter:url" content="https://jsoncrack.com" />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:image" content={image} />
</>
);

@ -0,0 +1,38 @@
export const baseURL = process.env.NEXT_PUBLIC_BASE_URL as string;
// Example taken from https://mdn.github.io/learning-area/javascript/oojs/json/superheroes.json
const sampleJson = Object.freeze({
squadName: "Super hero squad",
homeTown: "Metro City",
formed: 2016,
secretBase: "Super tower",
active: true,
members: [
{
name: "Molecule Man",
age: 29,
secretIdentity: "Dan Jukes",
powers: ["Radiation resistance", "Turning tiny", "Radiation blast"],
},
{
name: "Madame Uppercut",
age: 39,
secretIdentity: "Jane Wilson",
powers: ["Million tonne punch", "Damage resistance", "Superhuman reflexes"],
},
{
name: "Eternal Flame",
age: 1000000,
secretIdentity: "Unknown",
powers: [
"Immortality",
"Heat Immunity",
"Inferno",
"Teleportation",
"Interdimensional travel",
],
},
],
});
export const defaultJson = JSON.stringify(sampleJson, null, 2);

@ -0,0 +1,18 @@
import { Fira_Mono } from "next/font/google";
import localFont from "next/font/local";
const monaSans = localFont({
src: "../assets/fonts/Mona-Sans.woff2",
variable: "--mona-sans",
display: "swap",
fallback: ["Futura, Helvetica, sans-serif", "Tahoma, Verdana, sans-serif"],
});
const firaMono = Fira_Mono({
weight: ["500"],
subsets: ["latin"],
display: "swap",
fallback: ["Menlo, Monaco, monospace", "Consolas, Courier New, monospace"],
});
export { monaSans, firaMono };

@ -0,0 +1,45 @@
import { createGlobalStyle } from "styled-components";
const GlobalStyle = createGlobalStyle`
html, body {
background: rgb(246,249,253);
background: radial-gradient(circle, rgb(245 245 245) 33%, rgb(252 252 255) 100%);
-webkit-font-smoothing: subpixel-antialiased !important;
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
scroll-behavior: smooth !important;
-webkit-tap-highlight-color: transparent;
-webkit-font-smoothing: never;
}
.hide {
display: none;
}
svg {
vertical-align: text-top;
}
a {
color: unset;
text-decoration: none;
}
button {
border: none;
outline: none;
background: transparent;
width: fit-content;
margin: 0;
padding: 0;
cursor: pointer;
}
`;
export default GlobalStyle;

@ -0,0 +1,129 @@
const fixedColors = {
CRIMSON: "#DC143C",
BLURPLE: "#5865F2",
PURPLE: "#9036AF",
FULL_WHITE: "#FFFFFF",
BLACK: "#202225",
BLACK_DARK: "#2C2F33",
BLACK_LIGHT: "#2F3136",
BLACK_PRIMARY: "#36393f",
DARK_SALMON: "#E9967A",
DANGER: "hsl(359,calc(var(--saturation-factor, 1)*66.7%),54.1%)",
LIGHTGREEN: "#90EE90",
SEAGREEN: "#11883B",
ORANGE: "#FAA81A",
SILVER: "#B9BBBE",
PRIMARY: "#4D4D4D",
TEXT_DANGER: "#db662e",
};
const promptInputColors = {
dark: {
PROMPT_BG: "#072719",
PROMPT_PLACEHOLDER_COLOR: "#15593A",
PROMPT_TEXT_COLOR: "#3DCF8E",
PROMPT_BORDER_COLOR: "#0C3924",
},
light: {
PROMPT_BG: "#d3ede1",
PROMPT_PLACEHOLDER_COLOR: "#77c2a1",
PROMPT_TEXT_COLOR: "#289b67",
PROMPT_BORDER_COLOR: "#8ad7b3",
},
};
const nodeColors = {
dark: {
NODE_COLORS: {
TEXT: "#DCE5E7",
NODE_KEY: "#59b8ff",
NODE_VALUE: "#DCE5E7",
INTEGER: "#e8c479",
NULL: "#939598",
BOOL: {
FALSE: "#F85C50",
TRUE: "#00DC7D",
},
PARENT_ARR: "#FC9A40",
PARENT_OBJ: "#59b8ff",
CHILD_COUNT: "white",
},
},
light: {
NODE_COLORS: {
TEXT: "#000",
NODE_KEY: "#761CEA",
NODE_VALUE: "#535353",
INTEGER: "#FD0079",
NULL: "#afafaf",
BOOL: {
FALSE: "#FF0000",
TRUE: "#748700",
},
PARENT_ARR: "#FF6B00",
PARENT_OBJ: "#761CEA",
CHILD_COUNT: "#535353",
},
},
};
export const darkTheme = {
...fixedColors,
...nodeColors.dark,
...promptInputColors.dark,
BLACK_SECONDARY: "#23272A",
SILVER_DARK: "#4D4D4D",
NODE_KEY: "#FAA81A",
OBJECT_KEY: "#59b8ff",
SIDEBAR_ICONS: "#8B8E90",
INTERACTIVE_NORMAL: "#b9bbbe",
INTERACTIVE_HOVER: "#dcddde",
INTERACTIVE_ACTIVE: "#fff",
BACKGROUND_NODE: "#2B2C3E",
BACKGROUND_TERTIARY: "#202225",
BACKGROUND_SECONDARY: "#2f3136",
TOOLBAR_BG: "#262626",
BACKGROUND_PRIMARY: "#36393f",
BACKGROUND_MODIFIER_ACCENT: "rgba(79,84,92,0.48)",
MODAL_BACKGROUND: "#36393E",
TEXT_NORMAL: "#dcddde",
TEXT_POSITIVE: "hsl(139,calc(var(--saturation-factor, 1)*51.6%),52.2%)",
GRID_BG_COLOR: "#1E1E1E",
GRID_COLOR_PRIMARY: "#272626",
GRID_COLOR_SECONDARY: "#232323",
};
export const lightTheme = {
...fixedColors,
...nodeColors.light,
...promptInputColors.light,
BLACK_SECONDARY: "#F2F2F2",
SILVER_DARK: "#CCCCCC",
NODE_KEY: "#DC3790",
OBJECT_KEY: "#0260E8",
SIDEBAR_ICONS: "#6D6E70",
INTERACTIVE_NORMAL: "#4f5660",
INTERACTIVE_HOVER: "#2e3338",
INTERACTIVE_ACTIVE: "#060607",
BACKGROUND_NODE: "#F6F8FA",
BACKGROUND_TERTIARY: "#e3e5e8",
BACKGROUND_SECONDARY: "#f2f3f5",
TOOLBAR_BG: "#ECECEC",
BACKGROUND_PRIMARY: "#FFFFFF",
BACKGROUND_MODIFIER_ACCENT: "rgba(106,116,128,0.24)",
MODAL_BACKGROUND: "#FFFFFF",
TEXT_NORMAL: "#2e3338",
TEXT_POSITIVE: "#008736",
GRID_BG_COLOR: "#f3f3f3",
GRID_COLOR_PRIMARY: "#E0E0E0",
GRID_COLOR_SECONDARY: "#E4E4E4",
};
const themeDs = {
...lightTheme,
...darkTheme,
};
export default themeDs;

@ -0,0 +1,269 @@
import React from "react";
import Head from "next/head";
import { useRouter } from "next/router";
import { Flex, Popover, Text } from "@mantine/core";
import styled from "styled-components";
import toast from "react-hot-toast";
import {
AiOutlineCloudSync,
AiOutlineCloudUpload,
AiOutlineLink,
AiOutlineLock,
AiOutlineUnlock,
} from "react-icons/ai";
import { BiSolidDockLeft } from "react-icons/bi";
import { MdOutlineCheckCircleOutline } from "react-icons/md";
import { TbTransform } from "react-icons/tb";
import { VscError, VscFeedback, VscSourceControl, VscSync, VscSyncIgnored } from "react-icons/vsc";
import { documentSvc } from "src/services/document.service";
import useConfig from "src/store/useConfig";
import useFile from "src/store/useFile";
import useGraph from "src/store/useGraph";
import useModal from "src/store/useModal";
import useUser from "src/store/useUser";
const StyledBottomBar = styled.div`
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
background: ${({ theme }) => theme.TOOLBAR_BG};
max-height: 27px;
height: 27px;
z-index: 35;
padding-right: 6px;
@media screen and (max-width: 320px) {
display: none;
}
`;
const StyledLeft = styled.div`
display: flex;
align-items: center;
justify-content: left;
gap: 4px;
padding-left: 8px;
@media screen and (max-width: 480px) {
display: none;
}
`;
const StyledRight = styled.div`
display: flex;
align-items: center;
justify-content: right;
gap: 4px;
`;
const StyledBottomBarItem = styled.button<{ $bg?: string }>`
display: flex;
align-items: center;
gap: 4px;
width: fit-content;
margin: 0;
height: 28px;
padding: 4px;
font-size: 12px;
font-weight: 400;
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
background: ${({ $bg }) => $bg};
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
&:hover:not(&:disabled) {
background-image: linear-gradient(rgba(0, 0, 0, 0.1) 0 0);
color: ${({ theme }) => theme.INTERACTIVE_HOVER};
}
&:disabled {
opacity: 0.6;
cursor: default;
}
`;
export const BottomBar = () => {
const { query, replace } = useRouter();
const data = useFile(state => state.fileData);
const user = useUser(state => state.user);
const toggleLiveTransform = useConfig(state => state.toggleLiveTransform);
const liveTransformEnabled = useConfig(state => state.liveTransformEnabled);
const hasChanges = useFile(state => state.hasChanges);
const error = useFile(state => state.error);
const getContents = useFile(state => state.getContents);
const setContents = useFile(state => state.setContents);
const nodeCount = useGraph(state => state.nodes.length);
const fileName = useFile(state => state.fileData?.name);
const toggleFullscreen = useGraph(state => state.toggleFullscreen);
const fullscreen = useGraph(state => state.fullscreen);
const setVisible = useModal(state => state.setVisible);
const setHasChanges = useFile(state => state.setHasChanges);
const getFormat = useFile(state => state.getFormat);
const [isPrivate, setIsPrivate] = React.useState(false);
const [isUpdating, setIsUpdating] = React.useState(false);
const toggleEditor = () => toggleFullscreen(!fullscreen);
React.useEffect(() => {
setIsPrivate(data?.private ?? true);
}, [data]);
const handleSaveJson = React.useCallback(async () => {
if (!user) return setVisible("login")(true);
if (
hasChanges &&
!error &&
(typeof query.json === "string" || typeof query.json === "undefined")
) {
try {
setIsUpdating(true);
toast.loading("Saving document...", { id: "fileSave" });
const { data, error } = await documentSvc.upsert({
id: query?.json,
contents: getContents(),
format: getFormat(),
});
if (error) throw error;
if (data) replace({ query: { json: data } });
toast.success("Document saved to cloud", { id: "fileSave" });
setHasChanges(false);
} catch (error: any) {
toast.error(error.message, { id: "fileSave" });
} finally {
setIsUpdating(false);
}
}
}, [
error,
getContents,
getFormat,
hasChanges,
query.json,
replace,
setHasChanges,
setVisible,
user,
]);
const setPrivate = async () => {
try {
if (!query.json) return handleSaveJson();
setIsUpdating(true);
const { data: updatedJsonData, error } = await documentSvc.update(query.json as string, {
private: !isPrivate,
});
if (error) return toast.error(error.message);
if (updatedJsonData[0]) {
setIsPrivate(updatedJsonData[0].private);
toast.success(`Document set to ${isPrivate ? "public" : "private"}.`);
} else throw error;
} catch (error) {
console.error(error);
} finally {
setIsUpdating(false);
}
};
return (
<StyledBottomBar>
{data?.name && (
<Head>
<title>{data.name} | JSON Crack</title>
</Head>
)}
<StyledLeft>
<StyledBottomBarItem onClick={toggleEditor}>
<BiSolidDockLeft />
</StyledBottomBarItem>
{fileName && (
<StyledBottomBarItem onClick={() => setVisible("cloud")(true)}>
<VscSourceControl />
{fileName}
</StyledBottomBarItem>
)}
<StyledBottomBarItem>
{error ? (
<Popover width="auto" shadow="md" position="top" withArrow>
<Popover.Target>
<Flex align="center" gap={2}>
<VscError color="red" size={16} />
<Text c="red" fw={500} fz="xs">
Invalid
</Text>
</Flex>
</Popover.Target>
<Popover.Dropdown
style={{
pointerEvents: "none",
}}
>
<Text size="xs">{error}</Text>
</Popover.Dropdown>
</Popover>
) : (
<Flex align="center" gap={2}>
<MdOutlineCheckCircleOutline />
<Text size="xs">Valid</Text>
</Flex>
)}
</StyledBottomBarItem>
{(data?.owner_email === user?.email || (!data && user)) && (
<StyledBottomBarItem onClick={handleSaveJson} disabled={isUpdating || error}>
{hasChanges || !user ? <AiOutlineCloudUpload /> : <AiOutlineCloudSync />}
{hasChanges || !user ? (query?.json ? "Unsaved Changes" : "Save to Cloud") : "Saved"}
</StyledBottomBarItem>
)}
{data?.owner_email === user?.email && (
<StyledBottomBarItem onClick={setPrivate} disabled={isUpdating}>
{isPrivate ? <AiOutlineLock /> : <AiOutlineUnlock />}
{isPrivate ? "Private" : "Public"}
</StyledBottomBarItem>
)}
<StyledBottomBarItem
onClick={() => setVisible("share")(true)}
disabled={isPrivate || !data}
>
<AiOutlineLink />
Share
</StyledBottomBarItem>
{liveTransformEnabled ? (
<StyledBottomBarItem onClick={() => toggleLiveTransform(false)}>
<VscSync />
<Text fz="xs">Live Transform</Text>
</StyledBottomBarItem>
) : (
<StyledBottomBarItem onClick={() => toggleLiveTransform(true)}>
<VscSyncIgnored />
<Text fz="xs">Manual Transform</Text>
</StyledBottomBarItem>
)}
{!liveTransformEnabled && (
<StyledBottomBarItem onClick={() => setContents({})}>
<TbTransform />
Transform
</StyledBottomBarItem>
)}
</StyledLeft>
<StyledRight>
<StyledBottomBarItem>Nodes: {nodeCount}</StyledBottomBarItem>
<StyledBottomBarItem onClick={() => setVisible("review")(true)}>
<VscFeedback />
Feedback
</StyledBottomBarItem>
</StyledRight>
</StyledBottomBar>
);
};

@ -0,0 +1,22 @@
import React from "react";
import styled from "styled-components";
import { MonacoEditor } from "src/components/MonacoEditor";
import { PromptInput } from "src/components/PromptInput";
const StyledEditorWrapper = styled.div`
display: flex;
flex-direction: column;
height: 100%;
user-select: none;
`;
export const JsonEditor: React.FC = () => {
return (
<StyledEditorWrapper>
<PromptInput />
<MonacoEditor />
</StyledEditorWrapper>
);
};
export default JsonEditor;

@ -0,0 +1,78 @@
import React from "react";
import { Menu, Text } from "@mantine/core";
import styled from "styled-components";
import { firaMono } from "src/constants/fonts";
import { Graph } from "src/containers/Views/GraphView";
import { TreeView } from "src/containers/Views/TreeView";
import { ViewMode } from "src/enums/viewMode.enum";
import useConfig from "src/store/useConfig";
const StyledLiveEditor = styled.div`
position: relative;
height: 100%;
background: ${({ theme }) => theme.GRID_BG_COLOR};
overflow: auto;
cursor: url("/assets/cursor.svg"), auto;
& > ul {
margin-top: 0 !important;
padding: 12px !important;
font-family: ${firaMono.style.fontFamily};
font-size: 14px;
font-weight: 500;
}
`;
const View = () => {
const viewMode = useConfig(state => state.viewMode);
if (viewMode === ViewMode.Graph) return <Graph />;
if (viewMode === ViewMode.Tree) return <TreeView />;
return null;
};
const LiveEditor: React.FC = () => {
const [contextOpened, setContextOpened] = React.useState(false);
const [contextPosition, setContextPosition] = React.useState({
x: 0,
y: 0,
});
return (
<StyledLiveEditor
onContextMenuCapture={e => {
e.preventDefault();
setContextOpened(true);
setContextPosition({ x: e.pageX, y: e.pageY });
}}
onClick={() => setContextOpened(false)}
>
<div
style={{
position: "fixed",
top: contextPosition.y,
left: contextPosition.x,
zIndex: 100,
}}
>
<Menu opened={false} shadow="sm">
<Menu.Dropdown>
<Menu.Item>
<Text size="xs">Download as Image</Text>
</Menu.Item>
<Menu.Item>
<Text size="xs">Zoom to Fit</Text>
</Menu.Item>
<Menu.Item>
<Text size="xs">Rotate</Text>
</Menu.Item>
</Menu.Dropdown>
</Menu>
</div>
<View />
</StyledLiveEditor>
);
};
export default LiveEditor;

@ -0,0 +1,47 @@
import React from "react";
import dynamic from "next/dynamic";
import styled from "styled-components";
import { Allotment } from "allotment";
import "allotment/dist/style.css";
import useGraph from "src/store/useGraph";
export const StyledEditor = styled(Allotment)`
position: relative !important;
display: flex;
background: ${({ theme }) => theme.BACKGROUND_SECONDARY};
height: calc(100vh - 67px);
@media only screen and (max-width: 320px) {
height: 100vh;
}
`;
const JsonEditor = dynamic(() => import("src/containers/Editor/JsonEditor"), {
ssr: false,
});
const LiveEditor = dynamic(() => import("src/containers/Editor/LiveEditor"), {
ssr: false,
});
const Panes: React.FC = () => {
const fullscreen = useGraph(state => state.fullscreen);
return (
<StyledEditor proportionalLayout={false}>
<Allotment.Pane
preferredSize={450}
minSize={fullscreen ? 0 : 300}
maxSize={800}
visible={!fullscreen}
>
<JsonEditor />
</Allotment.Pane>
<Allotment.Pane minSize={0}>
<LiveEditor />
</Allotment.Pane>
</StyledEditor>
);
};
export default Panes;

@ -0,0 +1,98 @@
import React from "react";
import {
Modal,
Group,
Button,
Avatar,
Text,
Divider,
ModalProps,
Paper,
Badge,
} from "@mantine/core";
import { useUser as useSupaUser } from "@supabase/auth-helpers-react";
import { IoRocketSharp } from "react-icons/io5";
import useModal from "src/store/useModal";
import useUser from "src/store/useUser";
export const AccountModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const user = useSupaUser();
const isPremium = useUser(state => state.premium);
const isOrg = useUser(state => state.organization);
const isOrgAdmin = useUser(state => state.orgAdmin);
const premiumCancelled = useUser(state => state.premiumCancelled);
const setVisible = useModal(state => state.setVisible);
const logout = useUser(state => state.logout);
return (
<Modal title={`Hello, ${user?.user_metadata.name}!`} opened={opened} onClose={onClose} centered>
<Paper p="md">
<Group>
<Avatar src={user?.user_metadata.avatar_url} size={94}>
JC
</Avatar>
<div>
<Text fz="lg" tt="uppercase" fw={700}>
{user?.user_metadata.name}
</Text>
<Group gap={10} mt={3}>
<Text fz="xs" c="dimmed">
{user?.email}
</Text>
</Group>
<Group gap={10} mt={5}>
<Text fz="xs" c="dimmed">
<Badge
size="sm"
variant={isPremium ? "gradient" : "dot"}
color={premiumCancelled || !isPremium ? "dark" : "green"}
gradient={{ from: "#8800fe", to: "#ff00cc", deg: 35 }}
>
{isPremium ? "Premium" : "Free"}{" "}
{premiumCancelled ? "(Cancelled)" : isOrg && "(Organization)"}
</Badge>
</Text>
</Group>
</div>
</Group>
</Paper>
<Divider py="xs" />
<Group justify="right">
{isPremium && !premiumCancelled ? (
<Button
variant="light"
color="red"
onClick={() => {
setVisible("cancelPremium")(true);
onClose();
}}
disabled={isOrg && !isOrgAdmin}
>
Cancel Subscription
</Button>
) : (
<Button
variant="gradient"
gradient={{ from: "teal", to: "lime", deg: 105 }}
leftSection={<IoRocketSharp />}
onClick={() => setVisible("premium")(true)}
>
UPGRADE TO PREMIUM!
</Button>
)}
<Button
color="red"
onClick={() => {
logout();
onClose();
}}
>
Log Out
</Button>
</Group>
</Modal>
);
};

@ -0,0 +1,72 @@
import React from "react";
import { Modal, Group, Button, Divider, ModalProps, Text, Image, Anchor } from "@mantine/core";
import { toast } from "react-hot-toast";
import { supabase } from "src/lib/api/supabase";
import useModal from "src/store/useModal";
export const CancelPremiumModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const [cancelling, setCancelling] = React.useState(false);
const showFeedback = useModal(state => state.setVisible("review"));
const cancelSub = async () => {
try {
setCancelling(true);
const { data: user } = await supabase.auth.getSession();
if (user) {
const { error } = await supabase.functions.invoke("lemonsqueezy", {
method: "DELETE",
body: {
jwt: user.session?.access_token,
},
});
if (error) {
return toast.error(
"An error occured while cancelling subscription, please contact: contact@jsoncrack.com"
);
}
toast.success("Cancelled premium plan!");
showFeedback(true);
} else {
toast.error("Couldn't fetch user details, please contact: contact@jsoncrack.com");
}
toast.success("Cancelled premium plan!");
onClose();
} catch (err) {
console.error(err);
} finally {
setCancelling(false);
}
};
return (
<Modal title="CANCEL PREMIUM?" opened={opened} onClose={onClose} centered>
<Image py="xs" src="assets/taken.svg" mx="auto" w={200} alt="taken" />
<Text fz="sm" pb="md">
Cancellation will take effect at the end of your current billing period.
<br />
<br />
You can restart your subscription anytime.
<br />
<Anchor fz="xs" target="_blank" href="https://patreon.com/herowand">
Click here to cancel if you are Patreon member
</Anchor>
<Text size="xs" c="dimmed" mt="lg">
If you have problems with cancelling plan please contact: contact@jsoncrack.com
</Text>
</Text>
<Divider py="xs" />
<Group justify="right">
<Button color="dark" variant="subtle" onClick={onClose}>
Cancel
</Button>
<Button onClick={cancelSub} loading={cancelling} color="red">
QUIT SUBSCRIPTION
</Button>
</Group>
</Modal>
);
};

@ -0,0 +1,34 @@
import React from "react";
import { useRouter } from "next/router";
import { Modal, Group, Button, Text, Divider, ModalProps } from "@mantine/core";
import { documentSvc } from "src/services/document.service";
import useJson from "src/store/useJson";
export const ClearModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const setJson = useJson(state => state.setJson);
const { query, replace } = useRouter();
const handleClear = () => {
setJson("{}");
onClose();
if (typeof query.json === "string") {
documentSvc.delete(query.json);
replace("/editor");
}
};
return (
<Modal title="Delete JSON" opened={opened} onClose={onClose} centered>
<Group py="sm">
<Text>Are you sure you want to delete JSON?</Text>
</Group>
<Divider py="xs" />
<Group justify="right">
<Button color="red" onClick={handleClear}>
Confirm
</Button>
</Group>
</Modal>
);
};

@ -0,0 +1,296 @@
import React from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import {
Modal,
Text,
Divider,
ScrollArea,
ModalProps,
Table,
ActionIcon,
Badge,
Paper,
Flex,
DefaultMantineColor,
Input,
Button,
Group,
Stack,
RingProgress,
UnstyledButton,
Drawer,
LoadingOverlay,
} from "@mantine/core";
import { useQuery } from "@tanstack/react-query";
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import toast from "react-hot-toast";
import { AiOutlineLink } from "react-icons/ai";
import { FaTrash } from "react-icons/fa";
import { MdFileOpen } from "react-icons/md";
import { VscAdd, VscEdit, VscLock, VscUnlock } from "react-icons/vsc";
import { FileFormat } from "src/enums/file.enum";
import { documentSvc } from "src/services/document.service";
import useFile, { File } from "src/store/useFile";
import useUser from "src/store/useUser";
dayjs.extend(relativeTime);
const colorByFormat: Record<FileFormat, DefaultMantineColor> = {
json: "orange",
yaml: "blue",
xml: "red",
toml: "dark",
csv: "grape",
};
const UpdateNameModal: React.FC<{
file: File | null;
onClose: () => void;
refetch: () => void;
}> = ({ file, onClose, refetch }) => {
const [name, setName] = React.useState("");
const onSubmit = () => {
if (!file) return;
toast
.promise(documentSvc.update(file.id, { name }), {
loading: "Updating document...",
error: "Error occurred while updating document!",
success: `Renamed document to ${name}`,
})
.then(() => {
refetch();
setName("");
});
onClose();
};
return (
<Modal title="Update Document name" opened={!!file} onClose={onClose} centered zIndex={202}>
<Stack>
<Input
value={name}
placeholder={file?.name}
onChange={e => setName(e.currentTarget.value)}
/>
<Group justify="right">
<Button variant="outline" onClick={onClose}>
Cancel
</Button>
<Button onClick={onSubmit}>Update</Button>
</Group>
</Stack>
</Modal>
);
};
export const CloudModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const totalQuota = useUser(state => (state.premium ? 200 : 25));
const isPremium = useUser(state => state.premium);
const getContents = useFile(state => state.getContents);
const setHasChanges = useFile(state => state.setHasChanges);
const getFormat = useFile(state => state.getFormat);
const [currentFile, setCurrentFile] = React.useState<File | null>(null);
const { isReady, query, replace } = useRouter();
const { data, isLoading, refetch } = useQuery(["allJson", query], () => documentSvc.getAll(), {
enabled: isReady && opened,
});
const isCreateDisabled = React.useMemo(() => {
if (!data?.length) return false;
return isPremium ? data.length >= 200 : data.length >= 25;
}, [isPremium, data?.length]);
const onCreate = async () => {
try {
toast.loading("Saving document...", { id: "fileSave" });
const { data, error } = await documentSvc.upsert({
contents: getContents(),
format: getFormat(),
});
if (error) throw error;
toast.success("Document saved to cloud", { id: "fileSave" });
setHasChanges(false);
replace({ query: { json: data } });
onClose();
} catch (error: any) {
toast.error("Failed to save document!", { id: "fileSave" });
console.error(error);
}
};
const onDeleteClick = React.useCallback(
(file: File) => {
toast
.promise(documentSvc.delete(file.id), {
loading: "Deleting file...",
error: "An error occurred while deleting the file!",
success: `Deleted ${file.name}!`,
})
.then(() => refetch());
},
[refetch]
);
const copyShareLink = React.useCallback((fileId: string) => {
const shareLink = `${window.location.origin}/editor?json=${fileId}`;
navigator.clipboard.writeText(shareLink);
toast.success("Copied share link to clipboard!");
}, []);
const rows = React.useMemo(
() =>
data?.map(element => (
<Table.Tr key={element.id}>
<Table.Td>
<Flex align="center" gap="xs">
{element.private ? <VscLock /> : <VscUnlock />}
{element.id}
</Flex>
</Table.Td>
<Table.Td>
<Flex align="center" justify="space-between">
{element.name}
<ActionIcon
variant="transparent"
color="cyan"
onClick={() => setCurrentFile(element)}
>
<VscEdit />
</ActionIcon>
</Flex>
</Table.Td>
<Table.Td>{dayjs(element.created_at).format("DD.MM.YYYY")}</Table.Td>
<Table.Td>
<Badge variant="light" color={colorByFormat[element.format]} size="sm">
{element.format.toUpperCase()}
</Badge>
</Table.Td>
<Table.Td>{element.views.toLocaleString("en-US")}</Table.Td>
<Table.Td>
<Flex gap="xs">
<ActionIcon.Group>
<ActionIcon
variant="transparent"
component={Link}
href={`?json=${element.id}`}
prefetch={false}
color="blue"
onClick={onClose}
>
<MdFileOpen size="18" />
</ActionIcon>
<ActionIcon
variant="transparent"
color="red"
onClick={() => onDeleteClick(element)}
>
<FaTrash size="18" />
</ActionIcon>
<ActionIcon
variant="transparent"
color="green"
onClick={() => copyShareLink(element.id)}
>
<AiOutlineLink />
</ActionIcon>
</ActionIcon.Group>
</Flex>
</Table.Td>
</Table.Tr>
)),
[data, copyShareLink, onClose, onDeleteClick]
);
return (
<Drawer
title="Saved On The Cloud"
opened={opened}
size="xl"
onClose={onClose}
transitionProps={{ duration: 300, timingFunction: "ease", transition: "slide-right" }}
pos="relative"
>
<LoadingOverlay visible={isLoading} />
{data && (
<Flex gap="md">
<Paper my="lg" withBorder radius="md" p="xs" w="100%">
<Group>
<RingProgress
size={40}
roundCaps
thickness={6}
sections={[
{
value: (data.length * 100) / totalQuota,
color: data.length > totalQuota / 1.5 ? "red" : "blue",
},
]}
/>
<div>
<Text c="dimmed" fz="xs" fw={700} style={{ textTransform: "uppercase" }}>
Total Quota
</Text>
<Text fw={700} size="lg">
{data.length} / {totalQuota}
</Text>
</div>
</Group>
</Paper>
<Paper my="lg" withBorder radius="md" p="xs" w={250}>
<UnstyledButton
fw="bold"
w="100%"
h="100%"
onClick={onCreate}
disabled={isCreateDisabled}
>
<Text
fz="sm"
fw="bold"
c="blue"
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
textAlign: "center",
}}
>
<VscAdd size="18" strokeWidth={1} />
Create New Document
</Text>
</UnstyledButton>
</Paper>
</Flex>
)}
<Text fz="xs" pb="lg">
The Cloud Save feature is primarily designed for convenient access and is not advisable for
storing sensitive data.
</Text>
<Divider py="xs" />
<Paper>
<ScrollArea h="100%" offsetScrollbars>
<Table fz="xs" verticalSpacing="xs" striped withTableBorder>
<Table.Thead>
<Table.Tr>
<Table.Th>ID</Table.Th>
<Table.Th>Name</Table.Th>
<Table.Th>Create Date</Table.Th>
<Table.Th>Format</Table.Th>
<Table.Th>Views</Table.Th>
<Table.Th>Actions</Table.Th>
</Table.Tr>
</Table.Thead>
<Table.Tbody>{rows}</Table.Tbody>
</Table>
</ScrollArea>
</Paper>
<UpdateNameModal file={currentFile} onClose={() => setCurrentFile(null)} refetch={refetch} />
</Drawer>
);
};

@ -0,0 +1,171 @@
import React from "react";
import {
ColorPicker,
TextInput,
SegmentedControl,
Group,
Modal,
Button,
Divider,
ModalProps,
ColorInput,
} from "@mantine/core";
import { toBlob, toJpeg, toPng, toSvg } from "html-to-image";
import ReactGA from "react-ga4";
import toast from "react-hot-toast";
import { FiCopy, FiDownload } from "react-icons/fi";
enum Extensions {
SVG = "svg",
PNG = "png",
JPEG = "jpeg",
}
const getDownloadFormat = (format: Extensions) => {
switch (format) {
case Extensions.SVG:
return toSvg;
case Extensions.PNG:
return toPng;
case Extensions.JPEG:
return toJpeg;
}
};
const swatches = [
"#B80000",
"#DB3E00",
"#FCCB00",
"#008B02",
"#006B76",
"#1273DE",
"#004DCF",
"#5300EB",
"#EB9694",
"#FAD0C3",
"#FEF3BD",
"#C1E1C5",
"#BEDADC",
"#C4DEF6",
"#BED3F3",
"#D4C4FB",
"transparent",
];
function downloadURI(uri: string, name: string) {
var link = document.createElement("a");
link.download = name;
link.href = uri;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
export const DownloadModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const [extension, setExtension] = React.useState(Extensions.PNG);
const [fileDetails, setFileDetails] = React.useState({
filename: "jsoncrack.com",
backgroundColor: "#FFFFFF",
quality: 1,
});
const clipboardImage = async () => {
try {
toast.loading("Copying to clipboard...", { id: "toastClipboard" });
const imageElement = document.querySelector("svg[id*='ref']") as HTMLElement;
const blob = await toBlob(imageElement, {
quality: fileDetails.quality,
backgroundColor: fileDetails.backgroundColor,
});
if (!blob) return;
navigator.clipboard?.write([
new ClipboardItem({
[blob.type]: blob,
}),
]);
toast.success("Copied to clipboard");
} catch (error) {
toast.error("Failed to copy to clipboard");
} finally {
toast.dismiss("toastClipboard");
ReactGA.event({ action: "click_clipboard_image", category: "User" });
onClose();
}
};
const exportAsImage = async () => {
try {
toast.loading("Downloading...", { id: "toastDownload" });
const imageElement = document.querySelector("svg[id*='ref']") as HTMLElement;
const dataURI = await getDownloadFormat(extension)(imageElement, {
quality: fileDetails.quality,
backgroundColor: fileDetails.backgroundColor,
});
downloadURI(dataURI, `${fileDetails.filename}.${extension}`);
} catch (error) {
toast.error("Failed to download image!");
} finally {
toast.dismiss("toastDownload");
ReactGA.event({ action: "click_download_image", category: "User" });
onClose();
}
};
const updateDetails = (key: keyof typeof fileDetails, value: string | number) =>
setFileDetails({ ...fileDetails, [key]: value });
return (
<Modal opened={opened} onClose={onClose} title="Download Image" centered>
<TextInput
label="File Name"
value={fileDetails.filename}
onChange={e => updateDetails("filename", e.target.value)}
mb="lg"
/>
<SegmentedControl
value={extension}
onChange={e => setExtension(e as Extensions)}
fullWidth
data={[
{ label: "SVG", value: Extensions.SVG },
{ label: "PNG", value: Extensions.PNG },
{ label: "JPEG", value: Extensions.JPEG },
]}
mb="lg"
/>
<ColorInput
label="Background Color"
value={fileDetails.backgroundColor}
onChange={color => updateDetails("backgroundColor", color)}
withEyeDropper={false}
mb="lg"
/>
<ColorPicker
format="rgba"
value={fileDetails.backgroundColor}
onChange={color => updateDetails("backgroundColor", color)}
swatches={swatches}
withPicker={false}
fullWidth
/>
<Divider my="xs" />
<Group justify="right">
<Button leftSection={<FiCopy />} onClick={clipboardImage}>
Clipboard
</Button>
<Button color="green" leftSection={<FiDownload />} onClick={exportAsImage}>
Download
</Button>
</Group>
</Modal>
);
};

@ -0,0 +1,112 @@
import React from "react";
import { Modal, Group, Button, TextInput, Stack, Divider, ModalProps } from "@mantine/core";
import styled from "styled-components";
import toast from "react-hot-toast";
import { AiOutlineUpload } from "react-icons/ai";
import useFile from "src/store/useFile";
const StyledUploadWrapper = styled.label`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: ${({ theme }) => theme.GRID_BG_COLOR};
border: 2px dashed ${({ theme }) => theme.BACKGROUND_TERTIARY};
border-radius: 5px;
min-height: 200px;
padding: 16px;
cursor: pointer;
input[type="file"] {
display: none;
}
`;
const StyledFileName = styled.span`
padding-top: 14px;
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
`;
const StyledUploadMessage = styled.h3`
color: ${({ theme }) => theme.INTERACTIVE_ACTIVE};
margin-bottom: 0;
`;
export const ImportModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const setContents = useFile(state => state.setContents);
const [url, setURL] = React.useState("");
const [jsonFile, setJsonFile] = React.useState<File | null>(null);
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.target.files) setJsonFile(e.target.files?.item(0));
};
const handleFileDrag = (e: React.DragEvent<HTMLLabelElement>) => {
e.preventDefault();
if (e.type === "drop" && e.dataTransfer.files.length) {
if (e.dataTransfer.files[0].type === "application/json") {
setJsonFile(e.dataTransfer.files[0]);
} else {
toast.error("Please upload JSON file!");
}
}
};
const handleImportFile = () => {
if (url) {
setJsonFile(null);
toast.loading("Loading...", { id: "toastFetch" });
return fetch(url)
.then(res => res.json())
.then(json => {
setContents({ contents: JSON.stringify(json, null, 2) });
onClose();
})
.catch(() => toast.error("Failed to fetch JSON!"))
.finally(() => toast.dismiss("toastFetch"));
}
if (jsonFile) {
const reader = new FileReader();
reader.readAsText(jsonFile, "UTF-8");
reader.onload = function (data) {
if (typeof data.target?.result === "string") setContents({ contents: data.target?.result });
onClose();
};
}
};
return (
<Modal title="Import JSON" opened={opened} onClose={onClose} centered>
<Stack py="sm">
<TextInput
value={url}
onChange={e => setURL(e.target.value)}
type="url"
placeholder="URL of JSON to fetch"
data-autofocus
/>
<StyledUploadWrapper onDrop={handleFileDrag} onDragOver={handleFileDrag}>
<input
key={jsonFile?.name}
onChange={handleFileChange}
type="file"
accept="application/JSON"
/>
<AiOutlineUpload size={48} />
<StyledUploadMessage>Click Here to Upload JSON</StyledUploadMessage>
<StyledFileName>{jsonFile?.name ?? "None"}</StyledFileName>
</StyledUploadWrapper>
</Stack>
<Divider my="xs" />
<Group justify="right">
<Button onClick={handleImportFile} disabled={!(jsonFile || url)}>
Import
</Button>
</Group>
</Modal>
);
};

@ -0,0 +1,44 @@
import React from "react";
import {
Stack,
Modal,
Button,
ModalProps,
Text,
Anchor,
Group,
TextInput,
Divider,
} from "@mantine/core";
import { VscLinkExternal } from "react-icons/vsc";
import useJsonQuery from "src/hooks/useJsonQuery";
export const JQModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const { updateJson } = useJsonQuery();
const [query, setQuery] = React.useState("");
return (
<Modal title="JSON Query" size="lg" opened={opened} onClose={onClose} centered>
<Stack py="sm">
<Text fz="sm">
jq is a lightweight and flexible command-line JSON processor. JSON Crack uses simplified
version of jq, not all features are supported.
<br />
<Anchor fz="sm" target="_blank" href="https://jqlang.github.io/jq/manual/">
Read documentation. <VscLinkExternal />
</Anchor>
</Text>
<TextInput
leftSection="jq"
placeholder="Enter jq query"
value={query}
onChange={e => setQuery(e.currentTarget.value)}
/>
<Divider my="xs" />
<Group justify="right">
<Button onClick={() => updateJson(query, onClose)}>Display on Graph</Button>
</Group>
</Stack>
</Modal>
);
};

@ -0,0 +1,35 @@
import React from "react";
import { Modal, Button, ModalProps, Textarea, Divider } from "@mantine/core";
import { decode } from "jsonwebtoken";
import useFile from "src/store/useFile";
export const JWTModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const setContents = useFile(state => state.setContents);
const [token, setToken] = React.useState("");
const resolve = () => {
if (!token) return;
const json = decode(token);
setContents({ contents: JSON.stringify(json, null, 2) });
setToken("");
onClose();
};
return (
<Modal title="Decode JSON Web Token" opened={opened} onClose={onClose} centered>
<Textarea
placeholder="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikhlcm93YW5kIiwidXJsIjoiaHR0cHM6Ly9oZXJvd2FuZC5jb20iLCJpYXQiOjE1MTYyMzkwMjJ9.Tmm3Miq6KWCF_QRn3iERhhXThJzv4LQPKYwBhYUld88"
value={token}
onChange={e => setToken(e.target.value)}
autosize
minRows={4}
data-autofocus
/>
<Divider my="xs" />
<Button onClick={resolve} fullWidth>
Resolve
</Button>
</Modal>
);
};

@ -0,0 +1,16 @@
import React from "react";
import { Modal, Stack, Button, Text, Title, ModalProps } from "@mantine/core";
export const LoginModal: React.FC<ModalProps> = ({ opened, onClose }) => {
return (
<Modal title="Sign In" opened={opened} onClose={onClose} centered>
<Stack py="sm">
<Title order={2}>Welcome Back!</Title>
<Text>Login to unlock full potential of JSON Crack!</Text>
<Button component="a" href="/sign-in" size="md" fullWidth>
Sign In
</Button>
</Stack>
</Modal>
);
};

@ -0,0 +1,131 @@
import React from "react";
import { Modal, Stack, Text, ScrollArea, ModalProps, Button } from "@mantine/core";
import { CodeHighlight } from "@mantine/code-highlight";
import Editor from "@monaco-editor/react";
import { VscLock } from "react-icons/vsc";
import { isIframe } from "src/lib/utils/widget";
import useConfig from "src/store/useConfig";
import useFile from "src/store/useFile";
import useGraph from "src/store/useGraph";
import useModal from "src/store/useModal";
import useUser from "src/store/useUser";
const dataToString = (data: any) => {
const text = Array.isArray(data) ? Object.fromEntries(data) : data;
const replacer = (_: string, v: string) => {
if (typeof v === "string") return v.replaceAll('"', "");
return v;
};
return JSON.stringify(text, replacer, 2);
};
export const NodeModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const isPremium = useUser(state => state.premium);
const editContents = useFile(state => state.editContents);
const setVisible = useModal(state => state.setVisible);
const darkmodeEnabled = useConfig(state => (state.darkmodeEnabled ? "vs-dark" : "light"));
const nodeData = useGraph(state => dataToString(state.selectedNode?.text));
const path = useGraph(state => state.selectedNode?.path || "");
const isParent = useGraph(state => state.selectedNode?.data?.isParent);
const [editMode, setEditMode] = React.useState(false);
const [value, setValue] = React.useState(nodeData || "");
const onUpdate = () => {
if (!value) return setEditMode(false);
if (!isPremium) return;
editContents(path!, value, () => {
setEditMode(false);
onModalClose();
});
};
const onModalClose = () => {
setEditMode(false);
setValue("");
onClose();
};
const onEditClick = () => {
if (isPremium) return setEditMode(true);
setVisible("premium")(true);
};
const isEditVisible = React.useMemo(
() => path !== "{Root}" && !isParent && !isIframe(),
[isParent, path]
);
return (
<Modal title="Node Content" size="auto" opened={opened} onClose={onModalClose} centered>
<Stack py="sm" gap="sm">
<Stack gap="xs">
<Text fz="sm" fw={700}>
Content
</Text>
{editMode ? (
<Editor
theme={darkmodeEnabled}
defaultValue={nodeData}
onChange={e => setValue(e!)}
height={200}
language="json"
options={{
readOnly: !editMode,
minimap: {
enabled: false,
},
}}
/>
) : (
<ScrollArea>
<CodeHighlight
code={nodeData}
miw={350}
mah={250}
maw={600}
language="json"
withCopyButton
/>
</ScrollArea>
)}
</Stack>
{isEditVisible && (
<Stack gap="xs">
{editMode ? (
<Button
variant={value ? "filled" : "light"}
color={value ? "green" : "blue"}
onClick={onUpdate}
>
{value.length ? "Update Document" : "Cancel"}
</Button>
) : (
<Button
onClick={onEditClick}
leftSection={!isPremium && <VscLock />}
variant="filled"
>
Edit
</Button>
)}
</Stack>
)}
<Text fz="sm" fw={700}>
Node Path
</Text>
<ScrollArea>
<CodeHighlight
code={path}
miw={350}
mah={250}
language="json"
copyLabel="Copy to clipboard"
copiedLabel="Copied to clipboard"
withCopyButton
/>
</ScrollArea>
</Stack>
</Modal>
);
};

@ -0,0 +1,70 @@
import React from "react";
import {
Modal,
ModalProps,
Title,
Flex,
Button,
Stack,
List,
ThemeIcon,
Divider,
} from "@mantine/core";
import { BsCheck } from "react-icons/bs";
export const PremiumModal: React.FC<ModalProps> = ({ opened, onClose }) => {
return (
<Modal title="Your Plan" size="auto" opened={opened} onClose={onClose} centered zIndex={202}>
<Flex gap="lg">
<Stack gap="xs">
<Title order={3}>Free plan</Title>
<Button variant="filled" color="dark" size="md">
Your current plan
</Button>
<List
spacing="xs"
size="sm"
center
icon={
<ThemeIcon color="dark.6" size={20} radius="xl">
<BsCheck size="1rem" />
</ThemeIcon>
}
>
<List.Item>Store/Share up to 15 files</List.Item>
<List.Item>Visualize standard size data</List.Item>
</List>
</Stack>
<Divider color="gray" orientation="vertical" />
<Stack gap="xs">
<Title order={3}>JSON Crack Plus</Title>
<Button
component="a"
href="/pricing"
variant="filled"
color="teal"
size="md"
target="_blank"
>
Upgrade plan
</Button>
<List
spacing="xs"
size="sm"
center
icon={
<ThemeIcon color="teal" size={20} radius="xl">
<BsCheck size="1rem" />
</ThemeIcon>
}
>
<List.Item>Edit directly on graph</List.Item>
<List.Item>JSON Schema support</List.Item>
<List.Item>Visualize data at full capability</List.Item>
<List.Item>Save & share up to 200 files</List.Item>
</List>
</Stack>
</Flex>
</Modal>
);
};

@ -0,0 +1,58 @@
import React from "react";
import { Button, Modal, ModalProps, Rating, Text, Textarea } from "@mantine/core";
import { toast } from "react-hot-toast";
import { supabase } from "src/lib/api/supabase";
export const ReviewModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const [stars, setStars] = React.useState(0);
const [review, setReview] = React.useState("");
return (
<Modal
title="Leave a Review"
opened={opened}
onClose={() => {
onClose();
setStars(0);
setReview("");
}}
centered
>
<form
onSubmit={e => {
e.preventDefault();
if (stars === 0 && !review.length) return onClose();
supabase
.from("reviews")
.insert({ stars, review })
.then(({ error }) => {
if (error) return toast.error(error.message);
toast.success("Thank you for your feedback!");
});
onClose();
}}
>
<Text style={{ textAlign: "center" }}>How was your experience?</Text>
<Rating value={stars} onChange={setStars} my="lg" size="xl" mx="auto" />
<Textarea
placeholder="Please provide feedback on how we can enhance the product and let us know which features you require."
value={review}
onChange={e => setReview(e.currentTarget.value)}
minLength={10}
maxLength={500}
minRows={5}
/>
<Text fz={12} c="dimmed" style={{ textAlign: "right" }}>
500/{review.length}
</Text>
<Text fz={12}>
* Your feedback is kept anonymous. If you wish to be contacted, please provide your email
address along with your feedback.
</Text>
<Button type="submit" mt="lg" fullWidth>
Submit
</Button>
</form>
</Modal>
);
};

@ -0,0 +1,90 @@
import React from "react";
import { Stack, Modal, Button, ModalProps, Text, Anchor, Group, Divider } from "@mantine/core";
import Editor from "@monaco-editor/react";
import { toast } from "react-hot-toast";
import { VscLinkExternal, VscLock } from "react-icons/vsc";
import useConfig from "src/store/useConfig";
import useFile from "src/store/useFile";
import useModal from "src/store/useModal";
import useUser from "src/store/useUser";
export const SchemaModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const isPremium = useUser(state => state.premium);
const showPremiumModal = useModal(state => state.setVisible("premium"));
const setJsonSchema = useFile(state => state.setJsonSchema);
const [schema, setSchema] = React.useState(
JSON.stringify(
{
$schema: "http://json-schema.org/draft-04/schema#",
title: "Product",
description: "A product from catalog",
type: "object",
properties: {
id: {
description: "The unique identifier for a product",
type: "integer",
},
},
required: ["id"],
},
null,
2
)
);
const darkmodeEnabled = useConfig(state => (state.darkmodeEnabled ? "vs-dark" : "light"));
const onApply = () => {
if (!isPremium) return showPremiumModal(true);
try {
const parsedSchema = JSON.parse(schema);
setJsonSchema(parsedSchema);
toast.success("Applied schema!");
onClose();
} catch (error) {
toast.error("Invalid Schema");
}
};
const onClear = () => {
setJsonSchema(null);
setSchema("");
toast("Disabled JSON Schema");
onClose();
};
return (
<Modal title="JSON Schema" size="lg" opened={opened} onClose={onClose} centered>
<Stack py="sm">
<Text fz="sm">Any validation failures are shown at the bottom toolbar of pane.</Text>
<Anchor fz="sm" target="_blank" href="https://niem.github.io/json/sample-schema/">
View Examples <VscLinkExternal />
</Anchor>
<Editor
value={schema ?? ""}
theme={darkmodeEnabled}
onChange={e => setSchema(e!)}
height={300}
language="json"
options={{
formatOnPaste: true,
formatOnType: true,
minimap: {
enabled: false,
},
}}
/>
<Divider my="xs" />
<Group p="0" justify="right">
<Button variant="outline" onClick={onClear} disabled={!schema}>
Clear
</Button>
<Button onClick={onApply} disabled={!schema} rightSection={!isPremium && <VscLock />}>
Apply
</Button>
</Group>
</Stack>
</Modal>
);
};

@ -0,0 +1,59 @@
import React from "react";
import { useRouter } from "next/router";
import {
TextInput,
Stack,
Modal,
Button,
CopyButton,
Tooltip,
ActionIcon,
Text,
ModalProps,
} from "@mantine/core";
import { FiExternalLink } from "react-icons/fi";
import { MdCheck, MdCopyAll } from "react-icons/md";
export const ShareModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const { query } = useRouter();
const shareURL = `https://jsoncrack.com/editor?json=${query.json}`;
return (
<Modal title="Create a Share Link" opened={opened} onClose={onClose} centered>
<Stack py="sm">
<Text fz="sm" fw={700}>
Share Link
</Text>
<TextInput
value={shareURL}
type="url"
readOnly
rightSection={
<CopyButton value={shareURL} timeout={2000}>
{({ copied, copy }) => (
<Tooltip label={copied ? "Copied" : "Copy"} withArrow position="right">
<ActionIcon color={copied ? "teal" : "gray"} onClick={copy}>
{copied ? <MdCheck size="1rem" /> : <MdCopyAll size="1rem" />}
</ActionIcon>
</Tooltip>
)}
</CopyButton>
}
/>
<Text fz="sm" fw={700}>
Embed into your website
</Text>
<Button
component="a"
color="green"
target="_blank"
href="/docs"
leftSection={<FiExternalLink />}
fullWidth
>
Learn How to Embed
</Button>
</Stack>
</Modal>
);
};

@ -0,0 +1,112 @@
import React from "react";
import { Stack, Modal, ModalProps, Select, LoadingOverlay } from "@mantine/core";
import { CodeHighlight } from "@mantine/code-highlight";
import useJson from "src/store/useJson";
enum Language {
TypeScript = "typescript",
TypeScript_Combined = "typescript/typealias",
Go = "go",
JSON_SCHEMA = "json_schema",
Kotlin = "kotlin",
Rust = "rust",
}
const typeOptions = [
{
label: "TypeScript",
value: Language.TypeScript,
lang: "typescript",
},
{
label: "TypeScript (combined)",
value: Language.TypeScript_Combined,
lang: "typescript",
},
{
label: "Go",
value: Language.Go,
lang: "go",
},
{
label: "JSON Schema",
value: Language.JSON_SCHEMA,
lang: "json",
},
{
label: "Kotlin",
value: Language.Kotlin,
lang: "kotlin",
},
{
label: "Rust",
value: Language.Rust,
lang: "rust",
},
];
export const TypeModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const getJson = useJson(state => state.getJson);
const [type, setType] = React.useState("");
const [selectedType, setSelectedType] = React.useState<Language>(Language.TypeScript);
const [loading, setLoading] = React.useState(false);
const editorLanguage = React.useMemo(() => {
return typeOptions[typeOptions.findIndex(o => o.value === selectedType)]?.lang;
}, [selectedType]);
const transformer = React.useCallback(
async ({ value }) => {
const { run } = await import("json_typegen_wasm");
return run(
"Root",
value,
JSON.stringify({
output_mode: selectedType,
})
);
},
[selectedType]
);
React.useEffect(() => {
if (opened) {
try {
setLoading(true);
if (selectedType === Language.Go) {
import("src/lib/utils/json2go").then(jtg => {
import("gofmt.js").then(gofmt => {
const types = jtg.default(getJson());
setType(gofmt.default(types.go));
});
});
} else {
transformer({ value: getJson() }).then(setType);
}
} catch (error) {
console.error(error);
} finally {
setLoading(false);
}
}
}, [getJson, opened, selectedType, transformer]);
return (
<Modal title="Generate Types" size="md" opened={opened} onClose={onClose} centered>
<Stack pos="relative">
<Select
value={selectedType}
data={typeOptions}
onChange={e => setSelectedType(e as Language)}
/>
<LoadingOverlay visible={loading} />
<CodeHighlight
language={editorLanguage}
copyLabel="Copy to clipboard"
copiedLabel="Copied to clipboard"
code={type}
/>
</Stack>
</Modal>
);
};

@ -0,0 +1,34 @@
export { CloudModal } from "./CloudModal";
export { ClearModal } from "./ClearModal";
export { DownloadModal } from "./DownloadModal";
export { ImportModal } from "./ImportModal";
export { AccountModal } from "./AccountModal";
export { NodeModal } from "./NodeModal";
export { ShareModal } from "./ShareModal";
export { LoginModal } from "./LoginModal";
export { PremiumModal } from "./PremiumModal";
export { JWTModal } from "./JWTModal";
export { SchemaModal } from "./SchemaModal";
export { CancelPremiumModal } from "./CancelPremiumModal";
export { ReviewModal } from "./ReviewModal";
export { JQModal } from "./JQModal";
export { TypeModal } from "./TypeModal";
type Modal =
| "clear"
| "cloud"
| "download"
| "import"
| "account"
| "node"
| "share"
| "login"
| "premium"
| "jwt"
| "schema"
| "cancelPremium"
| "review"
| "jq"
| "type";
export type { Modal };

@ -0,0 +1,60 @@
import React from "react";
import Link from "next/link";
import { Menu, Avatar, Text } from "@mantine/core";
import { useUser as useSupabaseUser } from "@supabase/auth-helpers-react";
import { VscSignIn, VscFeedback, VscSignOut } from "react-icons/vsc";
import useModal from "src/store/useModal";
import useUser from "src/store/useUser";
import * as Styles from "./styles";
export const AccountMenu = () => {
const user = useSupabaseUser();
const logout = useUser(state => state.logout);
const setVisible = useModal(state => state.setVisible);
return (
<Menu shadow="md" trigger="click" closeOnItemClick={false} withArrow>
<Menu.Target>
<Styles.StyledToolElement>
<Avatar color={user ? "teal" : "indigo"} variant="filled" size={20} radius="xl">
{user && "JC"}
</Avatar>
</Styles.StyledToolElement>
</Menu.Target>
<Menu.Dropdown>
{user ? (
<Menu.Item
leftSection={
<Avatar color="indigo" alt={user.user_metadata?.name} size={20} radius="xl" />
}
onClick={() => setVisible("account")(true)}
closeMenuOnClick
>
<Text size="xs">{user.user_metadata?.name ?? "Account"}</Text>
</Menu.Item>
) : (
<Link href="/sign-in">
<Menu.Item leftSection={<VscSignIn />}>
<Text size="xs">Sign in</Text>
</Menu.Item>
</Link>
)}
{user && (
<>
<Menu.Divider />
<Menu.Item
leftSection={<VscFeedback />}
onClick={() => setVisible("review")(true)}
closeMenuOnClick
>
<Text size="xs">Feedback</Text>
</Menu.Item>
<Menu.Item leftSection={<VscSignOut />} onClick={() => logout()} closeMenuOnClick>
<Text size="xs">Log out</Text>
</Menu.Item>
</>
)}
</Menu.Dropdown>
</Menu>
);
};

@ -0,0 +1,29 @@
import React from "react";
import { Flex } from "@mantine/core";
import { JSONCrackLogo } from "src/layout/JsonCrackLogo";
import { isIframe } from "src/lib/utils/widget";
import * as Styles from "./styles";
export const Logo = () => {
const [logoURL, setLogoURL] = React.useState("");
React.useEffect(() => {
if (typeof window !== "undefined") {
const url = !isIframe()
? "https://jsoncrack.com"
: window.location.href.replace("widget", "editor");
setLogoURL(url);
}
}, []);
if (!logoURL) return null;
return (
<Styles.StyledToolElement title="JSON Crack">
<Flex gap="xs" align="center" justify="center">
<JSONCrackLogo fontSize="1.2em" href={logoURL} target={isIframe() ? "_blank" : "_parent"} />
</Flex>
</Styles.StyledToolElement>
);
};

@ -0,0 +1,85 @@
import React from "react";
import { Menu, Text, Flex, Badge } from "@mantine/core";
import { BsCheck2 } from "react-icons/bs";
import { MdSettings } from "react-icons/md";
import useConfig from "src/store/useConfig";
import * as Styles from "./styles";
export const OptionsMenu = () => {
const toggleGestures = useConfig(state => state.toggleGestures);
const toggleChildrenCount = useConfig(state => state.toggleChildrenCount);
const toggleDarkMode = useConfig(state => state.toggleDarkMode);
const toggleRulers = useConfig(state => state.toggleRulers);
const toggleCollapseButton = useConfig(state => state.toggleCollapseButton);
const toggleImagePreview = useConfig(state => state.toggleImagePreview);
const toggleAI = useConfig(state => state.toggleAI);
const gesturesEnabled = useConfig(state => state.gesturesEnabled);
const childrenCountVisible = useConfig(state => state.childrenCountVisible);
const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);
const rulersEnabled = useConfig(state => state.rulersEnabled);
const collapseButtonVisible = useConfig(state => state.collapseButtonVisible);
const imagePreviewEnabled = useConfig(state => state.imagePreviewEnabled);
const aiEnabled = useConfig(state => state.aiEnabled);
return (
<Menu shadow="md" trigger="click" closeOnItemClick={false} withArrow>
<Menu.Target>
<Styles.StyledToolElement>
<Flex gap={4}>
<MdSettings size="18" />
</Flex>
</Styles.StyledToolElement>
</Menu.Target>
<Menu.Dropdown>
<Menu.Item
leftSection={<BsCheck2 opacity={rulersEnabled ? 100 : 0} />}
onClick={() => toggleRulers(!rulersEnabled)}
>
<Text size="xs">Rulers</Text>
</Menu.Item>
<Menu.Item
leftSection={<BsCheck2 opacity={gesturesEnabled ? 100 : 0} />}
onClick={() => toggleGestures(!gesturesEnabled)}
>
<Text size="xs">Trackpad Gestures</Text>
</Menu.Item>
<Menu.Item
leftSection={<BsCheck2 opacity={childrenCountVisible ? 100 : 0} />}
onClick={() => toggleChildrenCount(!childrenCountVisible)}
>
<Text size="xs">Item Count</Text>
</Menu.Item>
<Menu.Item
leftSection={<BsCheck2 opacity={imagePreviewEnabled ? 100 : 0} />}
onClick={() => toggleImagePreview(!imagePreviewEnabled)}
>
<Text size="xs">Image Link Preview</Text>
</Menu.Item>
<Menu.Item
leftSection={<BsCheck2 opacity={collapseButtonVisible ? 100 : 0} />}
onClick={() => toggleCollapseButton(!collapseButtonVisible)}
>
<Text size="xs">Show Expand/Collapse</Text>
</Menu.Item>
<Menu.Item
leftSection={<BsCheck2 opacity={darkmodeEnabled ? 100 : 0} />}
onClick={() => toggleDarkMode(!darkmodeEnabled)}
>
<Text size="xs">Dark Mode</Text>
</Menu.Item>
<Menu.Item
leftSection={<BsCheck2 opacity={aiEnabled ? 100 : 0} />}
onClick={() => toggleAI(!aiEnabled)}
>
<Text size="xs">
JSON Crack AI{" "}
<Badge ml={2} size="xs" variant="light" radius={2}>
Alpha
</Badge>
</Text>
</Menu.Item>
</Menu.Dropdown>
</Menu>
);
};

@ -0,0 +1,45 @@
import React from "react";
import { Menu, Flex } from "@mantine/core";
import { CgChevronDown } from "react-icons/cg";
import { SiJsonwebtokens } from "react-icons/si";
import { VscSearchFuzzy, VscJson, VscGroupByRefType } from "react-icons/vsc";
import useModal from "src/store/useModal";
import * as Styles from "./styles";
export const ToolsMenu = () => {
const setVisible = useModal(state => state.setVisible);
return (
<Menu shadow="md" withArrow>
<Menu.Target>
<Styles.StyledToolElement>
<Flex align="center" gap={3}>
Tools <CgChevronDown />
</Flex>
</Styles.StyledToolElement>
</Menu.Target>
<Menu.Dropdown>
<Menu.Item fz={12} leftSection={<VscSearchFuzzy />} onClick={() => setVisible("jq")(true)}>
JSON Query (jq)
</Menu.Item>
<Menu.Item fz={12} leftSection={<VscJson />} onClick={() => setVisible("schema")(true)}>
JSON Schema
</Menu.Item>
<Menu.Item
fz={12}
leftSection={<SiJsonwebtokens />}
onClick={() => setVisible("jwt")(true)}
>
Decode JWT
</Menu.Item>
<Menu.Item
fz={12}
leftSection={<VscGroupByRefType />}
onClick={() => setVisible("type")(true)}
>
Generate Type
</Menu.Item>
</Menu.Dropdown>
</Menu>
);
};

@ -0,0 +1,142 @@
import React from "react";
import { Menu, Flex, Text } from "@mantine/core";
import { useHotkeys } from "@mantine/hooks";
import ReactGA from "react-ga4";
import toast from "react-hot-toast";
import { CgChevronDown, CgArrowsShrinkH, CgArrowsMergeAltH } from "react-icons/cg";
import { VscExpandAll, VscCollapseAll, VscTarget } from "react-icons/vsc";
import useToggleHide from "src/hooks/useToggleHide";
import { getNextDirection } from "src/lib/utils/graph/getNextDirection";
import useGraph from "src/store/useGraph";
import * as Styles from "./styles";
function rotateLayout(direction: "LEFT" | "RIGHT" | "DOWN" | "UP") {
if (direction === "LEFT") return 90;
if (direction === "UP") return 180;
if (direction === "RIGHT") return 270;
return 360;
}
export const ViewMenu = () => {
const { validateHiddenNodes } = useToggleHide();
const [coreKey, setCoreKey] = React.useState("CTRL");
const toggleFold = useGraph(state => state.toggleFold);
const setDirection = useGraph(state => state.setDirection);
const direction = useGraph(state => state.direction);
const expandGraph = useGraph(state => state.expandGraph);
const collapseGraph = useGraph(state => state.collapseGraph);
const focusFirstNode = useGraph(state => state.focusFirstNode);
const foldNodes = useGraph(state => state.foldNodes);
const graphCollapsed = useGraph(state => state.graphCollapsed);
const toggleFoldNodes = () => {
toggleFold(!foldNodes);
toast(`${foldNodes ? "Unfolded" : "Folded"} nodes`);
};
const toggleDirection = () => {
const nextDirection = getNextDirection(direction || "RIGHT");
if (setDirection) setDirection(nextDirection);
};
const toggleExpandCollapseGraph = () => {
if (graphCollapsed) expandGraph();
else collapseGraph();
validateHiddenNodes();
toast(`${graphCollapsed ? "Expanded" : "Collapsed"} graph.`);
};
useHotkeys([
["mod+shift+d", toggleDirection],
["mod+shift+f", toggleFoldNodes],
["mod+shift+c", toggleExpandCollapseGraph],
[
"mod+f",
() => {
const input = document.querySelector("#search-node") as HTMLInputElement;
input.focus();
},
],
]);
React.useEffect(() => {
if (typeof window !== "undefined") {
setCoreKey(navigator.userAgent.indexOf("Mac OS X") ? "⌘" : "CTRL");
}
}, []);
return (
<Menu shadow="md" closeOnItemClick={false} withArrow>
<Menu.Target>
<Styles.StyledToolElement>
<Flex align="center" gap={3}>
View <CgChevronDown />
</Flex>
</Styles.StyledToolElement>
</Menu.Target>
<Menu.Dropdown>
<Menu.Item
fz={12}
onClick={() => {
toggleDirection();
ReactGA.event({
action: "toggle_layout_direction",
category: "User",
label: "Tools",
});
}}
leftSection={<Styles.StyledFlowIcon rotate={rotateLayout(direction || "RIGHT")} />}
rightSection={
<Text ml="md" fz={10} c="dimmed">
{coreKey} Shift D
</Text>
}
>
Rotate Layout
</Menu.Item>
<Menu.Item
fz={12}
onClick={() => {
toggleFoldNodes();
ReactGA.event({
action: "toggle_fold_nodes",
category: "User",
label: "Tools",
});
}}
leftSection={foldNodes ? <CgArrowsShrinkH /> : <CgArrowsMergeAltH />}
rightSection={
<Text ml="md" fz={10} c="dimmed">
{coreKey} Shift F
</Text>
}
>
{foldNodes ? "Unfold" : "Fold"} Nodes
</Menu.Item>
<Menu.Item
fz={12}
onClick={() => {
toggleExpandCollapseGraph();
ReactGA.event({
action: "toggle_collapse_nodes",
category: "User",
label: "Tools",
});
}}
leftSection={graphCollapsed ? <VscExpandAll /> : <VscCollapseAll />}
rightSection={
<Text ml="md" fz={10} c="dimmed">
{coreKey} Shift C
</Text>
}
>
{graphCollapsed ? "Expand" : "Collapse"} Nodes
</Menu.Item>
<Menu.Item fz={12} onClick={focusFirstNode} leftSection={<VscTarget />}>
Focus to First Node
</Menu.Item>
</Menu.Dropdown>
</Menu>
);
};

@ -0,0 +1,33 @@
import React from "react";
import { Menu, Flex, SegmentedControl } from "@mantine/core";
import { CgChevronDown } from "react-icons/cg";
import { ViewMode } from "src/enums/viewMode.enum";
import useConfig from "src/store/useConfig";
import * as Styles from "./styles";
export const ViewModeMenu = () => {
const viewMode = useConfig(state => state.viewMode);
const setViewMode = useConfig(state => state.setViewMode);
return (
<Menu trigger="click" shadow="md" withArrow>
<Menu.Target>
<Styles.StyledToolElement title="View Mode">
<Flex align="center" gap={3}>
View Mode <CgChevronDown />
</Flex>
</Styles.StyledToolElement>
</Menu.Target>
<Menu.Dropdown>
<SegmentedControl
value={viewMode}
onChange={e => setViewMode(e as ViewMode)}
data={[
{ value: ViewMode.Graph, label: "Graph" },
{ value: ViewMode.Tree, label: "Tree" },
]}
/>
</Menu.Dropdown>
</Menu>
);
};

@ -0,0 +1,68 @@
import React from "react";
import { Menu, Flex, Input, Text } from "@mantine/core";
import { getHotkeyHandler, useHotkeys } from "@mantine/hooks";
import { CgChevronDown } from "react-icons/cg";
import useGraph from "src/store/useGraph";
import * as Styles from "./styles";
export const ZoomMenu = () => {
const zoomIn = useGraph(state => state.zoomIn);
const zoomOut = useGraph(state => state.zoomOut);
const centerView = useGraph(state => state.centerView);
const setZoomFactor = useGraph(state => state.setZoomFactor);
const zoomFactor = useGraph(state => state.viewPort?.zoomFactor || 1);
const [tempZoomValue, setTempZoomValue] = React.useState(zoomFactor);
React.useEffect(() => {
if (!Number.isNaN(zoomFactor)) setTempZoomValue(zoomFactor);
}, [zoomFactor]);
useHotkeys([
["shift+Digit0", () => setZoomFactor(100 / 100)],
["shift+Digit1", centerView],
]);
return (
<Menu shadow="md" trigger="click" closeOnItemClick={false} withArrow>
<Menu.Target>
<Styles.StyledToolElement>
<Flex gap={4} align="center">
{Math.round(zoomFactor * 100)}%
<CgChevronDown />
</Flex>
</Styles.StyledToolElement>
</Menu.Target>
<Menu.Dropdown>
<Menu.Item>
<Input
type="number"
value={Math.round(tempZoomValue * 100)}
onChange={e => setTempZoomValue(e.currentTarget.valueAsNumber / 100)}
onKeyDown={getHotkeyHandler([["Enter", () => setZoomFactor(tempZoomValue)]])}
size="xs"
rightSection="%"
/>
</Menu.Item>
<Menu.Item rightSection="+" onClick={zoomIn}>
<Text size="xs">Zoom in</Text>
</Menu.Item>
<Menu.Item rightSection="-" onClick={zoomOut}>
<Text size="xs">Zoom out</Text>
</Menu.Item>
<Menu.Item rightSection="⇧ 1" onClick={centerView}>
<Text size="xs">Zoom to fit</Text>
</Menu.Item>
<Menu.Item onClick={() => setZoomFactor(50 / 100)}>
<Text size="xs">Zoom to %50</Text>
</Menu.Item>
<Menu.Item rightSection="⇧ 0" onClick={() => setZoomFactor(100 / 100)}>
<Text size="xs">Zoom to %100</Text>
</Menu.Item>
<Menu.Item onClick={() => setZoomFactor(200 / 100)}>
<Text size="xs">Zoom to %200</Text>
</Menu.Item>
</Menu.Dropdown>
</Menu>
);
};

@ -0,0 +1,125 @@
import React from "react";
import { Flex, Group, Select, Text } from "@mantine/core";
import toast from "react-hot-toast";
import { AiOutlineFullscreen } from "react-icons/ai";
import { AiFillGift } from "react-icons/ai";
import { FiDownload } from "react-icons/fi";
import { SearchInput } from "src/components/SearchInput";
import { FileFormat } from "src/enums/file.enum";
import { JSONCrackLogo } from "src/layout/JsonCrackLogo";
import useFile from "src/store/useFile";
import useJson from "src/store/useJson";
import useModal from "src/store/useModal";
import useUser from "src/store/useUser";
import { AccountMenu } from "./AccountMenu";
import { Logo } from "./Logo";
import { OptionsMenu } from "./OptionsMenu";
import { ToolsMenu } from "./ToolsMenu";
import { ViewMenu } from "./ViewMenu";
import { ViewModeMenu } from "./ViewModeMenu";
import { ZoomMenu } from "./ZoomMenu";
import * as Styles from "./styles";
function fullscreenBrowser() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen().catch(() => {
toast.error("Unable to enter fullscreen mode.");
});
} else if (document.exitFullscreen) {
document.exitFullscreen();
}
}
export const Toolbar: React.FC<{ isWidget?: boolean }> = ({ isWidget = false }) => {
const getJson = useJson(state => state.getJson);
const setVisible = useModal(state => state.setVisible);
const setFormat = useFile(state => state.setFormat);
const format = useFile(state => state.format);
const premium = useUser(state => state.premium);
const handleSave = () => {
const a = document.createElement("a");
const file = new Blob([getJson()], { type: "text/plain" });
a.href = window.URL.createObjectURL(file);
a.download = "jsoncrack.json";
a.click();
};
return (
<Styles.StyledTools>
{isWidget && <Logo />}
{!isWidget && (
<Group gap="xs" justify="left" w="100%" style={{ flexWrap: "nowrap" }}>
<Styles.StyledToolElement title="JSON Crack">
<Flex gap="xs" align="center" justify="center">
<JSONCrackLogo fontSize="1.2em" />
</Flex>
</Styles.StyledToolElement>
<Select
defaultValue="json"
size="xs"
value={format}
onChange={e => setFormat(e as FileFormat)}
miw={80}
w={120}
data={[
{ value: FileFormat.JSON, label: "JSON" },
{ value: FileFormat.YAML, label: "YAML" },
{ value: FileFormat.XML, label: "XML" },
{ value: FileFormat.TOML, label: "TOML" },
{ value: FileFormat.CSV, label: "CSV" },
]}
/>
<ViewModeMenu />
<Styles.StyledToolElement title="Import File" onClick={() => setVisible("import")(true)}>
Import
</Styles.StyledToolElement>
<ViewMenu />
<ToolsMenu />
<Styles.StyledToolElement title="Cloud" onClick={() => setVisible("cloud")(true)}>
Cloud
</Styles.StyledToolElement>
<Styles.StyledToolElement title="Download as File" onClick={handleSave}>
Download
</Styles.StyledToolElement>
</Group>
)}
<Group gap="xs" justify="right" w="100%" style={{ flexWrap: "nowrap" }}>
{!premium && !isWidget && (
<Styles.StyledToolElement onClick={() => setVisible("premium")(true)}>
<Text display="flex" c="teal" fz="xs" fw="bold" style={{ textAlign: "center", gap: 4 }}>
<AiFillGift size="18" />
Get Premium
</Text>
</Styles.StyledToolElement>
)}
<SearchInput />
{!isWidget && (
<>
<Styles.StyledToolElement
title="Save as Image"
onClick={() => setVisible("download")(true)}
>
<FiDownload size="18" />
</Styles.StyledToolElement>
<ZoomMenu />
<AccountMenu />
<OptionsMenu />
<Styles.StyledToolElement
title="Fullscreen"
$hide={isWidget}
onClick={fullscreenBrowser}
>
<AiOutlineFullscreen size="18" />
</Styles.StyledToolElement>
</>
)}
</Group>
</Styles.StyledTools>
);
};

@ -0,0 +1,46 @@
import styled from "styled-components";
import { TiFlowMerge } from "react-icons/ti";
export const StyledTools = styled.div`
position: relative;
display: flex;
width: 100%;
align-items: center;
gap: 4px;
justify-content: space-between;
height: 40px;
padding: 4px 8px;
background: ${({ theme }) => theme.TOOLBAR_BG};
color: ${({ theme }) => theme.SILVER};
z-index: 36;
border-bottom: 1px solid ${({ theme }) => theme.SILVER_DARK};
@media only screen and (max-width: 320px) {
display: none;
}
`;
export const StyledToolElement = styled.button<{ $hide?: boolean }>`
display: ${({ $hide }) => ($hide ? "none" : "grid")};
place-content: center;
font-size: 12px;
background: none;
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
padding: 6px;
border-radius: 3px;
white-space: nowrap;
&:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.1) 0 0);
}
&:hover {
color: ${({ theme }) => theme.INTERACTIVE_HOVER};
opacity: 1;
box-shadow: none;
}
`;
export const StyledFlowIcon = styled(TiFlowMerge)<{ rotate: number }>`
transform: rotate(${({ rotate }) => `${rotate}deg`});
`;

@ -0,0 +1,13 @@
import React from "react";
import dynamic from "next/dynamic";
import { EdgeProps } from "reaflow/dist/symbols/Edge";
const Edge = dynamic(() => import("reaflow").then(r => r.Edge), {
ssr: false,
});
const CustomEdgeWrapper = (props: EdgeProps) => {
return <Edge containerClassName={`edge-${props.id}`} {...props} />;
};
export const CustomEdge = React.memo(CustomEdgeWrapper);

@ -0,0 +1,40 @@
import React from "react";
import { CustomNodeProps } from "src/containers/Views/GraphView/CustomNode";
import { TextRenderer } from "./TextRenderer";
import * as Styled from "./styles";
type Value = [string, string];
type RowProps = {
val: Value;
x: number;
y: number;
index: number;
};
const Row = ({ val, x, y, index }: RowProps) => {
const key = JSON.stringify(val);
const rowKey = JSON.stringify(val[0]).replaceAll('"', "");
const rowValue = JSON.stringify(val[1]);
return (
<Styled.StyledRow $value={rowValue} data-key={key} data-x={x} data-y={y + index * 17.8}>
<Styled.StyledKey $type="object">{rowKey}: </Styled.StyledKey>
<TextRenderer>{rowValue}</TextRenderer>
</Styled.StyledRow>
);
};
const Node: React.FC<CustomNodeProps> = ({ node, x, y }) => (
<Styled.StyledForeignObject width={node.width} height={node.height} x={0} y={0} $isObject>
{(node.text as Value[]).map((val, idx) => (
<Row val={val} index={idx} x={x} y={y} key={idx} />
))}
</Styled.StyledForeignObject>
);
function propsAreEqual(prev: CustomNodeProps, next: CustomNodeProps) {
return String(prev.node.text) === String(next.node.text) && prev.node.width === next.node.width;
}
export const ObjectNode = React.memo(Node, propsAreEqual);

@ -0,0 +1,111 @@
import React from "react";
import styled from "styled-components";
import { MdLink, MdLinkOff } from "react-icons/md";
import { CustomNodeProps } from "src/containers/Views/GraphView/CustomNode";
import useToggleHide from "src/hooks/useToggleHide";
import { isContentImage } from "src/lib/utils/graph/calculateNodeSize";
import useConfig from "src/store/useConfig";
import useGraph from "src/store/useGraph";
import { TextRenderer } from "./TextRenderer";
import * as Styled from "./styles";
const StyledExpand = styled.button`
pointer-events: all;
display: inline-flex;
align-items: center;
justify-content: center;
color: ${({ theme }) => theme.TEXT_NORMAL};
background: rgba(0, 0, 0, 0.1);
height: 100%;
width: 40px;
border-left: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
&:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.1) 0 0);
}
`;
const StyledTextNodeWrapper = styled.span<{ $hasCollapse: boolean }>`
display: flex;
justify-content: ${({ $hasCollapse }) => ($hasCollapse ? "space-between" : "center")};
align-items: center;
height: 100%;
width: 100%;
`;
const StyledImageWrapper = styled.div`
padding: 5px;
`;
const StyledImage = styled.img`
border-radius: 2px;
object-fit: contain;
background: ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
`;
const Node: React.FC<CustomNodeProps> = ({ node, x, y, hasCollapse = false }) => {
const {
id,
text,
width,
height,
data: { isParent, childrenCount, type },
} = node;
const { validateHiddenNodes } = useToggleHide();
const collapseButtonVisible = useConfig(state => state.collapseButtonVisible);
const childrenCountVisible = useConfig(state => state.childrenCountVisible);
const imagePreviewEnabled = useConfig(state => state.imagePreviewEnabled);
const expandNodes = useGraph(state => state.expandNodes);
const collapseNodes = useGraph(state => state.collapseNodes);
const isExpanded = useGraph(state => state.collapsedParents.includes(id));
const isImage = imagePreviewEnabled && isContentImage(text as string);
const value = JSON.stringify(text).replaceAll('"', "");
const handleExpand = (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
if (!isExpanded) collapseNodes(id);
else expandNodes(id);
validateHiddenNodes();
};
return (
<Styled.StyledForeignObject width={width} height={height} x={0} y={0}>
{isImage ? (
<StyledImageWrapper>
<StyledImage src={text as string} width="70" height="70" loading="lazy" />
</StyledImageWrapper>
) : (
<StyledTextNodeWrapper
data-x={x}
data-y={y}
data-key={JSON.stringify(text)}
$hasCollapse={isParent && collapseButtonVisible}
>
<Styled.StyledKey $value={value} $parent={isParent} $type={type}>
<TextRenderer>{value}</TextRenderer>
</Styled.StyledKey>
{isParent && childrenCount > 0 && childrenCountVisible && (
<Styled.StyledChildrenCount>({childrenCount})</Styled.StyledChildrenCount>
)}
{isParent && hasCollapse && collapseButtonVisible && (
<StyledExpand aria-label="Expand" onClick={handleExpand}>
{isExpanded ? <MdLinkOff size={18} /> : <MdLink size={18} />}
</StyledExpand>
)}
</StyledTextNodeWrapper>
)}
</Styled.StyledForeignObject>
);
};
function propsAreEqual(prev: CustomNodeProps, next: CustomNodeProps) {
return (
prev.node.text === next.node.text &&
prev.node.width === next.node.width &&
prev.node.data.childrenCount === next.node.data.childrenCount
);
}
export const TextNode = React.memo(Node, propsAreEqual);

@ -0,0 +1,41 @@
import React from "react";
import { ColorSwatch } from "@mantine/core";
import styled from "styled-components";
import * as Styled from "./styles";
const StyledRow = styled.span`
display: inline-flex;
align-items: center;
overflow: hidden;
gap: 4px;
vertical-align: middle;
`;
function isColorFormat(colorString: string) {
const hexCodeRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
const rgbRegex = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/;
const rgbaRegex = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0\.\d+)\s*\)$/;
return (
hexCodeRegex.test(colorString) || rgbRegex.test(colorString) || rgbaRegex.test(colorString)
);
}
const isURL =
/(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/gi;
export const TextRenderer: React.FC<{ children: string }> = ({ children }) => {
if (isURL.test(children?.replaceAll('"', ""))) {
return <Styled.StyledLinkItUrl>{children}</Styled.StyledLinkItUrl>;
}
if (isColorFormat(children?.replaceAll('"', ""))) {
return (
<StyledRow>
<ColorSwatch size={12} radius={4} mr={4} color={children?.replaceAll('"', "")} />
{children?.replaceAll('"', "")}
</StyledRow>
);
}
return <>{children}</>;
};

@ -0,0 +1,59 @@
import React from "react";
import dynamic from "next/dynamic";
import { NodeProps } from "reaflow";
import useGraph from "src/store/useGraph";
import useModal from "src/store/useModal";
import { NodeData } from "src/types/graph";
import { ObjectNode } from "./ObjectNode";
import { TextNode } from "./TextNode";
const Node = dynamic(() => import("reaflow").then(r => r.Node), {
ssr: false,
});
export interface CustomNodeProps {
node: NodeData;
x: number;
y: number;
hasCollapse?: boolean;
}
const rootProps = {
rx: 50,
ry: 50,
};
const CustomNodeWrapper = (nodeProps: NodeProps<NodeData["data"]>) => {
const data = nodeProps.properties.data;
const setSelectedNode = useGraph(state => state.setSelectedNode);
const setVisible = useModal(state => state.setVisible);
const handleNodeClick = React.useCallback(
(_: React.MouseEvent<SVGGElement, MouseEvent>, data: NodeData) => {
if (setSelectedNode) setSelectedNode(data);
setVisible("node")(true);
},
[setSelectedNode, setVisible]
);
return (
<Node
{...nodeProps}
{...(data?.isEmpty && rootProps)}
onClick={handleNodeClick as any}
animated={false}
label={null as any}
>
{({ node, x, y }) => {
if (Array.isArray(nodeProps.properties.text)) {
if (data?.isEmpty) return null;
return <ObjectNode node={node as NodeData} x={x} y={y} />;
}
return <TextNode node={node as NodeData} hasCollapse={!!data?.childrenCount} x={x} y={y} />;
}}
</Node>
);
};
export const CustomNode = React.memo(CustomNodeWrapper);

@ -0,0 +1,99 @@
import styled, { DefaultTheme } from "styled-components";
import { LinkItUrl } from "react-linkify-it";
import { firaMono } from "src/constants/fonts";
type TextColorFn = {
theme: DefaultTheme;
$type?: string;
$value?: string;
$parent?: boolean;
};
function getTextColor({ $value, $type, $parent, theme }: TextColorFn) {
// per type
if ($parent && $type === "array") return theme.NODE_COLORS.PARENT_ARR;
if ($parent && $type === "object") return theme.NODE_COLORS.PARENT_OBJ;
if ($type === "object") return theme.NODE_COLORS.NODE_KEY;
if ($type === "array") return theme.NODE_COLORS.NODE_VALUE;
// per value
if ($value && !Number.isNaN(+$value)) return theme.NODE_COLORS.INTEGER;
if ($value === "true") return theme.NODE_COLORS.BOOL.TRUE;
if ($value === "false") return theme.NODE_COLORS.BOOL.FALSE;
if ($value === "null") return theme.NODE_COLORS.NULL;
// default
return theme.NODE_COLORS.NODE_VALUE;
}
export const StyledLinkItUrl = styled(LinkItUrl)`
text-decoration: underline;
pointer-events: all;
`;
export const StyledForeignObject = styled.foreignObject<{ $isObject?: boolean }>`
text-align: ${({ $isObject }) => !$isObject && "center"};
color: ${({ theme }) => theme.NODE_COLORS.TEXT};
font-family: ${firaMono.style.fontFamily};
font-size: 12px;
font-weight: 500;
overflow: hidden;
pointer-events: none;
&.searched {
background: rgba(27, 255, 0, 0.1);
border: 2px solid ${({ theme }) => theme.TEXT_POSITIVE};
border-radius: 2px;
box-sizing: border-box;
}
.highlight {
background: rgba(255, 214, 0, 0.3);
}
.renderVisible {
display: flex;
justify-content: center;
align-items: center;
font-size: 12px;
width: 100%;
height: 100%;
overflow: hidden;
cursor: pointer;
}
`;
export const StyledKey = styled.span<{ $parent?: boolean; $type: string; $value?: string }>`
display: inline;
flex: 1;
color: ${({ theme, $type, $parent = false, $value = "" }) =>
getTextColor({ $parent, $type, $value, theme })};
font-size: ${({ $parent }) => $parent && "14px"};
overflow: hidden;
text-overflow: ellipsis;
padding: ${({ $type }) => $type !== "object" && "10px"};
white-space: nowrap;
`;
export const StyledRow = styled.span<{ $value: string }>`
padding: 0 10px;
color: ${({ theme, $value }) => getTextColor({ $value, theme })};
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&:first-of-type {
padding-top: 10px;
}
&:last-of-type {
padding-bottom: 10px;
}
`;
export const StyledChildrenCount = styled.span`
color: ${({ theme }) => theme.NODE_COLORS.CHILD_COUNT};
padding: 10px;
margin-left: -15px;
`;

@ -0,0 +1,32 @@
import React from "react";
import styled from "styled-components";
const StyledErrorView = styled.div`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
`;
const StyledTitle = styled.h2`
color: ${({ theme }) => theme.TEXT_DANGER};
`;
const StyledInfo = styled.p`
width: 60%;
text-align: center;
color: ${({ theme }) => theme.TEXT_NORMAL};
`;
export const ErrorView = () => (
<StyledErrorView>
<StyledTitle>JSON Crack is unable to handle this file!</StyledTitle>
<StyledInfo>
We apologize for the problem you encountered. We are doing our best as an Open Source
community to improve our service. Unfortunately, JSON Crack is currently unable to handle such
a large file. Please try the tree view from View Modes to see if it works.
</StyledInfo>
</StyledErrorView>
);

@ -0,0 +1,202 @@
import React from "react";
import { Button, List, ThemeIcon, Title } from "@mantine/core";
import styled from "styled-components";
import { BsCheck } from "react-icons/bs";
import { JSONCrackLogo } from "src/layout/JsonCrackLogo";
const StyledPremiumView = styled.div`
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background: #020015;
img {
filter: drop-shadow(2px 2px 1px black);
}
.glowing {
position: relative;
min-width: 700px;
height: 550px;
margin: -150px;
transform-origin: right;
animation: colorChange 5s linear infinite;
}
.glowing:nth-child(even) {
transform-origin: left;
}
@keyframes colorChange {
0% {
filter: hue-rotate(0deg);
transform: rotate(0deg);
}
100% {
filter: hue-rotate(360deg);
transform: rotate(360deg);
}
}
.glowing span {
--i: 1;
position: absolute;
top: calc(80px * var(--i));
left: calc(80px * var(--i));
bottom: calc(80px * var(--i));
right: calc(80px * var(--i));
}
.glowing span::before {
content: "";
position: absolute;
top: 50%;
left: -8px;
width: 15px;
height: 15px;
background: #f00;
border-radius: 50%;
}
.glowing span:nth-child(3n + 1)::before {
background: rgba(134, 255, 0, 1);
box-shadow:
0 0 20px rgba(134, 255, 0, 1),
0 0 40px rgba(134, 255, 0, 1),
0 0 60px rgba(134, 255, 0, 1),
0 0 80px rgba(134, 255, 0, 1),
0 0 0 8px rgba(134, 255, 0, 0.1);
}
.glowing span:nth-child(3n + 2)::before {
background: rgba(255, 214, 0, 1);
box-shadow:
0 0 20px rgba(255, 214, 0, 1),
0 0 40px rgba(255, 214, 0, 1),
0 0 60px rgba(255, 214, 0, 1),
0 0 80px rgba(255, 214, 0, 1),
0 0 0 8px rgba(255, 214, 0, 0.1);
}
.glowing span:nth-child(3n + 3)::before {
background: rgba(0, 226, 255, 1);
box-shadow:
0 0 20px rgba(0, 226, 255, 1),
0 0 40px rgba(0, 226, 255, 1),
0 0 60px rgba(0, 226, 255, 1),
0 0 80px rgba(0, 226, 255, 1),
0 0 0 8px rgba(0, 226, 255, 0.1);
}
.glowing span:nth-child(3n + 1) {
animation: animate 10s alternate infinite;
}
.glowing span:nth-child(3n + 2) {
animation: animate-reverse 3s alternate infinite;
}
.glowing span:nth-child(3n + 3) {
animation: animate 8s alternate infinite;
}
@keyframes animate {
0% {
transform: rotate(180deg);
}
50% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes animate-reverse {
0% {
transform: rotate(360deg);
}
50% {
transform: rotate(180deg);
}
100% {
transform: rotate(0deg);
}
}
`;
const StyledInfo = styled.p`
width: 60%;
font-weight: 600;
font-size: 20px;
text-align: center;
color: ${({ theme }) => theme.TEXT_NORMAL};
`;
const StyledContent = styled.div`
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 1;
`;
export const PremiumView = () => (
<StyledPremiumView>
<StyledContent>
<Title mb="lg" style={{ pointerEvents: "none" }}>
<JSONCrackLogo fontSize="4rem" />
</Title>
<StyledInfo>
Upgrade JSON Crack to premium and explore full potantial of your data!
</StyledInfo>
<List
mt="lg"
spacing="xs"
size="md"
center
icon={
<ThemeIcon color="teal" size={20} radius="xl">
<BsCheck size="1rem" />
</ThemeIcon>
}
>
<List.Item>Edit directly on graph</List.Item>
<List.Item>JSON Schema support</List.Item>
<List.Item>Visualize data at full capability</List.Item>
<List.Item>Save & share up to 200 files</List.Item>
</List>
<Button
mt="lg"
size="lg"
component="a"
fw="bolder"
variant="gradient"
gradient={{ from: "blue", to: "teal" }}
href="/pricing"
target="_blank"
>
UPGRADE TO PREMIUM
</Button>
</StyledContent>
<div className="glowing">
<span></span>
<span></span>
<span></span>
</div>
</StyledPremiumView>
);

@ -0,0 +1,219 @@
import React from "react";
import dynamic from "next/dynamic";
import styled from "styled-components";
import { toast } from "react-hot-toast";
import { Space } from "react-zoomable-ui";
import { ElkRoot } from "reaflow/dist/layout/useLayout";
import { useLongPress } from "use-long-press";
import { CustomNode } from "src/containers/Views/GraphView/CustomNode";
import { ViewMode } from "src/enums/viewMode.enum";
import useToggleHide from "src/hooks/useToggleHide";
import { Loading } from "src/layout/Loading";
import useConfig from "src/store/useConfig";
import useGraph from "src/store/useGraph";
import useUser from "src/store/useUser";
import { NodeData } from "src/types/graph";
import { CustomEdge } from "./CustomEdge";
import { ErrorView } from "./ErrorView";
import { PremiumView } from "./PremiumView";
const Canvas = dynamic(() => import("reaflow").then(r => r.Canvas), {
ssr: false,
});
interface GraphProps {
isWidget?: boolean;
}
const StyledEditorWrapper = styled.div<{ $widget: boolean; $showRulers: boolean }>`
position: absolute;
width: 100%;
height: ${({ $widget }) => ($widget ? "calc(100vh - 40px)" : "calc(100vh - 67px)")};
--bg-color: ${({ theme }) => theme.GRID_BG_COLOR};
--line-color-1: ${({ theme }) => theme.GRID_COLOR_PRIMARY};
--line-color-2: ${({ theme }) => theme.GRID_COLOR_SECONDARY};
background-color: var(--bg-color);
${({ $showRulers }) =>
$showRulers &&
`
background-image: linear-gradient(var(--line-color-1) 1.5px, transparent 1.5px),
linear-gradient(90deg, var(--line-color-1) 1.5px, transparent 1.5px),
linear-gradient(var(--line-color-2) 1px, transparent 1px),
linear-gradient(90deg, var(--line-color-2) 1px, transparent 1px);
background-position:
-1.5px -1.5px,
-1.5px -1.5px,
-1px -1px,
-1px -1px;
background-size:
100px 100px,
100px 100px,
20px 20px,
20px 20px;
`};
.jsoncrack-space {
cursor: url("/assets/cursor.svg"), auto;
}
:active {
cursor: move;
}
.dragging,
.dragging button {
pointer-events: none;
}
rect {
fill: ${({ theme }) => theme.BACKGROUND_NODE};
}
@media only screen and (max-width: 768px) {
height: ${({ $widget }) => ($widget ? "calc(100vh - 40px)" : "100vh")};
}
@media only screen and (max-width: 320px) {
height: 100vh;
}
`;
const layoutOptions = {
"elk.layered.compaction.postCompaction.strategy": "EDGE_LENGTH",
"elk.layered.nodePlacement.strategy": "NETWORK_SIMPLEX",
};
const PREMIUM_LIMIT = 200;
const ERROR_LIMIT_TREE = 5_000;
const ERROR_LIMIT = 10_000;
const GraphCanvas = ({ isWidget }: GraphProps) => {
const { validateHiddenNodes } = useToggleHide();
const setLoading = useGraph(state => state.setLoading);
const centerView = useGraph(state => state.centerView);
const direction = useGraph(state => state.direction);
const nodes = useGraph(state => state.nodes);
const edges = useGraph(state => state.edges);
const [paneWidth, setPaneWidth] = React.useState(2000);
const [paneHeight, setPaneHeight] = React.useState(2000);
const onLayoutChange = React.useCallback(
(layout: ElkRoot) => {
if (layout.width && layout.height) {
const areaSize = layout.width * layout.height;
const changeRatio = Math.abs((areaSize * 100) / (paneWidth * paneHeight) - 100);
setPaneWidth(layout.width + 50);
setPaneHeight((layout.height as number) + 50);
setTimeout(() => {
validateHiddenNodes();
window.requestAnimationFrame(() => {
if (changeRatio > 70 || isWidget) centerView();
setLoading(false);
});
});
}
},
[isWidget, paneHeight, paneWidth, centerView, setLoading, validateHiddenNodes]
);
return (
<Canvas
className="jsoncrack-canvas"
onLayoutChange={onLayoutChange}
node={p => <CustomNode {...p} />}
edge={p => <CustomEdge {...p} />}
nodes={nodes}
edges={edges}
maxHeight={paneHeight}
maxWidth={paneWidth}
height={paneHeight}
width={paneWidth}
direction={direction}
layoutOptions={layoutOptions}
key={direction}
pannable={false}
zoomable={false}
animated={false}
readonly={true}
dragEdge={null}
dragNode={null}
fit={true}
/>
);
};
function getViewType(nodes: NodeData[]) {
if (nodes.length > ERROR_LIMIT) return "error";
if (nodes.length > ERROR_LIMIT_TREE) return "tree";
if (nodes.length > PREMIUM_LIMIT) return "premium";
return "graph";
}
export const Graph = ({ isWidget = false }: GraphProps) => {
const setViewPort = useGraph(state => state.setViewPort);
const loading = useGraph(state => state.loading);
const isPremium = useUser(state => state.premium);
const viewType = useGraph(state => getViewType(state.nodes));
const gesturesEnabled = useConfig(state => state.gesturesEnabled);
const rulersEnabled = useConfig(state => state.rulersEnabled);
const setViewMode = useConfig(state => state.setViewMode);
const callback = React.useCallback(() => {
const canvas = document.querySelector(".jsoncrack-canvas") as HTMLDivElement | null;
canvas?.classList.add("dragging");
}, []);
const bindLongPress = useLongPress(callback, {
threshold: 150,
onFinish: () => {
const canvas = document.querySelector(".jsoncrack-canvas") as HTMLDivElement | null;
canvas?.classList.remove("dragging");
},
});
const blurOnClick = React.useCallback(() => {
if ("activeElement" in document) (document.activeElement as HTMLElement)?.blur();
}, []);
if (viewType === "error") {
return <ErrorView />;
}
if (viewType === "tree") {
setViewMode(ViewMode.Tree);
toast("This document is too large to display as a graph. Switching to tree view.");
}
if (viewType === "premium" && !isWidget) {
if (!isPremium) return <PremiumView />;
}
return (
<>
<Loading loading={loading} message="Painting graph..." />
<StyledEditorWrapper
$widget={isWidget}
onContextMenu={e => e.preventDefault()}
onClick={blurOnClick}
key={String(gesturesEnabled)}
$showRulers={rulersEnabled}
{...bindLongPress()}
>
<Space
onCreate={setViewPort}
onContextMenu={e => e.preventDefault()}
treatTwoFingerTrackPadGesturesLikeTouch={gesturesEnabled}
pollForElementResizing
className="jsoncrack-space"
>
<GraphCanvas isWidget={isWidget} />
</Space>
</StyledEditorWrapper>
</>
);
};

@ -0,0 +1,87 @@
import React from "react";
import { Button, Divider, Group, Modal, TextInput } from "@mantine/core";
import _unset from "lodash.unset";
import _update from "lodash.update";
import { VscLock } from "react-icons/vsc";
import useFile from "src/store/useFile";
import useJson from "src/store/useJson";
import useModal from "src/store/useModal";
import useUser from "src/store/useUser";
interface EditModalProps {
opened: boolean;
setOpened: React.Dispatch<React.SetStateAction<boolean>>;
selectedValue: string | number | null;
path: (string | number)[];
value: string;
setValue: React.Dispatch<React.SetStateAction<string>>;
errorMessage: string | null;
setErrorMessage: React.Dispatch<React.SetStateAction<string | null>>;
}
export const EditModal = ({
opened,
setOpened,
selectedValue,
path,
value,
setValue,
errorMessage,
setErrorMessage,
}: EditModalProps) => {
const setContents = useFile(state => state.setContents);
const getJson = useJson(state => state.getJson);
const showPremiumModal = useModal(state => state.setVisible("premium"));
const premium = useUser(state => state.premium);
return (
<Modal centered title={selectedValue} opened={opened} onClose={() => setOpened(false)}>
<TextInput
value={value}
onChange={e => {
setValue(e.currentTarget.value);
}}
error={errorMessage}
/>
<Divider my="md" />
<Group justify="right">
<Button
color="red"
onClick={() => {
try {
if (!premium) return showPremiumModal(true);
const updatedJson = JSON.parse(getJson());
_unset(updatedJson, path);
setContents({ contents: JSON.stringify(updatedJson, null, 2) });
setErrorMessage(null);
setOpened(false);
} catch (error: any) {
setErrorMessage(error.message);
}
}}
rightSection={!premium && <VscLock />}
>
Delete
</Button>
<Button
onClick={() => {
try {
if (!premium) return showPremiumModal(true);
const updatedJson = _update(JSON.parse(getJson()), path, () => JSON.parse(value));
setContents({ contents: JSON.stringify(updatedJson, null, 2) });
setErrorMessage(null);
setOpened(false);
} catch (error: any) {
setErrorMessage(error.message);
}
}}
rightSection={!premium && <VscLock />}
>
Apply
</Button>
</Group>
</Modal>
);
};

@ -0,0 +1,69 @@
import React from "react";
import { Button, HoverCard } from "@mantine/core";
import { styled, DefaultTheme } from "styled-components";
import _get from "lodash.get";
import { VscEdit } from "react-icons/vsc";
import { KeyPath } from "react-json-tree";
import useJson from "src/store/useJson";
interface LabelProps {
keyPath: KeyPath;
nodeType: string;
setOpened: React.Dispatch<React.SetStateAction<boolean>>;
setSelectedValue: React.Dispatch<React.SetStateAction<string | number | null>>;
setPath: React.Dispatch<React.SetStateAction<(string | number)[]>>;
setValue: React.Dispatch<React.SetStateAction<string>>;
}
function getLabelColor({ $type, theme }: { $type?: string; theme: DefaultTheme }) {
if ($type === "Object") return theme.NODE_COLORS.PARENT_OBJ;
if ($type === "Array") return theme.NODE_COLORS.PARENT_ARR;
return theme.NODE_COLORS.PARENT_OBJ;
}
const StyledLabel = styled.span<{ $nodeType?: string }>`
color: ${({ theme, $nodeType }) => getLabelColor({ theme, $type: $nodeType })};
&:hover {
filter: brightness(1.5);
transition: filter 0.2s ease-in-out;
}
`;
export const Label = ({
keyPath,
nodeType,
setOpened,
setSelectedValue,
setPath,
setValue,
}: LabelProps) => {
const getJson = useJson(state => state.getJson);
return (
<HoverCard shadow="sm" openDelay={50} closeDelay={250} withArrow position="left">
<HoverCard.Target>
<StyledLabel $nodeType={nodeType}>{keyPath[0]}:</StyledLabel>
</HoverCard.Target>
<HoverCard.Dropdown py={4}>
<Button
variant="transparent"
size="xs"
onClick={() => {
setOpened(true);
setSelectedValue(keyPath[0]);
const path = keyPath.toReversed();
const value = _get(JSON.parse(getJson()), path);
setPath(path);
setValue(JSON.stringify(value));
}}
leftSection={<VscEdit size="12" />}
>
Edit
</Button>
</HoverCard.Dropdown>
</HoverCard>
);
};

@ -0,0 +1,41 @@
import React from "react";
import { DefaultTheme, useTheme } from "styled-components";
import { TextRenderer } from "src/containers/Views/GraphView/CustomNode/TextRenderer";
type TextColorFn = {
theme: DefaultTheme;
$value?: string | unknown;
};
function getValueColor({ $value, theme }: TextColorFn) {
if ($value && !Number.isNaN(+$value)) return theme.NODE_COLORS.INTEGER;
if ($value === "true") return theme.NODE_COLORS.BOOL.TRUE;
if ($value === "false") return theme.NODE_COLORS.BOOL.FALSE;
if ($value === "null") return theme.NODE_COLORS.NULL;
// default
return theme.NODE_COLORS.NODE_VALUE;
}
interface ValueProps {
valueAsString: unknown;
value: unknown;
}
export const Value = (props: ValueProps) => {
const theme = useTheme();
const { valueAsString, value } = props;
return (
<span
style={{
color: getValueColor({
theme,
$value: valueAsString,
}),
}}
>
<TextRenderer>{JSON.stringify(value)}</TextRenderer>
</span>
);
};

@ -0,0 +1,60 @@
import React from "react";
import { useTheme } from "styled-components";
import { JSONTree } from "react-json-tree";
import useJson from "src/store/useJson";
import { EditModal } from "./EditModal";
import { Label } from "./Label";
import { Value } from "./Value";
export const TreeView = () => {
const theme = useTheme();
const json = useJson(state => state.json);
const [opened, setOpened] = React.useState(false);
const [selectedValue, setSelectedValue] = React.useState<string | number | null>(null);
const [path, setPath] = React.useState<(string | number)[]>([]);
const [value, setValue] = React.useState("");
const [errorMessage, setErrorMessage] = React.useState<string | null>(null);
return (
<>
<JSONTree
hideRoot
data={JSON.parse(json)}
valueRenderer={(valueAsString, value) => <Value {...{ valueAsString, value }} />}
labelRenderer={(keyPath, nodeType) => (
<Label
{...{
keyPath,
nodeType,
setOpened,
setSelectedValue,
setPath,
setValue,
}}
/>
)}
theme={{
extend: {
overflow: "scroll",
height: "100%",
scheme: "monokai",
author: "wimer hazenberg (http://www.monokai.nl)",
base00: theme.GRID_BG_COLOR,
},
}}
/>
<EditModal
{...{
opened,
setOpened,
selectedValue,
path,
value,
setValue,
errorMessage,
setErrorMessage,
}}
/>
</>
);
};

@ -0,0 +1,8 @@
// eslint-disable
export enum FileFormat {
"JSON" = "json",
"YAML" = "yaml",
"XML" = "xml",
"TOML" = "toml",
"CSV" = "csv",
}

@ -0,0 +1,4 @@
export enum ViewMode {
Graph = "graph",
Tree = "tree",
}

@ -0,0 +1,43 @@
import React from "react";
import { useDebouncedValue } from "@mantine/hooks";
import { searchQuery, cleanupHighlight, highlightMatchedNodes } from "src/lib/utils/graph/search";
import useGraph from "src/store/useGraph";
export const useFocusNode = () => {
const viewPort = useGraph(state => state.viewPort);
const [selectedNode, setSelectedNode] = React.useState(0);
const [nodeCount, setNodeCount] = React.useState(0);
const [value, setValue] = React.useState("");
const [debouncedValue] = useDebouncedValue(value, 600);
const skip = () => setSelectedNode(current => (current + 1) % nodeCount);
React.useEffect(() => {
if (!value) {
cleanupHighlight();
setSelectedNode(0);
setNodeCount(0);
return;
}
if (!viewPort || !debouncedValue) return;
const matchedNodes: NodeListOf<Element> = searchQuery(`span[data-key*='${debouncedValue}' i]`);
const matchedNode: Element | null = matchedNodes[selectedNode] || null;
cleanupHighlight();
if (matchedNode && matchedNode.parentElement) {
highlightMatchedNodes(matchedNodes, selectedNode);
setNodeCount(matchedNodes.length);
viewPort?.camera.centerFitElementIntoView(matchedNode.parentElement, {
elementExtraMarginForZoom: 400,
});
} else {
setSelectedNode(0);
setNodeCount(0);
}
}, [selectedNode, debouncedValue, value, viewPort]);
return [value, setValue, skip, nodeCount, selectedNode] as const;
};

@ -0,0 +1,34 @@
import jq from "jq-web";
import toast from "react-hot-toast";
import useFile from "src/store/useFile";
import useJson from "src/store/useJson";
const useJsonQuery = () => {
const getJson = useJson(state => state.getJson);
const setContents = useFile(state => state.setContents);
const transformer = async ({ value }) => {
const { run } = await import("json_typegen_wasm");
return run("Root", value, JSON.stringify({ output_mode: "typescript/typealias" }));
};
const updateJson = (query: string, cb?: () => void) => {
try {
const res = jq.json(JSON.parse(getJson()), query);
setContents({ contents: JSON.stringify(res, null, 2) });
cb?.();
} catch (error) {
console.error(error);
toast.error("Unable to process the request.");
}
};
const getJsonType = async () => {
const types = await transformer({ value: getJson() });
return types;
};
return { updateJson, getJsonType };
};
export default useJsonQuery;

@ -0,0 +1,37 @@
import React from "react";
import useGraph from "src/store/useGraph";
const useToggleHide = () => {
const getCollapsedNodeIds = useGraph(state => state.getCollapsedNodeIds);
const getCollapsedEdgeIds = useGraph(state => state.getCollapsedEdgeIds);
React.useEffect(() => {
validateHiddenNodes(getCollapsedNodeIds(), getCollapsedEdgeIds());
}, [getCollapsedEdgeIds, getCollapsedNodeIds]);
return {
validateHiddenNodes: () => validateHiddenNodes(getCollapsedNodeIds(), getCollapsedEdgeIds()),
};
};
function validateHiddenNodes(collapsedNodeIs: string[], collapsedEdgeIds: string[]) {
const nodeList = collapsedNodeIs.map(id => `[id$="node-${id}"]`);
const edgeList = collapsedEdgeIds.map(id => `[class$="edge-${id}"]`);
const hiddenItems = document.body.querySelectorAll(".hide");
hiddenItems.forEach(item => item.classList.remove("hide"));
if (nodeList.length) {
const selectedNodes = document.body.querySelectorAll(nodeList.join(","));
selectedNodes.forEach(node => node.classList.add("hide"));
}
if (edgeList.length) {
const selectedEdges = document.body.querySelectorAll(edgeList.join(","));
selectedEdges.forEach(edge => edge.classList.add("hide"));
}
}
export default useToggleHide;

@ -0,0 +1,29 @@
import React from "react";
import { MantineProvider } from "@mantine/core";
import { ThemeProvider } from "styled-components";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { lightTheme, darkTheme } from "src/constants/theme";
import useConfig from "src/store/useConfig";
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: false,
},
},
});
export const EditorWrapper: React.FC<{
children: React.ReactNode;
}> = ({ children }) => {
const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);
return (
<ThemeProvider theme={darkmodeEnabled ? darkTheme : lightTheme}>
<MantineProvider forceColorScheme={darkmodeEnabled ? "dark" : "light"}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</MantineProvider>
</ThemeProvider>
);
};

@ -0,0 +1,98 @@
import React from "react";
import { Anchor, Button, Group, Modal, Text } from "@mantine/core";
import styled from "styled-components";
import { VscCode } from "react-icons/vsc";
import { VscArrowRight } from "react-icons/vsc";
const StyledAlert = styled.div`
position: fixed;
bottom: 36px;
right: 10px;
background: rgba(255, 255, 255, 0.2);
border-radius: 16px;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.3);
font-weight: 500;
overflow: hidden;
`;
const StyledTitle = styled.div`
display: flex;
align-items: center;
color: ${({ theme }) => theme.TEXT_POSITIVE};
flex: 1;
font-weight: 700;
&::after {
background: ${({ theme }) => theme.TEXT_POSITIVE};
height: 1px;
content: "";
-webkit-box-flex: 1;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
margin-left: 4px;
opacity: 0.6;
}
`;
const ExternalMode = () => {
const [isExternal, setExternal] = React.useState(false);
const [isOpen, setOpen] = React.useState(false);
React.useEffect(() => {
if (typeof window !== "undefined") {
if (window.location.pathname.includes("widget")) return setExternal(false);
if (window.location.host !== "jsoncrack.com") return setExternal(true);
return setExternal(false);
}
}, []);
const closeModal = () => setOpen(false);
if (!isExternal) return null;
return (
<StyledAlert>
<Button
onClick={() => setOpen(true)}
color="red"
variant="subtle"
leftSection={<VscCode size="1.2rem" />}
>
External Host
</Button>
<Modal title="External Host of JSON Crack" opened={isOpen} onClose={closeModal} centered>
<Group>
<StyledTitle>Dear valued user,</StyledTitle>
<Text>
We would like to inform you that you are presently utilizing the external release of the{" "}
<Anchor href="https://jsoncrack.com">JSON Crack</Anchor>. Your continued support is
crucial in sustaining and improving our services.
<br />
<br />
We kindly encourage you to consider upgrading to the premium version, which not only
enhances your experience but also contributes to the ongoing development of JSON Crack.
</Text>
</Group>
<Group pt="lg" justify="right">
<Button
onClick={closeModal}
component="a"
href="https://jsoncrack.com/pricing"
target="_blank"
variant="outline"
color="red"
rightSection={<VscArrowRight />}
>
JSON Crack
</Button>
</Group>
</Modal>
</StyledAlert>
);
};
export default ExternalMode;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save