diff --git a/package.json b/package.json index 67550e0..6e3d997 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,15 @@ { "name": "tgrid", - "version": "0.9.8", + "version": "0.10.0", "main": "lib/index.js", "typings": "lib/index.d.ts", + "exports": { + ".": { + "types": "./lib/index.d.ts", + "require": "./lib/index.js", + "import": "./lib/index.mjs" + } + }, "description": "Grid Computing Framework for TypeScript", "author": { "name": "Jeongho Nam", @@ -12,7 +19,7 @@ "scripts": { "api": "typedoc src --excludeNotDocumented -out ../tgrid.com/docs/api", "build": "npm run build:main && npm run build:test", - "build:main": "rimraf lib && tsc", + "build:main": "rimraf lib && tsc && rollup -c", "build:test": "rimraf bin && tsc --project test/tsconfig.json", "dev": "npm run build:test -- --watch", "prepare": "ts-patch install", @@ -23,10 +30,12 @@ }, "dependencies": { "import2": "^1.0.3", - "tstl": "^2.5.16", + "tstl": "3.0.0", "ws": "^7.5.3" }, "devDependencies": { + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/browserify": "^12.0.40", "@types/node": "^20.11.26", @@ -41,11 +50,13 @@ "prettier": "^3.2.5", "puppeteer": "^22.4.1", "rimraf": "^5.0.5", + "rollup": "^4.13.1", "source-map-support": "^0.5.21", "ts-node": "^10.9.2", "ts-patch": "^3.1.2", + "tslib": "^2.6.2", "typedoc": "^0.25.12", - "typescript": "^5.4.2", + "typescript": "^5.4.3", "typescript-transform-paths": "^3.4.7", "whatwg-fetch": "^3.6.2" }, diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..f948ecc --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,29 @@ +const typescript = require("@rollup/plugin-typescript"); +const terser = require("@rollup/plugin-terser"); + +module.exports = { + input: "./src/index.ts", + output: { + dir: "lib", + format: "esm", + entryFileNames: "[name].mjs", + sourcemap: true, + }, + plugins: [ + typescript({ + tsconfig: "tsconfig.json", + module: "ES2020", + target: "ES2020", + }), + terser({ + format: { + comments: "some", + beautify: true, + ecma: "2020", + }, + compress: false, + mangle: false, + module: true, + }), + ], +}; diff --git a/src/components/Communicator.ts b/src/components/Communicator.ts index 300a80c..6282196 100644 --- a/src/components/Communicator.ts +++ b/src/components/Communicator.ts @@ -1,13 +1,14 @@ import { Driver } from "../typings/Driver"; import { Invoke } from "./Invoke"; -import { Pair } from "tstl/utility/Pair"; -import { HashMap } from "tstl/container/HashMap"; -import { ConditionVariable } from "tstl/thread/ConditionVariable"; - -import { DomainError } from "tstl/exception/DomainError"; -import { RuntimeError } from "tstl/exception/RuntimeError"; import { serializeError } from "../utils/internal/serializeError"; +import { + HashMap, + Pair, + ConditionVariable, + RuntimeError, + DomainError, +} from "tstl"; /** * The basic communicator. diff --git a/src/protocols/internal/AcceptorBase.ts b/src/protocols/internal/AcceptorBase.ts index 0f3c24a..ca2be5c 100644 --- a/src/protocols/internal/AcceptorBase.ts +++ b/src/protocols/internal/AcceptorBase.ts @@ -1,8 +1,6 @@ +import { DomainError, RuntimeError } from "tstl"; import { Communicator } from "../../components/Communicator"; -import { DomainError } from "tstl/exception/DomainError"; -import { RuntimeError } from "tstl/exception/RuntimeError"; - /** * Basic Acceptor. * diff --git a/src/protocols/internal/ConnectorBase.ts b/src/protocols/internal/ConnectorBase.ts index c1535c3..baa4346 100644 --- a/src/protocols/internal/ConnectorBase.ts +++ b/src/protocols/internal/ConnectorBase.ts @@ -1,8 +1,6 @@ +import { DomainError, RuntimeError } from "tstl"; import { Communicator } from "../../components/Communicator"; -import { DomainError } from "tstl/exception/DomainError"; -import { RuntimeError } from "tstl/exception/RuntimeError"; - /** * Basic Connector. * diff --git a/src/protocols/web/WebAcceptor.ts b/src/protocols/web/WebAcceptor.ts index e3c813b..7b6326c 100644 --- a/src/protocols/web/WebAcceptor.ts +++ b/src/protocols/web/WebAcceptor.ts @@ -1,6 +1,6 @@ import type http from "http"; import type WebSocket from "ws"; -import { DomainError } from "tstl/exception/DomainError"; +import { DomainError } from "tstl"; import { AcceptorBase } from "../internal/AcceptorBase"; import { IWebCommunicator } from "./internal/IWebCommunicator"; diff --git a/src/protocols/web/WebConnector.ts b/src/protocols/web/WebConnector.ts index eeb00ee..f18c6cd 100644 --- a/src/protocols/web/WebConnector.ts +++ b/src/protocols/web/WebConnector.ts @@ -1,7 +1,3 @@ -import { DomainError } from "tstl/exception/DomainError"; -import { is_node } from "tstl/utility/node"; -import { sleep_for } from "tstl/thread/global"; - import { Invoke } from "../../components/Invoke"; import { WebError } from "./WebError"; @@ -10,6 +6,7 @@ import { IHeaderWrapper } from "../internal/IHeaderWrapper"; import { IWebCommunicator } from "./internal/IWebCommunicator"; import { once } from "../internal/once"; import { WebSocketPolyfill } from "./internal/WebSocketPolyfill"; +import { DomainError, is_node, sleep_for } from "tstl"; /** * Web Socket Connector. diff --git a/src/protocols/web/WebError.ts b/src/protocols/web/WebError.ts index 22c7ee8..e55870d 100644 --- a/src/protocols/web/WebError.ts +++ b/src/protocols/web/WebError.ts @@ -1,4 +1,4 @@ -import { DomainError } from "tstl/exception/DomainError"; +import { DomainError } from "tstl"; /** * Web Socket Error. diff --git a/src/protocols/web/WebServer.ts b/src/protocols/web/WebServer.ts index a7c2564..1186ea5 100644 --- a/src/protocols/web/WebServer.ts +++ b/src/protocols/web/WebServer.ts @@ -2,15 +2,13 @@ import type http from "http"; import type https from "https"; import type net from "net"; import type WebSocket from "ws"; -import { is_node } from "tstl/utility/node"; import { WebAcceptor } from "./WebAcceptor"; import { IServer } from "../internal/IServer"; import { IHeaderWrapper } from "../internal/IHeaderWrapper"; -import { DomainError } from "tstl/exception/DomainError"; -import { RuntimeError } from "tstl/exception/RuntimeError"; import { NodeModule } from "../../utils/internal/NodeModule"; +import { is_node, DomainError, RuntimeError } from "tstl"; /** * Web Socket Server. diff --git a/src/protocols/workers/SharedWorkerAcceptor.ts b/src/protocols/workers/SharedWorkerAcceptor.ts index 8158837..90123b5 100644 --- a/src/protocols/workers/SharedWorkerAcceptor.ts +++ b/src/protocols/workers/SharedWorkerAcceptor.ts @@ -3,7 +3,7 @@ import { IWorkerSystem } from "./internal/IWorkerSystem"; import { Invoke } from "../../components/Invoke"; import { IReject } from "./internal/IReject"; -import { DomainError } from "tstl/exception/DomainError"; +import { DomainError } from "tstl"; /** * SharedWorker acceptor for client. diff --git a/src/protocols/workers/SharedWorkerConnector.ts b/src/protocols/workers/SharedWorkerConnector.ts index 8b79b0d..7b6971f 100644 --- a/src/protocols/workers/SharedWorkerConnector.ts +++ b/src/protocols/workers/SharedWorkerConnector.ts @@ -6,10 +6,7 @@ import { IHeaderWrapper } from "../internal/IHeaderWrapper"; import { IReject } from "./internal/IReject"; import { WebWorkerCompiler } from "./internal/WebWorkerCompiler"; import { once } from "../internal/once"; - -import { DomainError } from "tstl/exception/DomainError"; -import { RuntimeError } from "tstl/exception/RuntimeError"; -import { sleep_until } from "tstl/thread/global"; +import { DomainError, RuntimeError, sleep_until } from "tstl"; /** * SharedWorker Connector diff --git a/src/protocols/workers/SharedWorkerServer.ts b/src/protocols/workers/SharedWorkerServer.ts index a779feb..086e389 100644 --- a/src/protocols/workers/SharedWorkerServer.ts +++ b/src/protocols/workers/SharedWorkerServer.ts @@ -3,10 +3,7 @@ import { SharedWorkerAcceptor } from "./SharedWorkerAcceptor"; import { IHeaderWrapper } from "../internal/IHeaderWrapper"; import { once } from "../internal/once"; - -import { DomainError } from "tstl/exception/DomainError"; -import { HashSet } from "tstl/container/HashSet"; -import { is_node } from "tstl/utility/node"; +import { HashSet, is_node, DomainError } from "tstl"; /** * SharedWorker server. diff --git a/src/protocols/workers/WorkerConnector.ts b/src/protocols/workers/WorkerConnector.ts index 4d8ea62..c347b7f 100644 --- a/src/protocols/workers/WorkerConnector.ts +++ b/src/protocols/workers/WorkerConnector.ts @@ -1,7 +1,3 @@ -import { DomainError } from "tstl/exception/DomainError"; -import { is_node } from "tstl/utility/node"; -import { sleep_until } from "tstl/thread/global"; - import { Invoke } from "../../components/Invoke"; import { IHeaderWrapper } from "../internal/IHeaderWrapper"; @@ -11,7 +7,7 @@ import { ConnectorBase } from "../internal/ConnectorBase"; import { NodeWorkerCompiler } from "./internal/NodeWorkerCompiler"; import { WebWorkerCompiler } from "./internal/WebWorkerCompiler"; import { once } from "../internal/once"; -import { Singleton } from "tstl/thread/Singleton"; +import { Singleton, is_node, DomainError, sleep_until } from "tstl"; /** * Worker Connector. diff --git a/src/protocols/workers/WorkerServer.ts b/src/protocols/workers/WorkerServer.ts index b9b2993..d07353d 100644 --- a/src/protocols/workers/WorkerServer.ts +++ b/src/protocols/workers/WorkerServer.ts @@ -1,9 +1,3 @@ -import { DomainError } from "tstl/exception/DomainError"; -import { RuntimeError } from "tstl/exception/RuntimeError"; -import { Singleton } from "tstl/thread/Singleton"; -import { sleep_until } from "tstl/thread/global"; -import { is_node } from "tstl/utility/node"; - import { Communicator } from "../../components/Communicator"; import { IServer } from "../internal/IServer"; import { IWorkerSystem } from "./internal/IWorkerSystem"; @@ -14,6 +8,13 @@ import { once } from "../internal/once"; import { ThreadPort } from "./internal/threads/ThreadPort"; import { ProcessChannel } from "./internal/processes/ProcessChannel"; +import { + Singleton, + is_node, + DomainError, + sleep_until, + RuntimeError, +} from "tstl"; /** * Worker Server. diff --git a/src/utils/internal/NodeModule.ts b/src/utils/internal/NodeModule.ts index e0112e8..375a215 100644 --- a/src/utils/internal/NodeModule.ts +++ b/src/utils/internal/NodeModule.ts @@ -8,7 +8,7 @@ import type * as __ws from "ws"; import type * as __process from "process"; import import2 from "import2"; -import { Singleton } from "tstl/thread/Singleton"; +import { Singleton } from "tstl"; export namespace NodeModule { export const cp: Singleton> = new Singleton(() => diff --git a/test/browser/web-client.ts b/test/browser/web-client.ts index 6767646..ea1e9cd 100644 --- a/test/browser/web-client.ts +++ b/test/browser/web-client.ts @@ -1,4 +1,4 @@ -import { InvalidArgument } from "tstl/exception/InvalidArgument"; +import { InvalidArgument } from "tstl"; import { ICalculator } from "../controllers/ICalculator"; import { complete } from "./internal"; diff --git a/test/controllers/ICalculator.ts b/test/controllers/ICalculator.ts index 3f21a1f..fa5b1f5 100644 --- a/test/controllers/ICalculator.ts +++ b/test/controllers/ICalculator.ts @@ -1,7 +1,4 @@ -import { DomainError } from "tstl/exception/DomainError"; -import { InvalidArgument } from "tstl/exception/InvalidArgument"; -import { randint } from "tstl/algorithm/random"; - +import { DomainError, InvalidArgument, randint } from "tstl"; import { Calculator } from "../providers/Calculator"; import { Driver } from "tgrid"; diff --git a/test/controllers/IScript.ts b/test/controllers/IScript.ts index a87273e..4428192 100644 --- a/test/controllers/IScript.ts +++ b/test/controllers/IScript.ts @@ -1,5 +1,4 @@ -import { DomainError } from "tstl/exception/DomainError"; -import { LengthError } from "tstl/exception/LengthError"; +import { LengthError, DomainError } from "tstl"; export interface IScript { name: string; diff --git a/test/controllers/IVector.ts b/test/controllers/IVector.ts index 6da024d..28085a4 100644 --- a/test/controllers/IVector.ts +++ b/test/controllers/IVector.ts @@ -1,6 +1,5 @@ -import { DomainError } from "tstl/exception/DomainError"; -import { randint } from "tstl/algorithm/random"; import { Driver } from "tgrid"; +import { randint, DomainError } from "tstl"; export interface IVector { size(): T; diff --git a/test/node/components/test_pseudo.ts b/test/node/components/test_pseudo.ts index dd8f1df..c0b38d9 100644 --- a/test/node/components/test_pseudo.ts +++ b/test/node/components/test_pseudo.ts @@ -1,5 +1,5 @@ import { Communicator, Invoke, Driver } from "tgrid"; -import { InvalidArgument } from "tstl/exception/InvalidArgument"; +import { InvalidArgument } from "tstl"; import { Calculator } from "../../providers/Calculator"; import { ICalculator } from "../../controllers/ICalculator"; diff --git a/test/node/protocols/web/test_web_calculator.ts b/test/node/protocols/web/test_web_calculator.ts index 9a1c27c..572b3a2 100644 --- a/test/node/protocols/web/test_web_calculator.ts +++ b/test/node/protocols/web/test_web_calculator.ts @@ -2,7 +2,7 @@ import { Calculator } from "../../../providers/Calculator"; import { ICalculator } from "../../../controllers/ICalculator"; import { IVector } from "../../../controllers/IVector"; -import { Vector } from "tstl/container/Vector"; +import { Vector } from "tstl"; import { Driver, WebConnector, WebServer } from "tgrid"; const PORT: number = 10101; diff --git a/test/node/protocols/web/test_web_chat.ts b/test/node/protocols/web/test_web_chat.ts index e4ce5c4..48c6d4c 100644 --- a/test/node/protocols/web/test_web_chat.ts +++ b/test/node/protocols/web/test_web_chat.ts @@ -1,5 +1,5 @@ import { Driver, WebConnector, WebServer } from "tgrid"; -import { sleep_for } from "tstl/thread/global"; +import { sleep_for } from "tstl"; import { IScript } from "../../../controllers/IScript"; import { IChatPrinter } from "../../../controllers/IChatPrinter"; diff --git a/test/node/protocols/web/test_web_mutex.ts b/test/node/protocols/web/test_web_mutex.ts index cfb39b1..f86e4a5 100644 --- a/test/node/protocols/web/test_web_mutex.ts +++ b/test/node/protocols/web/test_web_mutex.ts @@ -1,11 +1,12 @@ -import { Vector } from "tstl/container/Vector"; -import { Mutex } from "tstl/thread/Mutex"; -import { DomainError } from "tstl/exception/DomainError"; -import { RuntimeError } from "tstl/exception/RuntimeError"; - -import { is_sorted } from "tstl/algorithm/sorting"; -import { sleep_for } from "tstl/thread/global"; import { Driver, WebConnector, WebServer } from "tgrid"; +import { + Mutex, + Vector, + sleep_for, + RuntimeError, + is_sorted, + DomainError, +} from "tstl"; const PORT: number = 10101; const COUNT: number = 10; diff --git a/test/node/protocols/workers/internal/chat-child.ts b/test/node/protocols/workers/internal/chat-child.ts index 881eca1..7a4a006 100644 --- a/test/node/protocols/workers/internal/chat-child.ts +++ b/test/node/protocols/workers/internal/chat-child.ts @@ -1,7 +1,7 @@ import { IScript } from "../../../../controllers/IScript"; import { IChatService } from "../../../../controllers/IChatService"; -import { sleep_for } from "tstl/thread/global"; +import { sleep_for } from "tstl"; import { Driver, WorkerServer } from "tgrid"; async function main(): Promise { diff --git a/test/node/protocols/workers/test_worker_chat.ts b/test/node/protocols/workers/test_worker_chat.ts index 938dba1..9b289f9 100644 --- a/test/node/protocols/workers/test_worker_chat.ts +++ b/test/node/protocols/workers/test_worker_chat.ts @@ -1,5 +1,4 @@ -import { DomainError } from "tstl/exception/DomainError"; -import { LengthError } from "tstl/exception/LengthError"; +import { LengthError, DomainError } from "tstl"; export interface IScript { name: string; diff --git a/test/node/protocols/workers/test_worker_join.ts b/test/node/protocols/workers/test_worker_join.ts index 6570051..746e8cf 100644 --- a/test/node/protocols/workers/test_worker_join.ts +++ b/test/node/protocols/workers/test_worker_join.ts @@ -1,6 +1,6 @@ import fs from "fs"; import { WorkerConnector } from "tgrid"; -import { sleep_for } from "tstl/thread"; +import { sleep_for } from "tstl"; const FILE_PATH = __dirname + "/log.dat"; diff --git a/test/providers/ChatService.ts b/test/providers/ChatService.ts index aa53187..0873618 100644 --- a/test/providers/ChatService.ts +++ b/test/providers/ChatService.ts @@ -1,11 +1,10 @@ import { IChatService } from "../controllers/IChatService"; -import { HashMap } from "tstl/container/HashMap"; import { IChatPrinter } from "../controllers/IChatPrinter"; import { IScript } from "../controllers/IScript"; -import { DomainError } from "tstl/exception/DomainError"; import { Driver } from "tgrid"; +import { HashMap, DomainError } from "tstl"; export class ChatService implements IChatService { private static participants_: HashMap> =