@fuzdev/fuz_ui 0.169.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/LICENSE +21 -0
- package/README.md +93 -0
- package/dist/Alert.svelte +108 -0
- package/dist/Alert.svelte.d.ts +16 -0
- package/dist/Alert.svelte.d.ts.map +1 -0
- package/dist/ApiDeclarationList.svelte +35 -0
- package/dist/ApiDeclarationList.svelte.d.ts +9 -0
- package/dist/ApiDeclarationList.svelte.d.ts.map +1 -0
- package/dist/ApiIndex.svelte +65 -0
- package/dist/ApiIndex.svelte.d.ts +23 -0
- package/dist/ApiIndex.svelte.d.ts.map +1 -0
- package/dist/ApiModule.svelte +124 -0
- package/dist/ApiModule.svelte.d.ts +22 -0
- package/dist/ApiModule.svelte.d.ts.map +1 -0
- package/dist/Breadcrumb.svelte +83 -0
- package/dist/Breadcrumb.svelte.d.ts +23 -0
- package/dist/Breadcrumb.svelte.d.ts.map +1 -0
- package/dist/Card.svelte +157 -0
- package/dist/Card.svelte.d.ts +13 -0
- package/dist/Card.svelte.d.ts.map +1 -0
- package/dist/ColorSchemeInput.svelte +65 -0
- package/dist/ColorSchemeInput.svelte.d.ts +11 -0
- package/dist/ColorSchemeInput.svelte.d.ts.map +1 -0
- package/dist/Contextmenu.svelte +30 -0
- package/dist/Contextmenu.svelte.d.ts +32 -0
- package/dist/Contextmenu.svelte.d.ts.map +1 -0
- package/dist/ContextmenuEntry.svelte +74 -0
- package/dist/ContextmenuEntry.svelte.d.ts +12 -0
- package/dist/ContextmenuEntry.svelte.d.ts.map +1 -0
- package/dist/ContextmenuLinkEntry.svelte +112 -0
- package/dist/ContextmenuLinkEntry.svelte.d.ts +12 -0
- package/dist/ContextmenuLinkEntry.svelte.d.ts.map +1 -0
- package/dist/ContextmenuRoot.svelte +372 -0
- package/dist/ContextmenuRoot.svelte.d.ts +71 -0
- package/dist/ContextmenuRoot.svelte.d.ts.map +1 -0
- package/dist/ContextmenuRootForSafariCompatibility.svelte +541 -0
- package/dist/ContextmenuRootForSafariCompatibility.svelte.d.ts +79 -0
- package/dist/ContextmenuRootForSafariCompatibility.svelte.d.ts.map +1 -0
- package/dist/ContextmenuSeparator.svelte +16 -0
- package/dist/ContextmenuSeparator.svelte.d.ts +4 -0
- package/dist/ContextmenuSeparator.svelte.d.ts.map +1 -0
- package/dist/ContextmenuSubmenu.svelte +116 -0
- package/dist/ContextmenuSubmenu.svelte.d.ts +10 -0
- package/dist/ContextmenuSubmenu.svelte.d.ts.map +1 -0
- package/dist/ContextmenuTextEntry.svelte +21 -0
- package/dist/ContextmenuTextEntry.svelte.d.ts +10 -0
- package/dist/ContextmenuTextEntry.svelte.d.ts.map +1 -0
- package/dist/CopyToClipboard.svelte +81 -0
- package/dist/CopyToClipboard.svelte.d.ts +18 -0
- package/dist/CopyToClipboard.svelte.d.ts.map +1 -0
- package/dist/DeclarationDetail.svelte +340 -0
- package/dist/DeclarationDetail.svelte.d.ts +8 -0
- package/dist/DeclarationDetail.svelte.d.ts.map +1 -0
- package/dist/DeclarationLink.svelte +50 -0
- package/dist/DeclarationLink.svelte.d.ts +8 -0
- package/dist/DeclarationLink.svelte.d.ts.map +1 -0
- package/dist/Details.svelte +51 -0
- package/dist/Details.svelte.d.ts +20 -0
- package/dist/Details.svelte.d.ts.map +1 -0
- package/dist/Dialog.svelte +217 -0
- package/dist/Dialog.svelte.d.ts +30 -0
- package/dist/Dialog.svelte.d.ts.map +1 -0
- package/dist/Dialogs.svelte +28 -0
- package/dist/Dialogs.svelte.d.ts +11 -0
- package/dist/Dialogs.svelte.d.ts.map +1 -0
- package/dist/Docs.svelte +179 -0
- package/dist/Docs.svelte.d.ts +13 -0
- package/dist/Docs.svelte.d.ts.map +1 -0
- package/dist/DocsContent.svelte +40 -0
- package/dist/DocsContent.svelte.d.ts +14 -0
- package/dist/DocsContent.svelte.d.ts.map +1 -0
- package/dist/DocsFooter.svelte +64 -0
- package/dist/DocsFooter.svelte.d.ts +15 -0
- package/dist/DocsFooter.svelte.d.ts.map +1 -0
- package/dist/DocsLink.svelte +41 -0
- package/dist/DocsLink.svelte.d.ts +12 -0
- package/dist/DocsLink.svelte.d.ts.map +1 -0
- package/dist/DocsList.svelte +44 -0
- package/dist/DocsList.svelte.d.ts +11 -0
- package/dist/DocsList.svelte.d.ts.map +1 -0
- package/dist/DocsMenu.svelte +55 -0
- package/dist/DocsMenu.svelte.d.ts +11 -0
- package/dist/DocsMenu.svelte.d.ts.map +1 -0
- package/dist/DocsMenuHeader.svelte +15 -0
- package/dist/DocsMenuHeader.svelte.d.ts +9 -0
- package/dist/DocsMenuHeader.svelte.d.ts.map +1 -0
- package/dist/DocsModulesList.svelte +32 -0
- package/dist/DocsModulesList.svelte.d.ts +7 -0
- package/dist/DocsModulesList.svelte.d.ts.map +1 -0
- package/dist/DocsPageLinks.svelte +61 -0
- package/dist/DocsPageLinks.svelte.d.ts +8 -0
- package/dist/DocsPageLinks.svelte.d.ts.map +1 -0
- package/dist/DocsPrimaryNav.svelte +93 -0
- package/dist/DocsPrimaryNav.svelte.d.ts +11 -0
- package/dist/DocsPrimaryNav.svelte.d.ts.map +1 -0
- package/dist/DocsSearch.svelte +48 -0
- package/dist/DocsSearch.svelte.d.ts +11 -0
- package/dist/DocsSearch.svelte.d.ts.map +1 -0
- package/dist/DocsSecondaryNav.svelte +63 -0
- package/dist/DocsSecondaryNav.svelte.d.ts +9 -0
- package/dist/DocsSecondaryNav.svelte.d.ts.map +1 -0
- package/dist/DocsTertiaryNav.svelte +118 -0
- package/dist/DocsTertiaryNav.svelte.d.ts +10 -0
- package/dist/DocsTertiaryNav.svelte.d.ts.map +1 -0
- package/dist/EcosystemLinks.svelte +53 -0
- package/dist/EcosystemLinks.svelte.d.ts +7 -0
- package/dist/EcosystemLinks.svelte.d.ts.map +1 -0
- package/dist/EcosystemLinksPanel.svelte +22 -0
- package/dist/EcosystemLinksPanel.svelte.d.ts +8 -0
- package/dist/EcosystemLinksPanel.svelte.d.ts.map +1 -0
- package/dist/GithubLink.svelte +75 -0
- package/dist/GithubLink.svelte.d.ts +14 -0
- package/dist/GithubLink.svelte.d.ts.map +1 -0
- package/dist/Glyph.svelte +28 -0
- package/dist/Glyph.svelte.d.ts +9 -0
- package/dist/Glyph.svelte.d.ts.map +1 -0
- package/dist/Hashlink.svelte +41 -0
- package/dist/Hashlink.svelte.d.ts +8 -0
- package/dist/Hashlink.svelte.d.ts.map +1 -0
- package/dist/HiddenPersonalLinks.svelte +6 -0
- package/dist/HiddenPersonalLinks.svelte.d.ts +27 -0
- package/dist/HiddenPersonalLinks.svelte.d.ts.map +1 -0
- package/dist/HueInput.svelte +127 -0
- package/dist/HueInput.svelte.d.ts +11 -0
- package/dist/HueInput.svelte.d.ts.map +1 -0
- package/dist/ImgOrSvg.svelte +58 -0
- package/dist/ImgOrSvg.svelte.d.ts +25 -0
- package/dist/ImgOrSvg.svelte.d.ts.map +1 -0
- package/dist/LibraryDetail.svelte +297 -0
- package/dist/LibraryDetail.svelte.d.ts +15 -0
- package/dist/LibraryDetail.svelte.d.ts.map +1 -0
- package/dist/LibrarySummary.svelte +151 -0
- package/dist/LibrarySummary.svelte.d.ts +16 -0
- package/dist/LibrarySummary.svelte.d.ts.map +1 -0
- package/dist/MdnLink.svelte +40 -0
- package/dist/MdnLink.svelte.d.ts +8 -0
- package/dist/MdnLink.svelte.d.ts.map +1 -0
- package/dist/Mdz.svelte +30 -0
- package/dist/Mdz.svelte.d.ts +10 -0
- package/dist/Mdz.svelte.d.ts.map +1 -0
- package/dist/MdzNodeView.svelte +93 -0
- package/dist/MdzNodeView.svelte.d.ts +9 -0
- package/dist/MdzNodeView.svelte.d.ts.map +1 -0
- package/dist/ModuleLink.svelte +48 -0
- package/dist/ModuleLink.svelte.d.ts +8 -0
- package/dist/ModuleLink.svelte.d.ts.map +1 -0
- package/dist/PasteFromClipboard.svelte +35 -0
- package/dist/PasteFromClipboard.svelte.d.ts +9 -0
- package/dist/PasteFromClipboard.svelte.d.ts.map +1 -0
- package/dist/PendingAnimation.svelte +62 -0
- package/dist/PendingAnimation.svelte.d.ts +13 -0
- package/dist/PendingAnimation.svelte.d.ts.map +1 -0
- package/dist/PendingButton.svelte +75 -0
- package/dist/PendingButton.svelte.d.ts +17 -0
- package/dist/PendingButton.svelte.d.ts.map +1 -0
- package/dist/ProjectLinks.svelte +54 -0
- package/dist/ProjectLinks.svelte.d.ts +19 -0
- package/dist/ProjectLinks.svelte.d.ts.map +1 -0
- package/dist/Redirect.svelte +44 -0
- package/dist/Redirect.svelte.d.ts +23 -0
- package/dist/Redirect.svelte.d.ts.map +1 -0
- package/dist/Spiders.svelte +57 -0
- package/dist/Spiders.svelte.d.ts +9 -0
- package/dist/Spiders.svelte.d.ts.map +1 -0
- package/dist/Svg.svelte +99 -0
- package/dist/Svg.svelte.d.ts +54 -0
- package/dist/Svg.svelte.d.ts.map +1 -0
- package/dist/Teleport.svelte +48 -0
- package/dist/Teleport.svelte.d.ts +15 -0
- package/dist/Teleport.svelte.d.ts.map +1 -0
- package/dist/ThemeInput.svelte +75 -0
- package/dist/ThemeInput.svelte.d.ts +15 -0
- package/dist/ThemeInput.svelte.d.ts.map +1 -0
- package/dist/Themed.svelte +101 -0
- package/dist/Themed.svelte.d.ts +24 -0
- package/dist/Themed.svelte.d.ts.map +1 -0
- package/dist/TomeContent.svelte +67 -0
- package/dist/TomeContent.svelte.d.ts +12 -0
- package/dist/TomeContent.svelte.d.ts.map +1 -0
- package/dist/TomeHeader.svelte +56 -0
- package/dist/TomeHeader.svelte.d.ts +4 -0
- package/dist/TomeHeader.svelte.d.ts.map +1 -0
- package/dist/TomeLink.svelte +29 -0
- package/dist/TomeLink.svelte.d.ts +10 -0
- package/dist/TomeLink.svelte.d.ts.map +1 -0
- package/dist/TomeSection.svelte +65 -0
- package/dist/TomeSection.svelte.d.ts +24 -0
- package/dist/TomeSection.svelte.d.ts.map +1 -0
- package/dist/TomeSectionHeader.svelte +90 -0
- package/dist/TomeSectionHeader.svelte.d.ts +13 -0
- package/dist/TomeSectionHeader.svelte.d.ts.map +1 -0
- package/dist/TypeLink.svelte +19 -0
- package/dist/TypeLink.svelte.d.ts +7 -0
- package/dist/TypeLink.svelte.d.ts.map +1 -0
- package/dist/alert.d.ts +7 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +6 -0
- package/dist/api_search.svelte.d.ts +16 -0
- package/dist/api_search.svelte.d.ts.map +1 -0
- package/dist/api_search.svelte.js +61 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +3 -0
- package/dist/context_helpers.d.ts +17 -0
- package/dist/context_helpers.d.ts.map +1 -0
- package/dist/context_helpers.js +19 -0
- package/dist/contextmenu_helpers.d.ts +16 -0
- package/dist/contextmenu_helpers.d.ts.map +1 -0
- package/dist/contextmenu_helpers.js +39 -0
- package/dist/contextmenu_state.svelte.d.ts +152 -0
- package/dist/contextmenu_state.svelte.d.ts.map +1 -0
- package/dist/contextmenu_state.svelte.js +424 -0
- package/dist/csp.d.ts +160 -0
- package/dist/csp.d.ts.map +1 -0
- package/dist/csp.js +354 -0
- package/dist/csp_of_ryanatkn.d.ts +6 -0
- package/dist/csp_of_ryanatkn.d.ts.map +1 -0
- package/dist/csp_of_ryanatkn.js +14 -0
- package/dist/declaration.svelte.d.ts +84 -0
- package/dist/declaration.svelte.d.ts.map +1 -0
- package/dist/declaration.svelte.js +66 -0
- package/dist/declaration_contextmenu.d.ts +4 -0
- package/dist/declaration_contextmenu.d.ts.map +1 -0
- package/dist/declaration_contextmenu.js +14 -0
- package/dist/dialog.d.ts +24 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +12 -0
- package/dist/dimensions.svelte.d.ts +5 -0
- package/dist/dimensions.svelte.d.ts.map +1 -0
- package/dist/dimensions.svelte.js +4 -0
- package/dist/docs_helpers.svelte.d.ts +48 -0
- package/dist/docs_helpers.svelte.d.ts.map +1 -0
- package/dist/docs_helpers.svelte.js +99 -0
- package/dist/helpers.d.ts +2 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +16 -0
- package/dist/intersect.svelte.d.ts +47 -0
- package/dist/intersect.svelte.d.ts.map +1 -0
- package/dist/intersect.svelte.js +92 -0
- package/dist/library.svelte.d.ts +197 -0
- package/dist/library.svelte.d.ts.map +1 -0
- package/dist/library.svelte.js +130 -0
- package/dist/library_gen.d.ts +34 -0
- package/dist/library_gen.d.ts.map +1 -0
- package/dist/library_gen.js +123 -0
- package/dist/library_gen_helpers.d.ts +85 -0
- package/dist/library_gen_helpers.d.ts.map +1 -0
- package/dist/library_gen_helpers.js +188 -0
- package/dist/library_helpers.d.ts +54 -0
- package/dist/library_helpers.d.ts.map +1 -0
- package/dist/library_helpers.js +102 -0
- package/dist/logos.d.ts +134 -0
- package/dist/logos.d.ts.map +1 -0
- package/dist/logos.js +281 -0
- package/dist/mdz.d.ts +106 -0
- package/dist/mdz.d.ts.map +1 -0
- package/dist/mdz.js +1481 -0
- package/dist/mdz_components.d.ts +37 -0
- package/dist/mdz_components.d.ts.map +1 -0
- package/dist/mdz_components.js +12 -0
- package/dist/module.svelte.d.ts +47 -0
- package/dist/module.svelte.d.ts.map +1 -0
- package/dist/module.svelte.js +56 -0
- package/dist/module_contextmenu.d.ts +4 -0
- package/dist/module_contextmenu.d.ts.map +1 -0
- package/dist/module_contextmenu.js +14 -0
- package/dist/module_helpers.d.ts +69 -0
- package/dist/module_helpers.d.ts.map +1 -0
- package/dist/module_helpers.js +87 -0
- package/dist/rune_helpers.svelte.d.ts +6 -0
- package/dist/rune_helpers.svelte.d.ts.map +1 -0
- package/dist/rune_helpers.svelte.js +10 -0
- package/dist/storage.d.ts +13 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +43 -0
- package/dist/svelte_helpers.d.ts +37 -0
- package/dist/svelte_helpers.d.ts.map +1 -0
- package/dist/svelte_helpers.js +245 -0
- package/dist/themer.svelte.d.ts +24 -0
- package/dist/themer.svelte.d.ts.map +1 -0
- package/dist/themer.svelte.js +43 -0
- package/dist/tome.d.ts +80 -0
- package/dist/tome.d.ts.map +1 -0
- package/dist/tome.js +27 -0
- package/dist/ts_helpers.d.ts +110 -0
- package/dist/ts_helpers.d.ts.map +1 -0
- package/dist/ts_helpers.js +533 -0
- package/dist/tsdoc_helpers.d.ts +98 -0
- package/dist/tsdoc_helpers.d.ts.map +1 -0
- package/dist/tsdoc_helpers.js +221 -0
- package/package.json +128 -0
- package/src/lib/alert.ts +14 -0
- package/src/lib/api_search.svelte.ts +85 -0
- package/src/lib/constants.ts +3 -0
- package/src/lib/context_helpers.ts +47 -0
- package/src/lib/contextmenu_helpers.ts +63 -0
- package/src/lib/contextmenu_state.svelte.ts +515 -0
- package/src/lib/csp.ts +576 -0
- package/src/lib/csp_of_ryanatkn.ts +16 -0
- package/src/lib/declaration.svelte.ts +102 -0
- package/src/lib/declaration_contextmenu.ts +22 -0
- package/src/lib/dialog.ts +35 -0
- package/src/lib/dimensions.svelte.ts +4 -0
- package/src/lib/docs_helpers.svelte.ts +149 -0
- package/src/lib/helpers.ts +10 -0
- package/src/lib/intersect.svelte.ts +152 -0
- package/src/lib/library.svelte.ts +162 -0
- package/src/lib/library_gen.ts +160 -0
- package/src/lib/library_gen_helpers.ts +262 -0
- package/src/lib/library_helpers.ts +123 -0
- package/src/lib/logos.ts +302 -0
- package/src/lib/mdz.ts +1819 -0
- package/src/lib/mdz_components.ts +34 -0
- package/src/lib/module.svelte.ts +78 -0
- package/src/lib/module_contextmenu.ts +20 -0
- package/src/lib/module_helpers.ts +113 -0
- package/src/lib/rune_helpers.svelte.ts +10 -0
- package/src/lib/storage.ts +48 -0
- package/src/lib/svelte_helpers.ts +303 -0
- package/src/lib/themer.svelte.ts +68 -0
- package/src/lib/tome.ts +38 -0
- package/src/lib/ts_helpers.ts +662 -0
- package/src/lib/tsdoc_helpers.ts +259 -0
package/dist/csp.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is designed for compatibility with SvelteKit
|
|
3
|
+
* and maps to the `KitConfig` `directives` option.
|
|
4
|
+
* The goal is to provide an ergonomic, modern, and safe API
|
|
5
|
+
* for Content Security Policy (CSP) creation
|
|
6
|
+
* that's simple to write and audit, and isn't error-prone.
|
|
7
|
+
*
|
|
8
|
+
* Things like validation and rendering to a string
|
|
9
|
+
* are out of scope and left to SvelteKit.
|
|
10
|
+
*/
|
|
11
|
+
export function create_csp_directives(options = {}) {
|
|
12
|
+
const { directives: directives_option, trusted_sources, value_defaults_base = csp_directive_value_defaults, value_defaults: value_defaults_option, required_trust_defaults_base = csp_directive_required_trust_defaults, required_trust_defaults: required_trust_defaults_option, } = options;
|
|
13
|
+
const directives = {};
|
|
14
|
+
// Shallowly merge any provided defaults with the base defaults
|
|
15
|
+
const value_defaults = { ...value_defaults_base, ...value_defaults_option };
|
|
16
|
+
// Merge required trust defaults with the base
|
|
17
|
+
const required_trust_defaults = {
|
|
18
|
+
...required_trust_defaults_base,
|
|
19
|
+
...required_trust_defaults_option,
|
|
20
|
+
};
|
|
21
|
+
// Apply defaults from directive specs
|
|
22
|
+
for (const spec of csp_directive_specs) {
|
|
23
|
+
const default_value = value_defaults[spec.name];
|
|
24
|
+
if (default_value == null)
|
|
25
|
+
continue; // omit null and undefined
|
|
26
|
+
directives[spec.name] = Array.isArray(default_value)
|
|
27
|
+
? [...default_value]
|
|
28
|
+
: default_value;
|
|
29
|
+
}
|
|
30
|
+
// Get trust requirements (with overrides applied)
|
|
31
|
+
const trust_requirements = new Map();
|
|
32
|
+
for (const spec of csp_directive_specs) {
|
|
33
|
+
const required_trust = required_trust_defaults[spec.name];
|
|
34
|
+
if (required_trust == null)
|
|
35
|
+
continue; // omit null and undefined
|
|
36
|
+
trust_requirements.set(spec.name, required_trust);
|
|
37
|
+
}
|
|
38
|
+
// Validate trusted_sources directives
|
|
39
|
+
if (trusted_sources?.length) {
|
|
40
|
+
for (const spec of trusted_sources) {
|
|
41
|
+
if (spec.directives) {
|
|
42
|
+
for (const directive of spec.directives) {
|
|
43
|
+
if (parse_csp_directive(directive) === null) {
|
|
44
|
+
throw new Error(`Invalid directive in trusted_sources: ${directive}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Apply trusted sources to directives
|
|
51
|
+
if (trusted_sources?.length) {
|
|
52
|
+
for (const [key, value] of Object.entries(directives)) {
|
|
53
|
+
const directive = parse_csp_directive(key);
|
|
54
|
+
if (directive === null) {
|
|
55
|
+
throw new Error(`Invalid directive in options.directives: ${key}`);
|
|
56
|
+
}
|
|
57
|
+
// Skip if directive is ['none'] or not an array
|
|
58
|
+
if (is_none_directive(value) || !Array.isArray(value)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
// Get required trust for this directive
|
|
62
|
+
const required_trust = trust_requirements.get(directive);
|
|
63
|
+
if (required_trust == null)
|
|
64
|
+
continue;
|
|
65
|
+
// Add matching sources - separate the filtering into trust-based and directive-based inclusion
|
|
66
|
+
const sources_to_add = trusted_sources
|
|
67
|
+
.filter((spec) => {
|
|
68
|
+
// Check for explicit inclusion in directives list
|
|
69
|
+
const explicitly_included = spec.directives?.includes(directive) ?? false;
|
|
70
|
+
// Check for trust level based inclusion
|
|
71
|
+
const has_trust_level = spec.trust !== undefined;
|
|
72
|
+
const include_by_trust = has_trust_level && is_csp_trusted(required_trust, spec.trust);
|
|
73
|
+
// Include the source if either condition is met
|
|
74
|
+
return explicitly_included || include_by_trust;
|
|
75
|
+
})
|
|
76
|
+
.map((spec) => spec.source);
|
|
77
|
+
if (sources_to_add.length > 0) {
|
|
78
|
+
directives[directive] = [...value, ...sources_to_add];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Apply directive overrides/transformations
|
|
83
|
+
if (directives_option) {
|
|
84
|
+
for (const [key, value_or_fn] of Object.entries(directives_option)) {
|
|
85
|
+
const directive = parse_csp_directive(key);
|
|
86
|
+
if (directive === null) {
|
|
87
|
+
throw new Error(`Invalid directive in options.directives: ${key}`);
|
|
88
|
+
}
|
|
89
|
+
const current = directives[directive];
|
|
90
|
+
const result = typeof value_or_fn === 'function' ? value_or_fn(current) : value_or_fn;
|
|
91
|
+
// Handle `undefined` too just in case
|
|
92
|
+
if (result == null) {
|
|
93
|
+
delete directives[directive]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
directives[directive] = structuredClone(result);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return directives;
|
|
101
|
+
}
|
|
102
|
+
export const parse_csp_directive = (directive) => typeof directive === 'string' && csp_directive_spec_by_name.has(directive)
|
|
103
|
+
? directive
|
|
104
|
+
: null;
|
|
105
|
+
export const csp_trust_levels = ['low', 'medium', 'high'];
|
|
106
|
+
/**
|
|
107
|
+
* Numeric values for CSP trust levels, `csp_trust_levels`.
|
|
108
|
+
* Lower is less trusted.
|
|
109
|
+
* Includes `undefined` in the type for safety.
|
|
110
|
+
*/
|
|
111
|
+
export const csp_trust_level_value = {
|
|
112
|
+
low: 0,
|
|
113
|
+
medium: 1,
|
|
114
|
+
high: 2,
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Validates and extracts a CSP trust level from an unknown value.
|
|
118
|
+
*/
|
|
119
|
+
export const parse_csp_trust_level = (trust) => csp_trust_levels.includes(trust) ? trust : null;
|
|
120
|
+
/**
|
|
121
|
+
* Determines if a granted trust level is sufficient to satisfy a required trust level.
|
|
122
|
+
*
|
|
123
|
+
* Trust levels have the following hierarchy:
|
|
124
|
+
* - 'high' sources can be used in high, medium, and low trust directives (highest privilege)
|
|
125
|
+
* - 'medium' sources can be used in medium and low trust directives
|
|
126
|
+
* - 'low' sources can only be used in low trust directives (lowest privilege)
|
|
127
|
+
*/
|
|
128
|
+
export const is_csp_trusted = (required_trust, granted_trust) => {
|
|
129
|
+
const required_value = required_trust && csp_trust_level_value[required_trust];
|
|
130
|
+
const granted_value = granted_trust && csp_trust_level_value[granted_trust];
|
|
131
|
+
if (required_value == null || granted_value == null) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
// A source with higher trust privilege (higher value)
|
|
135
|
+
// can be used in a directive with less privilege (lower value).
|
|
136
|
+
return granted_value >= required_value;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Helper to check if a directive value is `['none']`,
|
|
140
|
+
* or more precisely for robustness with malformed values, checks for an array with `'none'`.
|
|
141
|
+
*/
|
|
142
|
+
const is_none_directive = (value) => Array.isArray(value) && value.includes('none');
|
|
143
|
+
export const COLOR_SCHEME_SCRIPT_HASH = 'sha256-QOxqn7EUzb3ydF9SALJoJGWSvywW9R0AfTDSenB83Z8=';
|
|
144
|
+
/**
|
|
145
|
+
* The base CSP directive defaults.
|
|
146
|
+
* Prioritizes safety but loosens around media and styles, relying on defense-in-depth.
|
|
147
|
+
* Customizable via `CreateCspDirectivesOptions.defaults`.
|
|
148
|
+
*/
|
|
149
|
+
export const csp_directive_value_defaults = {
|
|
150
|
+
'default-src': ['none'],
|
|
151
|
+
'script-src': ['self', COLOR_SCHEME_SCRIPT_HASH], // Eval is opt-in, scripting is locked down except for self and the color scheme loader script
|
|
152
|
+
'script-src-elem': ['self', COLOR_SCHEME_SCRIPT_HASH], // Block script elements except for self and the color scheme loader
|
|
153
|
+
'script-src-attr': ['none'], // Block scripts in HTML attributes
|
|
154
|
+
'style-src': ['self', 'unsafe-inline'], // Main style directive (uses unsafe-inline but network connections are disallowed by other directives)
|
|
155
|
+
'style-src-elem': ['self', 'unsafe-inline'], // Style elements (standalone stylesheets)
|
|
156
|
+
'style-src-attr': ['unsafe-inline'], // Style attributes
|
|
157
|
+
'img-src': ['self', 'data:', 'blob:', 'filesystem:'], // Images
|
|
158
|
+
'media-src': ['self', 'data:', 'blob:', 'mediastream:', 'filesystem:'], // Audio/video
|
|
159
|
+
'font-src': ['self', 'data:'], // Fonts
|
|
160
|
+
'manifest-src': ['self'], // Web app manifests
|
|
161
|
+
'child-src': ['none'], // Not trusted, extends default-src so worker-src and frame-src are additionally blocked
|
|
162
|
+
'connect-src': ['self'], // Fetch, WebSockets
|
|
163
|
+
'frame-src': ['self'], // Frames/iframes
|
|
164
|
+
'frame-ancestors': ['self'], // Control what can embed this page
|
|
165
|
+
'form-action': ['self'], // Form submission targets
|
|
166
|
+
'worker-src': ['self', 'blob:'], // Web workers
|
|
167
|
+
'object-src': ['none'], // Block plugins (Flash, Java, etc.)
|
|
168
|
+
'base-uri': ['none'], // Prevent base tag hijacking
|
|
169
|
+
'upgrade-insecure-requests': true, // Upgrade http to https
|
|
170
|
+
'report-to': null, // Report violations (e.g. `'/csp-violation-report'`)
|
|
171
|
+
'require-trusted-types-for': null,
|
|
172
|
+
'trusted-types': null,
|
|
173
|
+
sandbox: null,
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Sources that meet this trust requirement are included for it by default.
|
|
177
|
+
* If null, no trusted sources are added to the directive automatically.
|
|
178
|
+
* Directives that don't support sources or default to `['none']` are null.
|
|
179
|
+
*
|
|
180
|
+
* Feedback is welcome, please see the issues - https://github.com/ryanatkn/fuz/issues
|
|
181
|
+
*/
|
|
182
|
+
export const csp_directive_required_trust_defaults = {
|
|
183
|
+
'default-src': null,
|
|
184
|
+
'script-src': 'high',
|
|
185
|
+
'script-src-elem': 'high',
|
|
186
|
+
'script-src-attr': null,
|
|
187
|
+
'style-src': 'medium',
|
|
188
|
+
'style-src-elem': 'medium',
|
|
189
|
+
'style-src-attr': 'medium',
|
|
190
|
+
'img-src': 'low',
|
|
191
|
+
'media-src': 'low',
|
|
192
|
+
'font-src': 'low',
|
|
193
|
+
'manifest-src': null,
|
|
194
|
+
'child-src': null,
|
|
195
|
+
'connect-src': 'medium',
|
|
196
|
+
'frame-src': 'medium',
|
|
197
|
+
'frame-ancestors': 'medium',
|
|
198
|
+
'form-action': 'medium',
|
|
199
|
+
'worker-src': 'medium',
|
|
200
|
+
'object-src': null,
|
|
201
|
+
'base-uri': null,
|
|
202
|
+
'upgrade-insecure-requests': null,
|
|
203
|
+
'report-to': null,
|
|
204
|
+
'require-trusted-types-for': null,
|
|
205
|
+
'trusted-types': null,
|
|
206
|
+
sandbox: null,
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Static data descriptors for the CSP directives.
|
|
210
|
+
* Fuz excludes deprecated directives, so those are intentionally omitted,
|
|
211
|
+
* but any newer missing directives are bugs.
|
|
212
|
+
*
|
|
213
|
+
* Could be moved to `csp.ts` but is currently here to keep that module smaller.
|
|
214
|
+
*
|
|
215
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy
|
|
216
|
+
*/
|
|
217
|
+
export const csp_directive_specs = [
|
|
218
|
+
{
|
|
219
|
+
name: 'default-src',
|
|
220
|
+
fallback: null,
|
|
221
|
+
fallback_of: [
|
|
222
|
+
'script-src',
|
|
223
|
+
'script-src-elem',
|
|
224
|
+
'script-src-attr',
|
|
225
|
+
'style-src',
|
|
226
|
+
'style-src-elem',
|
|
227
|
+
'style-src-attr',
|
|
228
|
+
'img-src',
|
|
229
|
+
'media-src',
|
|
230
|
+
'font-src',
|
|
231
|
+
'manifest-src',
|
|
232
|
+
'child-src',
|
|
233
|
+
'connect-src',
|
|
234
|
+
'worker-src',
|
|
235
|
+
'object-src',
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: 'script-src',
|
|
240
|
+
fallback: ['default-src'],
|
|
241
|
+
fallback_of: ['script-src-elem', 'script-src-attr', 'worker-src'],
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: 'script-src-elem',
|
|
245
|
+
fallback: ['script-src', 'default-src'],
|
|
246
|
+
fallback_of: null,
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: 'script-src-attr',
|
|
250
|
+
fallback: ['script-src', 'default-src'],
|
|
251
|
+
fallback_of: null,
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: 'style-src',
|
|
255
|
+
fallback: ['default-src'],
|
|
256
|
+
fallback_of: ['style-src-elem', 'style-src-attr'],
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: 'style-src-elem',
|
|
260
|
+
fallback: ['style-src', 'default-src'],
|
|
261
|
+
fallback_of: null,
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'style-src-attr',
|
|
265
|
+
fallback: ['style-src', 'default-src'],
|
|
266
|
+
fallback_of: null,
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: 'img-src',
|
|
270
|
+
fallback: ['default-src'],
|
|
271
|
+
fallback_of: null,
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: 'media-src',
|
|
275
|
+
fallback: ['default-src'],
|
|
276
|
+
fallback_of: null,
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: 'font-src',
|
|
280
|
+
fallback: ['default-src'],
|
|
281
|
+
fallback_of: null,
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
name: 'manifest-src',
|
|
285
|
+
fallback: ['default-src'],
|
|
286
|
+
fallback_of: null,
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: 'child-src',
|
|
290
|
+
fallback: ['default-src'],
|
|
291
|
+
fallback_of: ['frame-src', 'worker-src'],
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: 'connect-src',
|
|
295
|
+
fallback: ['default-src'],
|
|
296
|
+
fallback_of: null,
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: 'frame-src',
|
|
300
|
+
fallback: ['child-src'],
|
|
301
|
+
fallback_of: null,
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
name: 'frame-ancestors',
|
|
305
|
+
fallback: null,
|
|
306
|
+
fallback_of: null,
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
name: 'form-action',
|
|
310
|
+
fallback: null,
|
|
311
|
+
fallback_of: null,
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: 'worker-src',
|
|
315
|
+
fallback: ['child-src', 'script-src', 'default-src'],
|
|
316
|
+
fallback_of: null,
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: 'object-src',
|
|
320
|
+
fallback: ['default-src'],
|
|
321
|
+
fallback_of: null,
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: 'base-uri',
|
|
325
|
+
fallback: null,
|
|
326
|
+
fallback_of: null,
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: 'upgrade-insecure-requests',
|
|
330
|
+
fallback: null,
|
|
331
|
+
fallback_of: null,
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
name: 'report-to',
|
|
335
|
+
fallback: null,
|
|
336
|
+
fallback_of: null,
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: 'require-trusted-types-for',
|
|
340
|
+
fallback: null,
|
|
341
|
+
fallback_of: null,
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: 'trusted-types',
|
|
345
|
+
fallback: null,
|
|
346
|
+
fallback_of: null,
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: 'sandbox',
|
|
350
|
+
fallback: null,
|
|
351
|
+
fallback_of: null,
|
|
352
|
+
},
|
|
353
|
+
];
|
|
354
|
+
export const csp_directive_spec_by_name = new Map(csp_directive_specs.map((s) => [s.name, s]));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csp_of_ryanatkn.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/csp_of_ryanatkn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,KAAK,CAAC,aAAa,CAUhE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trusted sources owned by ryanatkn.
|
|
3
|
+
*/
|
|
4
|
+
export const csp_trusted_sources_of_ryanatkn = [
|
|
5
|
+
{ source: 'https://*.ryanatkn.com/', trust: 'low' },
|
|
6
|
+
{ source: 'https://*.spiderspace.org/', trust: 'low' },
|
|
7
|
+
{ source: 'https://*.webdevladder.net/', trust: 'low' },
|
|
8
|
+
{ source: 'https://*.dealt.dev/', trust: 'low' },
|
|
9
|
+
{ source: 'https://*.fuz.dev/', trust: 'low' },
|
|
10
|
+
{ source: 'https://*.ztack.net/', trust: 'low' },
|
|
11
|
+
{ source: 'https://*.zzz.software/', trust: 'low' },
|
|
12
|
+
{ source: 'https://*.cosmicplayground.org/', trust: 'low' },
|
|
13
|
+
{ source: 'https://ryanatkn.github.io/', trust: 'low' },
|
|
14
|
+
];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type DeclarationJson } from '@fuzdev/fuz_util/source_json.js';
|
|
2
|
+
import type { Module } from './module.svelte.js';
|
|
3
|
+
/**
|
|
4
|
+
* Rich runtime representation of an exported declaration.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Declaration {
|
|
7
|
+
readonly module: Module;
|
|
8
|
+
readonly declaration_json: DeclarationJson;
|
|
9
|
+
library: import("./library.svelte.ts").Library;
|
|
10
|
+
/**
|
|
11
|
+
* Module path where this declaration is defined.
|
|
12
|
+
*/
|
|
13
|
+
module_path: string;
|
|
14
|
+
name: string;
|
|
15
|
+
kind: "function" | "type" | "json" | "variable" | "class" | "constructor" | "component" | "css";
|
|
16
|
+
/**
|
|
17
|
+
* GitHub source URL with line number.
|
|
18
|
+
*/
|
|
19
|
+
url_github: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* API documentation URL.
|
|
22
|
+
*/
|
|
23
|
+
url_api: string;
|
|
24
|
+
/**
|
|
25
|
+
* Generated TypeScript import statement.
|
|
26
|
+
*/
|
|
27
|
+
import_statement: string;
|
|
28
|
+
/**
|
|
29
|
+
* Public documentation link (if homepage_url is available).
|
|
30
|
+
*/
|
|
31
|
+
url_api_full: string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Display name with generic parameters.
|
|
34
|
+
*/
|
|
35
|
+
display_name: string;
|
|
36
|
+
type_signature: string | undefined;
|
|
37
|
+
doc_comment: string | undefined;
|
|
38
|
+
deprecated_message: string | undefined;
|
|
39
|
+
parameters: {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
name: string;
|
|
42
|
+
type: string;
|
|
43
|
+
optional?: boolean | undefined;
|
|
44
|
+
description?: string | undefined;
|
|
45
|
+
default_value?: string | undefined;
|
|
46
|
+
}[] | undefined;
|
|
47
|
+
props: {
|
|
48
|
+
[x: string]: unknown;
|
|
49
|
+
name: string;
|
|
50
|
+
type: string;
|
|
51
|
+
optional?: boolean | undefined;
|
|
52
|
+
description?: string | undefined;
|
|
53
|
+
default_value?: string | undefined;
|
|
54
|
+
bindable?: boolean | undefined;
|
|
55
|
+
}[] | undefined;
|
|
56
|
+
return_type: string | undefined;
|
|
57
|
+
return_description: string | undefined;
|
|
58
|
+
generic_params: {
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
name: string;
|
|
61
|
+
constraint?: string | undefined;
|
|
62
|
+
default_type?: string | undefined;
|
|
63
|
+
}[] | undefined;
|
|
64
|
+
extends: string[] | undefined;
|
|
65
|
+
implements: string[] | undefined;
|
|
66
|
+
throws: {
|
|
67
|
+
[x: string]: unknown;
|
|
68
|
+
description: string;
|
|
69
|
+
type?: string | undefined;
|
|
70
|
+
}[] | undefined;
|
|
71
|
+
since: string | undefined;
|
|
72
|
+
examples: string[] | undefined;
|
|
73
|
+
see_also: string[] | undefined;
|
|
74
|
+
members: Array<DeclarationJson> | undefined;
|
|
75
|
+
properties: Array<DeclarationJson> | undefined;
|
|
76
|
+
has_examples: boolean;
|
|
77
|
+
is_deprecated: boolean;
|
|
78
|
+
has_documentation: boolean;
|
|
79
|
+
has_parameters: boolean;
|
|
80
|
+
has_props: boolean;
|
|
81
|
+
has_generics: boolean;
|
|
82
|
+
constructor(module: Module, declaration_json: DeclarationJson);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=declaration.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,eAAe,EAGpB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAG/C;;GAEG;AACH,qBAAa,WAAW;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAiB;IACxC,QAAQ,CAAC,gBAAgB,EAAE,eAAe,CAAiB;IAE3D,OAAO,wCAAiC;IAExC;;OAEG;IACH,WAAW,SAA8B;IAEzC,IAAI,SAAwC;IAC5C,IAAI,4FAAwC;IAE5C;;OAEG;IACH,UAAU,qBAQR;IAEF;;OAEG;IACH,OAAO,SAA0D;IAEjE;;OAEG;IACH,gBAAgB,SAMd;IAEF;;OAEG;IACH,YAAY,qBAIV;IAEF;;OAEG;IACH,YAAY,SAAiE;IAE7E,cAAc,qBAAkD;IAChE,WAAW,qBAA+C;IAC1D,kBAAkB,qBAAsD;IACxE,UAAU;;;;;;;oBAA8C;IACxD,KAAK;;;;;;;;oBAAyC;IAC9C,WAAW,qBAA+C;IAC1D,kBAAkB,qBAAsD;IACxE,cAAc;;;;;oBAAkD;IAChE,OAAO,uBAA2C;IAClD,UAAU,uBAA8C;IACxD,MAAM;;;;oBAA0C;IAChD,KAAK,qBAAyC;IAC9C,QAAQ,uBAA4C;IACpD,QAAQ,uBAA4C;IACpD,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,GAAG,SAAS,CAEzC;IACF,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,GAAG,SAAS,CAE5C;IAEF,YAAY,UAA2D;IACvE,aAAa,UAAuC;IACpD,iBAAiB,UAAgC;IACjD,cAAc,UAA+D;IAC7E,SAAS,UAAqD;IAC9D,YAAY,UAAuE;gBAEvE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,eAAe;CAI7D"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { declaration_generate_import, declaration_get_display_name, } from '@fuzdev/fuz_util/source_json.js';
|
|
2
|
+
import { url_github_file } from './library_helpers.js';
|
|
3
|
+
/**
|
|
4
|
+
* Rich runtime representation of an exported declaration.
|
|
5
|
+
*/
|
|
6
|
+
export class Declaration {
|
|
7
|
+
module = $state.raw();
|
|
8
|
+
declaration_json = $state.raw();
|
|
9
|
+
library = $derived(this.module.library);
|
|
10
|
+
/**
|
|
11
|
+
* Module path where this declaration is defined.
|
|
12
|
+
*/
|
|
13
|
+
module_path = $derived(this.module.path);
|
|
14
|
+
name = $derived(this.declaration_json.name);
|
|
15
|
+
kind = $derived(this.declaration_json.kind);
|
|
16
|
+
/**
|
|
17
|
+
* GitHub source URL with line number.
|
|
18
|
+
*/
|
|
19
|
+
url_github = $derived(this.library.repo_url && this.declaration_json.source_line
|
|
20
|
+
? url_github_file(this.library.repo_url, `src/lib/${this.module_path}`, this.declaration_json.source_line)
|
|
21
|
+
: undefined);
|
|
22
|
+
/**
|
|
23
|
+
* API documentation URL.
|
|
24
|
+
*/
|
|
25
|
+
url_api = $derived(`/docs/api/${this.module_path}#${this.name}`);
|
|
26
|
+
/**
|
|
27
|
+
* Generated TypeScript import statement.
|
|
28
|
+
*/
|
|
29
|
+
import_statement = $derived(declaration_generate_import(this.declaration_json, this.module_path, this.library.package_json.name));
|
|
30
|
+
/**
|
|
31
|
+
* Public documentation link (if homepage_url is available).
|
|
32
|
+
*/
|
|
33
|
+
url_api_full = $derived(this.library.homepage_url
|
|
34
|
+
? `${this.library.homepage_url.replace(/\/$/, '')}/docs/api/${this.module_path}#${this.name}`
|
|
35
|
+
: undefined);
|
|
36
|
+
/**
|
|
37
|
+
* Display name with generic parameters.
|
|
38
|
+
*/
|
|
39
|
+
display_name = $derived(declaration_get_display_name(this.declaration_json));
|
|
40
|
+
type_signature = $derived(this.declaration_json.type_signature);
|
|
41
|
+
doc_comment = $derived(this.declaration_json.doc_comment);
|
|
42
|
+
deprecated_message = $derived(this.declaration_json.deprecated_message);
|
|
43
|
+
parameters = $derived(this.declaration_json.parameters);
|
|
44
|
+
props = $derived(this.declaration_json.props);
|
|
45
|
+
return_type = $derived(this.declaration_json.return_type);
|
|
46
|
+
return_description = $derived(this.declaration_json.return_description);
|
|
47
|
+
generic_params = $derived(this.declaration_json.generic_params);
|
|
48
|
+
extends = $derived(this.declaration_json.extends);
|
|
49
|
+
implements = $derived(this.declaration_json.implements);
|
|
50
|
+
throws = $derived(this.declaration_json.throws);
|
|
51
|
+
since = $derived(this.declaration_json.since);
|
|
52
|
+
examples = $derived(this.declaration_json.examples);
|
|
53
|
+
see_also = $derived(this.declaration_json.see_also);
|
|
54
|
+
members = $derived(this.declaration_json.members);
|
|
55
|
+
properties = $derived(this.declaration_json.properties);
|
|
56
|
+
has_examples = $derived(!!(this.examples && this.examples.length > 0));
|
|
57
|
+
is_deprecated = $derived(!!this.deprecated_message);
|
|
58
|
+
has_documentation = $derived(!!this.doc_comment);
|
|
59
|
+
has_parameters = $derived(!!(this.parameters && this.parameters.length > 0));
|
|
60
|
+
has_props = $derived(!!(this.props && this.props.length > 0));
|
|
61
|
+
has_generics = $derived(!!(this.generic_params && this.generic_params.length > 0));
|
|
62
|
+
constructor(module, declaration_json) {
|
|
63
|
+
this.module = module;
|
|
64
|
+
this.declaration_json = declaration_json;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Declaration } from './declaration.svelte.js';
|
|
2
|
+
import type { ContextmenuParams } from './contextmenu_state.svelte.js';
|
|
3
|
+
export declare const create_declaration_contextmenu: (declaration: Declaration) => Array<ContextmenuParams>;
|
|
4
|
+
//# sourceMappingURL=declaration_contextmenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration_contextmenu.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration_contextmenu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AAIrE,eAAO,MAAM,8BAA8B,GAC1C,aAAa,WAAW,KACtB,KAAK,CAAC,iBAAiB,CAczB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// TODO @many expand contextmenus for docs
|
|
2
|
+
export const create_declaration_contextmenu = (declaration) => {
|
|
3
|
+
const entries = [];
|
|
4
|
+
// View source on GitHub
|
|
5
|
+
if (declaration.url_github) {
|
|
6
|
+
entries.push({
|
|
7
|
+
snippet: 'link',
|
|
8
|
+
props: {
|
|
9
|
+
href: declaration.url_github,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return entries;
|
|
14
|
+
};
|
package/dist/dialog.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComponentProps, Component } from 'svelte';
|
|
2
|
+
import type Dialog from './Dialog.svelte';
|
|
3
|
+
/**
|
|
4
|
+
* This helper function is needed to construct `DialogParams` with type safety.
|
|
5
|
+
* It uses TypeScript's inferred generics for functions,
|
|
6
|
+
* which do not work for plain objects as of v5.0.4.
|
|
7
|
+
* * `ContextmenuParams` uses a similar strategy.
|
|
8
|
+
*/
|
|
9
|
+
export declare const to_dialog_params: <T extends Component<any>>(Component: T, props: ComponentProps<T>, dialog_props?: Partial<ComponentProps<typeof Dialog>>) => DialogParams<T>;
|
|
10
|
+
/**
|
|
11
|
+
* This pattern is based on:
|
|
12
|
+
* https://github.com/ivanhofer/sveltekit-typescript-showcase/blob/main/src/01-props/09-svelte-component/Component.svelte
|
|
13
|
+
* The main limitation is that the generic cannot be inferred automatically,
|
|
14
|
+
* so we use `to_dialog_params` to construct instances in most cases.
|
|
15
|
+
* Definining `DialogParams` with no concrete `T` lacks typechecking for `props`.
|
|
16
|
+
*/
|
|
17
|
+
export interface DialogParams<T extends Component<any> = Component<any>> {
|
|
18
|
+
Component: T;
|
|
19
|
+
props: ComponentProps<T>;
|
|
20
|
+
dialog_props?: Partial<ComponentProps<typeof Dialog>> | undefined;
|
|
21
|
+
}
|
|
22
|
+
export type DialogLayout = 'centered' | 'page';
|
|
23
|
+
export declare const dialog_layouts: Array<DialogLayout>;
|
|
24
|
+
//# sourceMappingURL=dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAE,SAAS,EAAC,MAAM,QAAQ,CAAC;AAEtD,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EACxD,WAAW,CAAC,EACZ,OAAO,cAAc,CAAC,CAAC,CAAC,EACxB,eAAe,OAAO,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC,KACnD,YAAY,CAAC,CAAC,CAIf,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC;IACtE,SAAS,EAAE,CAAC,CAAC;IACb,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CAClE;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC;AAC/C,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,YAAY,CAAwB,CAAC"}
|
package/dist/dialog.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This helper function is needed to construct `DialogParams` with type safety.
|
|
3
|
+
* It uses TypeScript's inferred generics for functions,
|
|
4
|
+
* which do not work for plain objects as of v5.0.4.
|
|
5
|
+
* * `ContextmenuParams` uses a similar strategy.
|
|
6
|
+
*/
|
|
7
|
+
export const to_dialog_params = (Component, props, dialog_props) => ({
|
|
8
|
+
Component,
|
|
9
|
+
props,
|
|
10
|
+
dialog_props,
|
|
11
|
+
});
|
|
12
|
+
export const dialog_layouts = ['centered', 'page'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimensions.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/dimensions.svelte.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACtB,KAAK,EAAE,MAAM,CAAa;IAC1B,MAAM,EAAE,MAAM,CAAa;CAC3B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a string to a URL-safe fragment identifier, preserving case for API declarations.
|
|
4
|
+
* Only transforms spaces and special characters, keeping valid identifier characters intact.
|
|
5
|
+
* Used for hash anchors in documentation.
|
|
6
|
+
* @param str - The string to convert to a fragment
|
|
7
|
+
* @returns A URL-safe fragment identifier
|
|
8
|
+
*/
|
|
9
|
+
export declare const docs_slugify: (str: string) => string;
|
|
10
|
+
export declare const DOCS_PATH_DEFAULT = "/docs";
|
|
11
|
+
export declare const DOCS_PATH: string;
|
|
12
|
+
export declare const DOCS_API_PATH: string;
|
|
13
|
+
export declare const to_docs_path_info: (path_slug: string, pathname: string, root_path?: string) => {
|
|
14
|
+
path: string;
|
|
15
|
+
path_is_selected: boolean;
|
|
16
|
+
path_segment: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
export declare const docs_links_context: {
|
|
19
|
+
get: (error_message?: string) => DocsLinks;
|
|
20
|
+
get_maybe: () => DocsLinks | undefined;
|
|
21
|
+
set: (value: DocsLinks) => DocsLinks;
|
|
22
|
+
};
|
|
23
|
+
export type DocsLinkTag = 'h2' | 'h3' | 'h4';
|
|
24
|
+
export interface DocsLinkInfo {
|
|
25
|
+
id: string;
|
|
26
|
+
text: string;
|
|
27
|
+
fragment: string;
|
|
28
|
+
tag: DocsLinkTag | undefined;
|
|
29
|
+
depth: number;
|
|
30
|
+
order: number;
|
|
31
|
+
parent_id: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
export declare class DocsLinks {
|
|
34
|
+
#private;
|
|
35
|
+
readonly root_path: string;
|
|
36
|
+
readonly links: SvelteMap<string, DocsLinkInfo>;
|
|
37
|
+
docs_links: DocsLinkInfo[];
|
|
38
|
+
readonly fragments_onscreen: SvelteSet<string>;
|
|
39
|
+
constructor(root_path?: string);
|
|
40
|
+
add(fragment: string, text: string, pathname: string, tag?: DocsLinkTag, depth?: number, parent_id?: string, explicit_id?: string): string;
|
|
41
|
+
remove(id: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Generate a unique section ID for the current page render.
|
|
44
|
+
* This counter is instance-scoped, ensuring SSR/client consistency.
|
|
45
|
+
*/
|
|
46
|
+
generate_section_id(): string;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=docs_helpers.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs_helpers.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/docs_helpers.svelte.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAKvD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,MAY1C,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAU,CAAC;AACzC,eAAO,MAAM,SAAS,QAAmB,CAAC;AAC1C,eAAO,MAAM,aAAa,QAAqB,CAAC;AAEhD,eAAO,MAAM,iBAAiB,GAC7B,WAAW,MAAM,EACjB,UAAU,MAAM,EAChB,kBAA6B,KAC3B;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;CAK5E,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;CAA8B,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE7C,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,WAAW,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED,qBAAa,SAAS;;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAmB;IAgBlE,UAAU,iBA4BP;IAEH,QAAQ,CAAC,kBAAkB,EAAE,SAAS,CAAC,MAAM,CAAC,CAAmB;gBAErD,SAAS,SAAoB;IAIzC,GAAG,CACF,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,WAAW,EACjB,KAAK,SAAI,EACT,SAAS,CAAC,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GAClB,MAAM;IAkBT,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIxB;;;OAGG;IACH,mBAAmB,IAAI,MAAM;CAG7B"}
|