saito-js 0.0.5 → 0.0.7

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.
Files changed (87) hide show
  1. package/configs.js +2 -0
  2. package/configs.js.map +1 -0
  3. package/index.d.ts +5 -0
  4. package/index.d.ts.map +1 -0
  5. package/index.js +11 -0
  6. package/index.js.map +1 -0
  7. package/index.node.js +37 -0
  8. package/index.node.js.map +1 -0
  9. package/index.web.js +37 -0
  10. package/index.web.js.map +1 -0
  11. package/lib/block.js +33 -0
  12. package/lib/block.js.map +1 -0
  13. package/lib/blockchain.js +9 -0
  14. package/lib/blockchain.js.map +1 -0
  15. package/lib/custom/custom_shared_methods.js +70 -0
  16. package/lib/custom/custom_shared_methods.js.map +1 -0
  17. package/lib/custom/{shared_methods.web.ts → shared_methods.web.js} +31 -40
  18. package/lib/custom/shared_methods.web.js.map +1 -0
  19. package/lib/factory.js +28 -0
  20. package/lib/factory.js.map +1 -0
  21. package/lib/{peer.ts → peer.js} +12 -24
  22. package/lib/peer.js.map +1 -0
  23. package/lib/{saito_factory.ts → saito_factory.js} +2 -0
  24. package/lib/saito_factory.js.map +1 -0
  25. package/lib/{slip.ts → slip.js} +35 -63
  26. package/lib/slip.js.map +1 -0
  27. package/lib/{transaction.ts → transaction.js} +51 -76
  28. package/lib/transaction.js.map +1 -0
  29. package/lib/wallet.js +45 -0
  30. package/lib/wallet.js.map +1 -0
  31. package/package.json +2 -2
  32. package/{saito.ts → saito.js} +96 -198
  33. package/saito.js.map +1 -0
  34. package/shared_methods.js +2 -0
  35. package/shared_methods.js.map +1 -0
  36. package/tests/{index.test.ts → index.test.js} +2 -0
  37. package/tests/index.test.js.map +1 -0
  38. package/.github/workflows/publish.yml +0 -50
  39. package/.prettierrc.json +0 -3
  40. package/babel.config.json +0 -13
  41. package/configs.ts +0 -26
  42. package/dist/browser/index.js +0 -3669
  43. package/dist/server/index.js +0 -3731
  44. package/index.node.ts +0 -51
  45. package/index.web.ts +0 -47
  46. package/lib/block.ts +0 -42
  47. package/lib/blockchain.ts +0 -14
  48. package/lib/custom/custom_shared_methods.ts +0 -92
  49. package/lib/factory.ts +0 -32
  50. package/lib/wallet.ts +0 -61
  51. package/shared_methods.ts +0 -40
  52. package/tsconfig.json +0 -111
  53. package/tsconfig.testing.json +0 -19
  54. package/webpack.config.js +0 -136
  55. package/webpack.prod.config.js +0 -136
  56. /package/{dist/configs.d.ts → configs.d.ts} +0 -0
  57. /package/{dist/configs.d.ts.map → configs.d.ts.map} +0 -0
  58. /package/{dist/index.node.d.ts → index.node.d.ts} +0 -0
  59. /package/{dist/index.node.d.ts.map → index.node.d.ts.map} +0 -0
  60. /package/{dist/index.web.d.ts → index.web.d.ts} +0 -0
  61. /package/{dist/index.web.d.ts.map → index.web.d.ts.map} +0 -0
  62. /package/{dist/lib → lib}/block.d.ts +0 -0
  63. /package/{dist/lib → lib}/block.d.ts.map +0 -0
  64. /package/{dist/lib → lib}/blockchain.d.ts +0 -0
  65. /package/{dist/lib → lib}/blockchain.d.ts.map +0 -0
  66. /package/{dist/lib → lib}/custom/custom_shared_methods.d.ts +0 -0
  67. /package/{dist/lib → lib}/custom/custom_shared_methods.d.ts.map +0 -0
  68. /package/{dist/lib → lib}/custom/shared_methods.web.d.ts +0 -0
  69. /package/{dist/lib → lib}/custom/shared_methods.web.d.ts.map +0 -0
  70. /package/{dist/lib → lib}/factory.d.ts +0 -0
  71. /package/{dist/lib → lib}/factory.d.ts.map +0 -0
  72. /package/{dist/lib → lib}/peer.d.ts +0 -0
  73. /package/{dist/lib → lib}/peer.d.ts.map +0 -0
  74. /package/{dist/lib → lib}/saito_factory.d.ts +0 -0
  75. /package/{dist/lib → lib}/saito_factory.d.ts.map +0 -0
  76. /package/{dist/lib → lib}/slip.d.ts +0 -0
  77. /package/{dist/lib → lib}/slip.d.ts.map +0 -0
  78. /package/{dist/lib → lib}/transaction.d.ts +0 -0
  79. /package/{dist/lib → lib}/transaction.d.ts.map +0 -0
  80. /package/{dist/lib → lib}/wallet.d.ts +0 -0
  81. /package/{dist/lib → lib}/wallet.d.ts.map +0 -0
  82. /package/{dist/saito.d.ts → saito.d.ts} +0 -0
  83. /package/{dist/saito.d.ts.map → saito.d.ts.map} +0 -0
  84. /package/{dist/shared_methods.d.ts → shared_methods.d.ts} +0 -0
  85. /package/{dist/shared_methods.d.ts.map → shared_methods.d.ts.map} +0 -0
  86. /package/{dist/tests → tests}/index.test.d.ts +0 -0
  87. /package/{dist/tests → tests}/index.test.d.ts.map +0 -0
