-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
105 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]>", | ||
|
@@ -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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}), | ||
], | ||
}, | ||
}; |