Skip to content

Commit

Permalink
WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
Syndesi committed Mar 2, 2024
1 parent 07ad090 commit a419b6d
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 35 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
"main": "dist/EmberNexus.js",
"types": "dist/EmberNexus.d.ts",
"scripts": {
"watch": "webpack --mode development --watch",
"build": "webpack --mode production",
"build": "rm -rf ./dist && webpack --config webpack.release.config.cjs",
"cs": "eslint --ext .ts ./src ./test",
"cs:fix": "eslint --ext .ts ./src ./test --fix",
"test:unit": "jest ./test/Unit",
"test:feature": "jest ./test/Feature",
"test:unit:old": "mocha --config .mocharc.unit.json",
"test:feature:old": "mocha --config .mocharc.feature.json",
"prepare": "ts-patch install"
},
"author": "Syndesi <[email protected]>",
Expand Down Expand Up @@ -51,6 +48,7 @@
"prettier": "^3.0.3",
"rimraf": "~5.0.5",
"sinon": "^17.0.1",
"terser-webpack-plugin": "^5.3.10",
"ts-jest": "^29.1.2",
"ts-loader": "^9.5.1",
"ts-mockito": "^2.6.1",
Expand Down
35 changes: 8 additions & 27 deletions src/EmberNexus.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
import 'reflect-metadata';

import { Container, Service } from 'typedi';
// import { parse as uuidParse } from 'uuid';
import { Container } from 'typedi';

import { GetElementEvent } from '~/BrowserEvent/Element/GetElementEvent';
import { Logger } from '~/Service/Logger';
// import GetElementEndpoint from "~/Endpoint/Element/GetElementEndpoint";
import GetElementEndpoint from '~/Endpoint/Element/GetElementEndpoint';
import { WebSdkConfiguration } from '~/Service/WebSdkConfiguration';
import { validateUuidFromString } from '~/Type/Definition/Uuid';
import { Relation } from '~/Type/Definition/Relation';
import { Uuid } from '~/Type/Definition/Uuid';

@Service()
class TestService {
constructor(public logger: Logger) {}

test(): void {
this.logger.debug('level is debug');
this.logger.info('level is info');
this.logger.warn('level is warn');
this.logger.error('level is error');
console.log(new GetElementEvent(validateUuidFromString('b63a3196-7373-4d44-b590-f94e31021bf3')));
class EmberNexus {
test(uuid: Uuid): Promise<Node | Relation> {
return Container.get(GetElementEndpoint).getElement(uuid);
}
}

export { TestService, GetElementEvent };

const service = Container.get(TestService);
service.test();

const webSdkConfiguration = Container.get(WebSdkConfiguration);
webSdkConfiguration.setApiHost('http://localhost');

// const getElementEndpoint = Container.get(GetElementEndpoint);
// const res = await getElementEndpoint.getElement(uuidParse('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'));
// console.log(res);
export { EmberNexus, Container, WebSdkConfiguration };
1 change: 1 addition & 0 deletions src/Factory/LoggerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class LoggerFactory {
create(): Logger {
const tsLogger: TsLogger<ILogObj> = new TsLogger({
minLevel: LogLevel.Debug,
stylePrettyLogs: false,
});
return new Logger(tsLogger);
}
Expand Down
30 changes: 30 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
<script src="./dist/bundle.js"></script>
</head>
<body>

<p>Test</p>

<script>
const emberNexusWebSDK = new this.EmberNexusWebSDK.EmberNexus();
let configuration = this.EmberNexusWebSDK.Container.get(this.EmberNexusWebSDK.WebSdkConfiguration);
configuration.setApiHost("http://localhost:80");

let res = emberNexusWebSDK.test("9edb178e-1b4a-4518-a9d3-0fa97e6d1007");
res.then((node) => {
console.log(node);
})

let res2 = emberNexusWebSDK.test("9edb178e-1b4a-4518-a9d3-0fa97e6d1008");
res2.catch(() => {})


</script>

</body>
</html>
13 changes: 9 additions & 4 deletions tsconfig.release.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"module": "es2022",
"lib": [
"ES2022",
"dom"
],
"moduleResolution": "nodenext",
"moduleResolution": "bundler",
"outDir": "dist",
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
Expand All @@ -20,8 +20,13 @@
"noUnusedParameters": true,
"noImplicitAny": false,
"noImplicitThis": false,
"strictNullChecks": false,
"declaration": true
"strictNullChecks": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"paths": {
"~/*": ["./src/*"]
}
},
"include": ["src/**/*"]
}
55 changes: 55 additions & 0 deletions webpack.release.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const path = require('path');
const TerserPlugin = require("terser-webpack-plugin");

module.exports = {
entry: './src/EmberNexus.ts',
mode: "production",
module: {
rules: [
{
test: /\.ts?$/,
use: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.release.json'
}
}
],
exclude: /node_modules/
},
],
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
'~': path.resolve(__dirname, 'src/'),
}
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
library: 'EmberNexusWebSDK',
libraryTarget: 'umd',
umdNamedDefine: true
},
performance: {
hints: false
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
format: {
comments: false,
},
keep_classnames: true,
keep_fnames: true,
},
extractComments: false,
}),
],
},
};

0 comments on commit a419b6d

Please sign in to comment.