package/index.node.ts DELETED
@@ -1,51 +0,0 @@
1
- import Saito from "./saito";
2
- import SharedMethods from "./shared_methods";
3
- import Configs from "./configs";
4
- import Transaction from "./lib/transaction";
5
- import Slip from "./lib/slip";
6
- import Block from "./lib/block";
7
- import Peer from "./lib/peer";
8
- import Factory from "./lib/factory";
9
- import Wallet from "./lib/wallet";
10
- import Blockchain from "./lib/blockchain";
11
-
12
- const NODE_MAJOR_VERSION = parseInt(process.versions.node.split(".")[0]);
13
- if (NODE_MAJOR_VERSION < 20) {
14
- let cr = require("crypto");
15
- globalThis.crypto = cr.webcrypto;
16
- }
17
-
18
- /**
19
- *
20
- * @param configs
21
- * @param sharedMethods
22
- */
23
- export async function initialize(
24
- configs: Configs,
25
- sharedMethods: SharedMethods,
26
- factory: Factory,
27
- privateKey: string
28
- ) {
29
- if (Saito.getLibInstance()) {
30
- console.error("saito already initialized");
31
- return;
32
- }
33
- console.log("initializing saito-js");
34
- let saito = await import("saito-wasm/dist/server");
35
- console.log("wasm lib loaded");
36
-
37
- let s = await saito.default;
38
-
39
- Saito.setLibInstance(s);
40
-
41
- Transaction.Type = s.WasmTransaction;
42
- Slip.Type = s.WasmSlip;
43
- Block.Type = s.WasmBlock;
44
- Peer.Type = s.WasmPeer;
45
- Wallet.Type = s.WasmWallet;
46
- Blockchain.Type = s.WasmBlockchain;
47
-
48
- return Saito.initialize(configs, sharedMethods, factory, privateKey);
49
- }
50
-
51
- export default Saito;
package/index.web.ts DELETED
@@ -1,47 +0,0 @@
1
- import Saito from "./saito";
2
- import SharedMethods from "./shared_methods";
3
- import Configs from "./configs";
4
- import Transaction from "./lib/transaction";
5
- import Slip from "./lib/slip";
6
- import Block from "./lib/block";
7
- import Peer from "./lib/peer";
8
- import Factory from "./lib/factory";
9
- import Wallet from "./lib/wallet";
10
- import Blockchain from "./lib/blockchain";
11
-
12
- /**
13
- *
14
- * @param configs
15
- * @param sharedMethods
16
- */
17
- export async function initialize(
18
- configs: Configs,
19
- sharedMethods: SharedMethods,
20
- factory: Factory,
21
- privateKey: string
22
- ) {
23
- if (Saito.getLibInstance()) {
24
- console.error("saito already initialized");
25
- return;
26
- }
27
- console.log("initializing saito-js");
28
-
29
- return import("saito-wasm/dist/browser")
30
- .then((s: any) => {
31
- return s.default;
32
- })
33
- .then((s) => {
34
- Saito.setLibInstance(s);
35
- return s.default().then(() => {
36
- Transaction.Type = s.WasmTransaction;
37
- Slip.Type = s.WasmSlip;
38
- Block.Type = s.WasmBlock;
39
- Peer.Type = s.WasmPeer;
40
- Wallet.Type = s.WasmWallet;
41
- Blockchain.Type = s.WasmBlockchain;
42
- return Saito.initialize(configs, sharedMethods, factory, privateKey);
43
- });
44
- });
45
- }
46
-
47
- export default Saito;
package/lib/block.ts DELETED
@@ -1,42 +0,0 @@
1
- import type {WasmBlock} from 'saito-wasm/dist/types/pkg/node/index_bg';
2
- import Transaction from "./transaction";
3
- import Saito from "../saito";
4
-
5
- export enum BlockType {
6
- Ghost = 0,
7
- Header = 1,
8
- Pruned = 2,
9
- Full = 3,
10
- }
11
-
12
-
13
- export default class Block {
14
- protected block: WasmBlock;
15
- public static Type: any;
16
-
17
- constructor(block?: WasmBlock) {
18
- if (block) {
19
- this.block = block;
20
- } else {
21
- this.block = Block.Type();
22
- }
23
- }
24
-
25
- public get transactions(): Array<Transaction> {
26
- return this.block.transactions.map(tx => {
27
- return Saito.getInstance().factory.createTransaction(tx);
28
- });
29
- }
30
-
31
- public get id(): bigint {
32
- return this.block.id;
33
- }
34
-
35
- public get hash(): string {
36
- return this.block.hash;
37
- }
38
-
39
- public serialize(): Uint8Array {
40
- return this.block.serialize();
41
- }
42
- }
package/lib/blockchain.ts DELETED
@@ -1,14 +0,0 @@
1
- import type {WasmBlockchain} from "saito-wasm/dist/types/pkg/node/index_bg";
2
-
3
- export default class Blockchain {
4
- protected blockchain: WasmBlockchain;
5
- public static Type: any;
6
-
7
- constructor(blockchain: WasmBlockchain) {
8
- this.blockchain = blockchain;
9
- }
10
-
11
- public async reset() {
12
- return this.blockchain.reset();
13
- }
14
- }
@@ -1,92 +0,0 @@
1
- import SharedMethods from "../../shared_methods";
2
- import Saito from "../../saito";
3
- import Wallet from "../wallet";
4
- import Blockchain from "../blockchain";
5
-
6
- export default class CustomSharedMethods implements SharedMethods {
7
- processApiCall(buffer: Uint8Array, msgIndex: number, peerIndex: bigint): Promise<void> {
8
- throw new Error("Method not implemented.");
9
- }
10
-
11
- connectToPeer(peerData: any): void {
12
- throw new Error("Method not implemented.");
13
- }
14
-
15
- disconnectFromPeer(peerIndex: bigint): void {
16
- throw new Error("Method not implemented.");
17
- }
18
-
19
- fetchBlockFromPeer(url: string): Promise<Uint8Array> {
20
- throw new Error("Method not implemented.");
21
- }
22
-
23
- isExistingFile(key: string): boolean {
24
- throw new Error("Method not implemented.");
25
- }
26
-
27
- loadBlockFileList(): Array<string> {
28
- throw new Error("Method not implemented.");
29
- }
30
-
31
- processApiError(buffer: Uint8Array, msgIndex: number, peerIndex: bigint): void {
32
- let promise = Saito.getInstance().promises.get(msgIndex);
33
- if (promise) {
34
- promise.reject(buffer);
35
- } else {
36
- console.error(
37
- "callback not found for callback index : " + msgIndex + " from peer : " + peerIndex
38
- );
39
- }
40
- }
41
-
42
- processApiSuccess(buffer: Uint8Array, msgIndex: number, peerIndex: bigint): void {
43
- let promise = Saito.getInstance().promises.get(msgIndex);
44
- if (promise) {
45
- promise.resolve(buffer);
46
- } else {
47
- console.error(
48
- "callback not found for callback index : " + msgIndex + " from peer : " + peerIndex
49
- );
50
- }
51
- }
52
-
53
- readValue(key: string): Uint8Array | null {
54
- throw new Error("Method not implemented.");
55
- }
56
-
57
- removeValue(key: string): void {
58
- throw new Error("Method not implemented.");
59
- }
60
-
61
- sendMessage(peerIndex: bigint, buffer: Uint8Array): void {
62
- throw new Error("Method not implemented.");
63
- }
64
-
65
- sendMessageToAll(buffer: Uint8Array, exceptions: Array<bigint>): void {
66
- throw new Error("Method not implemented.");
67
- }
68
-
69
- writeValue(key: string, value: Uint8Array): void {
70
- throw new Error("Method not implemented.");
71
- }
72
-
73
- sendInterfaceEvent(event: String, peerIndex: bigint): void {
74
- throw new Error("Method not implemented.");
75
- }
76
-
77
- saveWallet(): void {
78
- throw new Error("Method not implemented.");
79
- }
80
-
81
- loadWallet(): void {
82
- throw new Error("Method not implemented.");
83
- }
84
-
85
- saveBlockchain(): void {
86
- throw new Error("Method not implemented.");
87
- }
88
-
89
- loadBlockchain(): void {
90
- throw new Error("Method not implemented.");
91
- }
92
- }
package/lib/factory.ts DELETED
@@ -1,32 +0,0 @@
1
- import Block from "./block";
2
- import Transaction from "./transaction";
3
- import Slip from "./slip";
4
- import Peer from "./peer";
5
- import Wallet from "./wallet";
6
- import Blockchain from "./blockchain";
7
-
8
- export default class Factory {
9
- constructor() {}
10
-
11
- public createBlock(data?: any): Block {
12
- return new Block(data);
13
- }
14
-
15
- public createTransaction<T extends Transaction>(data?: any): Transaction {
16
- return new Transaction(data);
17
- }
18
-
19
- public createSlip(data?: any): Slip {
20
- return new Slip(data);
21
- }
22
-
23
- public createPeer(data?: any): Peer {
24
- return new Peer(data);
25
- }
26
- public createWallet(data: any): Wallet {
27
- return new Wallet(data);
28
- }
29
- public createBlockchain(data: any): Blockchain {
30
- return new Blockchain(data);
31
- }
32
- }
package/lib/wallet.ts DELETED
@@ -1,61 +0,0 @@
1
- import type { WasmWallet } from "saito-wasm/dist/types/pkg/node/index_bg";
2
- import Saito from "../saito";
3
-
4
- export const DefaultEmptyPrivateKey =
5
- "0000000000000000000000000000000000000000000000000000000000000000";
6
- export const DefaultEmptyPublicKey =
7
- "000000000000000000000000000000000000000000000000000000000000000000";
8
-
9
- export default class Wallet {
10
- protected wallet: WasmWallet;
11
- public static Type: any;
12
-
13
- constructor(wallet: WasmWallet) {
14
- this.wallet = wallet;
15
- }
16
-
17
- public async save() {
18
- return this.wallet.save();
19
- }
20
-
21
- public async load() {
22
- return this.wallet.load();
23
- }
24
-
25
- public async reset() {
26
- return this.wallet.reset();
27
- }
28
-
29
- public async getPublicKey() {
30
- let key = await this.wallet.get_public_key();
31
- return key === DefaultEmptyPublicKey ? "" : key;
32
- }
33
-
34
- public async setPublicKey(key: string) {
35
- if (key === "") {
36
- key = DefaultEmptyPublicKey;
37
- }
38
- return this.wallet.set_public_key(key);
39
- }
40
-
41
- public async getPrivateKey() {
42
- let key = await this.wallet.get_private_key();
43
- return key === DefaultEmptyPrivateKey ? "" : key;
44
- }
45
-
46
- public async setPrivateKey(key: string) {
47
- if (key === "") {
48
- key = DefaultEmptyPrivateKey;
49
- }
50
- return this.wallet.set_private_key(key);
51
- }
52
-
53
- public async getBalance() {
54
- return this.wallet.get_balance();
55
- }
56
-
57
- public async getPendingTxs() {
58
- let txs = await this.wallet.get_pending_txs();
59
- return txs.map((tx: any) => Saito.getInstance().factory.createTransaction(tx));
60
- }
61
- }
package/shared_methods.ts DELETED
@@ -1,40 +0,0 @@
1
- import Wallet from "./lib/wallet";
2
- import Blockchain from "./lib/blockchain";
3
-
4
- export default interface SharedMethods {
5
- sendMessage(peerIndex: bigint, buffer: Uint8Array): void;
6
-
7
- sendMessageToAll(buffer: Uint8Array, exceptions: Array<bigint>): void;
8
-
9
- connectToPeer(peerData: any): void;
10
-
11
- writeValue(key: string, value: Uint8Array): void;
12
-
13
- readValue(key: string): Uint8Array | null;
14
-
15
- loadBlockFileList(): Array<string>;
16
-
17
- isExistingFile(key: string): boolean;
18
-
19
- removeValue(key: string): void;
20
-
21
- disconnectFromPeer(peerIndex: bigint): void;
22
-
23
- fetchBlockFromPeer(url: string): Promise<Uint8Array>;
24
-
25
- processApiCall(buffer: Uint8Array, msgIndex: number, peerIndex: bigint): Promise<void>;
26
-
27
- processApiSuccess(buffer: Uint8Array, msgIndex: number, peerIndex: bigint): void;
28
-
29
- processApiError(buffer: Uint8Array, msgIndex: number, peerIndex: bigint): void;
30
-
31
- sendInterfaceEvent(event: String, peerIndex: bigint): void;
32
-
33
- saveWallet(wallet: Wallet): void;
34
-
35
- loadWallet(wallet: Wallet): void;
36
-
37
- saveBlockchain(blockchain: Blockchain): void;
38
-
39
- loadBlockchain(blockchain: Blockchain): void;
40
- }
package/tsconfig.json DELETED
@@ -1,111 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Enable incremental compilation */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2020",
15
- /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
16
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
17
- // "jsx": "preserve", /* Specify what JSX code is generated. */
18
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
19
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
20
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
21
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
23
- // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
24
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
-
27
- /* Modules */
28
- "module": "es2020",
29
- /* Specify what module code is generated. */
30
- // "rootDir": "./", /* Specify the root folder within your source files. */
31
- "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
32
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
- // "paths": {
34
- // "*": ["saito-wasm","./node_modules/saito-wasm/dist/types/pkg/node/index.d.ts"]
35
- // }, /* Specify a set of entries that re-map imports to additional lookup locations. */
36
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
37
- // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
38
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
39
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
40
- // "resolveJsonModule": true, /* Enable importing .json files */
41
- // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
42
-
43
- /* JavaScript Support */
44
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
45
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
46
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
47
-
48
- /* Emit */
49
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
50
- "declarationMap": true, /* Create sourcemaps for d.ts files. */
51
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
52
- "sourceMap": true,
53
- /* Create source map files for emitted JavaScript files. */
54
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
55
- "outDir": "dist",
56
- /* Specify an output folder for all emitted files. */
57
- // "removeComments": true, /* Disable emitting comments. */
58
- // "noEmit": true, /* Disable emitting files from a compilation. */
59
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
60
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
61
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
62
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
63
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
64
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
65
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
66
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
67
- // "newLine": "crlf", /* Set the newline character for emitting files. */
68
- // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
69
- // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
70
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
71
- // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
72
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
73
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
74
-
75
- /* Interop Constraints */
76
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
77
- "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
78
- "esModuleInterop": true,
79
- /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
80
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
81
- "forceConsistentCasingInFileNames": true,
82
- /* Ensure that casing is correct in imports. */
83
-
84
- /* Type Checking */
85
- "strict": true,
86
- /* Enable all strict type-checking options. */
87
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
88
- // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
89
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
90
- // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
91
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
92
- // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
93
- // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
94
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
95
- // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
96
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
97
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
98
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
99
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
100
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
101
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
102
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
103
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
104
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
105
-
106
- /* Completeness */
107
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
108
- "skipLibCheck": true
109
- /* Skip type checking all .d.ts files. */
110
- }
111
- }
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "es2015",
5
- "lib": [
6
- "es2017"
7
- ],
8
- "declaration": false,
9
- "noImplicitAny": false,
10
- "removeComments": true,
11
- "inlineSourceMap": true,
12
- "moduleResolution": "node"
13
- },
14
- "include": [
15
- "scripts/**/*.ts",
16
- "src/**/*.ts",
17
- "node_modules/lodash-es/**/*.js"
18
- ]
19
- }
package/webpack.config.js DELETED
@@ -1,136 +0,0 @@
1
- const path = require('path');
2
- const webpack = require('webpack');
3
- const {merge} = require("webpack-merge");
4
-
5
- let config = {
6
- optimization: {
7
- minimize: false,
8
- },
9
- // Path to your entry point. From this file Webpack will begin his work
10
- // entry: ["babel-polyfill", path.resolve(__dirname, entrypoint)],
11
- resolve: {
12
- // Add '.ts' and '.tsx' as resolvable extensions.
13
- extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js", ".wasm", "..."],
14
- fallback: {
15
- "fs": false,
16
- "tls": false,
17
- "net": false,
18
- "path": require.resolve("path-browserify"),
19
- "zlib": false,
20
- "http": false,
21
- "https": false,
22
- "stream": require.resolve("stream-browserify"),
23
- "buffer": require.resolve("buffer"),
24
- "crypto": require.resolve("crypto-browserify"),
25
- "crypto-browserify": require.resolve("crypto-browserify"),
26
- "async_hooks": false,
27
- 'process/browser': require.resolve('process/browser'),
28
- "util": require.resolve("util/"),
29
- "url": require.resolve("url/")
30
- }
31
- },
32
- module: {
33
- rules: [
34
- // All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
35
- {
36
- test: /\.tsx?$/,
37
- loader: "ts-loader",
38
- exclude: ["/node_modules/", /\.d\.ts$/iu]
39
- },
40
- {
41
- test: /\.d\.ts$/,
42
- loader: 'ignore-loader'
43
- },
44
- // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
45
- {
46
- test: /\.js$/,
47
- use: [
48
- "source-map-loader",
49
- {
50
- loader: "babel-loader",
51
- options: {
52
- presets: ["@babel/preset-env"],
53
- sourceMaps: true
54
- }
55
- }
56
- ],
57
- exclude: /(node_modules)/
58
- },
59
- {
60
- test: /\.mjs$/,
61
- exclude: /(node_modules)/,
62
- type: "javascript/auto"
63
- },
64
- {
65
- test: /\.wasm$/,
66
- type: "asset/inline",
67
- },
68
- ],
69
- parser: {
70
- javascript: {
71
- dynamicImportMode: 'eager'
72
- }
73
- }
74
- },
75
- plugins: [
76
- // Work around for Buffer is undefined:
77
- // https://github.com/webpack/changelog-v5/issues/10
78
- new webpack.ProvidePlugin({
79
- Buffer: ["buffer", "Buffer"]
80
- }),
81
- new webpack.ProvidePlugin({
82
- process: "process/browser"
83
- })
84
- ],
85
- // ignoreWarnings: [/Failed to parse source map/],
86
- experiments: {
87
- asyncWebAssembly: true,
88
- topLevelAwait: true,
89
- syncWebAssembly: true,
90
- // futureDefaults: true,
91
- },
92
- mode: "development",
93
- devtool: "eval"
94
- };
95
-
96
- let nodeConfigs = merge(config, {
97
- output: {
98
- path: path.resolve(__dirname, "./dist/server"),
99
- filename: "index.js"
100
- },
101
- resolve: {
102
- fallback: {}
103
- },
104
- target: "node",
105
- entry: ["babel-polyfill", path.resolve(__dirname, "./index.node.ts")],
106
- externals: [
107
- {
108
- 'utf-8-validate': 'commonjs utf-8-validate',
109
- 'bufferutil': 'commonjs bufferutil',
110
- },
111
- ],
112
- });
113
- let webConfigs = merge(config, {
114
- output: {
115
- path: path.resolve(__dirname, "./dist/browser/"),
116
- filename: "index.js"
117
- },
118
- plugins: [
119
- // new CopyPlugin({
120
- // patterns: [{
121
- // from: "./dist/browser/saito.js",
122
- // to: "../../public/javascripts/saito.js",
123
- // }]
124
- // })
125
- ],
126
- resolve: {
127
- fallback: {
128
- "bufferutil": false,
129
- "utf-8-validate": false
130
- }
131
- },
132
- target: "web",
133
- entry: ["babel-polyfill", path.resolve(__dirname, "./index.web.ts")],
134
- });
135
-
136
- module.exports = [nodeConfigs, webConfigs];