@fuzdev/fuz_ui 0.181.1 → 0.182.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/DeclarationDetail.svelte +4 -8
- package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
- package/dist/GithubLink.svelte +12 -3
- package/dist/GithubLink.svelte.d.ts +12 -3
- package/dist/GithubLink.svelte.d.ts.map +1 -1
- package/dist/Mdz.svelte +1 -1
- package/dist/MdzPrecompiled.svelte +30 -0
- package/dist/MdzPrecompiled.svelte.d.ts +11 -0
- package/dist/MdzPrecompiled.svelte.d.ts.map +1 -0
- package/dist/declaration.svelte.d.ts +1 -1
- package/dist/library.svelte.d.ts +1 -1
- package/dist/mdz_to_svelte.d.ts +38 -0
- package/dist/mdz_to_svelte.d.ts.map +1 -0
- package/dist/mdz_to_svelte.js +89 -0
- package/dist/module_helpers.d.ts +48 -5
- package/dist/module_helpers.d.ts.map +1 -1
- package/dist/module_helpers.js +22 -0
- package/dist/package_helpers.d.ts +24 -0
- package/dist/package_helpers.d.ts.map +1 -1
- package/dist/package_helpers.js +24 -0
- package/dist/svelte_preprocess_mdz.d.ts +65 -0
- package/dist/svelte_preprocess_mdz.d.ts.map +1 -0
- package/dist/svelte_preprocess_mdz.js +513 -0
- package/dist/tsdoc_mdz.d.ts +1 -1
- package/dist/tsdoc_mdz.js +1 -1
- package/package.json +27 -10
- package/src/lib/mdz_to_svelte.ts +127 -0
- package/src/lib/module_helpers.ts +48 -5
- package/src/lib/package_helpers.ts +24 -0
- package/src/lib/svelte_preprocess_mdz.ts +726 -0
- package/src/lib/tsdoc_mdz.ts +1 -1
|
@@ -30,12 +30,16 @@ import type { PackageJson } from '@fuzdev/fuz_util/package_json.js';
|
|
|
30
30
|
* @returns Full GitHub URL to the file on the main branch
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
|
+
* ```ts
|
|
33
34
|
* url_github_file('https://github.com/foo/bar', 'src/index.ts')
|
|
34
35
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts'
|
|
36
|
+
* ```
|
|
35
37
|
*
|
|
36
38
|
* @example
|
|
39
|
+
* ```ts
|
|
37
40
|
* url_github_file('https://github.com/foo/bar', './src/index.ts', 42)
|
|
38
41
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts#L42'
|
|
42
|
+
* ```
|
|
39
43
|
*/
|
|
40
44
|
export declare const url_github_file: (repo_url: string, file_path: string, line?: number) => string;
|
|
41
45
|
/**
|
|
@@ -46,8 +50,10 @@ export declare const url_github_file: (repo_url: string, file_path: string, line
|
|
|
46
50
|
* @returns Organization URL, or null if repo_url doesn't end with repo_name
|
|
47
51
|
*
|
|
48
52
|
* @example
|
|
53
|
+
* ```ts
|
|
49
54
|
* url_github_org('https://github.com/fuzdev/fuz_ui', 'fuz_ui')
|
|
50
55
|
* // => 'https://github.com/fuzdev'
|
|
56
|
+
* ```
|
|
51
57
|
*/
|
|
52
58
|
export declare const url_github_org: (repo_url: string, repo_name: string) => string | null;
|
|
53
59
|
/**
|
|
@@ -57,12 +63,16 @@ export declare const url_github_org: (repo_url: string, repo_name: string) => st
|
|
|
57
63
|
* @returns Owner name, or null if not a valid GitHub URL
|
|
58
64
|
*
|
|
59
65
|
* @example
|
|
66
|
+
* ```ts
|
|
60
67
|
* repo_url_github_owner('https://github.com/fuzdev/fuz_ui')
|
|
61
68
|
* // => 'fuzdev'
|
|
69
|
+
* ```
|
|
62
70
|
*
|
|
63
71
|
* @example
|
|
72
|
+
* ```ts
|
|
64
73
|
* repo_url_github_owner('https://gitlab.com/foo/bar')
|
|
65
74
|
* // => null (not a GitHub URL)
|
|
75
|
+
* ```
|
|
66
76
|
*/
|
|
67
77
|
export declare const repo_url_github_owner: (repo_url: string) => string | null;
|
|
68
78
|
/**
|
|
@@ -72,8 +82,10 @@ export declare const repo_url_github_owner: (repo_url: string) => string | null;
|
|
|
72
82
|
* @returns Full npm package page URL
|
|
73
83
|
*
|
|
74
84
|
* @example
|
|
85
|
+
* ```ts
|
|
75
86
|
* url_npm_package('@fuzdev/fuz_ui')
|
|
76
87
|
* // => 'https://www.npmjs.com/package/@fuzdev/fuz_ui'
|
|
88
|
+
* ```
|
|
77
89
|
*/
|
|
78
90
|
export declare const url_npm_package: (package_name: string) => string;
|
|
79
91
|
/**
|
|
@@ -96,12 +108,16 @@ export declare const package_is_published: (package_json: PackageJson) => boolea
|
|
|
96
108
|
* @throws Error if scoped package name is malformed
|
|
97
109
|
*
|
|
98
110
|
* @example
|
|
111
|
+
* ```ts
|
|
99
112
|
* repo_name_parse('@fuzdev/fuz_ui')
|
|
100
113
|
* // => 'fuz_ui'
|
|
114
|
+
* ```
|
|
101
115
|
*
|
|
102
116
|
* @example
|
|
117
|
+
* ```ts
|
|
103
118
|
* repo_name_parse('lodash')
|
|
104
119
|
* // => 'lodash'
|
|
120
|
+
* ```
|
|
105
121
|
*/
|
|
106
122
|
export declare const repo_name_parse: (name: string) => string;
|
|
107
123
|
/**
|
|
@@ -114,16 +130,22 @@ export declare const repo_name_parse: (name: string) => string;
|
|
|
114
130
|
* @returns Clean repository URL, or null if not provided
|
|
115
131
|
*
|
|
116
132
|
* @example
|
|
133
|
+
* ```ts
|
|
117
134
|
* repo_url_parse('https://github.com/foo/bar')
|
|
118
135
|
* // => 'https://github.com/foo/bar'
|
|
136
|
+
* ```
|
|
119
137
|
*
|
|
120
138
|
* @example
|
|
139
|
+
* ```ts
|
|
121
140
|
* repo_url_parse({url: 'git+https://github.com/foo/bar.git'})
|
|
122
141
|
* // => 'https://github.com/foo/bar'
|
|
142
|
+
* ```
|
|
123
143
|
*
|
|
124
144
|
* @example
|
|
145
|
+
* ```ts
|
|
125
146
|
* repo_url_parse(undefined)
|
|
126
147
|
* // => null
|
|
148
|
+
* ```
|
|
127
149
|
*/
|
|
128
150
|
export declare const repo_url_parse: (repository: PackageJson["repository"]) => string | null;
|
|
129
151
|
/**
|
|
@@ -134,8 +156,10 @@ export declare const repo_url_parse: (repository: PackageJson["repository"]) =>
|
|
|
134
156
|
* @returns Full URL to the .well-known file
|
|
135
157
|
*
|
|
136
158
|
* @example
|
|
159
|
+
* ```ts
|
|
137
160
|
* url_well_known('https://fuz.dev', 'package.json')
|
|
138
161
|
* // => 'https://fuz.dev/.well-known/package.json'
|
|
162
|
+
* ```
|
|
139
163
|
*/
|
|
140
164
|
export declare const url_well_known: (homepage_url: string, filename: string) => string;
|
|
141
165
|
//# sourceMappingURL=package_helpers.d.ts.map
|
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,WAAW,MAAM,EAAE,OAAO,MAAM,KAAG,MAIpF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,WAAW,MAAM,KAAG,MAAM,GAAG,IAE7E,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,IAKjE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,cAAc,MAAM,KAAG,MACP,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,cAAc,WAAW,KAAG,OAEhE,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAS9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,WAAW,CAAC,YAAY,CAAC,KAAG,MAAM,GAAG,IAK/E,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,cAAc,MAAM,EAAE,UAAU,MAAM,KAAG,MAEvE,CAAC"}
|
package/dist/package_helpers.js
CHANGED
|
@@ -30,12 +30,16 @@ import { ensure_end, strip_end, strip_start } from '@fuzdev/fuz_util/string.js';
|
|
|
30
30
|
* @returns Full GitHub URL to the file on the main branch
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
|
+
* ```ts
|
|
33
34
|
* url_github_file('https://github.com/foo/bar', 'src/index.ts')
|
|
34
35
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts'
|
|
36
|
+
* ```
|
|
35
37
|
*
|
|
36
38
|
* @example
|
|
39
|
+
* ```ts
|
|
37
40
|
* url_github_file('https://github.com/foo/bar', './src/index.ts', 42)
|
|
38
41
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts#L42'
|
|
42
|
+
* ```
|
|
39
43
|
*/
|
|
40
44
|
export const url_github_file = (repo_url, file_path, line) => {
|
|
41
45
|
const clean_path = file_path.replace(/^\.\//, '');
|
|
@@ -50,8 +54,10 @@ export const url_github_file = (repo_url, file_path, line) => {
|
|
|
50
54
|
* @returns Organization URL, or null if repo_url doesn't end with repo_name
|
|
51
55
|
*
|
|
52
56
|
* @example
|
|
57
|
+
* ```ts
|
|
53
58
|
* url_github_org('https://github.com/fuzdev/fuz_ui', 'fuz_ui')
|
|
54
59
|
* // => 'https://github.com/fuzdev'
|
|
60
|
+
* ```
|
|
55
61
|
*/
|
|
56
62
|
export const url_github_org = (repo_url, repo_name) => {
|
|
57
63
|
return repo_url.endsWith('/' + repo_name) ? strip_end(repo_url, '/' + repo_name) : null;
|
|
@@ -63,12 +69,16 @@ export const url_github_org = (repo_url, repo_name) => {
|
|
|
63
69
|
* @returns Owner name, or null if not a valid GitHub URL
|
|
64
70
|
*
|
|
65
71
|
* @example
|
|
72
|
+
* ```ts
|
|
66
73
|
* repo_url_github_owner('https://github.com/fuzdev/fuz_ui')
|
|
67
74
|
* // => 'fuzdev'
|
|
75
|
+
* ```
|
|
68
76
|
*
|
|
69
77
|
* @example
|
|
78
|
+
* ```ts
|
|
70
79
|
* repo_url_github_owner('https://gitlab.com/foo/bar')
|
|
71
80
|
* // => null (not a GitHub URL)
|
|
81
|
+
* ```
|
|
72
82
|
*/
|
|
73
83
|
export const repo_url_github_owner = (repo_url) => {
|
|
74
84
|
const stripped = strip_start(repo_url, 'https://github.com/');
|
|
@@ -84,8 +94,10 @@ export const repo_url_github_owner = (repo_url) => {
|
|
|
84
94
|
* @returns Full npm package page URL
|
|
85
95
|
*
|
|
86
96
|
* @example
|
|
97
|
+
* ```ts
|
|
87
98
|
* url_npm_package('@fuzdev/fuz_ui')
|
|
88
99
|
* // => 'https://www.npmjs.com/package/@fuzdev/fuz_ui'
|
|
100
|
+
* ```
|
|
89
101
|
*/
|
|
90
102
|
export const url_npm_package = (package_name) => 'https://www.npmjs.com/package/' + package_name;
|
|
91
103
|
/**
|
|
@@ -110,12 +122,16 @@ export const package_is_published = (package_json) => {
|
|
|
110
122
|
* @throws Error if scoped package name is malformed
|
|
111
123
|
*
|
|
112
124
|
* @example
|
|
125
|
+
* ```ts
|
|
113
126
|
* repo_name_parse('@fuzdev/fuz_ui')
|
|
114
127
|
* // => 'fuz_ui'
|
|
128
|
+
* ```
|
|
115
129
|
*
|
|
116
130
|
* @example
|
|
131
|
+
* ```ts
|
|
117
132
|
* repo_name_parse('lodash')
|
|
118
133
|
* // => 'lodash'
|
|
134
|
+
* ```
|
|
119
135
|
*/
|
|
120
136
|
export const repo_name_parse = (name) => {
|
|
121
137
|
if (name[0] === '@') {
|
|
@@ -137,16 +153,22 @@ export const repo_name_parse = (name) => {
|
|
|
137
153
|
* @returns Clean repository URL, or null if not provided
|
|
138
154
|
*
|
|
139
155
|
* @example
|
|
156
|
+
* ```ts
|
|
140
157
|
* repo_url_parse('https://github.com/foo/bar')
|
|
141
158
|
* // => 'https://github.com/foo/bar'
|
|
159
|
+
* ```
|
|
142
160
|
*
|
|
143
161
|
* @example
|
|
162
|
+
* ```ts
|
|
144
163
|
* repo_url_parse({url: 'git+https://github.com/foo/bar.git'})
|
|
145
164
|
* // => 'https://github.com/foo/bar'
|
|
165
|
+
* ```
|
|
146
166
|
*
|
|
147
167
|
* @example
|
|
168
|
+
* ```ts
|
|
148
169
|
* repo_url_parse(undefined)
|
|
149
170
|
* // => null
|
|
171
|
+
* ```
|
|
150
172
|
*/
|
|
151
173
|
export const repo_url_parse = (repository) => {
|
|
152
174
|
if (!repository)
|
|
@@ -164,8 +186,10 @@ export const repo_url_parse = (repository) => {
|
|
|
164
186
|
* @returns Full URL to the .well-known file
|
|
165
187
|
*
|
|
166
188
|
* @example
|
|
189
|
+
* ```ts
|
|
167
190
|
* url_well_known('https://fuz.dev', 'package.json')
|
|
168
191
|
* // => 'https://fuz.dev/.well-known/package.json'
|
|
192
|
+
* ```
|
|
169
193
|
*/
|
|
170
194
|
export const url_well_known = (homepage_url, filename) => {
|
|
171
195
|
return `${ensure_end(homepage_url, '/')}.well-known/${filename}`;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte preprocessor that compiles static `Mdz` content to Svelte markup at build time.
|
|
3
|
+
*
|
|
4
|
+
* Detects `Mdz` components with static string `content` props, parses the mdz content,
|
|
5
|
+
* renders each `MdzNode` to equivalent Svelte markup via `mdz_to_svelte`, and replaces
|
|
6
|
+
* the `Mdz` with `MdzPrecompiled` containing pre-rendered children.
|
|
7
|
+
*
|
|
8
|
+
* Also handles ternary chains (`content={a ? 'x' : b ? 'y' : 'z'}`) where all leaf
|
|
9
|
+
* values are statically resolvable strings, emitting `{#if a}markup_x{:else if b}markup_y{:else}markup_z{/if}`
|
|
10
|
+
* as children of a single `MdzPrecompiled`.
|
|
11
|
+
*
|
|
12
|
+
* Truly dynamic `content` props are left untouched.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import { type PreprocessorGroup } from 'svelte/compiler';
|
|
17
|
+
/**
|
|
18
|
+
* Options for `svelte_preprocess_mdz`.
|
|
19
|
+
*/
|
|
20
|
+
export interface SveltePreprocessMdzOptions {
|
|
21
|
+
/** File patterns to exclude. */
|
|
22
|
+
exclude?: Array<string | RegExp>;
|
|
23
|
+
/**
|
|
24
|
+
* Component import mapping for mdz content.
|
|
25
|
+
* Key: component name as used in mdz (e.g., 'Alert').
|
|
26
|
+
* Value: import path (e.g., '$lib/Alert.svelte').
|
|
27
|
+
*
|
|
28
|
+
* If mdz content references a component not in this map,
|
|
29
|
+
* that Mdz usage is skipped (left as runtime).
|
|
30
|
+
*/
|
|
31
|
+
components?: Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Allowed HTML elements in mdz content.
|
|
34
|
+
* If mdz content references an element not in this list,
|
|
35
|
+
* that Mdz usage is skipped (left as runtime).
|
|
36
|
+
*/
|
|
37
|
+
elements?: Array<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Import sources that resolve to the Mdz component.
|
|
40
|
+
* Used to verify that `Mdz` in templates refers to fuz_ui's Mdz.svelte.
|
|
41
|
+
*
|
|
42
|
+
* @default ['@fuzdev/fuz_ui/Mdz.svelte']
|
|
43
|
+
*/
|
|
44
|
+
component_imports?: Array<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Import path for the precompiled wrapper component.
|
|
47
|
+
*
|
|
48
|
+
* @default '@fuzdev/fuz_ui/MdzPrecompiled.svelte'
|
|
49
|
+
*/
|
|
50
|
+
compiled_component_import?: string;
|
|
51
|
+
/**
|
|
52
|
+
* How to handle errors during mdz parsing or rendering.
|
|
53
|
+
*
|
|
54
|
+
* @default 'throw' in CI, 'log' otherwise
|
|
55
|
+
*/
|
|
56
|
+
on_error?: 'log' | 'throw';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates a Svelte preprocessor that compiles static `Mdz` content at build time.
|
|
60
|
+
*
|
|
61
|
+
* @param options Configuration for component/element resolution and file filtering.
|
|
62
|
+
* @returns A Svelte `PreprocessorGroup` for use in `svelte.config.js`.
|
|
63
|
+
*/
|
|
64
|
+
export declare const svelte_preprocess_mdz: (options?: SveltePreprocessMdzOptions) => PreprocessorGroup;
|
|
65
|
+
//# sourceMappingURL=svelte_preprocess_mdz.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svelte_preprocess_mdz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/svelte_preprocess_mdz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAQ,KAAK,iBAAiB,EAAW,MAAM,iBAAiB,CAAC;AA+BxE;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,gCAAgC;IAChC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAEjC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAElC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;CAC3B;AAID;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GACjC,UAAS,0BAA+B,KACtC,iBAsFF,CAAC"}
|