@fuzdev/fuz_ui 0.176.1 → 0.177.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/dist/ApiIndex.svelte +1 -1
- package/dist/ContextmenuRoot.svelte +2 -2
- package/dist/ContextmenuRootForSafariCompatibility.svelte +2 -2
- package/dist/DeclarationDetail.svelte +6 -6
- package/dist/DeclarationLink.svelte +5 -1
- package/dist/DeclarationLink.svelte.d.ts +2 -0
- package/dist/DeclarationLink.svelte.d.ts.map +1 -1
- package/dist/DocsLink.svelte +5 -2
- package/dist/DocsLink.svelte.d.ts +2 -0
- package/dist/DocsLink.svelte.d.ts.map +1 -1
- package/dist/GithubLink.svelte +6 -3
- package/dist/GithubLink.svelte.d.ts +2 -0
- package/dist/GithubLink.svelte.d.ts.map +1 -1
- package/dist/LibraryDetail.svelte +1 -1
- package/dist/MdnLink.svelte +7 -3
- package/dist/MdnLink.svelte.d.ts +2 -0
- package/dist/MdnLink.svelte.d.ts.map +1 -1
- package/dist/ModuleLink.svelte +5 -1
- package/dist/ModuleLink.svelte.d.ts +2 -0
- package/dist/ModuleLink.svelte.d.ts.map +1 -1
- package/dist/TomeContent.svelte +1 -1
- package/dist/TomeLink.svelte +6 -1
- package/dist/TomeLink.svelte.d.ts +1 -0
- package/dist/TomeLink.svelte.d.ts.map +1 -1
- package/dist/TomeSectionHeader.svelte +2 -2
- package/dist/TypeLink.svelte +10 -3
- package/dist/TypeLink.svelte.d.ts +2 -0
- package/dist/TypeLink.svelte.d.ts.map +1 -1
- package/dist/contextmenu_helpers.d.ts.map +1 -1
- package/dist/contextmenu_helpers.js +6 -8
- 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/dist/tome.d.ts +3 -0
- package/dist/tome.d.ts.map +1 -1
- package/dist/tome.js +5 -1
- package/package.json +2 -2
- package/src/lib/contextmenu_helpers.ts +3 -5
- 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/src/lib/tome.ts +5 -1
- package/dist/library_gen_helpers.d.ts.map +0 -1
- package/dist/library_gen_output.d.ts.map +0 -1
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates the library.json and library.ts files from analyzed metadata.
|
|
5
5
|
*
|
|
6
|
-
* @see
|
|
7
|
-
* @see
|
|
6
|
+
* @see library_generate.ts for the main generation entry point
|
|
7
|
+
* @see library_pipeline.ts for pipeline orchestration functions
|
|
8
|
+
* @see library_gen.ts for Gro-specific integration
|
|
8
9
|
*
|
|
9
10
|
* @module
|
|
10
11
|
*/
|
|
11
12
|
import type { PackageJson } from '@fuzdev/fuz_util/package_json.js';
|
|
12
13
|
import type { SourceJson } from '@fuzdev/fuz_util/source_json.js';
|
|
13
14
|
/**
|
|
14
|
-
* Result of generating library files.
|
|
15
|
+
* Result of generating library output files.
|
|
15
16
|
* Contains both the JSON data and the TypeScript wrapper file.
|
|
16
17
|
*/
|
|
17
|
-
export interface
|
|
18
|
+
export interface LibraryOutputResult {
|
|
18
19
|
/** JSON content for library.json */
|
|
19
20
|
json_content: string;
|
|
20
21
|
/** TypeScript wrapper content for library.ts */
|
|
@@ -30,5 +31,5 @@ export interface LibraryGenResult {
|
|
|
30
31
|
* - The .ts wrapper validates with zod and exports with proper types
|
|
31
32
|
* (JSON imports get widened types like `string` instead of literal unions)
|
|
32
33
|
*/
|
|
33
|
-
export declare const
|
|
34
|
-
//# sourceMappingURL=
|
|
34
|
+
export declare const library_generate_output: (package_json: PackageJson, source_json: SourceJson) => LibraryOutputResult;
|
|
35
|
+
//# sourceMappingURL=library_output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library_output.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,iCAAiC,CAAC;AAGhE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,cAAc,WAAW,EACzB,aAAa,UAAU,KACrB,mBAuBF,CAAC"}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates the library.json and library.ts files from analyzed metadata.
|
|
5
5
|
*
|
|
6
|
-
* @see
|
|
7
|
-
* @see
|
|
6
|
+
* @see library_generate.ts for the main generation entry point
|
|
7
|
+
* @see library_pipeline.ts for pipeline orchestration functions
|
|
8
|
+
* @see library_gen.ts for Gro-specific integration
|
|
8
9
|
*
|
|
9
10
|
* @module
|
|
10
11
|
*/
|
|
@@ -19,7 +20,7 @@ import { library_json_parse } from '@fuzdev/fuz_util/library_json.js';
|
|
|
19
20
|
* - The .ts wrapper validates with zod and exports with proper types
|
|
20
21
|
* (JSON imports get widened types like `string` instead of literal unions)
|
|
21
22
|
*/
|
|
22
|
-
export const
|
|
23
|
+
export const library_generate_output = (package_json, source_json) => {
|
|
23
24
|
const is_this_fuz_util = package_json.name === '@fuzdev/fuz_util';
|
|
24
25
|
const fuz_util_prefix = is_this_fuz_util ? './' : '@fuzdev/fuz_util/';
|
|
25
26
|
// Parse at generation time, not runtime
|
|
@@ -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
|
*/
|
|
@@ -107,4 +106,4 @@ export declare const library_merge_re_exports: (source_json: SourceJson, collect
|
|
|
107
106
|
* @param log Optional logger for status messages
|
|
108
107
|
*/
|
|
109
108
|
export declare const library_collect_source_files: (files: Iterable<SourceFileInfo>, options: ModuleSourceOptions, log?: Logger) => Array<SourceFileInfo>;
|
|
110
|
-
//# sourceMappingURL=
|
|
109
|
+
//# sourceMappingURL=library_pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library_pipeline.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;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,EACnB,KAAK,mBAAmB,EAIxB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,qCAAqC;IACrC,WAAW,EAAE,eAAe,CAAC;IAC7B,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,uBAAuB,GACnC,aAAa,UAAU,KACrB,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CA0BlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,KAAK,CAAC,UAAU,CAAC,KAAG,KAAK,CAAC,UAAU,CAEjF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IACjC,kDAAkD;IAClD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,SAAS,EAAE,YAAY,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,wBAAwB,GACpC,aAAa,UAAU,EACvB,sBAAsB,KAAK,CAAC,iBAAiB,CAAC,KAC5C,IAgCF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GACxC,OAAO,QAAQ,CAAC,cAAc,CAAC,EAC/B,SAAS,mBAAmB,EAC5B,MAAM,MAAM,KACV,KAAK,CAAC,cAAc,CA0BtB,CAAC"}
|
|
@@ -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/dist/module.svelte.js
CHANGED
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
import type { PackageJson } from '@fuzdev/fuz_util/package_json.js';
|
|
24
|
+
/**
|
|
25
|
+
* Build GitHub file URL for a repository.
|
|
26
|
+
*
|
|
27
|
+
* @param repo_url Repository URL (e.g., 'https://github.com/owner/repo')
|
|
28
|
+
* @param file_path Path to the file (leading './' is stripped)
|
|
29
|
+
* @param line Optional line number for deep linking
|
|
30
|
+
* @returns Full GitHub URL to the file on the main branch
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* url_github_file('https://github.com/foo/bar', 'src/index.ts')
|
|
34
|
+
* // => 'https://github.com/foo/bar/blob/main/src/index.ts'
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* url_github_file('https://github.com/foo/bar', './src/index.ts', 42)
|
|
38
|
+
* // => 'https://github.com/foo/bar/blob/main/src/index.ts#L42'
|
|
39
|
+
*/
|
|
40
|
+
export declare const url_github_file: (repo_url: string, file_path: string, line?: number) => string;
|
|
41
|
+
/**
|
|
42
|
+
* Build GitHub organization URL from repo URL and repo name.
|
|
43
|
+
*
|
|
44
|
+
* @param repo_url Repository URL (e.g., 'https://github.com/owner/repo')
|
|
45
|
+
* @param repo_name Repository name to strip from the URL
|
|
46
|
+
* @returns Organization URL, or null if repo_url doesn't end with repo_name
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* url_github_org('https://github.com/fuzdev/fuz_ui', 'fuz_ui')
|
|
50
|
+
* // => 'https://github.com/fuzdev'
|
|
51
|
+
*/
|
|
52
|
+
export declare const url_github_org: (repo_url: string, repo_name: string) => string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Extract GitHub owner/org name from repository URL.
|
|
55
|
+
*
|
|
56
|
+
* @param repo_url Repository URL (e.g., 'https://github.com/owner/repo')
|
|
57
|
+
* @returns Owner name, or null if not a valid GitHub URL
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* repo_url_github_owner('https://github.com/fuzdev/fuz_ui')
|
|
61
|
+
* // => 'fuzdev'
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* repo_url_github_owner('https://gitlab.com/foo/bar')
|
|
65
|
+
* // => null (not a GitHub URL)
|
|
66
|
+
*/
|
|
67
|
+
export declare const repo_url_github_owner: (repo_url: string) => string | null;
|
|
68
|
+
/**
|
|
69
|
+
* Build npm package URL.
|
|
70
|
+
*
|
|
71
|
+
* @param package_name Package name (can be scoped like '@org/package')
|
|
72
|
+
* @returns Full npm package page URL
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* url_npm_package('@fuzdev/fuz_ui')
|
|
76
|
+
* // => 'https://www.npmjs.com/package/@fuzdev/fuz_ui'
|
|
77
|
+
*/
|
|
78
|
+
export declare const url_npm_package: (package_name: string) => string;
|
|
79
|
+
/**
|
|
80
|
+
* Check if a package is published to npm.
|
|
81
|
+
*
|
|
82
|
+
* A package is considered published if:
|
|
83
|
+
* - It's not marked as private
|
|
84
|
+
* - It has exports defined
|
|
85
|
+
* - Its version is not the initial '0.0.1'
|
|
86
|
+
*
|
|
87
|
+
* @param package_json The package.json object to check
|
|
88
|
+
* @returns True if the package appears to be published
|
|
89
|
+
*/
|
|
90
|
+
export declare const package_is_published: (package_json: PackageJson) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Extract repository name without scope from package name.
|
|
93
|
+
*
|
|
94
|
+
* @param name Package name (can be scoped like '@org/package')
|
|
95
|
+
* @returns Repository name without scope
|
|
96
|
+
* @throws Error if scoped package name is malformed
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* repo_name_parse('@fuzdev/fuz_ui')
|
|
100
|
+
* // => 'fuz_ui'
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* repo_name_parse('lodash')
|
|
104
|
+
* // => 'lodash'
|
|
105
|
+
*/
|
|
106
|
+
export declare const repo_name_parse: (name: string) => string;
|
|
107
|
+
/**
|
|
108
|
+
* Parse repository URL from package.json format.
|
|
109
|
+
*
|
|
110
|
+
* Handles both string format and object format with `url` property.
|
|
111
|
+
* Strips common prefixes ('git+') and suffixes ('.git', '/').
|
|
112
|
+
*
|
|
113
|
+
* @param repository The repository field from package.json
|
|
114
|
+
* @returns Clean repository URL, or null if not provided
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* repo_url_parse('https://github.com/foo/bar')
|
|
118
|
+
* // => 'https://github.com/foo/bar'
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* repo_url_parse({url: 'git+https://github.com/foo/bar.git'})
|
|
122
|
+
* // => 'https://github.com/foo/bar'
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* repo_url_parse(undefined)
|
|
126
|
+
* // => null
|
|
127
|
+
*/
|
|
128
|
+
export declare const repo_url_parse: (repository: PackageJson["repository"]) => string | null;
|
|
129
|
+
/**
|
|
130
|
+
* Build .well-known URL for package metadata files.
|
|
131
|
+
*
|
|
132
|
+
* @param homepage_url Package homepage URL
|
|
133
|
+
* @param filename Filename in .well-known directory
|
|
134
|
+
* @returns Full URL to the .well-known file
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* url_well_known('https://fuz.dev', 'package.json')
|
|
138
|
+
* // => 'https://fuz.dev/.well-known/package.json'
|
|
139
|
+
*/
|
|
140
|
+
export declare const url_well_known: (homepage_url: string, filename: string) => string;
|
|
141
|
+
//# sourceMappingURL=package_helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/package_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAElE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,WAAW,MAAM,EAAE,OAAO,MAAM,KAAG,MAIpF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,WAAW,MAAM,KAAG,MAAM,GAAG,IAE7E,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,IAKjE,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,cAAc,MAAM,KAAG,MACP,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,cAAc,WAAW,KAAG,OAEhE,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAS9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,WAAW,CAAC,YAAY,CAAC,KAAG,MAAM,GAAG,IAK/E,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GAAI,cAAc,MAAM,EAAE,UAAU,MAAM,KAAG,MAEvE,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
import { ensure_end, strip_end, strip_start } from '@fuzdev/fuz_util/string.js';
|
|
24
|
+
/**
|
|
25
|
+
* Build GitHub file URL for a repository.
|
|
26
|
+
*
|
|
27
|
+
* @param repo_url Repository URL (e.g., 'https://github.com/owner/repo')
|
|
28
|
+
* @param file_path Path to the file (leading './' is stripped)
|
|
29
|
+
* @param line Optional line number for deep linking
|
|
30
|
+
* @returns Full GitHub URL to the file on the main branch
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* url_github_file('https://github.com/foo/bar', 'src/index.ts')
|
|
34
|
+
* // => 'https://github.com/foo/bar/blob/main/src/index.ts'
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* url_github_file('https://github.com/foo/bar', './src/index.ts', 42)
|
|
38
|
+
* // => 'https://github.com/foo/bar/blob/main/src/index.ts#L42'
|
|
39
|
+
*/
|
|
40
|
+
export const url_github_file = (repo_url, file_path, line) => {
|
|
41
|
+
const clean_path = file_path.replace(/^\.\//, '');
|
|
42
|
+
const base = `${repo_url}/blob/main/${clean_path}`;
|
|
43
|
+
return line ? `${base}#L${line}` : base;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Build GitHub organization URL from repo URL and repo name.
|
|
47
|
+
*
|
|
48
|
+
* @param repo_url Repository URL (e.g., 'https://github.com/owner/repo')
|
|
49
|
+
* @param repo_name Repository name to strip from the URL
|
|
50
|
+
* @returns Organization URL, or null if repo_url doesn't end with repo_name
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* url_github_org('https://github.com/fuzdev/fuz_ui', 'fuz_ui')
|
|
54
|
+
* // => 'https://github.com/fuzdev'
|
|
55
|
+
*/
|
|
56
|
+
export const url_github_org = (repo_url, repo_name) => {
|
|
57
|
+
return repo_url.endsWith('/' + repo_name) ? strip_end(repo_url, '/' + repo_name) : null;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Extract GitHub owner/org name from repository URL.
|
|
61
|
+
*
|
|
62
|
+
* @param repo_url Repository URL (e.g., 'https://github.com/owner/repo')
|
|
63
|
+
* @returns Owner name, or null if not a valid GitHub URL
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* repo_url_github_owner('https://github.com/fuzdev/fuz_ui')
|
|
67
|
+
* // => 'fuzdev'
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* repo_url_github_owner('https://gitlab.com/foo/bar')
|
|
71
|
+
* // => null (not a GitHub URL)
|
|
72
|
+
*/
|
|
73
|
+
export const repo_url_github_owner = (repo_url) => {
|
|
74
|
+
const stripped = strip_start(repo_url, 'https://github.com/');
|
|
75
|
+
if (stripped === repo_url)
|
|
76
|
+
return null;
|
|
77
|
+
const parts = stripped.split('/');
|
|
78
|
+
return parts[0] || null;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Build npm package URL.
|
|
82
|
+
*
|
|
83
|
+
* @param package_name Package name (can be scoped like '@org/package')
|
|
84
|
+
* @returns Full npm package page URL
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* url_npm_package('@fuzdev/fuz_ui')
|
|
88
|
+
* // => 'https://www.npmjs.com/package/@fuzdev/fuz_ui'
|
|
89
|
+
*/
|
|
90
|
+
export const url_npm_package = (package_name) => 'https://www.npmjs.com/package/' + package_name;
|
|
91
|
+
/**
|
|
92
|
+
* Check if a package is published to npm.
|
|
93
|
+
*
|
|
94
|
+
* A package is considered published if:
|
|
95
|
+
* - It's not marked as private
|
|
96
|
+
* - It has exports defined
|
|
97
|
+
* - Its version is not the initial '0.0.1'
|
|
98
|
+
*
|
|
99
|
+
* @param package_json The package.json object to check
|
|
100
|
+
* @returns True if the package appears to be published
|
|
101
|
+
*/
|
|
102
|
+
export const package_is_published = (package_json) => {
|
|
103
|
+
return !package_json.private && !!package_json.exports && package_json.version !== '0.0.1';
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Extract repository name without scope from package name.
|
|
107
|
+
*
|
|
108
|
+
* @param name Package name (can be scoped like '@org/package')
|
|
109
|
+
* @returns Repository name without scope
|
|
110
|
+
* @throws Error if scoped package name is malformed
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* repo_name_parse('@fuzdev/fuz_ui')
|
|
114
|
+
* // => 'fuz_ui'
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* repo_name_parse('lodash')
|
|
118
|
+
* // => 'lodash'
|
|
119
|
+
*/
|
|
120
|
+
export const repo_name_parse = (name) => {
|
|
121
|
+
if (name[0] === '@') {
|
|
122
|
+
const parts = name.split('/');
|
|
123
|
+
if (parts.length < 2) {
|
|
124
|
+
throw new Error(`invalid scoped package name: "${name}" (expected format: @org/package)`);
|
|
125
|
+
}
|
|
126
|
+
return parts[1];
|
|
127
|
+
}
|
|
128
|
+
return name;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Parse repository URL from package.json format.
|
|
132
|
+
*
|
|
133
|
+
* Handles both string format and object format with `url` property.
|
|
134
|
+
* Strips common prefixes ('git+') and suffixes ('.git', '/').
|
|
135
|
+
*
|
|
136
|
+
* @param repository The repository field from package.json
|
|
137
|
+
* @returns Clean repository URL, or null if not provided
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* repo_url_parse('https://github.com/foo/bar')
|
|
141
|
+
* // => 'https://github.com/foo/bar'
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* repo_url_parse({url: 'git+https://github.com/foo/bar.git'})
|
|
145
|
+
* // => 'https://github.com/foo/bar'
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* repo_url_parse(undefined)
|
|
149
|
+
* // => null
|
|
150
|
+
*/
|
|
151
|
+
export const repo_url_parse = (repository) => {
|
|
152
|
+
if (!repository)
|
|
153
|
+
return null;
|
|
154
|
+
const url = typeof repository === 'string' ? repository : repository.url;
|
|
155
|
+
if (!url)
|
|
156
|
+
return null;
|
|
157
|
+
return strip_end(strip_start(strip_end(url, '.git'), 'git+'), '/');
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Build .well-known URL for package metadata files.
|
|
161
|
+
*
|
|
162
|
+
* @param homepage_url Package homepage URL
|
|
163
|
+
* @param filename Filename in .well-known directory
|
|
164
|
+
* @returns Full URL to the .well-known file
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* url_well_known('https://fuz.dev', 'package.json')
|
|
168
|
+
* // => 'https://fuz.dev/.well-known/package.json'
|
|
169
|
+
*/
|
|
170
|
+
export const url_well_known = (homepage_url, filename) => {
|
|
171
|
+
return `${ensure_end(homepage_url, '/')}.well-known/${filename}`;
|
|
172
|
+
};
|
package/dist/tome.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export declare const Tome: z.ZodObject<{
|
|
|
9
9
|
related_declarations: z.ZodArray<z.ZodString>;
|
|
10
10
|
}, z.core.$strip>;
|
|
11
11
|
export type Tome = z.infer<typeof Tome>;
|
|
12
|
+
/**
|
|
13
|
+
* @param hash - URL fragment to append, with or without the `#`.
|
|
14
|
+
*/
|
|
12
15
|
export declare const to_tome_pathname: (item: Tome | string, docs_path?: string, hash?: string) => string;
|
|
13
16
|
export declare const tomes_context: {
|
|
14
17
|
get: (error_message?: string) => Map<string, {
|
package/dist/tome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tome.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/tome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"tome.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/tome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAMtB,eAAO,MAAM,IAAI;;;;;;;iBAQf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC5B,MAAM,IAAI,GAAG,MAAM,EACnB,kBAA6B,EAC7B,OAAO,MAAM,KACX,MAIF,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAsC,CAAC;AAEjE,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,IAK/C,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAyB,CAAC"}
|
package/dist/tome.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolve } from '$app/paths';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { ensure_start } from '@fuzdev/fuz_util/string.js';
|
|
3
4
|
import { create_context } from './context_helpers.js';
|
|
4
5
|
import { DOCS_PATH_DEFAULT, docs_slugify } from './docs_helpers.svelte.js';
|
|
5
6
|
export const Tome = z.object({
|
|
@@ -11,10 +12,13 @@ export const Tome = z.object({
|
|
|
11
12
|
related_modules: z.array(z.string()),
|
|
12
13
|
related_declarations: z.array(z.string()),
|
|
13
14
|
});
|
|
15
|
+
/**
|
|
16
|
+
* @param hash - URL fragment to append, with or without the `#`.
|
|
17
|
+
*/
|
|
14
18
|
export const to_tome_pathname = (item, docs_path = DOCS_PATH_DEFAULT, hash) => {
|
|
15
19
|
const name = typeof item === 'string' ? item : item.name;
|
|
16
20
|
const path = docs_path + '/' + docs_slugify(name);
|
|
17
|
-
return resolve((hash ? path + '#'
|
|
21
|
+
return resolve((hash ? path + ensure_start(hash, '#') : path));
|
|
18
22
|
};
|
|
19
23
|
export const tomes_context = create_context();
|
|
20
24
|
export const get_tome_by_name = (name) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuzdev/fuz_ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.177.1",
|
|
4
4
|
"description": "Svelte UI library",
|
|
5
5
|
"motto": "friendly user zystem",
|
|
6
6
|
"glyph": "🧶",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@changesets/changelog-git": "^0.2.1",
|
|
64
|
-
"@fuzdev/fuz_code": "^0.
|
|
64
|
+
"@fuzdev/fuz_code": "^0.39.0",
|
|
65
65
|
"@fuzdev/fuz_css": "^0.42.1",
|
|
66
66
|
"@fuzdev/fuz_util": "^0.45.1",
|
|
67
67
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
@@ -39,16 +39,14 @@ export const contextmenu_create_keyboard_handlers = (
|
|
|
39
39
|
['Enter', () => contextmenu.activate_selected()],
|
|
40
40
|
]);
|
|
41
41
|
|
|
42
|
-
export const contextmenu_create_keydown_handler =
|
|
43
|
-
keyboard_handlers: Map<string, () => void
|
|
44
|
-
|
|
45
|
-
return (e: KeyboardEvent): void => {
|
|
42
|
+
export const contextmenu_create_keydown_handler =
|
|
43
|
+
(keyboard_handlers: Map<string, () => void>): ((e: KeyboardEvent) => void) =>
|
|
44
|
+
(e: KeyboardEvent): void => {
|
|
46
45
|
const handler = keyboard_handlers.get(e.key);
|
|
47
46
|
if (!handler || is_editable(e.target)) return;
|
|
48
47
|
swallow(e);
|
|
49
48
|
handler();
|
|
50
49
|
};
|
|
51
|
-
};
|
|
52
50
|
|
|
53
51
|
export const contextmenu_calculate_constrained_x = (
|
|
54
52
|
menu_x: number,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from '@fuzdev/fuz_util/source_json.js';
|
|
6
6
|
|
|
7
7
|
import type {Module} from './module.svelte.js';
|
|
8
|
-
import {url_github_file} from './
|
|
8
|
+
import {url_github_file} from './package_helpers.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Rich runtime representation of an exported declaration.
|