@layerzerolabs/dfs 0.0.1

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/.eslintrc.cjs ADDED
@@ -0,0 +1,5 @@
1
+ /** @type {import("eslint").Linter.Config} */
2
+ module.exports = {
3
+ root: true,
4
+ extends: [require.resolve('@layerzerolabs/eslint-configuration/base')],
5
+ };
@@ -0,0 +1,21 @@
1
+
2
+ 
3
+ > @layerzerolabs/dfs@0.0.1 build /Users/ivan.kurinnyi/project/monorepo-internal/packages/dfs
4
+ > tsup
5
+
6
+ CLI Building entry: src/index.ts
7
+ CLI Using tsconfig: tsconfig.json
8
+ CLI tsup v8.4.0
9
+ CLI Using tsup config: /Users/ivan.kurinnyi/project/monorepo-internal/packages/dfs/tsup.config.ts
10
+ CLI Target: es2022
11
+ CLI Cleaning output folder
12
+ CJS Build start
13
+ ESM Build start
14
+ ESM You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin
15
+ ESM You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin
16
+ CJS dist/index.cjs 950.00 B
17
+ CJS dist/index.cjs.map 2.98 KB
18
+ CJS ⚡️ Build success in 27ms
19
+ ESM dist/index.js 928.00 B
20
+ ESM dist/index.js.map 2.98 KB
21
+ ESM ⚡️ Build success in 27ms
package/dist/index.cjs ADDED
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ require('reflect-metadata');
4
+
5
+ // src/index.ts
6
+ var dfs = (node, handler, _visited = /* @__PURE__ */ new Map(), _returns = {}) => {
7
+ if (_visited.has(node.name)) {
8
+ return async () => {
9
+ await _visited.get(node.name);
10
+ return _returns;
11
+ };
12
+ }
13
+ let resolver;
14
+ _visited.set(
15
+ node.name,
16
+ new Promise((res) => {
17
+ resolver = res;
18
+ })
19
+ );
20
+ const resolverFunctions = [];
21
+ if (node.dependencies) {
22
+ for (const [_, dependencyValue] of Object.entries(node.dependencies)) {
23
+ resolverFunctions.push(dfs(dependencyValue, handler, _visited, _returns));
24
+ }
25
+ }
26
+ return async () => {
27
+ await Promise.all(resolverFunctions.map((f) => f()));
28
+ const regRes = await handler(node);
29
+ if (regRes) {
30
+ (_returns[regRes.key] ??= {})[node.name] = regRes.value;
31
+ }
32
+ resolver();
33
+ return _returns;
34
+ };
35
+ };
36
+
37
+ exports.dfs = dfs;
38
+ //# sourceMappingURL=index.cjs.map
39
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAgBa,IAAA,GAAA,GAAM,CACf,IAAA,EACA,OACA,EAAA,QAAA,uBAA2C,GAAI,EAAA,EAC/C,QAAwB,GAAA,EACO,KAAA;AAC/B,EAAA,IAAI,QAAS,CAAA,GAAA,CAAI,IAAK,CAAA,IAAI,CAAG,EAAA;AACzB,IAAA,OAAO,YAAY;AACf,MAAM,MAAA,QAAA,CAAS,GAAI,CAAA,IAAA,CAAK,IAAI,CAAA;AAC5B,MAAO,OAAA,QAAA;AAAA,KACX;AAAA;AAEJ,EAAI,IAAA,QAAA;AAEJ,EAAS,QAAA,CAAA,GAAA;AAAA,IACL,IAAK,CAAA,IAAA;AAAA,IACL,IAAI,OAAc,CAAA,CAAC,GAAQ,KAAA;AACvB,MAAW,QAAA,GAAA,GAAA;AAAA,KACd;AAAA,GACL;AAGA,EAAA,MAAM,oBAA4C,EAAC;AACnD,EAAA,IAAI,KAAK,YAAc,EAAA;AACnB,IAAW,KAAA,MAAA,CAAC,GAAG,eAAe,CAAA,IAAK,OAAO,OAAQ,CAAA,IAAA,CAAK,YAAY,CAAG,EAAA;AAClE,MAAA,iBAAA,CAAkB,KAAK,GAAI,CAAA,eAAA,EAAiB,OAAS,EAAA,QAAA,EAAU,QAAQ,CAAC,CAAA;AAAA;AAC5E;AAGJ,EAAA,OAAO,YAAY;AACf,IAAM,MAAA,OAAA,CAAQ,IAAI,iBAAkB,CAAA,GAAA,CAAI,CAAC,CAAM,KAAA,CAAA,EAAG,CAAC,CAAA;AACnD,IAAM,MAAA,MAAA,GAAS,MAAM,OAAA,CAAQ,IAAI,CAAA;AACjC,IAAA,IAAI,MAAQ,EAAA;AACR,MAAE,CAAA,QAAA,CAAiB,OAAO,GAAG,CAAA,KAAM,EAAI,EAAA,IAAA,CAAK,IAAI,CAAA,GAAI,MAAO,CAAA,KAAA;AAAA;AAE/D,IAAS,QAAA,EAAA;AACT,IAAO,OAAA,QAAA;AAAA,GACX;AACJ","file":"index.cjs","sourcesContent":["import type { Dependencies, DependencyNode } from '@layerzerolabs/dependency-graph';\n\nexport interface Registrar<ReturnType> {\n traverseDependencies: (rootNode: DependencyNode<any, any>) => Promise<ReturnType>;\n}\nexport type NodeHandlerFunction = (\n node: DependencyNode<any, Dependencies>,\n) => Promise<{ key: string; value: any }>;\n\n/**\n * Performs a depth-first-search on a tree of dependency nodes, using the provided registrar map\n * to register the nodes into the root tsyringe container.\n * @param node the root node of the tree\n * @param handler a function that accepts a node and registers it\n * @returns all pure dependencies of the node\n */\nexport const dfs = <DependencyName extends string, ReturnTypes>(\n node: DependencyNode<DependencyName, Dependencies>,\n handler: NodeHandlerFunction,\n _visited: Map<string, Promise<void>> = new Map(),\n _returns: ReturnTypes = {} as any,\n): (() => Promise<ReturnTypes>) => {\n if (_visited.has(node.name)) {\n return async () => {\n await _visited.get(node.name);\n return _returns;\n };\n }\n let resolver: (value: void | PromiseLike<void>) => void;\n\n _visited.set(\n node.name,\n new Promise<void>((res) => {\n resolver = res;\n }),\n );\n\n // Resolve dependencies first\n const resolverFunctions: (() => Promise<any>)[] = [];\n if (node.dependencies) {\n for (const [_, dependencyValue] of Object.entries(node.dependencies)) {\n resolverFunctions.push(dfs(dependencyValue, handler, _visited, _returns));\n }\n }\n\n return async () => {\n await Promise.all(resolverFunctions.map((f) => f()));\n const regRes = await handler(node);\n if (regRes) {\n ((_returns as any)[regRes.key] ??= {})[node.name] = regRes.value;\n }\n resolver();\n return _returns;\n };\n};\n"]}
@@ -0,0 +1,17 @@
1
+ import type { Dependencies, DependencyNode } from '@layerzerolabs/dependency-graph';
2
+ export interface Registrar<ReturnType> {
3
+ traverseDependencies: (rootNode: DependencyNode<any, any>) => Promise<ReturnType>;
4
+ }
5
+ export type NodeHandlerFunction = (node: DependencyNode<any, Dependencies>) => Promise<{
6
+ key: string;
7
+ value: any;
8
+ }>;
9
+ /**
10
+ * Performs a depth-first-search on a tree of dependency nodes, using the provided registrar map
11
+ * to register the nodes into the root tsyringe container.
12
+ * @param node the root node of the tree
13
+ * @param handler a function that accepts a node and registers it
14
+ * @returns all pure dependencies of the node
15
+ */
16
+ export declare const dfs: <DependencyName extends string, ReturnTypes>(node: DependencyNode<DependencyName, Dependencies>, handler: NodeHandlerFunction, _visited?: Map<string, Promise<void>>, _returns?: ReturnTypes) => (() => Promise<ReturnTypes>);
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEpF,MAAM,WAAW,SAAS,CAAC,UAAU;IACjC,oBAAoB,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACrF;AACD,MAAM,MAAM,mBAAmB,GAAG,CAC9B,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,YAAY,CAAC,KACtC,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,GAAI,cAAc,SAAS,MAAM,EAAE,WAAW,EAC1D,MAAM,cAAc,CAAC,cAAc,EAAE,YAAY,CAAC,EAClD,SAAS,mBAAmB,EAC5B,WAAU,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAa,EAChD,WAAU,WAAuB,KAClC,CAAC,MAAM,OAAO,CAAC,WAAW,CAAC,CAiC7B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import 'reflect-metadata';
2
+
3
+ // src/index.ts
4
+ var dfs = (node, handler, _visited = /* @__PURE__ */ new Map(), _returns = {}) => {
5
+ if (_visited.has(node.name)) {
6
+ return async () => {
7
+ await _visited.get(node.name);
8
+ return _returns;
9
+ };
10
+ }
11
+ let resolver;
12
+ _visited.set(
13
+ node.name,
14
+ new Promise((res) => {
15
+ resolver = res;
16
+ })
17
+ );
18
+ const resolverFunctions = [];
19
+ if (node.dependencies) {
20
+ for (const [_, dependencyValue] of Object.entries(node.dependencies)) {
21
+ resolverFunctions.push(dfs(dependencyValue, handler, _visited, _returns));
22
+ }
23
+ }
24
+ return async () => {
25
+ await Promise.all(resolverFunctions.map((f) => f()));
26
+ const regRes = await handler(node);
27
+ if (regRes) {
28
+ (_returns[regRes.key] ??= {})[node.name] = regRes.value;
29
+ }
30
+ resolver();
31
+ return _returns;
32
+ };
33
+ };
34
+
35
+ export { dfs };
36
+ //# sourceMappingURL=index.js.map
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAgBa,IAAA,GAAA,GAAM,CACf,IAAA,EACA,OACA,EAAA,QAAA,uBAA2C,GAAI,EAAA,EAC/C,QAAwB,GAAA,EACO,KAAA;AAC/B,EAAA,IAAI,QAAS,CAAA,GAAA,CAAI,IAAK,CAAA,IAAI,CAAG,EAAA;AACzB,IAAA,OAAO,YAAY;AACf,MAAM,MAAA,QAAA,CAAS,GAAI,CAAA,IAAA,CAAK,IAAI,CAAA;AAC5B,MAAO,OAAA,QAAA;AAAA,KACX;AAAA;AAEJ,EAAI,IAAA,QAAA;AAEJ,EAAS,QAAA,CAAA,GAAA;AAAA,IACL,IAAK,CAAA,IAAA;AAAA,IACL,IAAI,OAAc,CAAA,CAAC,GAAQ,KAAA;AACvB,MAAW,QAAA,GAAA,GAAA;AAAA,KACd;AAAA,GACL;AAGA,EAAA,MAAM,oBAA4C,EAAC;AACnD,EAAA,IAAI,KAAK,YAAc,EAAA;AACnB,IAAW,KAAA,MAAA,CAAC,GAAG,eAAe,CAAA,IAAK,OAAO,OAAQ,CAAA,IAAA,CAAK,YAAY,CAAG,EAAA;AAClE,MAAA,iBAAA,CAAkB,KAAK,GAAI,CAAA,eAAA,EAAiB,OAAS,EAAA,QAAA,EAAU,QAAQ,CAAC,CAAA;AAAA;AAC5E;AAGJ,EAAA,OAAO,YAAY;AACf,IAAM,MAAA,OAAA,CAAQ,IAAI,iBAAkB,CAAA,GAAA,CAAI,CAAC,CAAM,KAAA,CAAA,EAAG,CAAC,CAAA;AACnD,IAAM,MAAA,MAAA,GAAS,MAAM,OAAA,CAAQ,IAAI,CAAA;AACjC,IAAA,IAAI,MAAQ,EAAA;AACR,MAAE,CAAA,QAAA,CAAiB,OAAO,GAAG,CAAA,KAAM,EAAI,EAAA,IAAA,CAAK,IAAI,CAAA,GAAI,MAAO,CAAA,KAAA;AAAA;AAE/D,IAAS,QAAA,EAAA;AACT,IAAO,OAAA,QAAA;AAAA,GACX;AACJ","file":"index.js","sourcesContent":["import type { Dependencies, DependencyNode } from '@layerzerolabs/dependency-graph';\n\nexport interface Registrar<ReturnType> {\n traverseDependencies: (rootNode: DependencyNode<any, any>) => Promise<ReturnType>;\n}\nexport type NodeHandlerFunction = (\n node: DependencyNode<any, Dependencies>,\n) => Promise<{ key: string; value: any }>;\n\n/**\n * Performs a depth-first-search on a tree of dependency nodes, using the provided registrar map\n * to register the nodes into the root tsyringe container.\n * @param node the root node of the tree\n * @param handler a function that accepts a node and registers it\n * @returns all pure dependencies of the node\n */\nexport const dfs = <DependencyName extends string, ReturnTypes>(\n node: DependencyNode<DependencyName, Dependencies>,\n handler: NodeHandlerFunction,\n _visited: Map<string, Promise<void>> = new Map(),\n _returns: ReturnTypes = {} as any,\n): (() => Promise<ReturnTypes>) => {\n if (_visited.has(node.name)) {\n return async () => {\n await _visited.get(node.name);\n return _returns;\n };\n }\n let resolver: (value: void | PromiseLike<void>) => void;\n\n _visited.set(\n node.name,\n new Promise<void>((res) => {\n resolver = res;\n }),\n );\n\n // Resolve dependencies first\n const resolverFunctions: (() => Promise<any>)[] = [];\n if (node.dependencies) {\n for (const [_, dependencyValue] of Object.entries(node.dependencies)) {\n resolverFunctions.push(dfs(dependencyValue, handler, _visited, _returns));\n }\n }\n\n return async () => {\n await Promise.all(resolverFunctions.map((f) => f()));\n const regRes = await handler(node);\n if (regRes) {\n ((_returns as any)[regRes.key] ??= {})[node.name] = regRes.value;\n }\n resolver();\n return _returns;\n };\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@layerzerolabs/dfs",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "main": "./dist/index.cjs",
6
+ "types": "./dist/index.d.ts",
7
+ "dependencies": {
8
+ "reflect-metadata": "^0.2.2",
9
+ "tsup": "^8.4.0",
10
+ "@layerzerolabs/dependency-graph": "0.0.1"
11
+ },
12
+ "publishConfig": {
13
+ "access": "restricted",
14
+ "registry": "https://registry.npmjs.org/"
15
+ },
16
+ "devDependencies": {
17
+ "@layerzerolabs/eslint-configuration": "0.0.0",
18
+ "@layerzerolabs/typescript-configuration": "0.0.0",
19
+ "@layerzerolabs/tsup-configuration": "0.0.1"
20
+ },
21
+ "module": "./dist/index.js",
22
+ "exports": {
23
+ "types": "./dist/index.d.ts",
24
+ "require": "./dist/index.cjs",
25
+ "import": "./dist/index.js",
26
+ "default": "./dist/index.cjs"
27
+ },
28
+ "type": "module",
29
+ "private": false,
30
+ "scripts": {
31
+ "clean": "rm -rf ./node_modules .turbo ./dist",
32
+ "build": "tsup",
33
+ "lint": "eslint . --max-warnings 0",
34
+ "lint:fix": "eslint . --fix --max-warnings 0",
35
+ "typecheck": "tsc --noEmit",
36
+ "dev": "tsup --watch"
37
+ }
38
+ }
package/src/index.ts ADDED
@@ -0,0 +1,55 @@
1
+ import type { Dependencies, DependencyNode } from '@layerzerolabs/dependency-graph';
2
+
3
+ export interface Registrar<ReturnType> {
4
+ traverseDependencies: (rootNode: DependencyNode<any, any>) => Promise<ReturnType>;
5
+ }
6
+ export type NodeHandlerFunction = (
7
+ node: DependencyNode<any, Dependencies>,
8
+ ) => Promise<{ key: string; value: any }>;
9
+
10
+ /**
11
+ * Performs a depth-first-search on a tree of dependency nodes, using the provided registrar map
12
+ * to register the nodes into the root tsyringe container.
13
+ * @param node the root node of the tree
14
+ * @param handler a function that accepts a node and registers it
15
+ * @returns all pure dependencies of the node
16
+ */
17
+ export const dfs = <DependencyName extends string, ReturnTypes>(
18
+ node: DependencyNode<DependencyName, Dependencies>,
19
+ handler: NodeHandlerFunction,
20
+ _visited: Map<string, Promise<void>> = new Map(),
21
+ _returns: ReturnTypes = {} as any,
22
+ ): (() => Promise<ReturnTypes>) => {
23
+ if (_visited.has(node.name)) {
24
+ return async () => {
25
+ await _visited.get(node.name);
26
+ return _returns;
27
+ };
28
+ }
29
+ let resolver: (value: void | PromiseLike<void>) => void;
30
+
31
+ _visited.set(
32
+ node.name,
33
+ new Promise<void>((res) => {
34
+ resolver = res;
35
+ }),
36
+ );
37
+
38
+ // Resolve dependencies first
39
+ const resolverFunctions: (() => Promise<any>)[] = [];
40
+ if (node.dependencies) {
41
+ for (const [_, dependencyValue] of Object.entries(node.dependencies)) {
42
+ resolverFunctions.push(dfs(dependencyValue, handler, _visited, _returns));
43
+ }
44
+ }
45
+
46
+ return async () => {
47
+ await Promise.all(resolverFunctions.map((f) => f()));
48
+ const regRes = await handler(node);
49
+ if (regRes) {
50
+ ((_returns as any)[regRes.key] ??= {})[node.name] = regRes.value;
51
+ }
52
+ resolver();
53
+ return _returns;
54
+ };
55
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "display": "Node 16",
4
+ "compilerOptions": {
5
+ "lib": ["es2020"],
6
+ "module": "commonjs",
7
+ "target": "es2020",
8
+ "experimentalDecorators": true,
9
+ "allowJs": true,
10
+ "strict": true,
11
+ "esModuleInterop": true,
12
+ "skipLibCheck": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "sourceMap": true,
15
+ "strictPropertyInitialization": false,
16
+ "emitDecoratorMetadata": true,
17
+ "resolveJsonModule": true,
18
+ "outDir": "./dist",
19
+ "rootDir": "./src",
20
+ "jsx": "react-jsx"
21
+ },
22
+ "exclude": [
23
+ "node_modules",
24
+ "**/__mocks__/*",
25
+ "**/__tests__/*",
26
+ "**/*.spec.ts",
27
+ "**/*.test.ts",
28
+ "dist"
29
+ ],
30
+ "include": ["src/**/*"],
31
+ "ts-node": {
32
+ "files": true,
33
+ "experimentalResolverFeatures": true,
34
+ "compilerOptions": {
35
+ "module": "CommonJS",
36
+ "types": ["node"]
37
+ }
38
+ }
39
+ }
@@ -0,0 +1 @@
1
+ {"root":["./src/index.ts"],"version":"5.8.2"}
package/tsup.config.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ import { createPackageTsupConfig } from '@layerzerolabs/tsup-configuration';
4
+
5
+ export default defineConfig(({ watch }) => ({
6
+ ...createPackageTsupConfig(),
7
+ entry: ['src/**/*.ts', 'src/**/*.tsx'],
8
+ splitting: true,
9
+ clean: !watch,
10
+ }));