@repometry/lockparse 0.0.0-stage → 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.
Files changed (78) hide show
  1. package/package.json +31 -4
  2. package/target/main/ts/formats/bundler-gemfile.d.ts +1 -0
  3. package/target/main/ts/formats/bundler-gemfile.js +191 -0
  4. package/target/main/ts/formats/bundler-lock.d.ts +26 -0
  5. package/target/main/ts/formats/bundler-lock.js +110 -0
  6. package/target/main/ts/formats/bundler.d.ts +3 -0
  7. package/target/main/ts/formats/bundler.js +84 -0
  8. package/target/main/ts/formats/cargo-lock.d.ts +15 -0
  9. package/target/main/ts/formats/cargo-lock.js +127 -0
  10. package/target/main/ts/formats/cargo-manifest.d.ts +25 -0
  11. package/target/main/ts/formats/cargo-manifest.js +146 -0
  12. package/target/main/ts/formats/cargo-roots.d.ts +10 -0
  13. package/target/main/ts/formats/cargo-roots.js +116 -0
  14. package/target/main/ts/formats/cargo.d.ts +3 -0
  15. package/target/main/ts/formats/cargo.js +108 -0
  16. package/target/main/ts/formats/carton.d.ts +3 -0
  17. package/target/main/ts/formats/carton.js +127 -0
  18. package/target/main/ts/formats/composer.d.ts +5 -0
  19. package/target/main/ts/formats/composer.js +126 -0
  20. package/target/main/ts/formats/conan-reference.d.ts +11 -0
  21. package/target/main/ts/formats/conan-reference.js +32 -0
  22. package/target/main/ts/formats/conan.d.ts +3 -0
  23. package/target/main/ts/formats/conan.js +138 -0
  24. package/target/main/ts/formats/dart.d.ts +3 -0
  25. package/target/main/ts/formats/dart.js +122 -0
  26. package/target/main/ts/formats/go-mod.d.ts +28 -0
  27. package/target/main/ts/formats/go-mod.js +148 -0
  28. package/target/main/ts/formats/go.d.ts +3 -0
  29. package/target/main/ts/formats/go.js +74 -0
  30. package/target/main/ts/formats/gradle.d.ts +3 -0
  31. package/target/main/ts/formats/gradle.js +42 -0
  32. package/target/main/ts/formats/lines.d.ts +5 -0
  33. package/target/main/ts/formats/lines.js +12 -0
  34. package/target/main/ts/formats/mix-literals.d.ts +22 -0
  35. package/target/main/ts/formats/mix-literals.js +145 -0
  36. package/target/main/ts/formats/mix.d.ts +3 -0
  37. package/target/main/ts/formats/mix.js +90 -0
  38. package/target/main/ts/formats/nuget.d.ts +3 -0
  39. package/target/main/ts/formats/nuget.js +112 -0
  40. package/target/main/ts/formats/pdm.d.ts +3 -0
  41. package/target/main/ts/formats/pdm.js +52 -0
  42. package/target/main/ts/formats/pipenv.d.ts +3 -0
  43. package/target/main/ts/formats/pipenv.js +151 -0
  44. package/target/main/ts/formats/poetry-lock.d.ts +15 -0
  45. package/target/main/ts/formats/poetry-lock.js +68 -0
  46. package/target/main/ts/formats/poetry.d.ts +3 -0
  47. package/target/main/ts/formats/poetry.js +9 -0
  48. package/target/main/ts/formats/python-graph.d.ts +16 -0
  49. package/target/main/ts/formats/python-graph.js +91 -0
  50. package/target/main/ts/formats/python-package.d.ts +15 -0
  51. package/target/main/ts/formats/python-package.js +63 -0
  52. package/target/main/ts/formats/python-project.d.ts +12 -0
  53. package/target/main/ts/formats/python-project.js +76 -0
  54. package/target/main/ts/formats/renv.d.ts +3 -0
  55. package/target/main/ts/formats/renv.js +93 -0
  56. package/target/main/ts/formats/swift.d.ts +3 -0
  57. package/target/main/ts/formats/swift.js +87 -0
  58. package/target/main/ts/formats/terraform.d.ts +3 -0
  59. package/target/main/ts/formats/terraform.js +85 -0
  60. package/target/main/ts/formats/toml-document.d.ts +11 -0
  61. package/target/main/ts/formats/toml-document.js +79 -0
  62. package/target/main/ts/formats/toml-statements.d.ts +13 -0
  63. package/target/main/ts/formats/toml-statements.js +144 -0
  64. package/target/main/ts/formats/toml-values.d.ts +12 -0
  65. package/target/main/ts/formats/toml-values.js +111 -0
  66. package/target/main/ts/formats/uv-lock.d.ts +27 -0
  67. package/target/main/ts/formats/uv-lock.js +80 -0
  68. package/target/main/ts/formats/uv.d.ts +3 -0
  69. package/target/main/ts/formats/uv.js +114 -0
  70. package/target/main/ts/index.d.ts +14 -0
  71. package/target/main/ts/index.js +66 -0
  72. package/target/main/ts/json-spans.d.ts +11 -0
  73. package/target/main/ts/json-spans.js +86 -0
  74. package/target/main/ts/json.d.ts +2 -0
  75. package/target/main/ts/json.js +29 -0
  76. package/target/main/ts/model.d.ts +48 -0
  77. package/target/main/ts/model.js +2 -0
  78. package/README.md +0 -3
