@soda-gql/common 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/LICENSE +21 -0
- package/dist/canonical-id/index.cjs +9 -0
- package/dist/canonical-id/index.d.cts +2 -0
- package/dist/canonical-id/index.d.ts +2 -0
- package/dist/canonical-id/index.js +4 -0
- package/dist/canonical-id-Bn6ZPdZl.js +155 -0
- package/dist/canonical-id-Bn6ZPdZl.js.map +1 -0
- package/dist/canonical-id-CE4Xjo2C.cjs +192 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/index-B_QJzQA2.d.cts +9 -0
- package/dist/index-B_QJzQA2.d.cts.map +1 -0
- package/dist/index-C0n5gWc3.d.cts +88 -0
- package/dist/index-C0n5gWc3.d.cts.map +1 -0
- package/dist/index-C8yyrGd7.d.cts +124 -0
- package/dist/index-C8yyrGd7.d.cts.map +1 -0
- package/dist/index-CcSB32XQ.d.ts +60 -0
- package/dist/index-CcSB32XQ.d.ts.map +1 -0
- package/dist/index-D6Lx478n.d.ts +124 -0
- package/dist/index-D6Lx478n.d.ts.map +1 -0
- package/dist/index-DN4VW1v7.d.ts +9 -0
- package/dist/index-DN4VW1v7.d.ts.map +1 -0
- package/dist/index-Fi3RpHje.d.cts +60 -0
- package/dist/index-Fi3RpHje.d.cts.map +1 -0
- package/dist/index-LjtXZhxM.d.ts +88 -0
- package/dist/index-LjtXZhxM.d.ts.map +1 -0
- package/dist/index.cjs +30 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/portable/index.cjs +13 -0
- package/dist/portable/index.d.cts +2 -0
- package/dist/portable/index.d.ts +2 -0
- package/dist/portable/index.js +3 -0
- package/dist/portable-BqSEwase.js +249 -0
- package/dist/portable-BqSEwase.js.map +1 -0
- package/dist/portable-Bq_Qob6b.cjs +308 -0
- package/dist/utils/index.cjs +9 -0
- package/dist/utils/index.d.cts +2 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils-DxBnV8tL.js +100 -0
- package/dist/utils-DxBnV8tL.js.map +1 -0
- package/dist/utils-NBAPoMgh.cjs +143 -0
- package/dist/zod/index.cjs +3 -0
- package/dist/zod/index.d.cts +2 -0
- package/dist/zod/index.d.ts +2 -0
- package/dist/zod/index.js +3 -0
- package/dist/zod-B1gOOwdX.cjs +16 -0
- package/dist/zod-BPbnZc6i.js +10 -0
- package/dist/zod-BPbnZc6i.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C8yyrGd7.d.cts","names":[],"sources":["../src/canonical-id/canonical-id.ts","../src/canonical-id/path-tracker.ts"],"sourcesContent":[],"mappings":";;;KAIY,WAAA;;AAAZ,CAAA;AAIa,cAAA,iBAA2F,EAAxE,GAAA,CAAE,OAAsE,CAA9D,WAA8D,CAAA;AAAA,cAG3F,iBAH2F,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,EAAA,GAGlC,WAHkC;;;;ACiCxG;;;AAM0F,KA1B9E,UAAA,GA0B8E;;WAuBnD,WAAA,EAAA,MAAA;EAAW;EAiDrC,SAAA,IAAA,EAAA,UAkGZ,GAAA,OA/FG,GAAA,UAAA,GAAA,UA+FH,GAAA,QAAA,GAAA,YAAA;EAKY;EAiBA,SAAA,UAAA,EAiBZ,MAAA;AAKD,CAAA;;;;KApOY,WAAA;;;;;;;UAQK,oBAAA;;;;;;;;UAM8B;;MAA2C;;;;;oBAMtE;;;;;;;;;;;;;;;uCAiBmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiD1B;;;MAGT;;;;cAoGS;;;;;;cAiBA;;;;;;cAsBA,+BAAgC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region packages/common/src/utils/cached-fn.d.ts
|
|
2
|
+
declare const cachedFn: <T>(fn: () => T) => {
|
|
3
|
+
(): T;
|
|
4
|
+
clear(): void;
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region packages/common/src/utils/path.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* File extensions to try when resolving module specifiers.
|
|
10
|
+
* Ordered by precedence: TypeScript, then JavaScript.
|
|
11
|
+
*/
|
|
12
|
+
declare const MODULE_EXTENSION_CANDIDATES: readonly [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
13
|
+
/**
|
|
14
|
+
* Normalize path to use forward slashes (cross-platform).
|
|
15
|
+
* Ensures consistent path handling across platforms.
|
|
16
|
+
*/
|
|
17
|
+
declare const normalizePath: (value: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a relative import specifier to an absolute file path.
|
|
20
|
+
* Tries the specifier as-is, with extensions, and as a directory with index files.
|
|
21
|
+
*
|
|
22
|
+
* @param from - Absolute path to the importing file
|
|
23
|
+
* @param specifier - Relative module specifier (must start with '.')
|
|
24
|
+
* @returns Absolute POSIX path to the resolved file, or null if not found
|
|
25
|
+
*/
|
|
26
|
+
declare const resolveRelativeImportWithExistenceCheck: ({
|
|
27
|
+
filePath,
|
|
28
|
+
specifier
|
|
29
|
+
}: {
|
|
30
|
+
filePath: string;
|
|
31
|
+
specifier: string;
|
|
32
|
+
}) => string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a relative import specifier to an absolute file path.
|
|
35
|
+
* Tries the specifier as-is, with extensions, and as a directory with index files.
|
|
36
|
+
*
|
|
37
|
+
* @param from - Absolute path to the importing file
|
|
38
|
+
* @param specifier - Relative module specifier (must start with '.')
|
|
39
|
+
* @returns Absolute POSIX path to the resolved file, or null if not found
|
|
40
|
+
*/
|
|
41
|
+
declare const resolveRelativeImportWithReferences: <_>({
|
|
42
|
+
filePath,
|
|
43
|
+
specifier,
|
|
44
|
+
references
|
|
45
|
+
}: {
|
|
46
|
+
filePath: string;
|
|
47
|
+
specifier: string;
|
|
48
|
+
references: Map<string, _> | Set<string>;
|
|
49
|
+
}) => string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a module specifier is relative (starts with '.' or '..')
|
|
52
|
+
*/
|
|
53
|
+
declare const isRelativeSpecifier: (specifier: string) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a module specifier is external (package name, not relative)
|
|
56
|
+
*/
|
|
57
|
+
declare const isExternalSpecifier: (specifier: string) => boolean;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { MODULE_EXTENSION_CANDIDATES, cachedFn, isExternalSpecifier, isRelativeSpecifier, normalizePath, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences };
|
|
60
|
+
//# sourceMappingURL=index-CcSB32XQ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CcSB32XQ.d.ts","names":[],"sources":["../src/utils/cached-fn.ts","../src/utils/path.ts"],"sourcesContent":[],"mappings":";cAAa,wBAAyB;EAAzB,EAAA,GAAA;EASZ,KAAA,EAAA,EAAA,IAAA;;;;;AATD;;;cCOa;;;;;AAAA,cAMA,aANqG,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,MAAA;AAMlH;AAUA;;;;;AAyCA;;AAAuD,cAzC1C,uCAyC0C,EAAA,CAAA;EAAA,QAAA;EAAA;CAAA,EAAA;UAAA,EAAA,MAAA;WAAA,EAAA,MAAA;YAO7B,GAAA,IAAA;;;;AA+B1B;AAKA;;;;cA3Ca;;;;;;;cAOC,YAAY,KAAK;;;;;cA+BlB;;;;cAKA"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import z$1 from "zod";
|
|
2
|
+
|
|
3
|
+
//#region packages/common/src/canonical-id/canonical-id.d.ts
|
|
4
|
+
type CanonicalId = string & {
|
|
5
|
+
readonly __brand: "CanonicalId";
|
|
6
|
+
};
|
|
7
|
+
declare const CanonicalIdSchema: z$1.ZodType<CanonicalId>;
|
|
8
|
+
declare const createCanonicalId: (filePath: string, astPath: string) => CanonicalId;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region packages/common/src/canonical-id/path-tracker.d.ts
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Scope frame for tracking AST path segments
|
|
14
|
+
*/
|
|
15
|
+
type ScopeFrame = {
|
|
16
|
+
/** Name segment (e.g., "MyComponent", "useQuery", "arrow#1") */
|
|
17
|
+
readonly nameSegment: string;
|
|
18
|
+
/** Kind of scope */
|
|
19
|
+
readonly kind: "function" | "class" | "variable" | "property" | "method" | "expression";
|
|
20
|
+
/** Occurrence index for disambiguation */
|
|
21
|
+
readonly occurrence: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Opaque handle for scope tracking
|
|
25
|
+
*/
|
|
26
|
+
type ScopeHandle = {
|
|
27
|
+
readonly __brand: "ScopeHandle";
|
|
28
|
+
readonly depth: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Canonical path tracker interface
|
|
32
|
+
*/
|
|
33
|
+
interface CanonicalPathTracker {
|
|
34
|
+
/**
|
|
35
|
+
* Enter a new scope during traversal
|
|
36
|
+
* @param options Scope information
|
|
37
|
+
* @returns Handle to use when exiting the scope
|
|
38
|
+
*/
|
|
39
|
+
enterScope(options: {
|
|
40
|
+
segment: string;
|
|
41
|
+
kind: ScopeFrame["kind"];
|
|
42
|
+
stableKey?: string;
|
|
43
|
+
}): ScopeHandle;
|
|
44
|
+
/**
|
|
45
|
+
* Exit a scope during traversal
|
|
46
|
+
* @param handle Handle returned from enterScope
|
|
47
|
+
*/
|
|
48
|
+
exitScope(handle: ScopeHandle): void;
|
|
49
|
+
/**
|
|
50
|
+
* Register a definition discovered during traversal
|
|
51
|
+
* @returns Definition metadata including astPath and canonical ID information
|
|
52
|
+
*/
|
|
53
|
+
registerDefinition(): {
|
|
54
|
+
astPath: string;
|
|
55
|
+
isTopLevel: boolean;
|
|
56
|
+
exportBinding?: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Resolve a canonical ID from an astPath
|
|
60
|
+
* @param astPath AST path string
|
|
61
|
+
* @returns Canonical ID
|
|
62
|
+
*/
|
|
63
|
+
resolveCanonicalId(astPath: string): CanonicalId;
|
|
64
|
+
/**
|
|
65
|
+
* Register an export binding
|
|
66
|
+
* @param local Local variable name
|
|
67
|
+
* @param exported Exported name
|
|
68
|
+
*/
|
|
69
|
+
registerExportBinding(local: string, exported: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Get current scope depth
|
|
72
|
+
* @returns Current depth (0 = top level)
|
|
73
|
+
*/
|
|
74
|
+
currentDepth(): number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a canonical path tracker
|
|
78
|
+
*
|
|
79
|
+
* @param options Configuration options
|
|
80
|
+
* @returns Tracker instance
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* // In a Babel plugin
|
|
85
|
+
* const tracker = createCanonicalTracker({ filePath: state.filename });
|
|
86
|
+
*
|
|
87
|
+
* const visitor = {
|
|
88
|
+
* FunctionDeclaration: {
|
|
89
|
+
* enter(path) {
|
|
90
|
+
* const handle = tracker.enterScope({
|
|
91
|
+
* segment: path.node.id.name,
|
|
92
|
+
* kind: 'function'
|
|
93
|
+
* });
|
|
94
|
+
* },
|
|
95
|
+
* exit(path) {
|
|
96
|
+
* tracker.exitScope(handle);
|
|
97
|
+
* }
|
|
98
|
+
* }
|
|
99
|
+
* };
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare const createCanonicalTracker: (options: {
|
|
103
|
+
filePath: string;
|
|
104
|
+
getExportName?: (localName: string) => string | undefined;
|
|
105
|
+
}) => CanonicalPathTracker;
|
|
106
|
+
/**
|
|
107
|
+
* Helper to create occurrence tracker (for backward compatibility)
|
|
108
|
+
*/
|
|
109
|
+
declare const createOccurrenceTracker: () => {
|
|
110
|
+
getNextOccurrence: (key: string) => number;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Helper to create path tracker (for backward compatibility)
|
|
114
|
+
*/
|
|
115
|
+
declare const createPathTracker: () => {
|
|
116
|
+
ensureUniquePath: (basePath: string) => string;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Build AST path from scope stack (for backward compatibility)
|
|
120
|
+
*/
|
|
121
|
+
declare const buildAstPath: (stack: readonly ScopeFrame[]) => string;
|
|
122
|
+
//#endregion
|
|
123
|
+
export { CanonicalId, CanonicalIdSchema, CanonicalPathTracker, ScopeFrame, ScopeHandle, buildAstPath, createCanonicalId, createCanonicalTracker, createOccurrenceTracker, createPathTracker };
|
|
124
|
+
//# sourceMappingURL=index-D6Lx478n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D6Lx478n.d.ts","names":[],"sources":["../src/canonical-id/canonical-id.ts","../src/canonical-id/path-tracker.ts"],"sourcesContent":[],"mappings":";;;KAIY,WAAA;;AAAZ,CAAA;AAIa,cAAA,iBAA2F,EAAxE,GAAA,CAAE,OAAsE,CAA9D,WAA8D,CAAA;AAAA,cAG3F,iBAH2F,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,EAAA,GAGlC,WAHkC;;;;ACiCxG;;;AAM0F,KA1B9E,UAAA,GA0B8E;;WAuBnD,WAAA,EAAA,MAAA;EAAW;EAiDrC,SAAA,IAAA,EAAA,UAkGZ,GAAA,OAAA,GA/FG,UAAA,GAAA,UA+FH,GAAA,QAAA,GAAA,YAAA;EAKY;EAiBA,SAAA,UAAA,EAiBZ,MAAA;AAKD,CAAA;;;;KApOY,WAAA;;;;;;;UAQK,oBAAA;;;;;;;;UAM8B;;MAA2C;;;;;oBAMtE;;;;;;;;;;;;;;;uCAiBmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiD1B;;;MAGT;;;;cAoGS;;;;;;cAiBA;;;;;;cAsBA,+BAAgC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region packages/common/src/zod/schema-helper.d.ts
|
|
4
|
+
type SchemaFor<TOutput> = z.ZodType<TOutput, any, any>;
|
|
5
|
+
type ShapeFor<TOutput extends object> = { [K in keyof TOutput]-?: SchemaFor<TOutput[K]> };
|
|
6
|
+
declare function defineSchemaFor<TOutput extends object>(): <TShape extends ShapeFor<NoInfer<TOutput>>>(shape: TShape & { [K in Exclude<keyof TShape, keyof TOutput>]: never }) => z.ZodObject<TShape & { [K in Exclude<keyof TShape, keyof TOutput>]: never } extends infer T ? { -readonly [P in keyof T]: T[P] } : never, z.core.$strict>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { SchemaFor, ShapeFor, defineSchemaFor };
|
|
9
|
+
//# sourceMappingURL=index-DN4VW1v7.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DN4VW1v7.d.ts","names":[],"sources":["../src/zod/schema-helper.ts"],"sourcesContent":[],"mappings":";;;KAGY,qBAAqB,CAAA,CAAE,QAAQ;KAE/B,2CAFA,MAEiD,OAFxC,KAEoD,SAFpD,CAE8D,OAF9D,CAEsE,CAFtE,CAAA,CAAA,EAAA;AAAsB,iBAI3B,eAJ2B,CAAA,gBAAA,MAAA,CAAA,CAAA,CAAA,EAAA,CAAA,eAKlB,QALkB,CAKT,OALS,CAKD,OALC,CAAA,CAAA,CAAA,CAAA,KAAA,EAKiB,MALjB,GAAA,QAKkC,OALlC,CAAA,MAKgD,MALhD,EAAA,MAK8D,OAL9D,CAAA,GAAA,KAAA,EAAA,EAAA,GAKgF,CAAA,CAAA,SALhF,CAKgF,MALhF,GAAA,QAK8B,OAL9B,CAAA,MAK8B,MAL9B,EAAA,MAK8B,OAL9B,CAAA,GAAA,KAAA,EAAA,SAAA,KAAA,EAAA,GAAA,kBAAA,MAK8B,CAL9B,GAK8B,CAL9B,CAK8B,CAL9B,CAAA,EAAA,GAAA,KAAA,EAK8B,CAAA,CAAA,IAAA,CAAA,OAL9B,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region packages/common/src/utils/cached-fn.d.ts
|
|
2
|
+
declare const cachedFn: <T>(fn: () => T) => {
|
|
3
|
+
(): T;
|
|
4
|
+
clear(): void;
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region packages/common/src/utils/path.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* File extensions to try when resolving module specifiers.
|
|
10
|
+
* Ordered by precedence: TypeScript, then JavaScript.
|
|
11
|
+
*/
|
|
12
|
+
declare const MODULE_EXTENSION_CANDIDATES: readonly [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
13
|
+
/**
|
|
14
|
+
* Normalize path to use forward slashes (cross-platform).
|
|
15
|
+
* Ensures consistent path handling across platforms.
|
|
16
|
+
*/
|
|
17
|
+
declare const normalizePath: (value: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a relative import specifier to an absolute file path.
|
|
20
|
+
* Tries the specifier as-is, with extensions, and as a directory with index files.
|
|
21
|
+
*
|
|
22
|
+
* @param from - Absolute path to the importing file
|
|
23
|
+
* @param specifier - Relative module specifier (must start with '.')
|
|
24
|
+
* @returns Absolute POSIX path to the resolved file, or null if not found
|
|
25
|
+
*/
|
|
26
|
+
declare const resolveRelativeImportWithExistenceCheck: ({
|
|
27
|
+
filePath,
|
|
28
|
+
specifier
|
|
29
|
+
}: {
|
|
30
|
+
filePath: string;
|
|
31
|
+
specifier: string;
|
|
32
|
+
}) => string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a relative import specifier to an absolute file path.
|
|
35
|
+
* Tries the specifier as-is, with extensions, and as a directory with index files.
|
|
36
|
+
*
|
|
37
|
+
* @param from - Absolute path to the importing file
|
|
38
|
+
* @param specifier - Relative module specifier (must start with '.')
|
|
39
|
+
* @returns Absolute POSIX path to the resolved file, or null if not found
|
|
40
|
+
*/
|
|
41
|
+
declare const resolveRelativeImportWithReferences: <_>({
|
|
42
|
+
filePath,
|
|
43
|
+
specifier,
|
|
44
|
+
references
|
|
45
|
+
}: {
|
|
46
|
+
filePath: string;
|
|
47
|
+
specifier: string;
|
|
48
|
+
references: Map<string, _> | Set<string>;
|
|
49
|
+
}) => string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a module specifier is relative (starts with '.' or '..')
|
|
52
|
+
*/
|
|
53
|
+
declare const isRelativeSpecifier: (specifier: string) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a module specifier is external (package name, not relative)
|
|
56
|
+
*/
|
|
57
|
+
declare const isExternalSpecifier: (specifier: string) => boolean;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { MODULE_EXTENSION_CANDIDATES, cachedFn, isExternalSpecifier, isRelativeSpecifier, normalizePath, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences };
|
|
60
|
+
//# sourceMappingURL=index-Fi3RpHje.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Fi3RpHje.d.cts","names":[],"sources":["../src/utils/cached-fn.ts","../src/utils/path.ts"],"sourcesContent":[],"mappings":";cAAa,wBAAyB;EAAzB,EAAA,GAAA;EASZ,KAAA,EAAA,EAAA,IAAA;;;;;AATD;;;cCOa;;;;;AAAA,cAMA,aANqG,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,MAAA;AAMlH;AAUA;;;;;AAyCA;;AAAuD,cAzC1C,uCAyC0C,EAAA,CAAA;EAAA,QAAA;EAAA;CAAA,EAAA;UAAA,EAAA,MAAA;WAAA,EAAA,MAAA;YAO7B,GAAA,IAAA;;;;AA+B1B;AAKA;;;;cA3Ca;;;;;;;cAOC,YAAY,KAAK;;;;;cA+BlB;;;;cAKA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//#region packages/common/src/portable/fs.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Portable filesystem API that works on both Bun and Node.js
|
|
4
|
+
*/
|
|
5
|
+
interface PortableFS {
|
|
6
|
+
readFile(path: string): Promise<string>;
|
|
7
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
8
|
+
exists(path: string): Promise<boolean>;
|
|
9
|
+
stat(path: string): Promise<{
|
|
10
|
+
mtime: Date;
|
|
11
|
+
size: number;
|
|
12
|
+
}>;
|
|
13
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
14
|
+
mkdir(path: string, options?: {
|
|
15
|
+
recursive?: boolean;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
declare function createPortableFS(): PortableFS;
|
|
19
|
+
declare function getPortableFS(): PortableFS;
|
|
20
|
+
/**
|
|
21
|
+
* Reset the filesystem singleton for testing
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
declare function __resetPortableFSForTests(): void;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region packages/common/src/portable/hash.d.ts
|
|
27
|
+
/**
|
|
28
|
+
* Portable hashing API that works on both Bun and Node.js
|
|
29
|
+
*/
|
|
30
|
+
type HashAlgorithm = "sha256" | "xxhash";
|
|
31
|
+
interface PortableHasher {
|
|
32
|
+
hash(content: string, algorithm?: HashAlgorithm): string;
|
|
33
|
+
}
|
|
34
|
+
declare function createPortableHasher(): PortableHasher;
|
|
35
|
+
declare function getPortableHasher(): PortableHasher;
|
|
36
|
+
/**
|
|
37
|
+
* Reset the hasher singleton for testing
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
declare function __resetPortableHasherForTests(): void;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region packages/common/src/portable/id.d.ts
|
|
43
|
+
/**
|
|
44
|
+
* Portable ID generation that works on both Bun and Node.js
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Generate a unique ID
|
|
48
|
+
* Uses UUIDv7 on Bun (monotonic), falls back to randomUUID on Node.js
|
|
49
|
+
*/
|
|
50
|
+
declare function generateId(): string;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region packages/common/src/portable/runtime.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* Runtime detection utilities for portable API implementation
|
|
55
|
+
*/
|
|
56
|
+
declare const runtime: {
|
|
57
|
+
readonly isBun: boolean;
|
|
58
|
+
readonly isNode: boolean;
|
|
59
|
+
readonly supportsWebCrypto: boolean;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Helper to cache module imports to avoid repeated dynamic imports
|
|
63
|
+
*/
|
|
64
|
+
declare function once<T>(fn: () => T): () => T;
|
|
65
|
+
/**
|
|
66
|
+
* Reset runtime state for testing purposes only
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
declare function resetPortableForTests(): void;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region packages/common/src/portable/spawn.d.ts
|
|
72
|
+
/**
|
|
73
|
+
* Portable subprocess spawning that works on both Bun and Node.js
|
|
74
|
+
*/
|
|
75
|
+
interface SpawnOptions {
|
|
76
|
+
cmd: string[];
|
|
77
|
+
cwd?: string;
|
|
78
|
+
env?: Record<string, string>;
|
|
79
|
+
}
|
|
80
|
+
interface SpawnResult {
|
|
81
|
+
stdout: string;
|
|
82
|
+
stderr: string;
|
|
83
|
+
exitCode: number;
|
|
84
|
+
}
|
|
85
|
+
declare function spawn(options: SpawnOptions): Promise<SpawnResult>;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { type HashAlgorithm, type PortableFS, type PortableHasher, type SpawnOptions, type SpawnResult, __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn };
|
|
88
|
+
//# sourceMappingURL=index-LjtXZhxM.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-LjtXZhxM.d.ts","names":[],"sources":["../src/portable/fs.ts","../src/portable/hash.ts","../src/portable/id.ts","../src/portable/runtime.ts","../src/portable/spawn.ts"],"sourcesContent":[],"mappings":";;AAMA;;AAC0B,UADT,UAAA,CACS;UACkB,CAAA,IAAA,EAAA,MAAA,CAAA,EADlB,OACkB,CAAA,MAAA,CAAA;WACpB,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,CAAA,EADoB,OACpB,CAAA,IAAA,CAAA;QACe,CAAA,IAAA,EAAA,MAAA,CAAA,EADf,OACe,CAAA,OAAA,CAAA;MAAjB,CAAA,IAAA,EAAA,MAAA,CAAA,EAAA,OAAA,CAAA;IACsB,KAAA,EADL,IACK;IACc,IAAA,EAAA,MAAA;EAAO,CAAA,CAAA;EAsBjD,MAAA,CAAA,OAAA,EAAA,MAAgB,EAAA,OAAI,EAAA,MAAA,CAAA,EAvBQ,OAuBE,CAAA,IAAA,CAAA;EA4F9B,KAAA,CAAA,IAAA,EAAA,MAAa,EAAA,QAAI,EAAA;IAWjB,SAAA,CAAA,EAAA,OAAA;MA7H0C;;iBAsB1C,gBAAA,CAAA,GAAoB;AC5BxB,iBDwHI,aAAA,CAAA,CCxHS,EDwHQ,UCxHR;AAEzB;AAWA;AAqCA;AAWA;iBDsEgB,yBAAA,CAAA;;;;AAnIhB;;AAC0B,KCDd,aAAA,GDCc,QAAA,GAAA,QAAA;AACkB,UCA3B,cAAA,CDA2B;MACpB,CAAA,OAAA,EAAA,MAAA,EAAA,SAAA,CAAA,ECAY,aDAZ,CAAA,EAAA,MAAA;;AACF,iBCSN,oBAAA,CAAA,CDTM,ECSkB,cDTlB;AACsB,iBC6C5B,iBAAA,CAAA,CD7C4B,EC6CP,cD7CO;;;AAuB5C;AA4FA;AAWgB,iBCtEA,6BAAA,CAAA,CDsEyB,EAAA,IAAA;;;;AAnIzC;;;;;;AAIsB,iBEAN,UAAA,CAAA,CFAM,EAAA,MAAA;;;;AAJtB;;AAC0B,cGHb,OHGa,EAAA;WACkB,KAAA,EAAA,OAAA;WACpB,MAAA,EAAA,OAAA;WACe,iBAAA,EAAA,OAAA;;;;;AAwBvB,iBGrBA,IHqBgB,CAAA,CAAA,CAAA,CAAA,EAAI,EAAA,GAAA,GGrBF,CHqBE,CAAA,EAAU,GAAA,GGrBF,CHqBE;AA4F9C;AAWA;;;iBG3GgB,qBAAA,CAAA;;;;AHxBhB;;AAC0B,UIDT,YAAA,CJCS;KACkB,EAAA,MAAA,EAAA;KACpB,CAAA,EAAA,MAAA;KACe,CAAA,EID/B,MJC+B,CAAA,MAAA,EAAA,MAAA,CAAA;;AACK,UIC3B,WAAA,CJD2B;QACc,EAAA,MAAA;EAAO,MAAA,EAAA,MAAA;EAsBjD,QAAA,EAAA,MAAA;AA4FhB;AAWgB,iBIvHM,KAAA,CJuHN,OAAyB,EIvHJ,YJuHI,CAAA,EIvHW,OJuHX,CIvHmB,WJuHnB,CAAA"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const require_utils = require('./utils-NBAPoMgh.cjs');
|
|
2
|
+
const require_canonical_id = require('./canonical-id-CE4Xjo2C.cjs');
|
|
3
|
+
const require_portable = require('./portable-Bq_Qob6b.cjs');
|
|
4
|
+
const require_zod = require('./zod-B1gOOwdX.cjs');
|
|
5
|
+
|
|
6
|
+
exports.CanonicalIdSchema = require_canonical_id.CanonicalIdSchema;
|
|
7
|
+
exports.MODULE_EXTENSION_CANDIDATES = require_utils.MODULE_EXTENSION_CANDIDATES;
|
|
8
|
+
exports.__resetPortableFSForTests = require_portable.__resetPortableFSForTests;
|
|
9
|
+
exports.__resetPortableHasherForTests = require_portable.__resetPortableHasherForTests;
|
|
10
|
+
exports.buildAstPath = require_canonical_id.buildAstPath;
|
|
11
|
+
exports.cachedFn = require_utils.cachedFn;
|
|
12
|
+
exports.createCanonicalId = require_canonical_id.createCanonicalId;
|
|
13
|
+
exports.createCanonicalTracker = require_canonical_id.createCanonicalTracker;
|
|
14
|
+
exports.createOccurrenceTracker = require_canonical_id.createOccurrenceTracker;
|
|
15
|
+
exports.createPathTracker = require_canonical_id.createPathTracker;
|
|
16
|
+
exports.createPortableFS = require_portable.createPortableFS;
|
|
17
|
+
exports.createPortableHasher = require_portable.createPortableHasher;
|
|
18
|
+
exports.defineSchemaFor = require_zod.defineSchemaFor;
|
|
19
|
+
exports.generateId = require_portable.generateId;
|
|
20
|
+
exports.getPortableFS = require_portable.getPortableFS;
|
|
21
|
+
exports.getPortableHasher = require_portable.getPortableHasher;
|
|
22
|
+
exports.isExternalSpecifier = require_utils.isExternalSpecifier;
|
|
23
|
+
exports.isRelativeSpecifier = require_utils.isRelativeSpecifier;
|
|
24
|
+
exports.normalizePath = require_utils.normalizePath;
|
|
25
|
+
exports.once = require_portable.once;
|
|
26
|
+
exports.resetPortableForTests = require_portable.resetPortableForTests;
|
|
27
|
+
exports.resolveRelativeImportWithExistenceCheck = require_utils.resolveRelativeImportWithExistenceCheck;
|
|
28
|
+
exports.resolveRelativeImportWithReferences = require_utils.resolveRelativeImportWithReferences;
|
|
29
|
+
exports.runtime = require_portable.runtime;
|
|
30
|
+
exports.spawn = require_portable.spawn;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CanonicalId, CanonicalIdSchema, CanonicalPathTracker, ScopeFrame, ScopeHandle, buildAstPath, createCanonicalId, createCanonicalTracker, createOccurrenceTracker, createPathTracker } from "./index-C8yyrGd7.cjs";
|
|
2
|
+
import { HashAlgorithm, PortableFS, PortableHasher, SpawnOptions, SpawnResult, __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn } from "./index-C0n5gWc3.cjs";
|
|
3
|
+
import { MODULE_EXTENSION_CANDIDATES, cachedFn, isExternalSpecifier, isRelativeSpecifier, normalizePath, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences } from "./index-Fi3RpHje.cjs";
|
|
4
|
+
import { SchemaFor, ShapeFor, defineSchemaFor } from "./index-B_QJzQA2.cjs";
|
|
5
|
+
export { CanonicalId, CanonicalIdSchema, CanonicalPathTracker, HashAlgorithm, MODULE_EXTENSION_CANDIDATES, PortableFS, PortableHasher, SchemaFor, ScopeFrame, ScopeHandle, ShapeFor, SpawnOptions, SpawnResult, __resetPortableFSForTests, __resetPortableHasherForTests, buildAstPath, cachedFn, createCanonicalId, createCanonicalTracker, createOccurrenceTracker, createPathTracker, createPortableFS, createPortableHasher, defineSchemaFor, generateId, getPortableFS, getPortableHasher, isExternalSpecifier, isRelativeSpecifier, normalizePath, once, resetPortableForTests, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences, runtime, spawn };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CanonicalId, CanonicalIdSchema, CanonicalPathTracker, ScopeFrame, ScopeHandle, buildAstPath, createCanonicalId, createCanonicalTracker, createOccurrenceTracker, createPathTracker } from "./index-D6Lx478n.js";
|
|
2
|
+
import { HashAlgorithm, PortableFS, PortableHasher, SpawnOptions, SpawnResult, __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn } from "./index-LjtXZhxM.js";
|
|
3
|
+
import { MODULE_EXTENSION_CANDIDATES, cachedFn, isExternalSpecifier, isRelativeSpecifier, normalizePath, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences } from "./index-CcSB32XQ.js";
|
|
4
|
+
import { SchemaFor, ShapeFor, defineSchemaFor } from "./index-DN4VW1v7.js";
|
|
5
|
+
export { CanonicalId, CanonicalIdSchema, CanonicalPathTracker, HashAlgorithm, MODULE_EXTENSION_CANDIDATES, PortableFS, PortableHasher, SchemaFor, ScopeFrame, ScopeHandle, ShapeFor, SpawnOptions, SpawnResult, __resetPortableFSForTests, __resetPortableHasherForTests, buildAstPath, cachedFn, createCanonicalId, createCanonicalTracker, createOccurrenceTracker, createPathTracker, createPortableFS, createPortableHasher, defineSchemaFor, generateId, getPortableFS, getPortableHasher, isExternalSpecifier, isRelativeSpecifier, normalizePath, once, resetPortableForTests, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences, runtime, spawn };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn } from "./portable-BqSEwase.js";
|
|
2
|
+
import { MODULE_EXTENSION_CANDIDATES, cachedFn, isExternalSpecifier, isRelativeSpecifier, normalizePath, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences } from "./utils-DxBnV8tL.js";
|
|
3
|
+
import { CanonicalIdSchema, buildAstPath, createCanonicalId, createCanonicalTracker, createOccurrenceTracker, createPathTracker } from "./canonical-id-Bn6ZPdZl.js";
|
|
4
|
+
import { defineSchemaFor } from "./zod-BPbnZc6i.js";
|
|
5
|
+
|
|
6
|
+
export { CanonicalIdSchema, MODULE_EXTENSION_CANDIDATES, __resetPortableFSForTests, __resetPortableHasherForTests, buildAstPath, cachedFn, createCanonicalId, createCanonicalTracker, createOccurrenceTracker, createPathTracker, createPortableFS, createPortableHasher, defineSchemaFor, generateId, getPortableFS, getPortableHasher, isExternalSpecifier, isRelativeSpecifier, normalizePath, once, resetPortableForTests, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences, runtime, spawn };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_portable = require('../portable-Bq_Qob6b.cjs');
|
|
2
|
+
|
|
3
|
+
exports.__resetPortableFSForTests = require_portable.__resetPortableFSForTests;
|
|
4
|
+
exports.__resetPortableHasherForTests = require_portable.__resetPortableHasherForTests;
|
|
5
|
+
exports.createPortableFS = require_portable.createPortableFS;
|
|
6
|
+
exports.createPortableHasher = require_portable.createPortableHasher;
|
|
7
|
+
exports.generateId = require_portable.generateId;
|
|
8
|
+
exports.getPortableFS = require_portable.getPortableFS;
|
|
9
|
+
exports.getPortableHasher = require_portable.getPortableHasher;
|
|
10
|
+
exports.once = require_portable.once;
|
|
11
|
+
exports.resetPortableForTests = require_portable.resetPortableForTests;
|
|
12
|
+
exports.runtime = require_portable.runtime;
|
|
13
|
+
exports.spawn = require_portable.spawn;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { HashAlgorithm, PortableFS, PortableHasher, SpawnOptions, SpawnResult, __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn } from "../index-C0n5gWc3.cjs";
|
|
2
|
+
export { HashAlgorithm, PortableFS, PortableHasher, SpawnOptions, SpawnResult, __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { HashAlgorithm, PortableFS, PortableHasher, SpawnOptions, SpawnResult, __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn } from "../index-LjtXZhxM.js";
|
|
2
|
+
export { HashAlgorithm, PortableFS, PortableHasher, SpawnOptions, SpawnResult, __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn } from "../portable-BqSEwase.js";
|
|
2
|
+
|
|
3
|
+
export { __resetPortableFSForTests, __resetPortableHasherForTests, createPortableFS, createPortableHasher, generateId, getPortableFS, getPortableHasher, once, resetPortableForTests, runtime, spawn };
|