├── .eslintignore
├── static
├── .gitkeep
└── json-lint.js
├── docs
├── .gitignore
├── logo.png
├── freddy.jpg
├── favicon.png
├── index.html
├── style.css
└── style.scss
├── .gitignore
├── src
├── renderer
│ ├── main.js
│ ├── App.vue
│ └── components
│ │ └── Editor.vue
├── index.ejs
└── main
│ ├── index.dev.js
│ └── index.js
├── .babelrc
├── appveyor.yml
├── .eslintrc.js
├── .travis.yml
├── .electron-vue
├── dev-client.js
├── webpack.main.config.js
├── build.js
├── webpack.web.config.js
├── dev-runner.js
└── webpack.renderer.config.js
├── README.md
└── package.json
/.eslintignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | .sass-cache
2 | css
3 | *.map
4 |
--------------------------------------------------------------------------------
/docs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dope/freddy/HEAD/docs/logo.png
--------------------------------------------------------------------------------
/docs/freddy.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dope/freddy/HEAD/docs/freddy.jpg
--------------------------------------------------------------------------------
/docs/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dope/freddy/HEAD/docs/favicon.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | dist/electron/*
3 | dist/web/*
4 | build/*
5 | !build/icons
6 | yarn-error.log
7 | node_modules/
8 | npm-debug.log
9 | npm-debug.log.*
10 | thumbs.db
11 | !.gitkeep
12 |
--------------------------------------------------------------------------------
/src/renderer/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App'
3 | import TreeView from 'vue-json-tree-view'
4 | import CmComponent from 'vue-codemirror-lite/codemirror.vue'
5 | Vue.component('codemirror', CmComponent)
6 |
7 | Vue.use(TreeView)
8 |
9 | Vue.config.productionTip = false
10 |
11 | /* eslint-disable no-new */
12 | new Vue({
13 | components: { App },
14 | template: ''
15 | }).$mount('#app')
16 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "comments": false,
3 | "env": {
4 | "main": {
5 | "presets": [
6 | ["env", {
7 | "targets": { "node": 7 }
8 | }],
9 | "stage-0"
10 | ]
11 | },
12 | "renderer": {
13 | "presets": [
14 | ["env", {
15 | "modules": false
16 | }],
17 | "stage-0"
18 | ]
19 | },
20 | "web": {
21 | "presets": [
22 | ["env", {
23 | "modules": false
24 | }],
25 | "stage-0"
26 | ]
27 | }
28 | },
29 | "plugins": ["transform-runtime"]
30 | }
31 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 0.1.{build}
2 |
3 | branches:
4 | only:
5 | - master
6 |
7 | image: Visual Studio 2017
8 | platform:
9 | - x64
10 |
11 | cache:
12 | - node_modules
13 | - '%APPDATA%\npm-cache'
14 | - '%USERPROFILE%\.electron'
15 | - '%USERPROFILE%\AppData\Local\Yarn\cache'
16 |
17 | init:
18 | - git config --global core.autocrlf input
19 |
20 | install:
21 | - ps: Install-Product node 8 x64
22 | - choco install yarn --ignore-dependencies
23 | - git reset --hard HEAD
24 | - yarn
25 | - node --version
26 |
27 | build_script:
28 | - yarn build
29 |
30 | test: off
31 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | parser: 'babel-eslint',
4 | parserOptions: {
5 | sourceType: 'module'
6 | },
7 | env: {
8 | browser: true,
9 | node: true
10 | },
11 | extends: 'standard',
12 | globals: {
13 | __static: true
14 | },
15 | plugins: [
16 | 'html'
17 | ],
18 | 'rules': {
19 | // allow paren-less arrow functions
20 | 'arrow-parens': 0,
21 | // allow async-await
22 | 'generator-star-spacing': 0,
23 | // allow debugger during development
24 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Freddy
6 |
7 | <% if (htmlWebpackPlugin.options.nodeModules) { %>
8 |
9 |
12 | <% } %>
13 |
14 |
15 |
16 |
17 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/main/index.dev.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is used specifically and only for development. It installs
3 | * `electron-debug` & `vue-devtools`. There shouldn't be any need to
4 | * modify this file, but it can be used to extend your development
5 | * environment.
6 | */
7 |
8 | /* eslint-disable */
9 |
10 | // Set environment for development
11 | process.env.NODE_ENV = 'development'
12 |
13 | // Install `electron-debug` with `devtron`
14 | require('electron-debug')({ showDevTools: true })
15 |
16 | // Install `vue-devtools`
17 | require('electron').app.on('ready', () => {
18 | let installExtension = require('electron-devtools-installer')
19 | installExtension.default(installExtension.VUEJS_DEVTOOLS)
20 | .then(() => {})
21 | .catch(err => {
22 | console.log('Unable to install `vue-devtools`: \n', err)
23 | })
24 | })
25 |
26 | // Require `main` process to boot app
27 | require('./index')
28 |
--------------------------------------------------------------------------------
/src/renderer/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
16 |
17 |
50 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | osx_image: xcode8.3
2 | sudo: required
3 | dist: trusty
4 | language: c
5 | matrix:
6 | include:
7 | - os: osx
8 | - os: linux
9 | env: CC=clang CXX=clang++ npm_config_clang=1
10 | compiler: clang
11 | cache:
12 | directories:
13 | - node_modules
14 | - "$HOME/.electron"
15 | - "$HOME/.cache"
16 | addons:
17 | apt:
18 | packages:
19 | - libgnome-keyring-dev
20 | - icnsutils
21 | before_install:
22 | - mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([
23 | "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz
24 | | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull
25 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi
26 | install:
27 | - nvm install 7
28 | - curl -o- -L https://yarnpkg.com/install.sh | bash
29 | - source ~/.bashrc
30 | - npm install -g xvfb-maybe
31 | - yarn
32 | script:
33 | - yarn run build
34 | branches:
35 | only:
36 | - master
37 |
--------------------------------------------------------------------------------
/.electron-vue/dev-client.js:
--------------------------------------------------------------------------------
1 | const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
2 |
3 | hotClient.subscribe(event => {
4 | /**
5 | * Reload browser when HTMLWebpackPlugin emits a new index.html
6 | */
7 | if (event.action === 'reload') {
8 | window.location.reload()
9 | }
10 |
11 | /**
12 | * Notify `mainWindow` when `main` process is compiling,
13 | * giving notice for an expected reload of the `electron` process
14 | */
15 | if (event.action === 'compiling') {
16 | document.body.innerHTML += `
17 |
30 |
31 |
32 | Compiling Main Process...
33 |
34 | `
35 | }
36 | })
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Freddy
2 |
3 | > Make your JSON more readable
4 |
5 | 
6 |
7 | #### Build Setup
8 |
9 | ``` bash
10 | # install dependencies
11 | npm install
12 |
13 | # serve with hot reload at localhost:3000
14 | npm run dev
15 |
16 | # build electron application for production
17 | npm run build
18 |
19 |
20 | # lint all JS/Vue component files in `src/`
21 | npm run lint
22 |
23 | ```
24 |
25 | ### License
26 |
27 | ```MIT License
28 |
29 | Copyright (c) 2017 Joe
30 |
31 | Permission is hereby granted, free of charge, to any person obtaining a copy
32 | of this software and associated documentation files (the "Software"), to deal
33 | in the Software without restriction, including without limitation the rights
34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35 | copies of the Software, and to permit persons to whom the Software is
36 | furnished to do so, subject to the following conditions:
37 |
38 | The above copyright notice and this permission notice shall be included in all
39 | copies or substantial portions of the Software.
40 |
41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47 | SOFTWARE.```
48 |
--------------------------------------------------------------------------------
/.electron-vue/webpack.main.config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | process.env.BABEL_ENV = 'main'
4 |
5 | const path = require('path')
6 | const { dependencies } = require('../package.json')
7 | const webpack = require('webpack')
8 |
9 | const BabiliWebpackPlugin = require('babili-webpack-plugin')
10 |
11 | let mainConfig = {
12 | entry: {
13 | main: path.join(__dirname, '../src/main/index.js')
14 | },
15 | externals: [
16 | ...Object.keys(dependencies || {})
17 | ],
18 | module: {
19 | rules: [
20 | {
21 | test: /\.(js)$/,
22 | enforce: 'pre',
23 | exclude: /node_modules/,
24 | use: {
25 | loader: 'eslint-loader',
26 | options: {
27 | formatter: require('eslint-friendly-formatter')
28 | }
29 | }
30 | },
31 | {
32 | test: /\.js$/,
33 | use: 'babel-loader',
34 | exclude: /node_modules/
35 | },
36 | {
37 | test: /\.node$/,
38 | use: 'node-loader'
39 | }
40 | ]
41 | },
42 | node: {
43 | __dirname: process.env.NODE_ENV !== 'production',
44 | __filename: process.env.NODE_ENV !== 'production'
45 | },
46 | output: {
47 | filename: '[name].js',
48 | libraryTarget: 'commonjs2',
49 | path: path.join(__dirname, '../dist/electron')
50 | },
51 | plugins: [
52 | new webpack.NoEmitOnErrorsPlugin()
53 | ],
54 | resolve: {
55 | extensions: ['.js', '.json', '.node']
56 | },
57 | target: 'electron-main'
58 | }
59 |
60 | /**
61 | * Adjust mainConfig for development settings
62 | */
63 | if (process.env.NODE_ENV !== 'production') {
64 | mainConfig.plugins.push(
65 | new webpack.DefinePlugin({
66 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
67 | })
68 | )
69 | }
70 |
71 | /**
72 | * Adjust mainConfig for production settings
73 | */
74 | if (process.env.NODE_ENV === 'production') {
75 | mainConfig.plugins.push(
76 | new BabiliWebpackPlugin(),
77 | new webpack.DefinePlugin({
78 | 'process.env.NODE_ENV': '"production"'
79 | })
80 | )
81 | }
82 |
83 | module.exports = mainConfig
84 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Freddy
20 |
21 |
22 |
23 |
30 |
31 |
39 |
40 |
41 |
42 |
47 |
48 |
49 |
50 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/docs/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | box-sizing: border-box; }
5 |
6 | html {
7 | background: #23202C; }
8 |
9 | body {
10 | font-family: "Space Mono";
11 | font-size: 13px;
12 | color: #FFF; }
13 |
14 | h1 {
15 | font-weight: 500;
16 | font-size: 25px;
17 | line-height: 1.4; }
18 | @media screen and (min-width: 40em) {
19 | h1 {
20 | font-size: 30px;
21 | max-width: 680px;
22 | line-height: 1.4; } }
23 |
24 | img {
25 | width: 100%;
26 | height: auto;
27 | display: block; }
28 |
29 | .mt {
30 | margin-top: 80px; }
31 |
32 | .mb {
33 | margin-bottom: 40px; }
34 |
35 | .container {
36 | max-width: 1380px;
37 | width: 90%;
38 | margin: 0 auto; }
39 |
40 | .header {
41 | position: relative;
42 | padding: 70px 0; }
43 | .header__link {
44 | display: block;
45 | max-width: 50px;
46 | position: relative; }
47 | .header__link:after {
48 | position: absolute;
49 | right: -37px;
50 | top: 0;
51 | content: "Beta";
52 | font-size: 9px;
53 | text-transform: uppercase;
54 | letter-spacing: 2px;
55 | color: #FFF;
56 | font-weight: 700; }
57 | .header .btn {
58 | color: #FFF;
59 | margin: 0;
60 | position: absolute;
61 | right: 0;
62 | top: 0;
63 | bottom: 0;
64 | right: 0;
65 | margin: auto;
66 | height: 35px;
67 | padding-bottom: 28px; }
68 |
69 | .btn {
70 | display: flex;
71 | align-items: center;
72 | justify-content: center;
73 | padding: 20px;
74 | max-width: 150px;
75 | text-decoration: none;
76 | border-radius: 100px;
77 | background-image: linear-gradient(120deg, #9A82FF, #03A4E8);
78 | color: #9A82FF;
79 | font-size: 14px;
80 | letter-spacing: 0.8px;
81 | position: relative;
82 | transition: box-shadow 300ms ease-in-out; }
83 | .btn:after {
84 | position: absolute;
85 | top: 0;
86 | left: 0;
87 | right: 0;
88 | bottom: 0;
89 | margin: auto;
90 | border-radius: 100px;
91 | width: calc(100% - 4px);
92 | height: calc(100% - 4px);
93 | background: #23202C;
94 | content: ""; }
95 | .btn:hover {
96 | box-shadow: 0 0 35px 0px rgba(154, 130, 255, 0.4); }
97 | .btn > * {
98 | position: relative;
99 | z-index: 10; }
100 | .btn path {
101 | fill: #9A82FF; }
102 | .btn span {
103 | margin-left: 10px; }
104 | .btn--small {
105 | display: inline-block;
106 | font-size: 12px;
107 | padding: 10px 15px;
108 | max-width: 140px;
109 | margin-left: 10px; }
110 | .btn--small:before, .btn--small:after {
111 | display: none; }
112 | .btn--small span {
113 | margin-left: 0; }
114 |
115 | .footer {
116 | padding: 40px 0;
117 | font-size: 14px;
118 | position: relative;
119 | text-align: center; }
120 | .footer__link {
121 | background-image: linear-gradient(120deg, #9A82FF, #03A4E8);
122 | -webkit-background-clip: text;
123 | -webkit-text-fill-color: transparent;
124 | font-weight: 600; }
125 |
126 | /*# sourceMappingURL=style.css.map */
127 |
--------------------------------------------------------------------------------
/src/main/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | import { app, BrowserWindow, Menu } from 'electron'
4 |
5 | /**
6 | * Set `__static` path to static files in production
7 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
8 | */
9 | if (process.env.NODE_ENV !== 'development') {
10 | global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
11 | }
12 |
13 | let mainWindow
14 | const winURL = process.env.NODE_ENV === 'development'
15 | ? `http://localhost:9080`
16 | : `file://${__dirname}/index.html`
17 |
18 | function createWindow () {
19 | /**
20 | * Initial window options
21 | */
22 | mainWindow = new BrowserWindow({
23 | height: 563,
24 | useContentSize: true,
25 | width: 1000,
26 | titleBarStyle: 'hidden-inset',
27 | backgroundColor: '#2A2734'
28 | })
29 |
30 | mainWindow.loadURL(winURL)
31 |
32 | mainWindow.on('closed', () => {
33 | mainWindow = null
34 | })
35 |
36 | var template = [{
37 | label: 'Freddy',
38 | submenu: [
39 | {
40 | label: 'Quit',
41 | accelerator: 'Command+Q',
42 | click: function () {
43 | app.quit()
44 | }
45 | }
46 | ]}, {
47 | label: 'Edit',
48 | submenu: [
49 | {
50 | label: 'Undo',
51 | accelerator: 'CmdOrCtrl+Z',
52 | selector: 'undo:'
53 | },
54 | {
55 | label: 'Redo',
56 | accelerator: 'Shift+CmdOrCtrl+Z',
57 | selector: 'redo:'
58 | },
59 | {
60 | type: 'separator'
61 | },
62 | {
63 | label: 'Cut',
64 | accelerator: 'CmdOrCtrl+X',
65 | selector: 'cut:'
66 | },
67 | {
68 | label: 'Copy',
69 | accelerator: 'CmdOrCtrl+C',
70 | selector: 'copy:'
71 | },
72 | {
73 | label: 'Paste',
74 | accelerator: 'CmdOrCtrl+V',
75 | selector: 'paste:'
76 | },
77 | {
78 | label: 'Select All',
79 | accelerator: 'CmdOrCtrl+A',
80 | selector: 'selectAll:'
81 | }
82 | ]}
83 | ]
84 |
85 | Menu.setApplicationMenu(Menu.buildFromTemplate(template))
86 | }
87 |
88 | app.on('ready', createWindow)
89 |
90 | app.on('window-all-closed', () => {
91 | if (process.platform !== 'darwin') {
92 | app.quit()
93 | }
94 | })
95 |
96 | app.on('activate', () => {
97 | if (mainWindow === null) {
98 | createWindow()
99 | }
100 | })
101 |
102 | /**
103 | * Auto Updater
104 | *
105 | * Uncomment the following code below and install `electron-updater` to
106 | * support auto updating. Code Signing with a valid certificate is required.
107 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating
108 | */
109 |
110 | /*
111 | import { autoUpdater } from 'electron-updater'
112 |
113 | autoUpdater.on('update-downloaded', () => {
114 | autoUpdater.quitAndInstall()
115 | })
116 |
117 | app.on('ready', () => {
118 | if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates()
119 | })
120 | */
121 |
--------------------------------------------------------------------------------
/docs/style.scss:
--------------------------------------------------------------------------------
1 | $font: "Space Mono";
2 | $font-size: 13px;
3 |
4 | $base-color: #FFF;
5 | $accent-color: #9A82FF;
6 |
7 | * {
8 | margin: 0;
9 | padding: 0;
10 | box-sizing: border-box;
11 | }
12 |
13 | html {
14 | background: #23202C;
15 | }
16 |
17 | body {
18 | font-family: $font;
19 | font-size: $font-size;
20 | color: $base-color;
21 | }
22 |
23 | h1 {
24 | font-weight: 500;
25 | font-size: 25px;
26 | line-height: 1.4;
27 | @media screen and (min-width: 40em) {
28 | font-size: 30px;
29 | max-width: 680px;
30 | line-height: 1.4;
31 | }
32 | }
33 |
34 | img {
35 | width: 100%;
36 | height: auto;
37 | display: block;
38 | }
39 |
40 | .mt {
41 | margin-top: 80px;
42 | }
43 |
44 | .mb {
45 | margin-bottom: 40px;
46 | }
47 |
48 | .container {
49 | max-width: 1380px;
50 | width: 90%;
51 | margin: 0 auto;
52 | }
53 |
54 | .header {
55 | position: relative;
56 | padding: 70px 0;
57 |
58 | &__link {
59 | display: block;
60 | max-width: 50px;
61 | position: relative;
62 |
63 | &:after {
64 | position: absolute;
65 | right: -37px;
66 | top: 0;
67 | content: "Beta";
68 | font-size: 9px;
69 | text-transform: uppercase;
70 | letter-spacing: 2px;
71 | color: $base-color;
72 | font-weight: 700;
73 | }
74 | }
75 |
76 | .btn {
77 | color: $base-color;
78 | margin: 0;
79 | position: absolute;
80 | right: 0;
81 | top: 0;
82 | bottom: 0;
83 | right: 0;
84 | margin: auto;
85 | height: 35px;
86 | padding-bottom: 28px;
87 | }
88 | }
89 |
90 | .btn {
91 | display: flex;
92 | align-items: center;
93 | justify-content: center;
94 | padding: 20px;
95 | max-width: 150px;
96 | text-decoration: none;
97 | border-radius: 100px;
98 | background-image: linear-gradient(120deg, $accent-color, #03A4E8);
99 | color: $accent-color;
100 | font-size: 14px;
101 | letter-spacing: 0.8px;
102 | position: relative;
103 | transition: box-shadow 300ms ease-in-out;
104 |
105 | &:after {
106 | position: absolute;
107 | top: 0;
108 | left: 0;
109 | right: 0;
110 | bottom: 0;
111 | margin: auto;
112 | border-radius: 100px;
113 | width: calc(100% - 4px);
114 | height: calc(100% - 4px);
115 | background: #23202C;
116 | content: "";
117 | }
118 |
119 | &:hover {
120 | box-shadow: 0 0 35px 0px rgba($accent-color, 0.4);
121 | }
122 |
123 | > * {
124 | position: relative;
125 | z-index: 10;
126 | }
127 |
128 | path {
129 | fill: $accent-color;
130 | }
131 |
132 | span {
133 | margin-left: 10px;
134 | }
135 |
136 | &--small {
137 | display: inline-block;
138 | font-size: 12px;
139 | padding: 10px 15px;
140 | max-width: 140px;
141 | margin-left: 10px;
142 |
143 | &:before,
144 | &:after {
145 | display: none;
146 | }
147 |
148 | span {
149 | margin-left: 0;
150 | }
151 | }
152 | }
153 |
154 | .footer {
155 | padding: 40px 0;
156 | font-size: 14px;
157 | position: relative;
158 | text-align: center;
159 |
160 |
161 | &__link {
162 | background-image: linear-gradient(120deg, $accent-color, #03A4E8);
163 | -webkit-background-clip: text;
164 | -webkit-text-fill-color: transparent;
165 | font-weight: 600;
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/.electron-vue/build.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | process.env.NODE_ENV = 'production'
4 |
5 | const { say } = require('cfonts')
6 | const chalk = require('chalk')
7 | const del = require('del')
8 | const { spawn } = require('child_process')
9 | const webpack = require('webpack')
10 | const Multispinner = require('multispinner')
11 |
12 |
13 | const mainConfig = require('./webpack.main.config')
14 | const rendererConfig = require('./webpack.renderer.config')
15 | const webConfig = require('./webpack.web.config')
16 |
17 | const doneLog = chalk.bgGreen.white(' DONE ') + ' '
18 | const errorLog = chalk.bgRed.white(' ERROR ') + ' '
19 | const okayLog = chalk.bgBlue.white(' OKAY ') + ' '
20 | const isCI = process.env.CI || false
21 |
22 | if (process.env.BUILD_TARGET === 'clean') clean()
23 | else if (process.env.BUILD_TARGET === 'web') web()
24 | else build()
25 |
26 | function clean () {
27 | del.sync(['build/*', '!build/icons', '!build/icons/icon.*'])
28 | console.log(`\n${doneLog}\n`)
29 | process.exit()
30 | }
31 |
32 | function build () {
33 | greeting()
34 |
35 | del.sync(['dist/electron/*', '!.gitkeep'])
36 |
37 | const tasks = ['main', 'renderer']
38 | const m = new Multispinner(tasks, {
39 | preText: 'building',
40 | postText: 'process'
41 | })
42 |
43 | let results = ''
44 |
45 | m.on('success', () => {
46 | process.stdout.write('\x1B[2J\x1B[0f')
47 | console.log(`\n\n${results}`)
48 | console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`)
49 | process.exit()
50 | })
51 |
52 | pack(mainConfig).then(result => {
53 | results += result + '\n\n'
54 | m.success('main')
55 | }).catch(err => {
56 | m.error('main')
57 | console.log(`\n ${errorLog}failed to build main process`)
58 | console.error(`\n${err}\n`)
59 | process.exit(1)
60 | })
61 |
62 | pack(rendererConfig).then(result => {
63 | results += result + '\n\n'
64 | m.success('renderer')
65 | }).catch(err => {
66 | m.error('renderer')
67 | console.log(`\n ${errorLog}failed to build renderer process`)
68 | console.error(`\n${err}\n`)
69 | process.exit(1)
70 | })
71 | }
72 |
73 | function pack (config) {
74 | return new Promise((resolve, reject) => {
75 | webpack(config, (err, stats) => {
76 | if (err) reject(err.stack || err)
77 | else if (stats.hasErrors()) {
78 | let err = ''
79 |
80 | stats.toString({
81 | chunks: false,
82 | colors: true
83 | })
84 | .split(/\r?\n/)
85 | .forEach(line => {
86 | err += ` ${line}\n`
87 | })
88 |
89 | reject(err)
90 | } else {
91 | resolve(stats.toString({
92 | chunks: false,
93 | colors: true
94 | }))
95 | }
96 | })
97 | })
98 | }
99 |
100 | function web () {
101 | del.sync(['dist/web/*', '!.gitkeep'])
102 | webpack(webConfig, (err, stats) => {
103 | if (err || stats.hasErrors()) console.log(err)
104 |
105 | console.log(stats.toString({
106 | chunks: false,
107 | colors: true
108 | }))
109 |
110 | process.exit()
111 | })
112 | }
113 |
114 | function greeting () {
115 | const cols = process.stdout.columns
116 | let text = ''
117 |
118 | if (cols > 85) text = 'lets-build'
119 | else if (cols > 60) text = 'lets-|build'
120 | else text = false
121 |
122 | if (text && !isCI) {
123 | say(text, {
124 | colors: ['yellow'],
125 | font: 'simple3d',
126 | space: false
127 | })
128 | } else console.log(chalk.yellow.bold('\n lets-build'))
129 | console.log()
130 | }
131 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Freddy",
3 | "version": "0.1.0",
4 | "author": "Joe Richardson ",
5 | "description": "JSON Tree View",
6 | "license": null,
7 | "main": "./dist/electron/main.js",
8 | "scripts": {
9 | "build": "node .electron-vue/build.js && electron-builder",
10 | "build:dir": "node .electron-vue/build.js && electron-builder --dir",
11 | "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
12 | "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
13 | "dev": "node .electron-vue/dev-runner.js",
14 | "lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src",
15 | "lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter --fix src",
16 | "pack": "npm run pack:main && npm run pack:renderer",
17 | "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
18 | "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
19 | "postinstall": "npm run lint:fix"
20 | },
21 | "build": {
22 | "productName": "Freddy",
23 | "appId": "org.simulatedgreg.electron-vue",
24 | "directories": {
25 | "output": "build"
26 | },
27 | "files": [
28 | "dist/electron/**/*"
29 | ],
30 | "dmg": {
31 | "contents": [
32 | {
33 | "x": 410,
34 | "y": 150,
35 | "type": "link",
36 | "path": "/Applications"
37 | },
38 | {
39 | "x": 130,
40 | "y": 150,
41 | "type": "file"
42 | }
43 | ]
44 | },
45 | "mac": {
46 | "icon": "build/icons/icon.icns"
47 | }
48 | },
49 | "dependencies": {
50 | "node-sass": "^4.13.1",
51 | "sass-loader": "^6.0.6",
52 | "vue": "*",
53 | "vue-codemirror-lite": "^1.0.3",
54 | "vue-json-tree-view": "^2.1.1"
55 | },
56 | "devDependencies": {
57 | "babel-core": "^6.25.0",
58 | "babel-eslint": "^7.2.3",
59 | "babel-loader": "^7.1.1",
60 | "babel-plugin-transform-runtime": "^6.23.0",
61 | "babel-preset-env": "^1.6.0",
62 | "babel-preset-stage-0": "^6.24.1",
63 | "babel-register": "^6.24.1",
64 | "babili-webpack-plugin": "^0.1.2",
65 | "brace": "^0.11.0",
66 | "cfonts": "^1.1.3",
67 | "chalk": "^2.1.0",
68 | "codemirror": "^5.32.0",
69 | "copy-webpack-plugin": "^4.0.1",
70 | "cross-env": "^5.0.5",
71 | "css-loader": "^0.28.4",
72 | "del": "^3.0.0",
73 | "devtron": "^1.4.0",
74 | "electron": "^1.8.2-beta5",
75 | "electron-builder": "^19.19.1",
76 | "electron-debug": "^1.4.0",
77 | "electron-devtools-installer": "^2.2.0",
78 | "eslint": "^4.4.1",
79 | "eslint-config-standard": "^10.2.1",
80 | "eslint-friendly-formatter": "^3.0.0",
81 | "eslint-loader": "^1.9.0",
82 | "eslint-plugin-html": "^3.1.1",
83 | "eslint-plugin-import": "^2.7.0",
84 | "eslint-plugin-node": "^5.1.1",
85 | "eslint-plugin-promise": "^3.5.0",
86 | "eslint-plugin-standard": "^3.0.1",
87 | "extract-text-webpack-plugin": "^3.0.0",
88 | "file-loader": "^0.11.2",
89 | "html-webpack-plugin": "^2.30.1",
90 | "jsonlint": "^1.6.2",
91 | "multispinner": "^0.2.1",
92 | "node-loader": "^0.6.0",
93 | "style-loader": "^0.18.2",
94 | "url-loader": "^0.5.9",
95 | "vue-html-loader": "^1.2.4",
96 | "vue-loader": "^13.0.5",
97 | "vue-style-loader": "^3.0.1",
98 | "vue-template-compiler": "*",
99 | "vue2-ace-editor": "0.0.3",
100 | "webpack": "^3.8.1",
101 | "webpack-dev-server": "^2.7.1",
102 | "webpack-hot-middleware": "^2.18.2"
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/.electron-vue/webpack.web.config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | process.env.BABEL_ENV = 'web'
4 |
5 | const path = require('path')
6 | const webpack = require('webpack')
7 |
8 | const BabiliWebpackPlugin = require('babili-webpack-plugin')
9 | const CopyWebpackPlugin = require('copy-webpack-plugin')
10 | const ExtractTextPlugin = require('extract-text-webpack-plugin')
11 | const HtmlWebpackPlugin = require('html-webpack-plugin')
12 |
13 | let webConfig = {
14 | devtool: '#cheap-module-eval-source-map',
15 | entry: {
16 | web: path.join(__dirname, '../src/renderer/main.js')
17 | },
18 | module: {
19 | rules: [
20 | {
21 | test: /\.(js|vue)$/,
22 | enforce: 'pre',
23 | exclude: /node_modules/,
24 | use: {
25 | loader: 'eslint-loader',
26 | options: {
27 | formatter: require('eslint-friendly-formatter')
28 | }
29 | }
30 | },
31 | {
32 | test: /\.css$/,
33 | use: ExtractTextPlugin.extract({
34 | fallback: 'style-loader',
35 | use: 'css-loader'
36 | })
37 | },
38 | {
39 | test: /\.html$/,
40 | use: 'vue-html-loader'
41 | },
42 | {
43 | test: /\.js$/,
44 | use: 'babel-loader',
45 | include: [ path.resolve(__dirname, '../src/renderer') ],
46 | exclude: /node_modules/
47 | },
48 | {
49 | test: /\.vue$/,
50 | use: {
51 | loader: 'vue-loader',
52 | options: {
53 | extractCSS: true,
54 | loaders: {
55 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1',
56 | scss: 'vue-style-loader!css-loader!sass-loader'
57 | }
58 | }
59 | }
60 | },
61 | {
62 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
63 | use: {
64 | loader: 'url-loader',
65 | query: {
66 | limit: 10000,
67 | name: 'imgs/[name].[ext]'
68 | }
69 | }
70 | },
71 | {
72 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
73 | use: {
74 | loader: 'url-loader',
75 | query: {
76 | limit: 10000,
77 | name: 'fonts/[name].[ext]'
78 | }
79 | }
80 | }
81 | ]
82 | },
83 | plugins: [
84 | new ExtractTextPlugin('styles.css'),
85 | new HtmlWebpackPlugin({
86 | filename: 'index.html',
87 | template: path.resolve(__dirname, '../src/index.ejs'),
88 | minify: {
89 | collapseWhitespace: true,
90 | removeAttributeQuotes: true,
91 | removeComments: true
92 | },
93 | nodeModules: false
94 | }),
95 | new webpack.DefinePlugin({
96 | 'process.env.IS_WEB': 'true'
97 | }),
98 | new webpack.HotModuleReplacementPlugin(),
99 | new webpack.NoEmitOnErrorsPlugin()
100 | ],
101 | output: {
102 | filename: '[name].js',
103 | path: path.join(__dirname, '../dist/web')
104 | },
105 | resolve: {
106 | alias: {
107 | '@': path.join(__dirname, '../src/renderer'),
108 | 'vue$': 'vue/dist/vue.esm.js'
109 | },
110 | extensions: ['.js', '.vue', '.json', '.css']
111 | },
112 | target: 'web'
113 | }
114 |
115 | /**
116 | * Adjust webConfig for production settings
117 | */
118 | if (process.env.NODE_ENV === 'production') {
119 | webConfig.devtool = ''
120 |
121 | webConfig.plugins.push(
122 | new BabiliWebpackPlugin(),
123 | new CopyWebpackPlugin([
124 | {
125 | from: path.join(__dirname, '../static'),
126 | to: path.join(__dirname, '../dist/web/static'),
127 | ignore: ['.*']
128 | }
129 | ]),
130 | new webpack.DefinePlugin({
131 | 'process.env.NODE_ENV': '"production"'
132 | }),
133 | new webpack.LoaderOptionsPlugin({
134 | minimize: true
135 | })
136 | )
137 | }
138 |
139 | module.exports = webConfig
140 |
--------------------------------------------------------------------------------
/src/renderer/components/Editor.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
47 |
48 |
183 |
--------------------------------------------------------------------------------
/.electron-vue/dev-runner.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const chalk = require('chalk')
4 | const electron = require('electron')
5 | const path = require('path')
6 | const { say } = require('cfonts')
7 | const { spawn } = require('child_process')
8 | const webpack = require('webpack')
9 | const WebpackDevServer = require('webpack-dev-server')
10 | const webpackHotMiddleware = require('webpack-hot-middleware')
11 |
12 | const mainConfig = require('./webpack.main.config')
13 | const rendererConfig = require('./webpack.renderer.config')
14 |
15 | let electronProcess = null
16 | let manualRestart = false
17 | let hotMiddleware
18 |
19 | function logStats (proc, data) {
20 | let log = ''
21 |
22 | log += chalk.yellow.bold(`┏ ${proc} Process ${new Array((19 - proc.length) + 1).join('-')}`)
23 | log += '\n\n'
24 |
25 | if (typeof data === 'object') {
26 | data.toString({
27 | colors: true,
28 | chunks: false
29 | }).split(/\r?\n/).forEach(line => {
30 | log += ' ' + line + '\n'
31 | })
32 | } else {
33 | log += ` ${data}\n`
34 | }
35 |
36 | log += '\n' + chalk.yellow.bold(`┗ ${new Array(28 + 1).join('-')}`) + '\n'
37 |
38 | console.log(log)
39 | }
40 |
41 | function startRenderer () {
42 | return new Promise((resolve, reject) => {
43 | rendererConfig.entry.renderer = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.renderer)
44 |
45 | const compiler = webpack(rendererConfig)
46 | hotMiddleware = webpackHotMiddleware(compiler, {
47 | log: false,
48 | heartbeat: 2500
49 | })
50 |
51 | compiler.plugin('compilation', compilation => {
52 | compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => {
53 | hotMiddleware.publish({ action: 'reload' })
54 | cb()
55 | })
56 | })
57 |
58 | compiler.plugin('done', stats => {
59 | logStats('Renderer', stats)
60 | })
61 |
62 | const server = new WebpackDevServer(
63 | compiler,
64 | {
65 | contentBase: path.join(__dirname, '../'),
66 | quiet: true,
67 | setup (app, ctx) {
68 | app.use(hotMiddleware)
69 | ctx.middleware.waitUntilValid(() => {
70 | resolve()
71 | })
72 | }
73 | }
74 | )
75 |
76 | server.listen(9080)
77 | })
78 | }
79 |
80 | function startMain () {
81 | return new Promise((resolve, reject) => {
82 | mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main)
83 |
84 | const compiler = webpack(mainConfig)
85 |
86 | compiler.plugin('watch-run', (compilation, done) => {
87 | logStats('Main', chalk.white.bold('compiling...'))
88 | hotMiddleware.publish({ action: 'compiling' })
89 | done()
90 | })
91 |
92 | compiler.watch({}, (err, stats) => {
93 | if (err) {
94 | console.log(err)
95 | return
96 | }
97 |
98 | logStats('Main', stats)
99 |
100 | if (electronProcess && electronProcess.kill) {
101 | manualRestart = true
102 | process.kill(electronProcess.pid)
103 | electronProcess = null
104 | startElectron()
105 |
106 | setTimeout(() => {
107 | manualRestart = false
108 | }, 5000)
109 | }
110 |
111 | resolve()
112 | })
113 | })
114 | }
115 |
116 | function startElectron () {
117 | electronProcess = spawn(electron, ['--inspect=5858', path.join(__dirname, '../dist/electron/main.js')])
118 |
119 | electronProcess.stdout.on('data', data => {
120 | electronLog(data, 'blue')
121 | })
122 | electronProcess.stderr.on('data', data => {
123 | electronLog(data, 'red')
124 | })
125 |
126 | electronProcess.on('close', () => {
127 | if (!manualRestart) process.exit()
128 | })
129 | }
130 |
131 | function electronLog (data, color) {
132 | let log = ''
133 | data = data.toString().split(/\r?\n/)
134 | data.forEach(line => {
135 | log += ` ${line}\n`
136 | })
137 | if (/[0-9A-z]+/.test(log)) {
138 | console.log(
139 | chalk[color].bold('┏ Electron -------------------') +
140 | '\n\n' +
141 | log +
142 | chalk[color].bold('┗ ----------------------------') +
143 | '\n'
144 | )
145 | }
146 | }
147 |
148 | function greeting () {
149 | const cols = process.stdout.columns
150 | let text = ''
151 |
152 | if (cols > 104) text = 'electron-vue'
153 | else if (cols > 76) text = 'electron-|vue'
154 | else text = false
155 |
156 | if (text) {
157 | say(text, {
158 | colors: ['yellow'],
159 | font: 'simple3d',
160 | space: false
161 | })
162 | } else console.log(chalk.yellow.bold('\n electron-vue'))
163 | console.log(chalk.blue(' getting ready...') + '\n')
164 | }
165 |
166 | function init () {
167 | greeting()
168 |
169 | Promise.all([startRenderer(), startMain()])
170 | .then(() => {
171 | startElectron()
172 | })
173 | .catch(err => {
174 | console.error(err)
175 | })
176 | }
177 |
178 | init()
179 |
--------------------------------------------------------------------------------
/.electron-vue/webpack.renderer.config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | process.env.BABEL_ENV = 'renderer'
4 |
5 | const path = require('path')
6 | const { dependencies } = require('../package.json')
7 | const webpack = require('webpack')
8 |
9 | const BabiliWebpackPlugin = require('babili-webpack-plugin')
10 | const CopyWebpackPlugin = require('copy-webpack-plugin')
11 | const ExtractTextPlugin = require('extract-text-webpack-plugin')
12 | const HtmlWebpackPlugin = require('html-webpack-plugin')
13 |
14 | /**
15 | * List of node_modules to include in webpack bundle
16 | *
17 | * Required for specific packages like Vue UI libraries
18 | * that provide pure *.vue files that need compiling
19 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals
20 | */
21 | let whiteListedModules = ['vue']
22 |
23 | let rendererConfig = {
24 | devtool: '#cheap-module-eval-source-map',
25 | entry: {
26 | renderer: path.join(__dirname, '../src/renderer/main.js')
27 | },
28 | externals: [
29 | ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))
30 | ],
31 | module: {
32 | rules: [
33 | {
34 | test: /\.(js|vue)$/,
35 | enforce: 'pre',
36 | exclude: /node_modules/,
37 | use: {
38 | loader: 'eslint-loader',
39 | options: {
40 | formatter: require('eslint-friendly-formatter')
41 | }
42 | }
43 | },
44 | {
45 | test: /\.css$/,
46 | use: ExtractTextPlugin.extract({
47 | fallback: 'style-loader',
48 | use: 'css-loader'
49 | })
50 | },
51 | {
52 | test: /\.html$/,
53 | use: 'vue-html-loader'
54 | },
55 | {
56 | test: /\.js$/,
57 | use: 'babel-loader',
58 | exclude: /node_modules/
59 | },
60 | {
61 | test: /\.node$/,
62 | use: 'node-loader'
63 | },
64 | {
65 | test: /\.scss$/,
66 | use: [{
67 | loader: 'style-loader'
68 | }, {
69 | loader: 'css-loader'
70 | }, {
71 | loader: 'sass-loader'
72 | }]
73 |
74 | },
75 | {
76 | test: /\.vue$/,
77 | use: {
78 | loader: 'vue-loader',
79 | options: {
80 | extractCSS: process.env.NODE_ENV === 'production',
81 | loaders: {
82 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1',
83 | scss: 'vue-style-loader!css-loader!sass-loader'
84 | }
85 | }
86 | }
87 | },
88 | {
89 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
90 | use: {
91 | loader: 'url-loader',
92 | query: {
93 | limit: 10000,
94 | name: 'imgs/[name]--[folder].[ext]'
95 | }
96 | }
97 | },
98 | {
99 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
100 | loader: 'url-loader',
101 | options: {
102 | limit: 10000,
103 | name: 'media/[name]--[folder].[ext]'
104 | }
105 | },
106 | {
107 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
108 | use: {
109 | loader: 'url-loader',
110 | query: {
111 | limit: 10000,
112 | name: 'fonts/[name]--[folder].[ext]'
113 | }
114 | }
115 | }
116 | ]
117 | },
118 | node: {
119 | __dirname: process.env.NODE_ENV !== 'production',
120 | __filename: process.env.NODE_ENV !== 'production'
121 | },
122 | plugins: [
123 | new ExtractTextPlugin('styles.css'),
124 | new HtmlWebpackPlugin({
125 | filename: 'index.html',
126 | template: path.resolve(__dirname, '../src/index.ejs'),
127 | minify: {
128 | collapseWhitespace: true,
129 | removeAttributeQuotes: true,
130 | removeComments: true
131 | },
132 | nodeModules: process.env.NODE_ENV !== 'production'
133 | ? path.resolve(__dirname, '../node_modules')
134 | : false
135 | }),
136 | new webpack.HotModuleReplacementPlugin(),
137 | new webpack.NoEmitOnErrorsPlugin()
138 | ],
139 | output: {
140 | filename: '[name].js',
141 | libraryTarget: 'commonjs2',
142 | path: path.join(__dirname, '../dist/electron')
143 | },
144 | resolve: {
145 | alias: {
146 | '@': path.join(__dirname, '../src/renderer'),
147 | 'vue$': 'vue/dist/vue.esm.js'
148 | },
149 | extensions: ['.js', '.vue', '.json', '.css', '.node']
150 | },
151 | target: 'electron-renderer'
152 | }
153 |
154 | /**
155 | * Adjust rendererConfig for development settings
156 | */
157 | if (process.env.NODE_ENV !== 'production') {
158 | rendererConfig.plugins.push(
159 | new webpack.DefinePlugin({
160 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
161 | })
162 | )
163 | }
164 |
165 | /**
166 | * Adjust rendererConfig for production settings
167 | */
168 | if (process.env.NODE_ENV === 'production') {
169 | rendererConfig.devtool = ''
170 |
171 | rendererConfig.plugins.push(
172 | new BabiliWebpackPlugin(),
173 | new CopyWebpackPlugin([
174 | {
175 | from: path.join(__dirname, '../static'),
176 | to: path.join(__dirname, '../dist/electron/static'),
177 | ignore: ['.*']
178 | }
179 | ]),
180 | new webpack.DefinePlugin({
181 | 'process.env.NODE_ENV': '"production"'
182 | }),
183 | new webpack.LoaderOptionsPlugin({
184 | minimize: true
185 | })
186 | )
187 | }
188 |
189 | module.exports = rendererConfig
190 |
--------------------------------------------------------------------------------
/static/json-lint.js:
--------------------------------------------------------------------------------
1 | /* Jison generated parser */
2 | var jsonlint = (function(){
3 | var parser = {trace: function trace() { },
4 | yy: {},
5 | symbols_: {"error":2,"JSONString":3,"STRING":4,"JSONNumber":5,"NUMBER":6,"JSONNullLiteral":7,"NULL":8,"JSONBooleanLiteral":9,"TRUE":10,"FALSE":11,"JSONText":12,"JSONValue":13,"EOF":14,"JSONObject":15,"JSONArray":16,"{":17,"}":18,"JSONMemberList":19,"JSONMember":20,":":21,",":22,"[":23,"]":24,"JSONElementList":25,"$accept":0,"$end":1},
6 | terminals_: {2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},
7 | productions_: [0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],
8 | performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
9 |
10 | var $0 = $$.length - 1;
11 | switch (yystate) {
12 | case 1: // replace escaped characters with actual character
13 | this.$ = yytext.replace(/\\(\\|")/g, "$"+"1")
14 | .replace(/\\n/g,'\n')
15 | .replace(/\\r/g,'\r')
16 | .replace(/\\t/g,'\t')
17 | .replace(/\\v/g,'\v')
18 | .replace(/\\f/g,'\f')
19 | .replace(/\\b/g,'\b');
20 |
21 | break;
22 | case 2:this.$ = Number(yytext);
23 | break;
24 | case 3:this.$ = null;
25 | break;
26 | case 4:this.$ = true;
27 | break;
28 | case 5:this.$ = false;
29 | break;
30 | case 6:return this.$ = $$[$0-1];
31 | break;
32 | case 13:this.$ = {};
33 | break;
34 | case 14:this.$ = $$[$0-1];
35 | break;
36 | case 15:this.$ = [$$[$0-2], $$[$0]];
37 | break;
38 | case 16:this.$ = {}; this.$[$$[$0][0]] = $$[$0][1];
39 | break;
40 | case 17:this.$ = $$[$0-2]; $$[$0-2][$$[$0][0]] = $$[$0][1];
41 | break;
42 | case 18:this.$ = [];
43 | break;
44 | case 19:this.$ = $$[$0-1];
45 | break;
46 | case 20:this.$ = [$$[$0]];
47 | break;
48 | case 21:this.$ = $$[$0-2]; $$[$0-2].push($$[$0]);
49 | break;
50 | }
51 | },
52 | table: [{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],12:1,13:2,15:7,16:8,17:[1,14],23:[1,15]},{1:[3]},{14:[1,16]},{14:[2,7],18:[2,7],22:[2,7],24:[2,7]},{14:[2,8],18:[2,8],22:[2,8],24:[2,8]},{14:[2,9],18:[2,9],22:[2,9],24:[2,9]},{14:[2,10],18:[2,10],22:[2,10],24:[2,10]},{14:[2,11],18:[2,11],22:[2,11],24:[2,11]},{14:[2,12],18:[2,12],22:[2,12],24:[2,12]},{14:[2,3],18:[2,3],22:[2,3],24:[2,3]},{14:[2,4],18:[2,4],22:[2,4],24:[2,4]},{14:[2,5],18:[2,5],22:[2,5],24:[2,5]},{14:[2,1],18:[2,1],21:[2,1],22:[2,1],24:[2,1]},{14:[2,2],18:[2,2],22:[2,2],24:[2,2]},{3:20,4:[1,12],18:[1,17],19:18,20:19},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:23,15:7,16:8,17:[1,14],23:[1,15],24:[1,21],25:22},{1:[2,6]},{14:[2,13],18:[2,13],22:[2,13],24:[2,13]},{18:[1,24],22:[1,25]},{18:[2,16],22:[2,16]},{21:[1,26]},{14:[2,18],18:[2,18],22:[2,18],24:[2,18]},{22:[1,28],24:[1,27]},{22:[2,20],24:[2,20]},{14:[2,14],18:[2,14],22:[2,14],24:[2,14]},{3:20,4:[1,12],20:29},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:30,15:7,16:8,17:[1,14],23:[1,15]},{14:[2,19],18:[2,19],22:[2,19],24:[2,19]},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:31,15:7,16:8,17:[1,14],23:[1,15]},{18:[2,17],22:[2,17]},{18:[2,15],22:[2,15]},{22:[2,21],24:[2,21]}],
53 | defaultActions: {16:[2,6]},
54 | parseError: function parseError(str, hash) {
55 | throw new Error(str);
56 | },
57 | parse: function parse(input) {
58 | var self = this,
59 | stack = [0],
60 | vstack = [null], // semantic value stack
61 | lstack = [], // location stack
62 | table = this.table,
63 | yytext = '',
64 | yylineno = 0,
65 | yyleng = 0,
66 | recovering = 0,
67 | TERROR = 2,
68 | EOF = 1;
69 |
70 | //this.reductionCount = this.shiftCount = 0;
71 |
72 | this.lexer.setInput(input);
73 | this.lexer.yy = this.yy;
74 | this.yy.lexer = this.lexer;
75 | if (typeof this.lexer.yylloc == 'undefined')
76 | this.lexer.yylloc = {};
77 | var yyloc = this.lexer.yylloc;
78 | lstack.push(yyloc);
79 |
80 | if (typeof this.yy.parseError === 'function')
81 | this.parseError = this.yy.parseError;
82 |
83 | function popStack (n) {
84 | stack.length = stack.length - 2*n;
85 | vstack.length = vstack.length - n;
86 | lstack.length = lstack.length - n;
87 | }
88 |
89 | function lex() {
90 | var token;
91 | token = self.lexer.lex() || 1; // $end = 1
92 | // if token isn't its numeric value, convert
93 | if (typeof token !== 'number') {
94 | token = self.symbols_[token] || token;
95 | }
96 | return token;
97 | }
98 |
99 | var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
100 | while (true) {
101 | // retreive state number from top of stack
102 | state = stack[stack.length-1];
103 |
104 | // use default actions if available
105 | if (this.defaultActions[state]) {
106 | action = this.defaultActions[state];
107 | } else {
108 | if (symbol == null)
109 | symbol = lex();
110 | // read action for current state and first input
111 | action = table[state] && table[state][symbol];
112 | }
113 |
114 | // handle parse error
115 | _handle_error:
116 | if (typeof action === 'undefined' || !action.length || !action[0]) {
117 |
118 | if (!recovering) {
119 | // Report error
120 | expected = [];
121 | for (p in table[state]) if (this.terminals_[p] && p > 2) {
122 | expected.push("'"+this.terminals_[p]+"'");
123 | }
124 | var errStr = '';
125 | if (this.lexer.showPosition) {
126 | errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
127 | } else {
128 | errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
129 | (symbol == 1 /*EOF*/ ? "end of input" :
130 | ("'"+(this.terminals_[symbol] || symbol)+"'"));
131 | }
132 | this.parseError(errStr,
133 | {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
134 | }
135 |
136 | // just recovered from another error
137 | if (recovering == 3) {
138 | if (symbol == EOF) {
139 | throw new Error(errStr || 'Parsing halted.');
140 | }
141 |
142 | // discard current lookahead and grab another
143 | yyleng = this.lexer.yyleng;
144 | yytext = this.lexer.yytext;
145 | yylineno = this.lexer.yylineno;
146 | yyloc = this.lexer.yylloc;
147 | symbol = lex();
148 | }
149 |
150 | // try to recover from error
151 | while (1) {
152 | // check for error recovery rule in this state
153 | if ((TERROR.toString()) in table[state]) {
154 | break;
155 | }
156 | if (state == 0) {
157 | throw new Error(errStr || 'Parsing halted.');
158 | }
159 | popStack(1);
160 | state = stack[stack.length-1];
161 | }
162 |
163 | preErrorSymbol = symbol; // save the lookahead token
164 | symbol = TERROR; // insert generic error symbol as new lookahead
165 | state = stack[stack.length-1];
166 | action = table[state] && table[state][TERROR];
167 | recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
168 | }
169 |
170 | // this shouldn't happen, unless resolve defaults are off
171 | if (action[0] instanceof Array && action.length > 1) {
172 | throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
173 | }
174 |
175 | switch (action[0]) {
176 |
177 | case 1: // shift
178 | //this.shiftCount++;
179 |
180 | stack.push(symbol);
181 | vstack.push(this.lexer.yytext);
182 | lstack.push(this.lexer.yylloc);
183 | stack.push(action[1]); // push state
184 | symbol = null;
185 | if (!preErrorSymbol) { // normal execution/no error
186 | yyleng = this.lexer.yyleng;
187 | yytext = this.lexer.yytext;
188 | yylineno = this.lexer.yylineno;
189 | yyloc = this.lexer.yylloc;
190 | if (recovering > 0)
191 | recovering--;
192 | } else { // error just occurred, resume old lookahead f/ before error
193 | symbol = preErrorSymbol;
194 | preErrorSymbol = null;
195 | }
196 | break;
197 |
198 | case 2: // reduce
199 | //this.reductionCount++;
200 |
201 | len = this.productions_[action[1]][1];
202 |
203 | // perform semantic action
204 | yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
205 | // default location, uses first token for firsts, last for lasts
206 | yyval._$ = {
207 | first_line: lstack[lstack.length-(len||1)].first_line,
208 | last_line: lstack[lstack.length-1].last_line,
209 | first_column: lstack[lstack.length-(len||1)].first_column,
210 | last_column: lstack[lstack.length-1].last_column
211 | };
212 | r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
213 |
214 | if (typeof r !== 'undefined') {
215 | return r;
216 | }
217 |
218 | // pop off stack
219 | if (len) {
220 | stack = stack.slice(0,-1*len*2);
221 | vstack = vstack.slice(0, -1*len);
222 | lstack = lstack.slice(0, -1*len);
223 | }
224 |
225 | stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
226 | vstack.push(yyval.$);
227 | lstack.push(yyval._$);
228 | // goto new state = table[STATE][NONTERMINAL]
229 | newState = table[stack[stack.length-2]][stack[stack.length-1]];
230 | stack.push(newState);
231 | break;
232 |
233 | case 3: // accept
234 | return true;
235 | }
236 |
237 | }
238 |
239 | return true;
240 | }};
241 | /* Jison generated lexer */
242 | var lexer = (function(){
243 | var lexer = ({EOF:1,
244 | parseError:function parseError(str, hash) {
245 | if (this.yy.parseError) {
246 | this.yy.parseError(str, hash);
247 | } else {
248 | throw new Error(str);
249 | }
250 | },
251 | setInput:function (input) {
252 | this._input = input;
253 | this._more = this._less = this.done = false;
254 | this.yylineno = this.yyleng = 0;
255 | this.yytext = this.matched = this.match = '';
256 | this.conditionStack = ['INITIAL'];
257 | this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
258 | return this;
259 | },
260 | input:function () {
261 | var ch = this._input[0];
262 | this.yytext+=ch;
263 | this.yyleng++;
264 | this.match+=ch;
265 | this.matched+=ch;
266 | var lines = ch.match(/\n/);
267 | if (lines) this.yylineno++;
268 | this._input = this._input.slice(1);
269 | return ch;
270 | },
271 | unput:function (ch) {
272 | this._input = ch + this._input;
273 | return this;
274 | },
275 | more:function () {
276 | this._more = true;
277 | return this;
278 | },
279 | less:function (n) {
280 | this._input = this.match.slice(n) + this._input;
281 | },
282 | pastInput:function () {
283 | var past = this.matched.substr(0, this.matched.length - this.match.length);
284 | return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
285 | },
286 | upcomingInput:function () {
287 | var next = this.match;
288 | if (next.length < 20) {
289 | next += this._input.substr(0, 20-next.length);
290 | }
291 | return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
292 | },
293 | showPosition:function () {
294 | var pre = this.pastInput();
295 | var c = new Array(pre.length + 1).join("-");
296 | return pre + this.upcomingInput() + "\n" + c+"^";
297 | },
298 | next:function () {
299 | if (this.done) {
300 | return this.EOF;
301 | }
302 | if (!this._input) this.done = true;
303 |
304 | var token,
305 | match,
306 | tempMatch,
307 | index,
308 | col,
309 | lines;
310 | if (!this._more) {
311 | this.yytext = '';
312 | this.match = '';
313 | }
314 | var rules = this._currentRules();
315 | for (var i=0;i < rules.length; i++) {
316 | tempMatch = this._input.match(this.rules[rules[i]]);
317 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
318 | match = tempMatch;
319 | index = i;
320 | if (!this.options.flex) break;
321 | }
322 | }
323 | if (match) {
324 | lines = match[0].match(/\n.*/g);
325 | if (lines) this.yylineno += lines.length;
326 | this.yylloc = {first_line: this.yylloc.last_line,
327 | last_line: this.yylineno+1,
328 | first_column: this.yylloc.last_column,
329 | last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
330 | this.yytext += match[0];
331 | this.match += match[0];
332 | this.yyleng = this.yytext.length;
333 | this._more = false;
334 | this._input = this._input.slice(match[0].length);
335 | this.matched += match[0];
336 | token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
337 | if (this.done && this._input) this.done = false;
338 | if (token) return token;
339 | else return;
340 | }
341 | if (this._input === "") {
342 | return this.EOF;
343 | } else {
344 | this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
345 | {text: "", token: null, line: this.yylineno});
346 | }
347 | },
348 | lex:function lex() {
349 | var r = this.next();
350 | if (typeof r !== 'undefined') {
351 | return r;
352 | } else {
353 | return this.lex();
354 | }
355 | },
356 | begin:function begin(condition) {
357 | this.conditionStack.push(condition);
358 | },
359 | popState:function popState() {
360 | return this.conditionStack.pop();
361 | },
362 | _currentRules:function _currentRules() {
363 | return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
364 | },
365 | topState:function () {
366 | return this.conditionStack[this.conditionStack.length-2];
367 | },
368 | pushState:function begin(condition) {
369 | this.begin(condition);
370 | }});
371 | lexer.options = {};
372 | lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
373 |
374 | var YYSTATE=YY_START
375 | switch($avoiding_name_collisions) {
376 | case 0:/* skip whitespace */
377 | break;
378 | case 1:return 6
379 | break;
380 | case 2:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 4
381 | break;
382 | case 3:return 17
383 | break;
384 | case 4:return 18
385 | break;
386 | case 5:return 23
387 | break;
388 | case 6:return 24
389 | break;
390 | case 7:return 22
391 | break;
392 | case 8:return 21
393 | break;
394 | case 9:return 10
395 | break;
396 | case 10:return 11
397 | break;
398 | case 11:return 8
399 | break;
400 | case 12:return 14
401 | break;
402 | case 13:return 'INVALID'
403 | break;
404 | }
405 | };
406 | lexer.rules = [/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/];
407 | lexer.conditions = {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}};
408 |
409 |
410 | ;
411 | return lexer;})()
412 | parser.lexer = lexer;
413 | return parser;
414 | })();
415 | if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
416 | exports.parser = jsonlint;
417 | exports.parse = function () { return jsonlint.parse.apply(jsonlint, arguments); }
418 | exports.main = function commonjsMain(args) {
419 | if (!args[1])
420 | throw new Error('Usage: '+args[0]+' FILE');
421 | if (typeof process !== 'undefined') {
422 | var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
423 | } else {
424 | var cwd = require("file").path(require("file").cwd());
425 | var source = cwd.join(args[1]).read({charset: "utf-8"});
426 | }
427 | return exports.parser.parse(source);
428 | }
429 | if (typeof module !== 'undefined' && require.main === module) {
430 | exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
431 | }
432 | }
433 |
--------------------------------------------------------------------------------