lincd-cli 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/defaults/app3/package.json +2 -1
- package/package.json +1 -1
- package/defaults/app/src/App.scss +0 -3
- package/defaults/app/src/App.tsx +0 -5
- package/defaults/app/src/index.tsx +0 -10
- package/defaults/app/tsconfig.json +0 -18
- package/defaults/app2/backend/src/server.js +0 -152
- package/defaults/app2/backend/src/server.js.map +0 -1
- package/defaults/app2/backend/src/server.tsx +0 -137
- package/defaults/app2/frontend/src/App.js +0 -52
- package/defaults/app2/frontend/src/App.js.map +0 -1
- package/defaults/app2/frontend/src/App.tsx +0 -35
- package/defaults/app2/frontend/src/Html.js +0 -12
- package/defaults/app2/frontend/src/Html.js.map +0 -0
- package/defaults/app2/frontend/src/Html.tsx +0 -29
- package/defaults/app2/frontend/src/Layout.js +0 -153
- package/defaults/app2/frontend/src/Layout.js.map +0 -1
- package/defaults/app2/frontend/src/Layout.tsx +0 -5
- package/defaults/app2/frontend/src/Spinner.js +0 -9
- package/defaults/app2/frontend/src/Spinner.js.map +0 -0
- package/defaults/app2/frontend/src/Spinner.scss +0 -17
- package/defaults/app2/frontend/src/Spinner.tsx +0 -10
- package/defaults/app2/frontend/src/index.js +0 -14
- package/defaults/app2/frontend/src/index.js.map +0 -0
- package/defaults/app2/frontend/src/index.tsx +0 -16
- package/defaults/app2/tsconfig.json +0 -17
- package/defaults/app3/frontend/src/App.tsx +0 -72
- package/defaults/app3/frontend/src/Header.tsx +0 -16
- package/defaults/app3/frontend/src/Html.tsx +0 -29
- package/defaults/app3/frontend/src/Layout.tsx +0 -11
- package/defaults/app3/frontend/src/_tailwind.scss +0 -3
- package/defaults/app3/frontend/src/components/Spinner.scss +0 -17
- package/defaults/app3/frontend/src/components/Spinner.tsx +0 -10
- package/defaults/app3/frontend/src/index.tsx +0 -20
- package/defaults/app3/frontend/src/pages/Home.tsx +0 -15
- package/defaults/app3/frontend/src/pages/Page1.scss +0 -3
- package/defaults/app3/frontend/src/pages/Page1.scss.json +0 -1
- package/defaults/app3/frontend/src/pages/Page1.tsx +0 -15
- package/defaults/app3/frontend/src/pages/Page2.scss +0 -16
- package/defaults/app3/frontend/src/pages/Page2.scss.json +0 -1
- package/defaults/app3/frontend/src/pages/Page2.tsx +0 -21
- package/defaults/app3/tsconfig.json +0 -17
- package/defaults/module/Gruntfile.js +0 -16
- package/defaults/module/src/components/ExampleComponent.tsx +0 -20
- package/defaults/module/src/data/example-ontology.json +0 -20
- package/defaults/module/src/data/example-ontology.json.d.ts +0 -1
- package/defaults/module/src/index.ts +0 -7
- package/defaults/module/src/module.ts +0 -4
- package/defaults/module/src/ontologies/example-ontology.ts +0 -36
- package/defaults/module/src/shapes/ExampleShapeClass.ts +0 -29
- package/defaults/module/tsconfig-es5.json +0 -18
- package/defaults/module/tsconfig.json +0 -18
package/package.json
CHANGED
package/defaults/app/src/App.tsx
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {createRoot} from 'react-dom/client';
|
|
3
|
-
import {App} from './App';
|
|
4
|
-
|
|
5
|
-
declare var document;
|
|
6
|
-
if (typeof document !== 'undefined') {
|
|
7
|
-
const container = document.getElementById('root');
|
|
8
|
-
const root = createRoot(container!);
|
|
9
|
-
root.render(<App></App>);
|
|
10
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"sourceMap": true,
|
|
5
|
-
"target": "es6",
|
|
6
|
-
"outDir": "lib",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"downlevelIteration": true,
|
|
11
|
-
"experimentalDecorators": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"jsx": "react",
|
|
14
|
-
"baseUrl": "./",
|
|
15
|
-
"rootDir": "src"
|
|
16
|
-
},
|
|
17
|
-
"files": ["./src/index.tsx"]
|
|
18
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
//not sure what this does, but removing it causes errors
|
|
7
|
-
// const babelRegister = require('@babel/register');
|
|
8
|
-
// babelRegister({
|
|
9
|
-
// ignore: [/[\\\/](frontend\/build|frontend\/lib|backend\/lib|node_modules)[\\\/]/],
|
|
10
|
-
// presets: [['react-app', {runtime: 'automatic'}]],
|
|
11
|
-
// plugins: ['@babel/transform-modules-commonjs'],
|
|
12
|
-
// });
|
|
13
|
-
//make sure nodejs doesn't choke when css files are imported in js
|
|
14
|
-
const ignore_styles_1 = __importDefault(require("ignore-styles"));
|
|
15
|
-
(0, ignore_styles_1.default)(['.sass', '.scss', '.css']);
|
|
16
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
17
|
-
const body_parser_1 = __importDefault(require("body-parser"));
|
|
18
|
-
const fs_1 = __importDefault(require("fs"));
|
|
19
|
-
globalThis.fetch = node_fetch_1.default;
|
|
20
|
-
const express = require('express');
|
|
21
|
-
const compress = require('compression');
|
|
22
|
-
const { readFileSync } = require('fs');
|
|
23
|
-
const path = require('path');
|
|
24
|
-
const render_1 = __importDefault(require("./render"));
|
|
25
|
-
const JSONWriter_1 = require("lincd-jsonld/lib/JSONWriter");
|
|
26
|
-
const Schema_1 = require("lincd-graphql/lib/shapes/Schema");
|
|
27
|
-
const GraphQLParser_1 = require("lincd-graphql/lib/GraphQLParser");
|
|
28
|
-
const JSONLDWriter_1 = require("lincd-jsonld/lib/JSONLDWriter");
|
|
29
|
-
const PORT = process.env.PORT || 4000;
|
|
30
|
-
const app = express();
|
|
31
|
-
const REGISTRY_URL = process.env.REGISTRY_URL;
|
|
32
|
-
//does this compress things with gzip?
|
|
33
|
-
app.use(compress());
|
|
34
|
-
app.use(body_parser_1.default.json());
|
|
35
|
-
// app.use(bodyParser.urlencoded({extended: true}));
|
|
36
|
-
app.use('/static', express.static('./frontend/web'));
|
|
37
|
-
app.use('/images', express.static('./frontend/web/images'));
|
|
38
|
-
app.use('/css', express.static('./frontend/web/css'));
|
|
39
|
-
app.use('/js', express.static('./frontend/build'));
|
|
40
|
-
app.get('*', handleErrors(async function (req, res) {
|
|
41
|
-
//make sure the frontend bundle has finished building
|
|
42
|
-
await waitForWebpack();
|
|
43
|
-
(0, render_1.default)(req.url, res);
|
|
44
|
-
}));
|
|
45
|
-
//reject any requests that are not from localhost
|
|
46
|
-
function localOnly(req, res, next) {
|
|
47
|
-
var hostmachine = req.headers.host.split(':')[0];
|
|
48
|
-
if (hostmachine !== 'localhost' && hostmachine !== 'dev.lincd.org' && hostmachine !== 'www.lincd.org') {
|
|
49
|
-
return res.send(401);
|
|
50
|
-
}
|
|
51
|
-
next();
|
|
52
|
-
}
|
|
53
|
-
const sendJson = async function (res, obj) {
|
|
54
|
-
let json = await JSONWriter_1.JSONWriter.stringify(obj, true);
|
|
55
|
-
// console.log('Sending data...', json);
|
|
56
|
-
res.send(json);
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Handles data requests from the frontend and sends them off to the registry.
|
|
60
|
-
* We don't expose the registry through a URL. instead we always access it on the local network from the backend.
|
|
61
|
-
*/
|
|
62
|
-
app.post('/request/*', async (req, res) => {
|
|
63
|
-
let url = REGISTRY_URL + req.url.substr('/request'.length);
|
|
64
|
-
let body = req.body;
|
|
65
|
-
// if(Object.keys(body).length === 0)
|
|
66
|
-
// {
|
|
67
|
-
// console.warn("Empty body");
|
|
68
|
-
// console.warn('Content type :'+req.headers['content-type']);
|
|
69
|
-
// res.send(false);
|
|
70
|
-
// return;
|
|
71
|
-
// }
|
|
72
|
-
return (0, node_fetch_1.default)(url, {
|
|
73
|
-
method: 'POST',
|
|
74
|
-
headers: {
|
|
75
|
-
Accept: 'application/json, text/plain, */*',
|
|
76
|
-
'Content-Type': 'application/json',
|
|
77
|
-
},
|
|
78
|
-
body: JSON.stringify(body),
|
|
79
|
-
})
|
|
80
|
-
.then((res) => {
|
|
81
|
-
if (!res.ok) {
|
|
82
|
-
throw new Error(url + ' returned ' + res.status + ' - ' + res.statusText);
|
|
83
|
-
}
|
|
84
|
-
return res.json();
|
|
85
|
-
})
|
|
86
|
-
.then((jsonObject) => {
|
|
87
|
-
sendJson(res, jsonObject);
|
|
88
|
-
})
|
|
89
|
-
.catch((err) => {
|
|
90
|
-
console.warn('error during internal registry request to ' + url + ': ', err);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
app.post('/api/tools/graphql', async (req, res) => {
|
|
94
|
-
let { url, headers } = req.body;
|
|
95
|
-
// let parser = new GraphQLParser(url);
|
|
96
|
-
let parseResult = await GraphQLParser_1.GraphQLParser.parseSchema(url, headers); //parser.parseSchema();
|
|
97
|
-
if (parseResult instanceof Schema_1.Schema) {
|
|
98
|
-
let rawJSONLD = await JSONLDWriter_1.JSONLDWriter.toJSONObject([parseResult.node, parseResult.publicShapes]);
|
|
99
|
-
fs_1.default.writeFile(path.join('../tmp', url.replace(/[^a-z0-9]+/gi, '-') + '.json'), JSON.stringify(rawJSONLD, null, 2), (err) => {
|
|
100
|
-
console.log(err);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
sendJson(res, parseResult instanceof Schema_1.Schema ? parseResult.node : parseResult);
|
|
104
|
-
// if (type === owl.Ontology) {
|
|
105
|
-
// sendJson(res, instances);
|
|
106
|
-
});
|
|
107
|
-
app
|
|
108
|
-
.listen(PORT, () => {
|
|
109
|
-
console.log(`Up and running at http://localhost:${PORT}`);
|
|
110
|
-
})
|
|
111
|
-
.on('error', function (error) {
|
|
112
|
-
if (error.syscall !== 'listen') {
|
|
113
|
-
throw error;
|
|
114
|
-
}
|
|
115
|
-
const isPipe = (portOrPipe) => Number.isNaN(portOrPipe);
|
|
116
|
-
const bind = isPipe(PORT) ? 'Pipe ' + PORT : 'Port ' + PORT;
|
|
117
|
-
switch (error.code) {
|
|
118
|
-
case 'EACCES':
|
|
119
|
-
console.error(bind + ' requires elevated privileges');
|
|
120
|
-
process.exit(1);
|
|
121
|
-
break;
|
|
122
|
-
case 'EADDRINUSE':
|
|
123
|
-
console.error(bind + ' is already in use');
|
|
124
|
-
process.exit(1);
|
|
125
|
-
break;
|
|
126
|
-
default:
|
|
127
|
-
throw error;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
function handleErrors(fn) {
|
|
131
|
-
return async function (req, res, next) {
|
|
132
|
-
try {
|
|
133
|
-
return await fn(req, res);
|
|
134
|
-
}
|
|
135
|
-
catch (x) {
|
|
136
|
-
next(x);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
async function waitForWebpack() {
|
|
141
|
-
while (true) {
|
|
142
|
-
try {
|
|
143
|
-
readFileSync(path.resolve(__dirname, '../../frontend/build/main.js'));
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
catch (err) {
|
|
147
|
-
console.log('Could not find webpack build output. Will retry in a second...');
|
|
148
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["server.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,wDAAwD;AACxD,oDAAoD;AACpD,kBAAkB;AAClB,sFAAsF;AACtF,qDAAqD;AACrD,mDAAmD;AACnD,MAAM;AAEN,kEAAkE;AAClE,kEAAqC;AACrC,IAAA,uBAAQ,EAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAErC,4DAA+B;AAC/B,8DA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AE;YACV,IAAI,CAAC,CAAC,CAAC,CAAC;SACT;IACH,CAAC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,cAAc;IAC3B,OAAO,IAAI,EAAE;QACX,IAAI;YACF,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,8BAA8B,CAAC,CAAC,CAAC;YACtE,OAAO;SACR;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAC;YAC9E,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;SAC3D;KACF;AACH,CAAC"}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
//prevent errors in node.js when (s)css files are imported in js
|
|
4
|
-
import register from 'ignore-styles';
|
|
5
|
-
import fetch from 'node-fetch';
|
|
6
|
-
import bodyParser from 'body-parser';
|
|
7
|
-
|
|
8
|
-
import {JSONWriter} from 'lincd-jsonld/lib/utils/JSONWriter';
|
|
9
|
-
import * as React from 'react';
|
|
10
|
-
import {renderToPipeableStream} from 'react-dom/server';
|
|
11
|
-
import App from '../../frontend/src/App';
|
|
12
|
-
import {StaticRouter} from 'react-router-dom/server';
|
|
13
|
-
|
|
14
|
-
register(['.sass', '.scss', '.css']);
|
|
15
|
-
|
|
16
|
-
declare var globalThis: any;
|
|
17
|
-
globalThis.fetch = fetch;
|
|
18
|
-
|
|
19
|
-
const express = require('express');
|
|
20
|
-
const compress = require('compression');
|
|
21
|
-
const {readFileSync} = require('fs');
|
|
22
|
-
const path = require('path');
|
|
23
|
-
|
|
24
|
-
let assets = {
|
|
25
|
-
'main.js': '/js/main.js', //output js bundle from Webpack of frontend/src
|
|
26
|
-
'main.css': '/js/main.css', //output css from Webpack of frontend/src
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const isProduction = process.env.NODE_ENV === 'production';
|
|
30
|
-
if (!isProduction) {
|
|
31
|
-
assets['tailwind-cdn'] = 'https://cdn.tailwindcss.com';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const PORT = process.env.PORT || 4000;
|
|
35
|
-
const app = express();
|
|
36
|
-
|
|
37
|
-
//compress server output with gzip
|
|
38
|
-
app.use(compress());
|
|
39
|
-
app.use(bodyParser.json());
|
|
40
|
-
|
|
41
|
-
app.use('/static', express.static('./frontend/web'));
|
|
42
|
-
app.use('/images', express.static('./frontend/web/images'));
|
|
43
|
-
app.use('/css', express.static('./frontend/web/css'));
|
|
44
|
-
app.use('/js', express.static('./frontend/build'));
|
|
45
|
-
|
|
46
|
-
app.get(
|
|
47
|
-
'*',
|
|
48
|
-
handleErrors(async function (req, res) {
|
|
49
|
-
//make sure the frontend bundle has finished building
|
|
50
|
-
await waitForWebpack();
|
|
51
|
-
render(req.url, res);
|
|
52
|
-
}),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const sendJson = async function (res, obj) {
|
|
56
|
-
let json = await JSONWriter.stringify(obj, true);
|
|
57
|
-
res.send(json);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
app
|
|
61
|
-
.listen(PORT, () => {
|
|
62
|
-
console.log(`Up and running at http://localhost:${PORT}`);
|
|
63
|
-
})
|
|
64
|
-
.on('error', function (error) {
|
|
65
|
-
if (error.syscall !== 'listen') {
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
const isPipe = (portOrPipe) => Number.isNaN(portOrPipe);
|
|
69
|
-
const bind = isPipe(PORT) ? 'Pipe ' + PORT : 'Port ' + PORT;
|
|
70
|
-
switch (error.code) {
|
|
71
|
-
case 'EACCES':
|
|
72
|
-
console.error(bind + ' requires elevated privileges');
|
|
73
|
-
process.exit(1);
|
|
74
|
-
break;
|
|
75
|
-
case 'EADDRINUSE':
|
|
76
|
-
console.error(bind + ' is already in use');
|
|
77
|
-
process.exit(1);
|
|
78
|
-
break;
|
|
79
|
-
default:
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
function handleErrors(fn) {
|
|
85
|
-
return async function (req, res, next) {
|
|
86
|
-
try {
|
|
87
|
-
return await fn(req, res);
|
|
88
|
-
} catch (x) {
|
|
89
|
-
next(x);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function waitForWebpack() {
|
|
95
|
-
while (true) {
|
|
96
|
-
try {
|
|
97
|
-
readFileSync(path.resolve(__dirname, '../../frontend/build/main.js'));
|
|
98
|
-
return;
|
|
99
|
-
} catch (err) {
|
|
100
|
-
console.log('Could not find webpack build output. Will retry in a second...');
|
|
101
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function render(url, res) {
|
|
107
|
-
res.socket.on('error', (error) => {
|
|
108
|
-
console.error('Fatal', error);
|
|
109
|
-
});
|
|
110
|
-
let didError = false;
|
|
111
|
-
|
|
112
|
-
const stream = renderToPipeableStream(
|
|
113
|
-
<React.StrictMode>
|
|
114
|
-
<StaticRouter location={url}>
|
|
115
|
-
<App assets={assets} />
|
|
116
|
-
</StaticRouter>
|
|
117
|
-
</React.StrictMode>,
|
|
118
|
-
{
|
|
119
|
-
bootstrapScripts: [
|
|
120
|
-
assets['main.js'], //generated webpack bundle from frontend/src
|
|
121
|
-
],
|
|
122
|
-
onShellReady() {
|
|
123
|
-
// If something errored before we started streaming, we set the error code appropriately.
|
|
124
|
-
res.statusCode = didError ? 500 : 200;
|
|
125
|
-
res.setHeader('Content-type', 'text/html');
|
|
126
|
-
stream.pipe(res);
|
|
127
|
-
},
|
|
128
|
-
onError(x) {
|
|
129
|
-
didError = true;
|
|
130
|
-
console.error(x);
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
);
|
|
134
|
-
// Abandon and switch to client rendering if enough time passes.
|
|
135
|
-
// Try lowering this to see the client recover.
|
|
136
|
-
setTimeout(() => stream.abort(), 10000);
|
|
137
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
|
-
const react_1 = require("react");
|
|
31
|
-
const react_error_boundary_1 = require("react-error-boundary");
|
|
32
|
-
const Html_1 = __importDefault(require("./Html"));
|
|
33
|
-
const Spinner_1 = __importDefault(require("./Spinner"));
|
|
34
|
-
const Layout_1 = __importDefault(require("./Layout"));
|
|
35
|
-
const react_router_dom_1 = require("react-router-dom");
|
|
36
|
-
const MappingTools_1 = require("./MappingTools");
|
|
37
|
-
const Browse = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./Browse' /* webpackPrefetch: true */))));
|
|
38
|
-
const Docs = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./Docs' /* webpackPrefetch: true */))));
|
|
39
|
-
const Academy = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./Academy' /* webpackPrefetch: true */))));
|
|
40
|
-
const Home = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./Home' /* webpackPrefetch: true */))));
|
|
41
|
-
function App({ assets = typeof window !== 'undefined' ? window['assetManifest'] : {} }) {
|
|
42
|
-
return ((0, jsx_runtime_1.jsx)(Html_1.default, { assets: assets, title: "LINCD - Linked Interoperable Code & Data", children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Spinner_1.default, {}), children: (0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: Error, children: (0, jsx_runtime_1.jsx)(Content, {}) }) }) }));
|
|
43
|
-
}
|
|
44
|
-
exports.default = App;
|
|
45
|
-
function Content() {
|
|
46
|
-
let [sidebarIsOpen, setSidebarisOpen] = (0, react_1.useState)(false);
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(Layout_1.default, { sidebarIsOpen: sidebarIsOpen, setSidebarIsOpen: setSidebarisOpen, children: (0, jsx_runtime_1.jsx)("div", { className: "content", children: (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "/", element: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Spinner_1.default, {}), children: (0, jsx_runtime_1.jsx)(Home, {}) }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "/browse/*", element: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Spinner_1.default, {}), children: (0, jsx_runtime_1.jsx)(Browse, { sidebarIsOpen: sidebarIsOpen }) }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "/browse/mapping-tools", element: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Spinner_1.default, {}), children: (0, jsx_runtime_1.jsx)(MappingTools_1.MappingTools, {}) }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "/academy", element: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Spinner_1.default, {}), children: (0, jsx_runtime_1.jsx)(Academy, {}) }) })] }) }) }));
|
|
48
|
-
}
|
|
49
|
-
function Error({ error }) {
|
|
50
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { color: 'white', margin: '2rem' }, children: [(0, jsx_runtime_1.jsx)("h1", { children: "Application Error" }), (0, jsx_runtime_1.jsx)("pre", { style: { whiteSpace: 'pre-wrap', padding: '1rem' }, children: error.stack })] }));
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=App.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"App.js","sourceRoot":"","sources":["App.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA+C;AAC/C,+DAAmD;AACnD,kDAA0B;AAC1B,wDAAgC;AAChC,sDAA8B;AAC9B,uDAA+C;AAC/C,iDAA4C;AAE5C,MAAM,MAAM,GAAG,IAAA,YAAI,EAAC,GAAG,EAAE,mDAAQ,UAAU,CAAC,2BAA2B,GAAC,CAAC,CAAC;AAC1E,MAAM,IAAI,GAAG,IAAA,YAAI,EAAC,GAAG,EAAE,mDAAQ,QAAQ,CAAC,2BAA2B,GAAC,CAAC,CAAC;AACtE,MAA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,EACL,uBAAC,gBAAQ,IAAC,QAAQ,EAAE,uBAAC,iBAAO,KAAG,YAC7B,uBAAC,2BAAY,KAAG,GACP,GAEb,EACF,uBAAC,wBAAK,IACJ,IAAI,EAAC,UAAU,EACf,OAAO,EACL,uBAAC,gBAAQ,IAAC,QAAQ,EAAE,uBAAC,iBAAO,KAAG,YAC7B,uBAAC,OAAO,KAAG,GACF,GAEb,IACK,GACL,GACC,CACV,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,EAAC,KAAK,EAAC;IACpB,OAAO,CACL,iCAAK,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAC,aAC1C,+DAA0B,EAC1B,gCAAK,KAAK,EAAE,EAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAC,YAAG,KAAK,CAAC,KAAK,GAAO,IACtE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {lazy, Suspense} from 'react';
|
|
2
|
-
import {ErrorBoundary} from 'react-error-boundary';
|
|
3
|
-
import Html from './Html';
|
|
4
|
-
import Spinner from './Spinner';
|
|
5
|
-
import Layout from './Layout';
|
|
6
|
-
|
|
7
|
-
declare var window;
|
|
8
|
-
export default function App({assets = typeof window !== 'undefined' ? window['assetManifest'] : {}}) {
|
|
9
|
-
return (
|
|
10
|
-
<Html assets={assets} title="${name} - LINCD App">
|
|
11
|
-
<Suspense fallback={<Spinner />}>
|
|
12
|
-
<ErrorBoundary FallbackComponent={Error}>
|
|
13
|
-
<Content />
|
|
14
|
-
</ErrorBoundary>
|
|
15
|
-
</Suspense>
|
|
16
|
-
</Html>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function Content() {
|
|
21
|
-
return (
|
|
22
|
-
<Layout>
|
|
23
|
-
<div>${name} - LINCD App</div>
|
|
24
|
-
</Layout>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function Error({error}) {
|
|
29
|
-
return (
|
|
30
|
-
<div style={{color: 'white', margin: '2rem'}}>
|
|
31
|
-
<h1>Application Error</h1>
|
|
32
|
-
<pre style={{whiteSpace: 'pre-wrap', padding: '1rem'}}>{error.stack}</pre>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
function Html({ assets, children, title }) {
|
|
5
|
-
return ((0, jsx_runtime_1.jsxs)("html", { lang: "en", children: [(0, jsx_runtime_1.jsxs)("head", { children: [(0, jsx_runtime_1.jsx)("meta", { charSet: "utf-8" }), (0, jsx_runtime_1.jsx)("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), (0, jsx_runtime_1.jsx)("link", { rel: "shortcut icon", href: "/static/favicon.ico" }), (0, jsx_runtime_1.jsx)("link", { rel: "stylesheet", href: assets['webpack.css'] }), (0, jsx_runtime_1.jsx)("title", { children: title })] }), (0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)("noscript", { dangerouslySetInnerHTML: {
|
|
6
|
-
__html: `<b>Enable JavaScript to run this app.</b>`,
|
|
7
|
-
} }), children, (0, jsx_runtime_1.jsx)("script", { dangerouslySetInnerHTML: {
|
|
8
|
-
__html: `assetManifest = ${JSON.stringify(assets)};`,
|
|
9
|
-
} })] })] }));
|
|
10
|
-
}
|
|
11
|
-
exports.default = Html;
|
|
12
|
-
//# sourceMappingURL=Html.js.map
|
|
File without changes
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export default function Html({assets, children, title}) {
|
|
2
|
-
return (
|
|
3
|
-
<html lang="en">
|
|
4
|
-
<head>
|
|
5
|
-
<meta charSet="utf-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
<link rel="shortcut icon" href="/static/favicon.ico" />
|
|
8
|
-
<link rel="stylesheet" href={assets['main.css']} />
|
|
9
|
-
{assets['tailwind-cdn'] && (
|
|
10
|
-
<script src={assets['tailwind-cdn']}></script>
|
|
11
|
-
)}
|
|
12
|
-
<title>{title}</title>
|
|
13
|
-
</head>
|
|
14
|
-
<body>
|
|
15
|
-
<noscript
|
|
16
|
-
dangerouslySetInnerHTML={{
|
|
17
|
-
__html: `<b>Enable JavaScript to run this app.</b>`,
|
|
18
|
-
}}
|
|
19
|
-
/>
|
|
20
|
-
{children}
|
|
21
|
-
<script
|
|
22
|
-
dangerouslySetInnerHTML={{
|
|
23
|
-
__html: `assetManifest = ${JSON.stringify(assets)};`,
|
|
24
|
-
}}
|
|
25
|
-
/>
|
|
26
|
-
</body>
|
|
27
|
-
</html>
|
|
28
|
-
);
|
|
29
|
-
}
|