@@ -0,0 +1,86 @@
1
+ export function pointer(path) {
2
+ return path.map(segment => typeof segment === 'number' ? '#' + segment : JSON.stringify(segment)).join('');
3
+ }
4
+ /**
5
+ * Find the lines of the wanted values in JSON text that JSON.parse has already accepted. A member starts on the line
6
+ * of its key and ends on the line where its value ends. Only paths up to `depth` keys deep are tracked.
7
+ */
8
+ export function locateJsonSpans(text, wanted, depth) {
9
+ const spans = new Map();
10
+ const stack = [];
11
+ let line = 1;
12
+ const child = () => {
13
+ const parent = stack.at(-1);
14
+ if (!parent)
15
+ return { path: '', line };
16
+ const path = parent.path === undefined || stack.length > depth ? undefined
17
+ : parent.path + (parent.array ? `#${parent.index}` : JSON.stringify(parent.key));
18
+ return { path, line: parent.array ? line : parent.keyLine };
19
+ };
20
+ const scalar = () => {
21
+ const { path, line: start } = child();
22
+ if (path !== undefined && wanted.has(path))
23
+ spans.set(path, { line: start, endLine: line });
24
+ };
25
+ for (let index = 0; index < text.length;) {
26
+ const char = text[index];
27
+ if (char === '\n')
28
+ line++;
29
+ if (char === '\n' || char === ' ' || char === '\t' || char === '\r' || char === ':') {
30
+ index++;
31
+ }
32
+ else if (char === ',') {
33
+ const parent = stack.at(-1);
34
+ if (parent?.array)
35
+ parent.index++;
36
+ else if (parent)
37
+ parent.expectKey = true;
38
+ index++;
39
+ }
40
+ else if (char === '"') {
41
+ const end = stringEnd(text, index);
42
+ const parent = stack.at(-1);
43
+ if (parent && !parent.array && parent.expectKey) {
44
+ const raw = text.slice(index + 1, end);
45
+ parent.key = raw.includes('\\') ? JSON.parse(text.slice(index, end + 1)) : raw;
46
+ parent.keyLine = line;
47
+ parent.expectKey = false;
48
+ }
49
+ else {
50
+ scalar();
51
+ }
52
+ index = end + 1;
53
+ }
54
+ else if (char === '{' || char === '[') {
55
+ const { path, line: start } = child();
56
+ stack.push({ path, line: start, array: char === '[', index: 0, key: '', keyLine: line, expectKey: char === '{' });
57
+ index++;
58
+ }
59
+ else if (char === '}' || char === ']') {
60
+ const frame = stack.pop();
61
+ if (frame?.path !== undefined && wanted.has(frame.path))
62
+ spans.set(frame.path, { line: frame.line, endLine: line });
63
+ index++;
64
+ }
65
+ else {
66
+ scalar();
67
+ while (index < text.length && !/[\s,\]}]/.test(text[index]))
68
+ index++;
69
+ }
70
+ }
71
+ return spans;
72
+ }
73
+ function stringEnd(text, start) {
74
+ for (let from = start + 1;;) {
75
+ const quote = text.indexOf('"', from);
76
+ if (quote < 0)
77
+ return text.length;
78
+ let slashes = 0;
79
+ while (text[quote - 1 - slashes] === '\\')
80
+ slashes++;
81
+ if (slashes % 2 === 0)
82
+ return quote;
83
+ from = quote + 1;
84
+ }
85
+ }
86
+ //# sourceMappingURL=json-spans.js.map
@@ -0,0 +1,2 @@
1
+ export declare function readJson(text: string): unknown;
2
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
@@ -0,0 +1,29 @@
1
+ const jsonNestingLimit = 128;
2
+ export function readJson(text) {
3
+ let depth = 0;
4
+ let inString = false;
5
+ for (let index = 0; index < text.length; index++) {
6
+ const char = text[index];
7
+ if (inString) {
8
+ if (char === '\\')
9
+ index++;
10
+ else if (char === '"')
11
+ inString = false;
12
+ }
13
+ else if (char === '"') {
14
+ inString = true;
15
+ }
16
+ else if (char === '{' || char === '[') {
17
+ if (++depth > jsonNestingLimit)
18
+ throw new Error('JSON nesting exceeds 128 levels');
19
+ }
20
+ else if (char === '}' || char === ']') {
21
+ depth--;
22
+ }
23
+ }
24
+ return JSON.parse(text);
25
+ }
26
+ export function isRecord(value) {
27
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
28
+ }
29
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1,48 @@
1
+ export type FormatId = 'composer' | 'cargo' | 'go' | 'bundler' | 'poetry' | 'uv' | 'pipenv' | 'gradle' | 'nuget' | 'swift' | 'dart' | 'mix' | 'terraform' | 'renv' | 'carton' | 'pdm' | 'conan';
2
+ export type Ecosystem = 'composer' | 'cargo' | 'go' | 'rubygems' | 'pypi' | 'maven' | 'nuget' | 'swift' | 'pub' | 'hex' | 'terraform' | 'cran' | 'cpan' | 'conan';
3
+ export type Loss = 'edges' | 'roots' | 'direct' | 'groups' | 'licenses' | 'resolution' | 'integrity';
4
+ export type PackageSource = 'registry' | 'git' | 'path' | 'url' | 'unknown';
5
+ export interface LockPackage {
6
+ readonly id: string;
7
+ readonly name: string;
8
+ readonly version?: string;
9
+ readonly source: PackageSource;
10
+ readonly integrity?: string;
11
+ readonly license?: string;
12
+ readonly groups: readonly string[];
13
+ readonly direct: boolean | 'unknown';
14
+ readonly line: number;
15
+ readonly endLine: number;
16
+ }
17
+ export interface LockEdge {
18
+ readonly from: string;
19
+ readonly to: string;
20
+ }
21
+ export interface LockGraph {
22
+ readonly format: FormatId;
23
+ readonly ecosystem: Ecosystem;
24
+ readonly packages: readonly LockPackage[];
25
+ readonly edges: readonly LockEdge[];
26
+ readonly roots: readonly string[];
27
+ readonly losses: readonly Loss[];
28
+ }
29
+ export interface LockInput {
30
+ readonly path: string;
31
+ readonly text: string;
32
+ readonly manifests?: Readonly<Record<string, string>>;
33
+ }
34
+ export interface LockError {
35
+ readonly error: {
36
+ readonly code: 'unsupported-format' | 'invalid-input' | 'input-limit';
37
+ readonly message: string;
38
+ };
39
+ }
40
+ export interface LockFormat {
41
+ readonly id: FormatId;
42
+ readonly ecosystem: Ecosystem;
43
+ readonly files: readonly string[];
44
+ readonly edges: boolean;
45
+ readonly direct: boolean;
46
+ readonly licenses: boolean;
47
+ readonly integrity?: true;
48
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=model.js.map
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.