@fuzdev/fuz_ui 0.176.1 → 0.177.0
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/dist/LibraryDetail.svelte +1 -1
- package/dist/declaration.svelte.js +1 -1
- package/dist/library_gen.d.ts +19 -40
- package/dist/library_gen.d.ts.map +1 -1
- package/dist/library_gen.js +30 -128
- package/dist/library_generate.d.ts +94 -0
- package/dist/library_generate.d.ts.map +1 -0
- package/dist/library_generate.js +147 -0
- package/dist/library_helpers.d.ts +35 -33
- package/dist/library_helpers.d.ts.map +1 -1
- package/dist/library_helpers.js +36 -65
- package/dist/{library_gen_output.d.ts → library_output.d.ts} +7 -6
- package/dist/library_output.d.ts.map +1 -0
- package/dist/{library_gen_output.js → library_output.js} +4 -3
- package/dist/{library_gen_helpers.d.ts → library_pipeline.d.ts} +7 -8
- package/dist/library_pipeline.d.ts.map +1 -0
- package/dist/{library_gen_helpers.js → library_pipeline.js} +6 -7
- package/dist/module.svelte.js +1 -1
- package/dist/package_helpers.d.ts +141 -0
- package/dist/package_helpers.d.ts.map +1 -0
- package/dist/package_helpers.js +172 -0
- package/package.json +1 -1
- package/src/lib/declaration.svelte.ts +1 -1
- package/src/lib/library_gen.ts +33 -163
- package/src/lib/library_generate.ts +215 -0
- package/src/lib/library_helpers.ts +37 -72
- package/src/lib/{library_gen_output.ts → library_output.ts} +7 -6
- package/src/lib/{library_gen_helpers.ts → library_pipeline.ts} +6 -7
- package/src/lib/module.svelte.ts +1 -1
- package/src/lib/package_helpers.ts +180 -0
- package/dist/library_gen_helpers.d.ts.map +0 -1
- package/dist/library_gen_output.d.ts.map +0 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Library metadata generation
|
|
2
|
+
* Library metadata generation pipeline.
|
|
3
3
|
*
|
|
4
4
|
* These functions handle collection, validation, and transformation of library metadata
|
|
5
|
-
* during the generation pipeline.
|
|
6
|
-
*
|
|
7
|
-
* For source analysis (the consumer-facing API), see `library_analysis.ts`.
|
|
5
|
+
* during the generation pipeline.
|
|
8
6
|
*
|
|
9
7
|
* Pipeline stages:
|
|
10
8
|
* 1. **Collection** - `library_collect_source_files` gathers and filters source files
|
|
@@ -13,9 +11,10 @@
|
|
|
13
11
|
* 4. **Transformation** - `library_merge_re_exports` resolves re-export relationships
|
|
14
12
|
* 5. **Output** - `library_sort_modules` prepares deterministic output
|
|
15
13
|
*
|
|
16
|
-
* @see
|
|
17
|
-
* @see
|
|
18
|
-
* @see
|
|
14
|
+
* @see library_generate.ts for the main generation entry point
|
|
15
|
+
* @see library_analysis.ts for module-level analysis
|
|
16
|
+
* @see library_output.ts for output file generation (JSON/TS wrapper)
|
|
17
|
+
* @see library_gen.ts for Gro-specific integration
|
|
19
18
|
*
|
|
20
19
|
* @module
|
|
21
20
|
*/
|
package/src/lib/module.svelte.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type {ModuleJson} from '@fuzdev/fuz_util/source_json.js';
|
|
|
2
2
|
|
|
3
3
|
import {Declaration} from './declaration.svelte.js';
|
|
4
4
|
import type {Library} from './library.svelte.js';
|
|
5
|
-
import {url_github_file} from './
|
|
5
|
+
import {url_github_file} from './package_helpers.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Rich runtime representation of a module with computed properties.
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package and repository URL helpers.
|
|
3
|
+
*
|
|
4
|
+
* Generic utilities for building URLs and parsing package/repository metadata.
|
|
5
|
+
* These functions have no framework dependencies and can be used at build-time or runtime.
|
|
6
|
+
*
|
|
7
|
+
* URL builders:
|
|
8
|
+
* - `url_github_file` - GitHub file permalink
|
|
9
|
+
* - `url_github_org` - GitHub organization page
|
|
10
|
+
* - `url_npm_package` - npm package page
|
|
11
|
+
* - `url_well_known` - .well-known metadata file
|
|
12
|
+
*
|
|
13
|
+
* Parsers:
|
|
14
|
+
* - `repo_url_parse` - extract repo URL from package.json repository field
|
|
15
|
+
* - `repo_name_parse` - extract repo name from scoped package name
|
|
16
|
+
* - `repo_url_github_owner` - extract GitHub owner from repo URL
|
|
17
|
+
*
|
|
18
|
+
* Predicates:
|
|
19
|
+
* - `package_is_published` - check if package is published to npm
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import {ensure_end, strip_end, strip_start} from '@fuzdev/fuz_util/string.js';
|
|
25
|
+
import type {PackageJson} from '@fuzdev/fuz_util/package_json.js';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Build GitHub file URL for a repository.
|
|
29
|
+
*
|
|
30
|
+
* @param repo_url Repository URL (e.g., 'https://github.com/owner/repo')
|
|
31
|
+
* @param file_path Path to the file (leading './' is stripped)
|
|
32
|
+
* @param line Optional line number for deep linking
|
|
33
|
+
* @returns Full GitHub URL to the file on the main branch
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* url_github_file('https://github.com/foo/bar', 'src/index.ts')
|
|
37
|
+
* // => 'https://github.com/foo/bar/blob/main/src/index.ts'
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* url_github_file('https://github.com/foo/bar', './src/index.ts', 42)
|
|
41
|
+
* // => 'https://github.com/foo/bar/blob/main/src/index.ts#L42'
|
|
42
|
+
*/
|
|
43
|
+
export const url_github_file = (repo_url: string, file_path: string, line?: number): string => {
|
|
44
|
+
const clean_path = file_path.replace(/^\.\//, '');
|
|
45
|
+
const base = `${repo_url}/blob/main/${clean_path}`;
|
|
46
|
+
return line ? `${base}#L${line}` : base;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Build GitHub organization URL from repo URL and repo name.
|
|
51
|
+
*
|
|
52
|
+
* @param repo_url Repository URL (e.g., 'https://github.com/owner/repo')
|
|
53
|
+
* @param repo_name Repository name to strip from the URL
|
|
54
|
+
* @returns Organization URL, or null if repo_url doesn't end with repo_name
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* url_github_org('https://github.com/fuzdev/fuz_ui', 'fuz_ui')
|
|
58
|
+
* // => 'https://github.com/fuzdev'
|
|
59
|
+
*/
|
|
60
|
+
export const url_github_org = (repo_url: string, repo_name: string): string | null => {
|
|
61
|
+
return repo_url.endsWith('/' + repo_name) ? strip_end(repo_url, '/' + repo_name) : null;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Extract GitHub owner/org name from repository URL.
|
|
66
|
+
*
|
|
67
|
+
* @param repo_url Repository URL (e.g., 'https://github.com/owner/repo')
|
|
68
|
+
* @returns Owner name, or null if not a valid GitHub URL
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* repo_url_github_owner('https://github.com/fuzdev/fuz_ui')
|
|
72
|
+
* // => 'fuzdev'
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* repo_url_github_owner('https://gitlab.com/foo/bar')
|
|
76
|
+
* // => null (not a GitHub URL)
|
|
77
|
+
*/
|
|
78
|
+
export const repo_url_github_owner = (repo_url: string): string | null => {
|
|
79
|
+
const stripped = strip_start(repo_url, 'https://github.com/');
|
|
80
|
+
if (stripped === repo_url) return null;
|
|
81
|
+
const parts = stripped.split('/');
|
|
82
|
+
return parts[0] || null;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Build npm package URL.
|
|
87
|
+
*
|
|
88
|
+
* @param package_name Package name (can be scoped like '@org/package')
|
|
89
|
+
* @returns Full npm package page URL
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* url_npm_package('@fuzdev/fuz_ui')
|
|
93
|
+
* // => 'https://www.npmjs.com/package/@fuzdev/fuz_ui'
|
|
94
|
+
*/
|
|
95
|
+
export const url_npm_package = (package_name: string): string =>
|
|
96
|
+
'https://www.npmjs.com/package/' + package_name;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Check if a package is published to npm.
|
|
100
|
+
*
|
|
101
|
+
* A package is considered published if:
|
|
102
|
+
* - It's not marked as private
|
|
103
|
+
* - It has exports defined
|
|
104
|
+
* - Its version is not the initial '0.0.1'
|
|
105
|
+
*
|
|
106
|
+
* @param package_json The package.json object to check
|
|
107
|
+
* @returns True if the package appears to be published
|
|
108
|
+
*/
|
|
109
|
+
export const package_is_published = (package_json: PackageJson): boolean => {
|
|
110
|
+
return !package_json.private && !!package_json.exports && package_json.version !== '0.0.1';
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Extract repository name without scope from package name.
|
|
115
|
+
*
|
|
116
|
+
* @param name Package name (can be scoped like '@org/package')
|
|
117
|
+
* @returns Repository name without scope
|
|
118
|
+
* @throws Error if scoped package name is malformed
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* repo_name_parse('@fuzdev/fuz_ui')
|
|
122
|
+
* // => 'fuz_ui'
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* repo_name_parse('lodash')
|
|
126
|
+
* // => 'lodash'
|
|
127
|
+
*/
|
|
128
|
+
export const repo_name_parse = (name: string): string => {
|
|
129
|
+
if (name[0] === '@') {
|
|
130
|
+
const parts = name.split('/');
|
|
131
|
+
if (parts.length < 2) {
|
|
132
|
+
throw new Error(`invalid scoped package name: "${name}" (expected format: @org/package)`);
|
|
133
|
+
}
|
|
134
|
+
return parts[1]!;
|
|
135
|
+
}
|
|
136
|
+
return name;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Parse repository URL from package.json format.
|
|
141
|
+
*
|
|
142
|
+
* Handles both string format and object format with `url` property.
|
|
143
|
+
* Strips common prefixes ('git+') and suffixes ('.git', '/').
|
|
144
|
+
*
|
|
145
|
+
* @param repository The repository field from package.json
|
|
146
|
+
* @returns Clean repository URL, or null if not provided
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* repo_url_parse('https://github.com/foo/bar')
|
|
150
|
+
* // => 'https://github.com/foo/bar'
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* repo_url_parse({url: 'git+https://github.com/foo/bar.git'})
|
|
154
|
+
* // => 'https://github.com/foo/bar'
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* repo_url_parse(undefined)
|
|
158
|
+
* // => null
|
|
159
|
+
*/
|
|
160
|
+
export const repo_url_parse = (repository: PackageJson['repository']): string | null => {
|
|
161
|
+
if (!repository) return null;
|
|
162
|
+
const url = typeof repository === 'string' ? repository : repository.url;
|
|
163
|
+
if (!url) return null;
|
|
164
|
+
return strip_end(strip_start(strip_end(url, '.git'), 'git+'), '/');
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Build .well-known URL for package metadata files.
|
|
169
|
+
*
|
|
170
|
+
* @param homepage_url Package homepage URL
|
|
171
|
+
* @param filename Filename in .well-known directory
|
|
172
|
+
* @returns Full URL to the .well-known file
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* url_well_known('https://fuz.dev', 'package.json')
|
|
176
|
+
* // => 'https://fuz.dev/.well-known/package.json'
|
|
177
|
+
*/
|
|
178
|
+
export const url_well_known = (homepage_url: string, filename: string): string => {
|
|
179
|
+
return `${ensure_end(homepage_url, '/')}.well-known/${filename}`;
|
|
180
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"library_gen_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_gen_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,eAAe,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,iCAAiC,CAAC;AAE7F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACN,KAAK,cAAc,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B,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GACjC,cAAc,WAAW,EACzB,aAAa,UAAU,KACrB,gBAuBF,CAAC"}
|