@threadlabs/looma 0.51.5 → 0.52.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/README.md +4 -4
- package/components/shared/overlay.js +7 -2
- package/components/ui-breadcrumb-item/ui-breadcrumb-item.html +1 -0
- package/components/ui-calendar/ui-calendar.js +11 -7
- package/components/ui-card/ui-card.html +7 -0
- package/components/ui-date-field/ui-date-field.js +0 -5
- package/components/ui-disclosure/ui-disclosure.js +19 -4
- package/components/ui-editor-link-form/ui-editor-link-form.js +5 -0
- package/components/ui-editor-mention-menu-item/ui-editor-mention-menu-item.html +2 -3
- package/components/ui-editor-table-context-menu/ui-editor-table-context-menu.html +10 -1
- package/components/ui-file-input/ui-file-input.js +0 -2
- package/components/ui-status-message/ui-status-message.html +1 -0
- package/components/ui-tabs/ui-tabs.html +1 -0
- package/components/ui-tooltip/ui-tooltip.html +11 -32
- package/dist/index.js +14 -8
- package/docs/catalog.json +592 -131
- package/editor/components.css +530 -551
- package/editor/index.js +72 -47
- package/package.json +30 -35
- package/styles/ui-action-bar.css +8 -8
- package/styles/ui-affordance-scope.css +10 -10
- package/styles/ui-avatar-group.css +11 -11
- package/styles/ui-avatar.css +14 -14
- package/styles/ui-badge.css +67 -67
- package/styles/ui-breadcrumb-item.css +10 -10
- package/styles/ui-breadcrumbs.css +8 -8
- package/styles/ui-button.css +99 -99
- package/styles/ui-calendar.css +1 -1
- package/styles/ui-callout.css +14 -14
- package/styles/ui-card-group.css +11 -11
- package/styles/ui-card.css +40 -35
- package/styles/ui-checkbox.css +28 -28
- package/styles/ui-cluster.css +30 -30
- package/styles/ui-color-picker.css +16 -16
- package/styles/ui-combobox.css +50 -50
- package/styles/ui-compact-content.css +1 -1
- package/styles/ui-compact-editor.css +1 -1
- package/styles/ui-compact-mark.css +1 -1
- package/styles/ui-compact-node.css +1 -1
- package/styles/ui-container.css +14 -14
- package/styles/ui-context-menu.css +8 -8
- package/styles/ui-cover.css +9 -9
- package/styles/ui-curve-editor.css +9 -9
- package/styles/ui-cycle-button.css +10 -10
- package/styles/ui-date-field.css +1 -1
- package/styles/ui-date-picker.css +1 -1
- package/styles/ui-date-range-picker.css +1 -1
- package/styles/ui-description-item.css +8 -8
- package/styles/ui-description-list.css +18 -18
- package/styles/ui-dialog.css +37 -37
- package/styles/ui-disclosure.css +26 -26
- package/styles/ui-editable.css +13 -13
- package/styles/ui-editor-block-actions.css +1 -1
- package/styles/ui-editor-chip-editor.css +1 -1
- package/styles/ui-editor-code-language.css +1 -1
- package/styles/ui-editor-footnote-editor.css +1 -1
- package/styles/ui-editor-formatting-tools.css +1 -1
- package/styles/ui-editor-image-toolbar.css +1 -1
- package/styles/ui-editor-insert-table-grid.css +9 -9
- package/styles/ui-editor-link-card.css +1 -1
- package/styles/ui-editor-link-form.css +1 -1
- package/styles/ui-editor-mention-menu-item.css +13 -15
- package/styles/ui-editor-mention-menu.css +12 -12
- package/styles/ui-editor-slash-menu-group.css +7 -7
- package/styles/ui-editor-slash-menu-item.css +12 -12
- package/styles/ui-editor-slash-menu.css +13 -13
- package/styles/ui-editor-surface.css +8 -8
- package/styles/ui-editor-table-context-menu.css +19 -15
- package/styles/ui-editor-table-overlay.css +15 -15
- package/styles/ui-editor-table-toolbar.css +19 -19
- package/styles/ui-editor-toolbar.css +16 -16
- package/styles/ui-editor.css +1 -1
- package/styles/ui-file-input.css +1 -1
- package/styles/ui-floating-action-button.css +14 -14
- package/styles/ui-form-field.css +9 -9
- package/styles/ui-grid.css +19 -19
- package/styles/ui-icon-button.css +73 -73
- package/styles/ui-icon.css +11 -11
- package/styles/ui-image.css +23 -23
- package/styles/ui-input-group.css +26 -26
- package/styles/ui-input.css +23 -23
- package/styles/ui-light-editor.css +15 -15
- package/styles/ui-list-item.css +25 -25
- package/styles/ui-list.css +16 -16
- package/styles/ui-listbox.css +22 -22
- package/styles/ui-menu-group.css +7 -7
- package/styles/ui-menu-item.css +20 -20
- package/styles/ui-menu.css +20 -20
- package/styles/ui-meter.css +32 -32
- package/styles/ui-nav-item.css +18 -18
- package/styles/ui-number-input.css +12 -12
- package/styles/ui-page-header.css +10 -10
- package/styles/ui-pagination.css +1 -1
- package/styles/ui-popover.css +17 -17
- package/styles/ui-radio-group.css +10 -10
- package/styles/ui-radio.css +25 -25
- package/styles/ui-reel.css +21 -21
- package/styles/ui-scroll-area.css +20 -20
- package/styles/ui-search-result-row.css +16 -16
- package/styles/ui-search-shell.css +10 -10
- package/styles/ui-section.css +18 -18
- package/styles/ui-select.css +22 -22
- package/styles/ui-separator.css +12 -12
- package/styles/ui-sidebar.css +26 -26
- package/styles/ui-site-header.css +65 -65
- package/styles/ui-skeleton.css +18 -18
- package/styles/ui-slider.css +11 -11
- package/styles/ui-spinner.css +9 -9
- package/styles/ui-stack.css +22 -22
- package/styles/ui-status-message.css +12 -12
- package/styles/ui-swatch.css +14 -14
- package/styles/ui-switch.css +23 -23
- package/styles/ui-switcher.css +20 -20
- package/styles/ui-table.css +12 -12
- package/styles/ui-tabs.css +18 -17
- package/styles/ui-text.css +40 -40
- package/styles/ui-textarea.css +21 -21
- package/styles/ui-time-field.css +1 -1
- package/styles/ui-time-picker.css +1 -1
- package/styles/ui-toast-region.css +29 -29
- package/styles/ui-toast.css +19 -19
- package/styles/ui-tooltip.css +37 -58
- package/styles/ui-top-bar.css +8 -8
- package/styles/ui-tree-item.css +112 -112
- package/styles/ui-tree.css +11 -11
- package/vanilla/UiActionBar.d.ts +1 -1
- package/vanilla/UiActionBar.js +2 -2
- package/vanilla/UiAffordanceScope.d.ts +1 -1
- package/vanilla/UiAffordanceScope.js +2 -2
- package/vanilla/UiAvatar.d.ts +1 -1
- package/vanilla/UiAvatar.js +2 -2
- package/vanilla/UiAvatarGroup.d.ts +1 -1
- package/vanilla/UiAvatarGroup.js +2 -2
- package/vanilla/UiBadge.d.ts +1 -1
- package/vanilla/UiBadge.js +2 -2
- package/vanilla/UiBreadcrumbItem.d.ts +1 -1
- package/vanilla/UiBreadcrumbItem.js +2 -2
- package/vanilla/UiBreadcrumbs.d.ts +1 -1
- package/vanilla/UiBreadcrumbs.js +2 -2
- package/vanilla/UiButton.d.ts +1 -1
- package/vanilla/UiButton.js +5 -5
- package/vanilla/UiCalendar.d.ts +1 -1
- package/vanilla/UiCalendar.js +10 -10
- package/vanilla/UiCallout.d.ts +1 -1
- package/vanilla/UiCallout.js +2 -2
- package/vanilla/UiCard.d.ts +2 -1
- package/vanilla/UiCard.js +18 -18
- package/vanilla/UiCardGroup.d.ts +1 -1
- package/vanilla/UiCardGroup.js +2 -2
- package/vanilla/UiCheckbox.d.ts +1 -1
- package/vanilla/UiCheckbox.js +2 -2
- package/vanilla/UiCluster.d.ts +1 -1
- package/vanilla/UiCluster.js +2 -2
- package/vanilla/UiColorPicker.d.ts +1 -1
- package/vanilla/UiColorPicker.js +2 -2
- package/vanilla/UiCombobox.d.ts +1 -1
- package/vanilla/UiCombobox.js +8 -8
- package/vanilla/UiCompactContent.d.ts +1 -1
- package/vanilla/UiCompactContent.js +4 -4
- package/vanilla/UiCompactEditor.d.ts +1 -1
- package/vanilla/UiCompactEditor.js +2 -2
- package/vanilla/UiCompactMark.d.ts +1 -1
- package/vanilla/UiCompactMark.js +5 -5
- package/vanilla/UiCompactNode.d.ts +1 -1
- package/vanilla/UiCompactNode.js +8 -8
- package/vanilla/UiContainer.d.ts +1 -1
- package/vanilla/UiContainer.js +2 -2
- package/vanilla/UiContextMenu.d.ts +1 -1
- package/vanilla/UiContextMenu.js +2 -2
- package/vanilla/UiCover.d.ts +1 -1
- package/vanilla/UiCover.js +2 -2
- package/vanilla/UiCurveEditor.d.ts +1 -1
- package/vanilla/UiCurveEditor.js +2 -2
- package/vanilla/UiCycleButton.d.ts +1 -1
- package/vanilla/UiCycleButton.js +2 -2
- package/vanilla/UiDateField.d.ts +1 -1
- package/vanilla/UiDateField.js +2 -2
- package/vanilla/UiDatePicker.d.ts +1 -1
- package/vanilla/UiDatePicker.js +2 -2
- package/vanilla/UiDateRangePicker.d.ts +1 -1
- package/vanilla/UiDateRangePicker.js +4 -4
- package/vanilla/UiDescriptionItem.d.ts +1 -1
- package/vanilla/UiDescriptionItem.js +2 -2
- package/vanilla/UiDescriptionList.d.ts +1 -1
- package/vanilla/UiDescriptionList.js +2 -2
- package/vanilla/UiDialog.d.ts +1 -1
- package/vanilla/UiDialog.js +2 -2
- package/vanilla/UiDisclosure.d.ts +1 -1
- package/vanilla/UiDisclosure.js +2 -2
- package/vanilla/UiEditable.d.ts +1 -1
- package/vanilla/UiEditable.js +2 -2
- package/vanilla/UiEditor.d.ts +1 -1
- package/vanilla/UiEditor.js +6 -6
- package/vanilla/UiEditorBlockActions.d.ts +1 -1
- package/vanilla/UiEditorBlockActions.js +2 -2
- package/vanilla/UiEditorChipEditor.d.ts +1 -1
- package/vanilla/UiEditorChipEditor.js +2 -2
- package/vanilla/UiEditorCodeLanguage.d.ts +1 -1
- package/vanilla/UiEditorCodeLanguage.js +4 -4
- package/vanilla/UiEditorFootnoteEditor.d.ts +1 -1
- package/vanilla/UiEditorFootnoteEditor.js +2 -2
- package/vanilla/UiEditorFormattingTools.d.ts +1 -1
- package/vanilla/UiEditorFormattingTools.js +4 -4
- package/vanilla/UiEditorImageToolbar.d.ts +1 -1
- package/vanilla/UiEditorImageToolbar.js +2 -2
- package/vanilla/UiEditorInsertTableGrid.d.ts +1 -1
- package/vanilla/UiEditorInsertTableGrid.js +4 -4
- package/vanilla/UiEditorLinkCard.d.ts +1 -1
- package/vanilla/UiEditorLinkCard.js +2 -2
- package/vanilla/UiEditorLinkForm.d.ts +1 -1
- package/vanilla/UiEditorLinkForm.js +4 -4
- package/vanilla/UiEditorMentionMenu.d.ts +1 -1
- package/vanilla/UiEditorMentionMenu.js +4 -4
- package/vanilla/UiEditorMentionMenuItem.d.ts +1 -1
- package/vanilla/UiEditorMentionMenuItem.js +2 -2
- package/vanilla/UiEditorSlashMenu.d.ts +1 -1
- package/vanilla/UiEditorSlashMenu.js +4 -4
- package/vanilla/UiEditorSlashMenuGroup.d.ts +1 -1
- package/vanilla/UiEditorSlashMenuGroup.js +2 -2
- package/vanilla/UiEditorSlashMenuItem.d.ts +1 -1
- package/vanilla/UiEditorSlashMenuItem.js +2 -2
- package/vanilla/UiEditorSurface.d.ts +1 -1
- package/vanilla/UiEditorSurface.js +2 -2
- package/vanilla/UiEditorTableContextMenu.d.ts +1 -1
- package/vanilla/UiEditorTableContextMenu.js +7 -6
- package/vanilla/UiEditorTableOverlay.d.ts +1 -1
- package/vanilla/UiEditorTableOverlay.js +5 -5
- package/vanilla/UiEditorTableToolbar.d.ts +1 -1
- package/vanilla/UiEditorTableToolbar.js +8 -8
- package/vanilla/UiEditorToolbar.d.ts +1 -1
- package/vanilla/UiEditorToolbar.js +2 -2
- package/vanilla/UiFileInput.d.ts +1 -1
- package/vanilla/UiFileInput.js +4 -4
- package/vanilla/UiFloatingActionButton.d.ts +1 -1
- package/vanilla/UiFloatingActionButton.js +2 -2
- package/vanilla/UiFormField.d.ts +1 -1
- package/vanilla/UiFormField.js +2 -2
- package/vanilla/UiGrid.d.ts +1 -1
- package/vanilla/UiGrid.js +4 -4
- package/vanilla/UiIcon.d.ts +1 -1
- package/vanilla/UiIcon.js +4 -4
- package/vanilla/UiIconButton.d.ts +1 -1
- package/vanilla/UiIconButton.js +2 -2
- package/vanilla/UiImage.d.ts +1 -1
- package/vanilla/UiImage.js +2 -2
- package/vanilla/UiInput.d.ts +1 -1
- package/vanilla/UiInput.js +2 -2
- package/vanilla/UiInputGroup.d.ts +1 -1
- package/vanilla/UiInputGroup.js +2 -2
- package/vanilla/UiLightEditor.d.ts +1 -1
- package/vanilla/UiLightEditor.js +2 -2
- package/vanilla/UiList.d.ts +1 -1
- package/vanilla/UiList.js +3 -3
- package/vanilla/UiListItem.d.ts +1 -1
- package/vanilla/UiListItem.js +2 -2
- package/vanilla/UiListbox.d.ts +1 -1
- package/vanilla/UiListbox.js +5 -5
- package/vanilla/UiMenu.d.ts +1 -1
- package/vanilla/UiMenu.js +2 -2
- package/vanilla/UiMenuGroup.d.ts +1 -1
- package/vanilla/UiMenuGroup.js +2 -2
- package/vanilla/UiMenuItem.d.ts +1 -1
- package/vanilla/UiMenuItem.js +3 -3
- package/vanilla/UiMeter.d.ts +1 -1
- package/vanilla/UiMeter.js +4 -4
- package/vanilla/UiNavItem.d.ts +1 -1
- package/vanilla/UiNavItem.js +3 -3
- package/vanilla/UiNumberInput.d.ts +1 -1
- package/vanilla/UiNumberInput.js +2 -2
- package/vanilla/UiPageHeader.d.ts +1 -1
- package/vanilla/UiPageHeader.js +2 -2
- package/vanilla/UiPagination.d.ts +1 -1
- package/vanilla/UiPagination.js +4 -4
- package/vanilla/UiPopover.d.ts +1 -1
- package/vanilla/UiPopover.js +2 -2
- package/vanilla/UiRadio.d.ts +1 -1
- package/vanilla/UiRadio.js +2 -2
- package/vanilla/UiRadioGroup.d.ts +1 -1
- package/vanilla/UiRadioGroup.js +2 -2
- package/vanilla/UiReel.d.ts +1 -1
- package/vanilla/UiReel.js +2 -2
- package/vanilla/UiScrollArea.d.ts +1 -1
- package/vanilla/UiScrollArea.js +2 -2
- package/vanilla/UiSearchResultRow.d.ts +1 -1
- package/vanilla/UiSearchResultRow.js +2 -2
- package/vanilla/UiSearchShell.d.ts +1 -1
- package/vanilla/UiSearchShell.js +2 -2
- package/vanilla/UiSection.d.ts +1 -1
- package/vanilla/UiSection.js +3 -3
- package/vanilla/UiSelect.d.ts +1 -1
- package/vanilla/UiSelect.js +2 -2
- package/vanilla/UiSeparator.d.ts +1 -1
- package/vanilla/UiSeparator.js +2 -2
- package/vanilla/UiSidebar.d.ts +1 -1
- package/vanilla/UiSidebar.js +2 -2
- package/vanilla/UiSiteHeader.d.ts +1 -1
- package/vanilla/UiSiteHeader.js +2 -2
- package/vanilla/UiSkeleton.d.ts +1 -1
- package/vanilla/UiSkeleton.js +2 -2
- package/vanilla/UiSlider.d.ts +1 -1
- package/vanilla/UiSlider.js +2 -2
- package/vanilla/UiSpinner.d.ts +1 -1
- package/vanilla/UiSpinner.js +2 -2
- package/vanilla/UiStack.d.ts +1 -1
- package/vanilla/UiStack.js +2 -2
- package/vanilla/UiStatusMessage.d.ts +1 -1
- package/vanilla/UiStatusMessage.js +2 -2
- package/vanilla/UiSwatch.d.ts +1 -1
- package/vanilla/UiSwatch.js +2 -2
- package/vanilla/UiSwitch.d.ts +1 -1
- package/vanilla/UiSwitch.js +2 -2
- package/vanilla/UiSwitcher.d.ts +1 -1
- package/vanilla/UiSwitcher.js +2 -2
- package/vanilla/UiTable.d.ts +1 -1
- package/vanilla/UiTable.js +2 -2
- package/vanilla/UiTabs.d.ts +1 -1
- package/vanilla/UiTabs.js +4 -4
- package/vanilla/UiText.d.ts +1 -1
- package/vanilla/UiText.js +13 -13
- package/vanilla/UiTextarea.d.ts +1 -1
- package/vanilla/UiTextarea.js +2 -2
- package/vanilla/UiTimeField.d.ts +1 -1
- package/vanilla/UiTimeField.js +2 -2
- package/vanilla/UiTimePicker.d.ts +1 -1
- package/vanilla/UiTimePicker.js +6 -6
- package/vanilla/UiToast.d.ts +1 -1
- package/vanilla/UiToast.js +2 -2
- package/vanilla/UiToastRegion.d.ts +1 -1
- package/vanilla/UiToastRegion.js +4 -4
- package/vanilla/UiTooltip.d.ts +1 -1
- package/vanilla/UiTooltip.js +2 -2
- package/vanilla/UiTopBar.d.ts +1 -1
- package/vanilla/UiTopBar.js +2 -2
- package/vanilla/UiTree.d.ts +1 -1
- package/vanilla/UiTree.js +2 -2
- package/vanilla/UiTreeItem.d.ts +1 -1
- package/vanilla/UiTreeItem.js +2 -2
- package/bin/looma-docs.mjs +0 -3
- package/docs/README.md +0 -323
- package/docs/card.html +0 -79
- package/docs/card.js +0 -18
- package/docs/catalog-view.js +0 -24
- package/docs/catalog-view.mjs +0 -13
- package/docs/catalog.mjs +0 -131
- package/docs/cli.mjs +0 -26
- package/docs/commands.mjs +0 -94
- package/docs/customizer-render.mjs +0 -157
- package/docs/customizer.js +0 -494
- package/docs/documentation.css +0 -14
- package/docs/example-invocations.mjs +0 -63
- package/docs/fonts.mjs +0 -73
- package/docs/framework-examples.d.mts +0 -9
- package/docs/framework-examples.mjs +0 -195
- package/docs/index.d.ts +0 -59
- package/docs/index.mjs +0 -4
- package/docs/local-server.mjs +0 -65
- package/docs/navigation.mjs +0 -26
- package/docs/palette.mjs +0 -68
- package/docs/pastoral.svg +0 -54
- package/docs/portrait.svg +0 -15
- package/docs/reference.html +0 -1
- package/docs/reference.js +0 -36
- package/docs/render.mjs +0 -97
- package/docs/site.mjs +0 -237
- package/docs/store.mjs +0 -92
- package/docs/theme-session.mjs +0 -72
- package/docs/theme.mjs +0 -669
- package/docs/value-editors.mjs +0 -37
- package/docs/workspace.mjs +0 -32
package/docs/fonts.mjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/** A focused searchable Google Fonts collection; system fonts never require a request. */
|
|
2
|
-
export const googleFonts = Object.fromEntries([
|
|
3
|
-
['Inter', 'sans-serif'], ['Roboto', 'sans-serif'], ['Open Sans', 'sans-serif'],
|
|
4
|
-
['Source Sans 3', 'sans-serif'], ['Lato', 'sans-serif'], ['Nunito Sans', 'sans-serif'],
|
|
5
|
-
['DM Sans', 'sans-serif'], ['Manrope', 'sans-serif'], ['Work Sans', 'sans-serif'],
|
|
6
|
-
['IBM Plex Sans', 'sans-serif'], ['Public Sans', 'sans-serif'], ['Atkinson Hyperlegible', 'sans-serif'],
|
|
7
|
-
['Outfit', 'sans-serif'], ['Fraunces', 'serif'], ['Merriweather', 'serif'], ['Lora', 'serif'],
|
|
8
|
-
['Source Serif 4', 'serif'], ['Newsreader', 'serif'], ['Libre Baskerville', 'serif'], ['Crimson Pro', 'serif'],
|
|
9
|
-
['EB Garamond', 'serif'], ['Playfair Display', 'serif'], ['Roboto Mono', 'monospace'],
|
|
10
|
-
['IBM Plex Mono', 'monospace'], ['JetBrains Mono', 'monospace'], ['Fira Code', 'monospace'],
|
|
11
|
-
].map(([family, category]) => [family, { family, category, weights: ['Lato', 'Atkinson Hyperlegible', 'Libre Baskerville'].includes(family) ? '400;700' : '400;500;600;700' }]));
|
|
12
|
-
|
|
13
|
-
export const systemFont = 'system-ui, sans-serif';
|
|
14
|
-
export const googleFontStack = family => `"${family}", ${googleFonts[family].category}`;
|
|
15
|
-
export function googleFontURL(fonts = {}) {
|
|
16
|
-
const families = [...new Set(Object.values(fonts))].sort();
|
|
17
|
-
if (!families.length) return '';
|
|
18
|
-
return 'https://fonts.googleapis.com/css2?' + families.map(family => {
|
|
19
|
-
if (!Object.hasOwn(googleFonts, family)) throw new Error('Choose a supported Google font.');
|
|
20
|
-
return 'family=' + encodeURIComponent(family).replaceAll('%20', '+') + ':wght@' + googleFonts[family].weights;
|
|
21
|
-
}).join('&') + '&display=swap';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Load and confirm actual faces before reporting a selected font as ready. */
|
|
25
|
-
const fontLoads = new WeakMap();
|
|
26
|
-
export async function loadGoogleFonts(document, fonts) {
|
|
27
|
-
const url = googleFontURL(fonts);
|
|
28
|
-
let link = document.head.querySelector('link[data-looma-google-fonts]');
|
|
29
|
-
if (!url) { fontLoads.get(link)?.cancel(); link?.remove(); return; }
|
|
30
|
-
if (link?.href !== url) {
|
|
31
|
-
fontLoads.get(link)?.cancel(); link?.remove(); link = document.createElement('link');
|
|
32
|
-
link.rel = 'stylesheet'; link.dataset.loomaGoogleFonts = '';
|
|
33
|
-
let cancel;
|
|
34
|
-
const loaded = new Promise((resolve, reject) => {
|
|
35
|
-
cancel = () => resolve(false);
|
|
36
|
-
link.onload = () => resolve(true); link.onerror = () => reject(new Error('The Google font could not load. Check your connection or select the system font.'));
|
|
37
|
-
});
|
|
38
|
-
fontLoads.set(link, { loaded, cancel }); link.href = url; document.head.append(link);
|
|
39
|
-
}
|
|
40
|
-
if (await fontLoads.get(link)?.loaded === false) return;
|
|
41
|
-
for (const family of new Set(Object.values(fonts))) {
|
|
42
|
-
const faces = await document.fonts.load(`400 16px "${family}"`);
|
|
43
|
-
if (!faces.length) throw new Error(`${family} is unavailable; the fallback is currently displayed.`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** Request only a font name's glyphs; selected fonts use the unrestricted stylesheet above. */
|
|
48
|
-
export function googleFontPreviewURL(family) {
|
|
49
|
-
if (!Object.hasOwn(googleFonts, family)) throw new Error('Choose a supported Google font.');
|
|
50
|
-
return 'https://fonts.googleapis.com/css2?family=' + encodeURIComponent(family).replaceAll('%20', '+') + ':wght@400&display=swap&text=' + encodeURIComponent(family);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const previewLoads = new WeakMap();
|
|
54
|
-
/** Isolate subset faces under aliases so document typography always uses full selected fonts. */
|
|
55
|
-
export function loadGoogleFontPreview(document, family) {
|
|
56
|
-
let loads = previewLoads.get(document);
|
|
57
|
-
if (!loads) { loads = new Map(); previewLoads.set(document, loads); }
|
|
58
|
-
if (!loads.has(family)) {
|
|
59
|
-
const loaded = (async () => {
|
|
60
|
-
const response = await document.defaultView.fetch(googleFontPreviewURL(family));
|
|
61
|
-
if (!response.ok) throw new Error('Font preview unavailable.');
|
|
62
|
-
const source = (await response.text()).match(/src\s*:\s*([^;]+);/)?.[1];
|
|
63
|
-
if (!source) throw new Error('Font preview unavailable.');
|
|
64
|
-
const alias = `Looma Font Preview ${family}`;
|
|
65
|
-
const face = new document.defaultView.FontFace(alias, source, { weight: '400', style: 'normal', display: 'swap' });
|
|
66
|
-
await face.load(); document.fonts.add(face);
|
|
67
|
-
return alias;
|
|
68
|
-
})();
|
|
69
|
-
loads.set(family, loaded);
|
|
70
|
-
loaded.catch(() => { if (loads.get(family) === loaded) loads.delete(family); });
|
|
71
|
-
}
|
|
72
|
-
return loads.get(family);
|
|
73
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TypeNode } from '@nextwebwg/html-next';
|
|
2
|
-
|
|
3
|
-
export type Framework = 'html-next' | 'vue' | 'react' | 'svelte';
|
|
4
|
-
export interface FrameworkExample { language: 'html' | 'vue' | 'tsx' | 'svelte'; code: string; }
|
|
5
|
-
export const frameworkLabels: Readonly<Record<Framework, string>>;
|
|
6
|
-
export function frameworkExamples(
|
|
7
|
-
example: { markup: string; frameworks?: Partial<Record<Framework, FrameworkExample>> },
|
|
8
|
-
components: readonly { tag: string; package: string; root?: string; resource?: string; importSource?: string; attributes?: readonly { name: string; property?: string; type?: string; valueType?: TypeNode }[] }[],
|
|
9
|
-
): Record<Framework, FrameworkExample>;
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { camel, componentName, exampleInvocations, nativeBooleans } from './example-invocations.mjs';
|
|
2
|
-
|
|
3
|
-
const escapeHtml = value => String(value).replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
4
|
-
const indent = depth => ' '.repeat(depth);
|
|
5
|
-
const textValue = node => node.preserve ? node.value : node.value.replace(/[\t\n\r\f ]+/g, ' ');
|
|
6
|
-
const formattingSpace = node => node?.kind === 'text' && !node.preserve && /^[\t\n\r\f ]*$/.test(node.value);
|
|
7
|
-
const key = (value, quote = JSON.stringify) => /^[a-zA-Z_$][\w$]*$/.test(value) ? value : quote(value);
|
|
8
|
-
const singleQuoted = value => `'${JSON.stringify(value).slice(1, -1).replaceAll('\\"', '"').replaceAll("'", "\\'")}'`;
|
|
9
|
-
const kebab = value => value.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
|
|
10
|
-
const voidElements = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
|
|
11
|
-
const reactAttributes = { class: 'className', for: 'htmlFor', readonly: 'readOnly', tabindex: 'tabIndex', autofocus: 'autoFocus', maxlength: 'maxLength', minlength: 'minLength', colspan: 'colSpan', rowspan: 'rowSpan', srcset: 'srcSet', crossorigin: 'crossOrigin', spellcheck: 'spellCheck', contenteditable: 'contentEditable', allowfullscreen: 'allowFullScreen', formnovalidate: 'formNoValidate', novalidate: 'noValidate', playsinline: 'playsInline' };
|
|
12
|
-
const numericAttributes = new Set(['cols', 'rows', 'size', 'span', 'rowSpan', 'colSpan', 'tabIndex', 'maxLength', 'minLength', 'start']);
|
|
13
|
-
const inlineElements = new Set('a abbr b bdi bdo br button cite code del em i img input ins kbd label mark q s samp small span strong sub sup time u var wbr'.split(' '));
|
|
14
|
-
const reserved = new Set('await break case catch class const continue debugger default delete do else enum export extends false finally for function if implements import in instanceof interface let new null package private protected public return static super switch this throw true try typeof var void while with yield arguments eval'.split(' '));
|
|
15
|
-
|
|
16
|
-
export const frameworkLabels = { 'html-next': 'HTML Next', vue: 'Vue', react: 'React', svelte: 'Svelte' };
|
|
17
|
-
|
|
18
|
-
function vueExpression(value) {
|
|
19
|
-
if (typeof value === 'string') return singleQuoted(value);
|
|
20
|
-
if (Array.isArray(value)) return `[${value.map(vueExpression).join(', ')}]`;
|
|
21
|
-
if (value && typeof value === 'object') {
|
|
22
|
-
const fields = Object.entries(value).map(([name, item]) => `${key(name, singleQuoted)}: ${vueExpression(item)}`);
|
|
23
|
-
return fields.length ? `{ ${fields.join(', ')} }` : '{}';
|
|
24
|
-
}
|
|
25
|
-
return JSON.stringify(value);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Derive block layout from the tree. Mixed text and inline adjacency stay together.
|
|
29
|
-
function layout(nodes, owner) {
|
|
30
|
-
const structural = nodes.some(node => node.kind === 'slot' || node.kind === 'element' && (node.component || !inlineElements.has(node.tag)));
|
|
31
|
-
const labels = nodes.filter(node => node.kind === 'text' && !formattingSpace(node));
|
|
32
|
-
const namedSlot = node => node.kind === 'element' && node.attributes.some(attribute => attribute.name === 'slot' && attribute.value);
|
|
33
|
-
const slottedLabel = owner?.tag.includes('-') && labels.length === 1 && !labels[0].preserve
|
|
34
|
-
&& nodes.some(namedSlot) && nodes.every(node => node.kind !== 'element' || namedSlot(node));
|
|
35
|
-
const multiline = slottedLabel || structural
|
|
36
|
-
&& !nodes.some(node => node.kind === 'text' && !formattingSpace(node));
|
|
37
|
-
if (!multiline) return { multiline, nodes };
|
|
38
|
-
const displayed = nodes.filter(node => !formattingSpace(node)).map(node => {
|
|
39
|
-
if (!slottedLabel || node.kind !== 'text') return node;
|
|
40
|
-
return { ...node, value: node.value.replace(/^[\t\n\r\f ]+|[\t\n\r\f ]+$/g, '') };
|
|
41
|
-
});
|
|
42
|
-
return { multiline, nodes: displayed };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function text(node, target) {
|
|
46
|
-
const value = textValue(node);
|
|
47
|
-
if (target === 'html-next') return escapeHtml(value);
|
|
48
|
-
if (target === 'react') {
|
|
49
|
-
if (node.preserve || /[\n\r\t]/.test(node.value)) {
|
|
50
|
-
return `{${JSON.stringify(value)}}`;
|
|
51
|
-
}
|
|
52
|
-
return escapeHtml(value).replace(/[{}]/g, char => `{${JSON.stringify(char)}}`);
|
|
53
|
-
}
|
|
54
|
-
const escaped = escapeHtml(value);
|
|
55
|
-
return target === 'svelte' ? escaped.replaceAll('{', "{'{'}") : escaped.replaceAll('{', '{');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function attribute(value, target, component) {
|
|
59
|
-
let name = value.property;
|
|
60
|
-
let data = value.value;
|
|
61
|
-
if (target === 'html-next') return data === true || data === '' ? name : `${name}="${escapeHtml(data)}"`;
|
|
62
|
-
if (target === 'react') {
|
|
63
|
-
name = reactAttributes[name] ?? name;
|
|
64
|
-
if (name === 'style') {
|
|
65
|
-
data = Object.fromEntries(String(data).split(';').filter(part => part.includes(':')).map(part => {
|
|
66
|
-
const at = part.indexOf(':');
|
|
67
|
-
const property = part.slice(0, at).trim();
|
|
68
|
-
return [property.startsWith('--') ? property : camel(property), part.slice(at + 1).trim()];
|
|
69
|
-
}));
|
|
70
|
-
} else if (!component && numericAttributes.has(name) && /^[-+]?\d+$/.test(data)) data = Number(data);
|
|
71
|
-
if (data === true) return name;
|
|
72
|
-
return typeof data === 'string' ? `${name}="${escapeHtml(data)}"` : `${name}={${JSON.stringify(data)}}`;
|
|
73
|
-
}
|
|
74
|
-
if (target === 'svelte') {
|
|
75
|
-
if (data === true) return name;
|
|
76
|
-
return typeof data === 'string' ? `${name}="${escapeHtml(data).replaceAll('{', '{')}"` : `${name}={${JSON.stringify(data)}}`;
|
|
77
|
-
}
|
|
78
|
-
name = component ? kebab(name) : value.name;
|
|
79
|
-
if (data === true && nativeBooleans.has(name) && !component) return name;
|
|
80
|
-
return typeof data === 'string' ? `${name}="${escapeHtml(data).replaceAll('{', '{')}"` : `:${name}="${escapeHtml(vueExpression(data))}"`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function snippetBindings(model) {
|
|
84
|
-
const taken = new Set([...reserved, ...model.components.map(component => componentName(component.tag))]);
|
|
85
|
-
const bindings = new Map();
|
|
86
|
-
function visit(nodes) {
|
|
87
|
-
for (const node of nodes) {
|
|
88
|
-
if (node.kind === 'slot') {
|
|
89
|
-
let base = camel(node.name.replace(/[^\w$-]/g, '-')).replace(/-/g, '');
|
|
90
|
-
if (!/^[a-zA-Z_$]/.test(base)) base = `slot${base}`;
|
|
91
|
-
if (reserved.has(base)) base += 'Content';
|
|
92
|
-
let name = base;
|
|
93
|
-
if (taken.has(name)) {
|
|
94
|
-
const owner = componentName(node.owner.tag).replace(/^Ui/, '');
|
|
95
|
-
base = owner[0].toLowerCase() + owner.slice(1) + base[0].toUpperCase() + base.slice(1);
|
|
96
|
-
name = base;
|
|
97
|
-
for (let index = 2; taken.has(name); index++) name = `${base}${index}`;
|
|
98
|
-
}
|
|
99
|
-
taken.add(name);
|
|
100
|
-
bindings.set(node, name);
|
|
101
|
-
}
|
|
102
|
-
if (node.children) visit(node.children);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
visit(model.nodes);
|
|
106
|
-
return bindings;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** Print the public invocation API, keeping framework-specific syntax out of the parsed model. */
|
|
110
|
-
function printer(model, target) {
|
|
111
|
-
const bindings = target === 'svelte' ? snippetBindings(model) : new Map();
|
|
112
|
-
|
|
113
|
-
function sequence(nodes, depth, forceLines = false, owner) {
|
|
114
|
-
const arranged = layout(nodes, owner);
|
|
115
|
-
const content = arranged.nodes.map(node => (arranged.multiline ? indent(depth) : '') + render(node, depth)).join(arranged.multiline ? '\n' : '');
|
|
116
|
-
return (forceLines && !arranged.multiline ? indent(depth) : '') + content;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function reactValue(nodes, depth) {
|
|
120
|
-
const content = [...nodes];
|
|
121
|
-
const boundaryIndentation = node => formattingSpace(node) && /[\n\r]/.test(node.value);
|
|
122
|
-
while (boundaryIndentation(content[0])) content.shift();
|
|
123
|
-
while (boundaryIndentation(content.at(-1))) content.pop();
|
|
124
|
-
const arranged = layout(content);
|
|
125
|
-
if (!arranged.nodes.length) return 'null';
|
|
126
|
-
if (arranged.nodes.length === 1) {
|
|
127
|
-
const node = arranged.nodes[0];
|
|
128
|
-
if (node.kind === 'text') return JSON.stringify(textValue(node));
|
|
129
|
-
if (node.kind === 'comment') return `null /*${node.value}*/`;
|
|
130
|
-
return render(node, depth);
|
|
131
|
-
}
|
|
132
|
-
return arranged.multiline
|
|
133
|
-
? `<>\n${sequence(content, depth + 1)}\n${indent(depth)}</>`
|
|
134
|
-
: `<>${sequence(content, depth)}</>`;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function render(node, depth) {
|
|
138
|
-
if (node.kind === 'text') return text(node, target);
|
|
139
|
-
if (node.kind === 'comment') return target === 'react' ? `{/*${node.value}*/}` : `<!--${node.value}-->`;
|
|
140
|
-
if (node.kind === 'slot') {
|
|
141
|
-
return `<template #${node.name}>\n${sequence(node.children, depth + 1, true)}\n${indent(depth)}</template>`;
|
|
142
|
-
}
|
|
143
|
-
const attrs = node.attributes.map(value => attribute(value, target, node.component));
|
|
144
|
-
if (node.slots.length && target === 'svelte') {
|
|
145
|
-
attrs.push(`slots={{ ${node.slots.map(slot => slot.name === bindings.get(slot) ? slot.name : `${key(slot.name)}: ${bindings.get(slot)}`).join(', ')} }}`);
|
|
146
|
-
}
|
|
147
|
-
if (node.slots.length && target === 'react') {
|
|
148
|
-
attrs.push(`slots={{\n${node.slots.map(slot => `${indent(depth + 2)}${key(slot.name)}: ${reactValue(slot.children, depth + 2)},`).join('\n')}\n${indent(depth + 1)}}}`);
|
|
149
|
-
}
|
|
150
|
-
const wrapped = attrs.length > 0;
|
|
151
|
-
const start = wrapped ? `<${node.tag}\n${attrs.map(value => indent(depth + 1) + value).join('\n')}\n${indent(depth)}` : `<${node.tag}`;
|
|
152
|
-
const children = target === 'vue' ? node.children : node.children.filter(child => child.kind !== 'slot');
|
|
153
|
-
const owner = target === 'html-next' ? node : undefined;
|
|
154
|
-
const arranged = layout(children, owner);
|
|
155
|
-
if (!arranged.nodes.length && (node.component || target === 'react')) return `${start}${wrapped ? '' : ' '}/>`;
|
|
156
|
-
if (voidElements.has(node.tag)) return `${start}>`;
|
|
157
|
-
const content = sequence(children, depth + 1, false, owner);
|
|
158
|
-
return arranged.multiline
|
|
159
|
-
? `${start}>\n${content}\n${indent(depth)}</${node.tag}>`
|
|
160
|
-
: `${start}>${content}</${node.tag}>`;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function body(depth) {
|
|
164
|
-
const arranged = layout(model.nodes);
|
|
165
|
-
if (target === 'react') return reactValue(model.nodes, depth);
|
|
166
|
-
return (arranged.multiline ? '' : indent(depth)) + sequence(model.nodes, depth);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
body,
|
|
171
|
-
snippets: () => [...bindings].map(([slot, name]) => `{#snippet ${name}()}\n${sequence(slot.children, 1, true)}\n{/snippet}`).join('\n\n'),
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/** Present invocations using the public APIs produced by each Vite framework target. */
|
|
176
|
-
export function frameworkExamples(example, components) {
|
|
177
|
-
const model = exampleInvocations(example.markup, components);
|
|
178
|
-
const importSource = component => component.importSource ?? component.package;
|
|
179
|
-
const imports = [...new Set(model.components.map(importSource))].map(owner => {
|
|
180
|
-
const names = model.components.filter(component => importSource(component) === owner).map(component => componentName(component.tag)).sort();
|
|
181
|
-
const line = `import { ${names.join(', ')} } from ${JSON.stringify(owner)};`;
|
|
182
|
-
return line.length <= 100 ? line : `import {\n${names.map(name => ` ${name},`).join('\n')}\n} from ${JSON.stringify(owner)};`;
|
|
183
|
-
}).join('\n');
|
|
184
|
-
const links = model.components.map(component => `<link\n rel="component"\n href="${escapeHtml(component.resource ?? `${component.package}/components/${component.tag}/${component.tag}.html`)}"\n>`).join('\n');
|
|
185
|
-
const html = printer(exampleInvocations(example.markup, []), 'html-next').body(0);
|
|
186
|
-
const codes = { 'html-next': { language: 'html', code: [links, html].filter(Boolean).join('\n\n') } };
|
|
187
|
-
for (const target of ['vue', 'react', 'svelte']) {
|
|
188
|
-
const output = printer(model, target);
|
|
189
|
-
const script = imports ? `<script${target === 'vue' ? ' setup' : ''}>\n${imports.split('\n').map(line => ' ' + line).join('\n')}\n</script>\n\n` : '';
|
|
190
|
-
codes[target] = target === 'react'
|
|
191
|
-
? { language: 'tsx', code: `${imports ? imports + '\n\n' : ''}export default function Example() {\n return ${output.body(1)};\n}` }
|
|
192
|
-
: { language: target, code: script + (target === 'vue' ? `<template>\n${output.body(1)}\n</template>` : [output.snippets(), output.body(0)].filter(Boolean).join('\n\n')) };
|
|
193
|
-
}
|
|
194
|
-
return { ...codes, ...example.frameworks };
|
|
195
|
-
}
|
package/docs/index.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export interface DocumentationGroup { id: string; label: string }
|
|
2
|
-
export interface ExampleCode { language: string; code: string }
|
|
3
|
-
export interface DocumentationExample {
|
|
4
|
-
id: string; name: string; title: string; description: string; markup: string;
|
|
5
|
-
resizable: boolean; stretch?: boolean; frameworks: Record<string, ExampleCode>; behavior?: string; bindings?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface DocumentationComponent {
|
|
8
|
-
id: string; package: string; tag: string; title: string; description: string; group: string;
|
|
9
|
-
root: string; resource: string; source?: string; importSource?: string; navigationParent?: string;
|
|
10
|
-
targets: string[]; examples: DocumentationExample[];
|
|
11
|
-
attributes: Record<string, unknown>[]; properties: Record<string, unknown>[];
|
|
12
|
-
events: Record<string, unknown>[]; slots: Record<string, unknown>[];
|
|
13
|
-
designTokens: { sources?: string[]; component: Record<string, unknown>[]; shared: Record<string, unknown>[] };
|
|
14
|
-
}
|
|
15
|
-
export interface DocumentationCatalog {
|
|
16
|
-
schemaVersion: 1; package?: string; version?: string; groups: DocumentationGroup[];
|
|
17
|
-
resources?: { tag: string; package: string; resource: string }[]; components: DocumentationComponent[];
|
|
18
|
-
}
|
|
19
|
-
export interface DiscoveryRoot { directory: string; packageName: string; groups?: DocumentationGroup[] }
|
|
20
|
-
export interface ThemeRecipe { schemaVersion: 1; values: Record<string, string>; origin?: string; fonts?: Partial<Record<'body-font' | 'display-font', string>>; presets?: Partial<Record<'material' | 'palette', string>> }
|
|
21
|
-
export interface ThemeField { family: string; id: string; label: string; property: string | null; type: string; defaultValue: string; description: string; min?: number; max?: number; choices?: Record<string, string> }
|
|
22
|
-
export interface DocumentationConfiguration {
|
|
23
|
-
title?: string; base?: string; origin?: string; outDir?: string; content?: string;
|
|
24
|
-
logo?: string | { light: string; dark?: string }; nav?: { label: string; href: string; position?: 'start' }[];
|
|
25
|
-
components?: DiscoveryRoot[]; catalogs?: string[]; categories?: Record<string, string>;
|
|
26
|
-
theme?: { recipe?: string; css?: string }; overrides?: string[];
|
|
27
|
-
recipe?: ThemeRecipe;
|
|
28
|
-
}
|
|
29
|
-
export interface DocumentationInput { root?: string; config?: DocumentationConfiguration; catalog?: DocumentationCatalog }
|
|
30
|
-
export interface DocumentationSite {
|
|
31
|
-
root: string; config: DocumentationConfiguration; base: string; catalog: DocumentationCatalog;
|
|
32
|
-
examples: (DocumentationExample & { file: string; component: string; path: string })[];
|
|
33
|
-
generated: string; content: string; previews: string; redirects: Record<string, string>;
|
|
34
|
-
}
|
|
35
|
-
export interface DocumentationBuild { outDir: string; routes: readonly string[]; browserInputs: readonly string[]; site: DocumentationSite }
|
|
36
|
-
export interface DocumentationServer { url: string; close(): Promise<void> }
|
|
37
|
-
export function readCatalog(specifier?: string | URL): Promise<DocumentationCatalog>;
|
|
38
|
-
export function discoverComponents(input: DiscoveryRoot & { root: string }): Promise<DocumentationCatalog>;
|
|
39
|
-
export function mergeCatalogs(catalogs: DocumentationCatalog[], options?: { categories?: Record<string, string> }): DocumentationCatalog;
|
|
40
|
-
export function prepareDocumentation(input: DocumentationInput & { root: string }): Promise<DocumentationSite>;
|
|
41
|
-
export function buildDocumentation(input?: DocumentationInput): Promise<DocumentationBuild>;
|
|
42
|
-
/** Optional MarkupKit integration; server tooling peers are loaded only when invoked. */
|
|
43
|
-
export function documentationOptions(site: DocumentationSite): Promise<import('@threadlabs/markupkit').ApplicationOptions>;
|
|
44
|
-
export function documentationPlugin(site: DocumentationSite): import('@threadlabs/markupkit').MarkupKitPlugin;
|
|
45
|
-
export function initializeDocumentation(input?: { root?: string; title?: string }): Promise<{ config: DocumentationConfiguration; files: string[]; applicationImport: string }>;
|
|
46
|
-
export function readConfiguration(root?: string): Promise<{ root: string; config: DocumentationConfiguration }>;
|
|
47
|
-
export function buildProjectDocumentation(input?: DocumentationInput): Promise<DocumentationBuild>;
|
|
48
|
-
export function devProjectDocumentation(input?: DocumentationInput & { port?: number; onError?: (error: unknown) => void }): Promise<DocumentationServer>;
|
|
49
|
-
export function previewProjectDocumentation(input?: DocumentationInput & { port?: number }): Promise<DocumentationServer>;
|
|
50
|
-
export const themeFields: readonly ThemeField[];
|
|
51
|
-
export const startingPoints: Record<string, ThemeRecipe>;
|
|
52
|
-
export function defaultRecipe(): ThemeRecipe;
|
|
53
|
-
export const materialPresets: Record<string, { label: string; values: Record<string, string> }>;
|
|
54
|
-
export function applyRefinement(input: ThemeRecipe, family: 'material' | 'palette', id: string): ThemeRecipe;
|
|
55
|
-
export function refinementState(input: ThemeRecipe, family: 'material' | 'palette'): { id: string; customized: boolean };
|
|
56
|
-
export function validateRecipe(input: unknown): ThemeRecipe;
|
|
57
|
-
export interface ResolvedTheme { tokens: Record<string, string>; adjustments: { id: string; requested: string; resolved: string; reason: string }[] }
|
|
58
|
-
export function deriveTheme(input: ThemeRecipe, options?: { mode?: 'light' | 'dark' }): ResolvedTheme;
|
|
59
|
-
export function themeCSS(input: ThemeRecipe, systemCSS?: string, options?: { scope?: 'portable' | 'documentation' }): string;
|
package/docs/index.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { readCatalog, discoverComponents, mergeCatalogs } from './catalog.mjs';
|
|
2
|
-
export { prepareDocumentation, documentationOptions, documentationPlugin, buildDocumentation } from './site.mjs';
|
|
3
|
-
export { defaultRecipe, startingPoints, themeFields, validateRecipe, deriveTheme, themeCSS, materialPresets, statusPresets, applyRefinement, refinementState } from './theme.mjs';
|
|
4
|
-
export { initializeDocumentation, buildProjectDocumentation, devProjectDocumentation, previewProjectDocumentation, readConfiguration } from './commands.mjs';
|
package/docs/local-server.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
-
import { createServer, request as proxyRequest } from 'node:http';
|
|
3
|
-
|
|
4
|
-
const rejected = (message, status = 403) => Object.assign(new Error(message), { status });
|
|
5
|
-
const secretMatches = (value, secret) => typeof value === 'string' && Buffer.byteLength(value) === secret.length && timingSafeEqual(Buffer.from(value), Buffer.from(secret));
|
|
6
|
-
async function body(request) {
|
|
7
|
-
const chunks = []; let size = 0;
|
|
8
|
-
for await (const chunk of request) {
|
|
9
|
-
size += chunk.length;
|
|
10
|
-
if (size > 64 * 1024) throw rejected('Theme request is too large.', 413);
|
|
11
|
-
chunks.push(chunk);
|
|
12
|
-
}
|
|
13
|
-
try { return JSON.parse(Buffer.concat(chunks).toString('utf8')); }
|
|
14
|
-
catch { throw rejected('Expected a JSON theme recipe and revision.', 400); }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Serve trusted project documentation with a constrained, same-origin theme writer. */
|
|
18
|
-
export async function serveLocalDocumentation({ upstream, store, base = '/', port = 0, onSaved = async () => {} }) {
|
|
19
|
-
const target = new URL(upstream);
|
|
20
|
-
if (target.protocol !== 'http:' || target.hostname !== '127.0.0.1') throw new Error('The documentation upstream must be a loopback MarkupKit server.');
|
|
21
|
-
const capability = randomBytes(32).toString('hex');
|
|
22
|
-
let origin;
|
|
23
|
-
const json = (response, status, data) => {
|
|
24
|
-
response.writeHead(status, { 'content-type': 'application/json', 'cache-control': 'no-store', 'x-content-type-options': 'nosniff' });
|
|
25
|
-
response.end(JSON.stringify(data));
|
|
26
|
-
};
|
|
27
|
-
const sameOrigin = request => {
|
|
28
|
-
if (request.headers.origin) return request.headers.origin === origin;
|
|
29
|
-
return request.headers['sec-fetch-site'] === 'same-origin';
|
|
30
|
-
};
|
|
31
|
-
const server = createServer((request, response) => {
|
|
32
|
-
void (async () => {
|
|
33
|
-
if (request.headers.host !== new URL(origin).host) throw rejected('Unexpected local documentation host.');
|
|
34
|
-
const url = new URL(request.url, origin);
|
|
35
|
-
const api = base + '_looma/';
|
|
36
|
-
if (url.pathname === api + 'session' || url.pathname === api + 'theme') {
|
|
37
|
-
if (!sameOrigin(request)) throw rejected('Open this editor from its local documentation address.');
|
|
38
|
-
if (url.pathname.endsWith('/session')) {
|
|
39
|
-
if (request.method !== 'GET') throw rejected('Use GET for the local session.', 405);
|
|
40
|
-
json(response, 200, { ...await store.read(), capability }); return;
|
|
41
|
-
}
|
|
42
|
-
if (request.method !== 'POST') throw rejected('Use POST to save a theme.', 405);
|
|
43
|
-
if (request.headers['content-type']?.split(';')[0].trim() !== 'application/json') throw rejected('Use application/json to save a theme.', 415);
|
|
44
|
-
if (!secretMatches(request.headers['x-looma-capability'], capability)) throw rejected('The local editing session expired. Reload before saving.');
|
|
45
|
-
const result = await store.save(await body(request));
|
|
46
|
-
try { await onSaved(result); }
|
|
47
|
-
catch (error) { throw rejected(`Theme files were saved, but the documentation could not rebuild: ${error.message}`, 500); }
|
|
48
|
-
json(response, 200, result); return;
|
|
49
|
-
}
|
|
50
|
-
if (!['GET', 'HEAD'].includes(request.method)) throw rejected('Documentation supports GET and HEAD.', 405);
|
|
51
|
-
const headers = { ...request.headers, host: target.host };
|
|
52
|
-
delete headers['x-looma-capability'];
|
|
53
|
-
const proxy = proxyRequest(target.origin + request.url, { method: request.method, headers }, remote => {
|
|
54
|
-
const responseHeaders = { ...remote.headers };
|
|
55
|
-
|
|
56
|
-
response.writeHead(remote.statusCode, responseHeaders); remote.pipe(response);
|
|
57
|
-
});
|
|
58
|
-
proxy.on('error', () => { if (!response.headersSent) json(response, 502, { error: 'The documentation renderer is unavailable.' }); else response.destroy(); });
|
|
59
|
-
request.on('aborted', () => proxy.destroy()); proxy.end();
|
|
60
|
-
})().catch(error => { if (!response.headersSent) json(response, error.status ?? 500, { error: error.status ? error.message : 'Could not process this local documentation request.' }); else response.destroy(); });
|
|
61
|
-
});
|
|
62
|
-
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(port, '127.0.0.1', resolve); });
|
|
63
|
-
origin = `http://127.0.0.1:${server.address().port}`;
|
|
64
|
-
return { url: origin + base, close: () => new Promise((resolve, reject) => { server.close(error => error ? reject(error) : resolve()); server.closeIdleConnections(); }) };
|
|
65
|
-
}
|
package/docs/navigation.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/** Place explicitly leading links before Markupress's generated sections in server-rendered order. */
|
|
2
|
-
export function orderNavigation(options, { nav = [], base }) {
|
|
3
|
-
const order = new Map(nav.filter(entry => entry.position === 'start').map((entry, index) => [entry.href, index]));
|
|
4
|
-
const rank = entry => {
|
|
5
|
-
const href = entry.href.startsWith(base) ? '/' + entry.href.slice(base.length).replace(/^v\/[^/]+\//, '') : entry.href;
|
|
6
|
-
return order.get(href) ?? order.size;
|
|
7
|
-
};
|
|
8
|
-
const layout = layer => {
|
|
9
|
-
if (!layer?.server?.load) return layer;
|
|
10
|
-
const load = layer.server.load;
|
|
11
|
-
return { ...layer, server: { ...layer.server, async load(context) {
|
|
12
|
-
const result = await load(context);
|
|
13
|
-
const shell = result.data?.markupress;
|
|
14
|
-
if (!shell?.nav) return result;
|
|
15
|
-
const links = [...shell.nav].sort((left, right) => rank(left) - rank(right));
|
|
16
|
-
return { ...result,
|
|
17
|
-
props: { ...result.props, ...('nav' in (result.props ?? {}) ? { nav: links } : {}) },
|
|
18
|
-
data: { ...result.data, markupress: { ...shell, nav: links } },
|
|
19
|
-
};
|
|
20
|
-
} } };
|
|
21
|
-
};
|
|
22
|
-
return { ...options,
|
|
23
|
-
...(options.pages ? { pages: options.pages.map(page => ({ ...page, layout: layout(page.layout) })) } : {}),
|
|
24
|
-
...(options.layouts ? { layouts: Object.fromEntries(Object.entries(options.layouts).map(([name, layer]) => [name, layout(layer)])) } : {}),
|
|
25
|
-
};
|
|
26
|
-
}
|
package/docs/palette.mjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// Perceptual palette operations use Oklab/OKLCH; output remains portable sRGB hex.
|
|
2
|
-
const linear = value => value <= .04045 ? value / 12.92 : ((value + .055) / 1.055) ** 2.4;
|
|
3
|
-
const encoded = value => value <= .0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - .055;
|
|
4
|
-
const clamp = (value, min = 0, max = 1) => Math.max(min, Math.min(max, value));
|
|
5
|
-
export function toLch(hex) {
|
|
6
|
-
const [r, g, b] = [1, 3, 5].map(i => linear(parseInt(hex.slice(i, i + 2), 16) / 255));
|
|
7
|
-
const l = Math.cbrt(.4122214708 * r + .5363325363 * g + .0514459929 * b);
|
|
8
|
-
const m = Math.cbrt(.2119034982 * r + .6806995451 * g + .1073969566 * b);
|
|
9
|
-
const s = Math.cbrt(.0883024619 * r + .2817188376 * g + .6299787005 * b);
|
|
10
|
-
const a = 1.9779984951 * l - 2.428592205 * m + .4505937099 * s;
|
|
11
|
-
const bb = .0259040371 * l + .7827717662 * m - .808675766 * s;
|
|
12
|
-
return [.2104542553 * l + .793617785 * m - .0040720468 * s, Math.hypot(a, bb), (Math.atan2(bb, a) * 180 / Math.PI + 360) % 360];
|
|
13
|
-
}
|
|
14
|
-
const channels = ([lightness, chroma, hue]) => {
|
|
15
|
-
const a = chroma * Math.cos(hue * Math.PI / 180), b = chroma * Math.sin(hue * Math.PI / 180);
|
|
16
|
-
const l = (lightness + .3963377774 * a + .2158037573 * b) ** 3;
|
|
17
|
-
const m = (lightness - .1055613458 * a - .0638541728 * b) ** 3;
|
|
18
|
-
const s = (lightness - .0894841775 * a - 1.291485548 * b) ** 3;
|
|
19
|
-
return [4.0767416621 * l - 3.3077115913 * m + .2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - .3413193965 * s, -.0041960863 * l - .7034186147 * m + 1.707614701 * s];
|
|
20
|
-
};
|
|
21
|
-
export function fromLch([lightness, chroma, hue]) {
|
|
22
|
-
lightness = clamp(lightness); chroma = Math.max(0, chroma);
|
|
23
|
-
let rgb = channels([lightness, chroma, hue]);
|
|
24
|
-
if (rgb.some(n => n < -.000001 || n > 1.000001)) {
|
|
25
|
-
// Reduce chroma at fixed hue/lightness instead of clipping individual channels.
|
|
26
|
-
let low = 0, high = chroma;
|
|
27
|
-
for (let i = 0; i < 18; i++) {
|
|
28
|
-
const middle = (low + high) / 2;
|
|
29
|
-
if (channels([lightness, middle, hue]).every(n => n >= 0 && n <= 1)) low = middle;
|
|
30
|
-
else high = middle;
|
|
31
|
-
}
|
|
32
|
-
rgb = channels([lightness, low, hue]);
|
|
33
|
-
}
|
|
34
|
-
return '#' + rgb.map(n => Math.round(clamp(encoded(n)) * 255).toString(16).padStart(2, '0')).join('');
|
|
35
|
-
}
|
|
36
|
-
export function mixColour(a, b, weight) {
|
|
37
|
-
// Cartesian Oklab mixing avoids a hue discontinuity around 0/360 degrees.
|
|
38
|
-
const cartesian = hex => { const [l, c, h] = toLch(hex); return [l, c * Math.cos(h * Math.PI / 180), c * Math.sin(h * Math.PI / 180)]; };
|
|
39
|
-
const first = cartesian(a), second = cartesian(b), mixed = first.map((n, i) => n * weight + second[i] * (1 - weight));
|
|
40
|
-
return fromLch([mixed[0], Math.hypot(mixed[1], mixed[2]), Math.atan2(mixed[2], mixed[1]) * 180 / Math.PI]);
|
|
41
|
-
}
|
|
42
|
-
export function paletteSeeds(values) {
|
|
43
|
-
const intensity = Number(values['color-intensity']) * 2, warmth = (Number(values.warmth) - .5) * 2;
|
|
44
|
-
const relationship = values['palette-relationship'];
|
|
45
|
-
const brandHue = toLch(values.action)[2];
|
|
46
|
-
return Object.fromEntries(['action', 'secondary-action', 'tertiary-action', 'canvas', 'surface', 'text'].map(key => {
|
|
47
|
-
const seed = values[key] === 'none' ? values.action : values[key];
|
|
48
|
-
if (intensity === 1 && warmth === 0 && relationship === 'preserve') return [key, seed];
|
|
49
|
-
let [l, c, h] = toLch(seed);
|
|
50
|
-
if (!['action','secondary-action','tertiary-action'].includes(key)) {
|
|
51
|
-
const tint = Math.max(Math.abs(warmth), relationship === 'preserve' ? 0 : .5);
|
|
52
|
-
if (tint) l = clamp(l, .08 * tint, 1 - .03 * tint);
|
|
53
|
-
if (relationship !== 'preserve') { h = brandHue + (relationship === 'neighboring' ? 30 : 180); c = Math.max(c, .018); }
|
|
54
|
-
if (warmth !== 0) {
|
|
55
|
-
const strength = Math.abs(warmth);
|
|
56
|
-
const target = fromLch([l, warmth > 0 ? .025 : .018, warmth > 0 ? 85 : 255]);
|
|
57
|
-
[l, c, h] = toLch(mixColour(fromLch([l, c, h]), target, 1 - strength));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return [key, fromLch([l, c * intensity, h])];
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function companionSurface(seed, mode) {
|
|
65
|
-
const [l, c, h] = toLch(seed);
|
|
66
|
-
// Retain hue and restrained colorfulness; convert the tonal role, not the identity.
|
|
67
|
-
return fromLch([mode === 'dark' ? .16 + (1 - l) * .12 : .94 + (1 - l) * .045, Math.min(c, .045), h]);
|
|
68
|
-
}
|
package/docs/pastoral.svg
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 400" role="img" aria-labelledby="title description">
|
|
2
|
-
<title id="title">A quiet afternoon in the countryside</title>
|
|
3
|
-
<desc id="description">Soft green hills surround a red-roofed farmhouse, a winding stream, and sheep grazing beneath a broad oak tree.</desc>
|
|
4
|
-
<rect width="640" height="400" fill="#e9efdf"/>
|
|
5
|
-
<circle cx="486" cy="85" r="36" fill="#edcd79"/>
|
|
6
|
-
<g fill="#faf8ed">
|
|
7
|
-
<path d="M65 89c0-12 10-21 22-20 4-20 35-24 46-6 16-4 30 8 29 23 14-2 25 7 25 18H65Z"/>
|
|
8
|
-
<path d="M300 58c2-11 17-16 26-9 10-15 33-10 36 7 13-3 25 6 25 17h-87Z"/>
|
|
9
|
-
</g>
|
|
10
|
-
<path d="M0 183c76-55 128-46 196-8 67 37 112-68 199-45 85 22 134 67 245 22v248H0Z" fill="#a9c2ad"/>
|
|
11
|
-
<path d="M0 227c108-62 189-36 285-8 111 33 182-60 355-18v199H0Z" fill="#89aa79"/>
|
|
12
|
-
<path d="M0 287c89-20 165-64 267-45 110 21 219 79 373 18v140H0Z" fill="#6b925e"/>
|
|
13
|
-
<path d="M0 349c128-72 240-22 363-4 116 17 190-36 277-31v86H0Z" fill="#52784f"/>
|
|
14
|
-
<path d="M362 211c-43 31 63 45 28 72-35 26-113 35-99 64 9 20 54 32 84 53h92c-40-44-127-52-124-72 3-19 79-31 84-57 6-30-94-38-55-60Z" fill="#c7deda"/>
|
|
15
|
-
<path d="M368 213c-28 26 57 44 31 65" fill="none" stroke="#e5eee0" stroke-width="4" stroke-linecap="round"/>
|
|
16
|
-
<path d="M168 214c-21 37-74 45-90 75-17 33 26 56 21 111h40c-1-57-48-77-38-105 10-27 72-45 80-81Z" fill="#d9c38b"/>
|
|
17
|
-
<g>
|
|
18
|
-
<rect x="121" y="173" width="88" height="53" fill="#f6ead0"/>
|
|
19
|
-
<path d="m109 177 56-39 56 39Z" fill="#a55d48"/>
|
|
20
|
-
<path d="m118 177 47-32 47 32Z" fill="#bd7458"/>
|
|
21
|
-
<rect x="181" y="191" width="15" height="35" rx="1" fill="#637961"/>
|
|
22
|
-
<rect x="135" y="189" width="20" height="19" rx="1" fill="#75999a"/>
|
|
23
|
-
<path d="M145 189v19m-10-9h20" stroke="#f6ead0" stroke-width="3"/>
|
|
24
|
-
<path d="M194 155v-17h9v23" fill="#a55d48"/>
|
|
25
|
-
<rect x="238" y="192" width="47" height="35" fill="#b67456"/>
|
|
26
|
-
<path d="m231 194 30-26 31 26Z" fill="#805947"/>
|
|
27
|
-
<rect x="253" y="207" width="16" height="20" fill="#765940"/>
|
|
28
|
-
</g>
|
|
29
|
-
<g fill="none" stroke="#f0dfb7" stroke-width="4" stroke-linecap="round">
|
|
30
|
-
<path d="m27 253 76-18m-65 3v27m25-34v27m25-34v27"/>
|
|
31
|
-
<path d="m222 248 74 11m-63-24v27m26-22v27m26-23v27"/>
|
|
32
|
-
</g>
|
|
33
|
-
<g>
|
|
34
|
-
<path d="m535 220-8 112h24l-6-112Z" fill="#6d6246"/>
|
|
35
|
-
<path d="m539 263-23-28m24 14 23-24" fill="none" stroke="#6d6246" stroke-width="8" stroke-linecap="round"/>
|
|
36
|
-
<path d="M482 232c-26-5-33-36-14-54-10-23 9-45 33-42 9-28 48-31 64-8 26-13 55 6 52 32 28 10 29 45 6 59 0 23-35 34-51 19-24 21-63 16-67-5Z" fill="#3c684d"/>
|
|
37
|
-
<path d="M484 174c4-21 29-30 44-18 9-24 45-22 53 3 22-5 38 13 34 31-43-17-86 6-131-16Z" fill="#527d55"/>
|
|
38
|
-
</g>
|
|
39
|
-
<g stroke="#465b48" stroke-width="3" stroke-linecap="round">
|
|
40
|
-
<path d="M385 323v9m17-10v9m47 13v8m16-10v9"/>
|
|
41
|
-
</g>
|
|
42
|
-
<g fill="#f4edda">
|
|
43
|
-
<ellipse cx="392" cy="317" rx="16" ry="10"/>
|
|
44
|
-
<ellipse cx="455" cy="338" rx="14" ry="9"/>
|
|
45
|
-
</g>
|
|
46
|
-
<g fill="#465b48">
|
|
47
|
-
<ellipse cx="406" cy="318" rx="5" ry="7"/>
|
|
48
|
-
<ellipse cx="468" cy="338" rx="4" ry="6"/>
|
|
49
|
-
</g>
|
|
50
|
-
<g fill="#e4ca80">
|
|
51
|
-
<circle cx="41" cy="370" r="3"/><circle cx="56" cy="351" r="3"/><circle cx="186" cy="346" r="3"/>
|
|
52
|
-
<circle cx="202" cy="364" r="3"/><circle cx="569" cy="363" r="3"/><circle cx="590" cy="346" r="3"/>
|
|
53
|
-
</g>
|
|
54
|
-
</svg>
|
package/docs/portrait.svg
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-labelledby="title description">
|
|
2
|
-
<title id="title">Illustrated portrait of Maya Chen</title>
|
|
3
|
-
<desc id="description">A warm, abstract profile portrait on a violet background.</desc>
|
|
4
|
-
<defs>
|
|
5
|
-
<linearGradient id="background" x1="0" y1="0" x2="1" y2="1">
|
|
6
|
-
<stop offset="0" stop-color="#8078ed"/>
|
|
7
|
-
<stop offset="1" stop-color="#40389e"/>
|
|
8
|
-
</linearGradient>
|
|
9
|
-
</defs>
|
|
10
|
-
<rect width="96" height="96" rx="24" fill="url(#background)"/>
|
|
11
|
-
<circle cx="48" cy="38" r="18" fill="#f5c9a7"/>
|
|
12
|
-
<path d="M29 38c0-17 10-25 21-25 13 0 22 10 21 26-5-8-13-13-24-13-7 0-13 4-18 12Z" fill="#292238"/>
|
|
13
|
-
<path d="M18 96c2-23 13-35 30-35s28 12 30 35H18Z" fill="#f6f3ff"/>
|
|
14
|
-
<path d="M39 43c3 3 15 3 18 0" fill="none" stroke="#a45b50" stroke-width="2" stroke-linecap="round"/>
|
|
15
|
-
</svg>
|
package/docs/reference.html
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<template component="looma-reference" module="./reference.js"><defs></defs><div><slot></slot></div></template>
|
package/docs/reference.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/** A deep link opens its containing tab through the tab's native, accessible activation. */
|
|
2
|
-
export function connect(host) {
|
|
3
|
-
const root = host.element;
|
|
4
|
-
const view = root.ownerDocument.defaultView;
|
|
5
|
-
let currentHash = view.location.hash;
|
|
6
|
-
const open = () => {
|
|
7
|
-
let id;
|
|
8
|
-
try { id = decodeURIComponent(currentHash.slice(1)); } catch { return; }
|
|
9
|
-
const target = root.ownerDocument.getElementById(id);
|
|
10
|
-
if (!target || !root.contains(target)) { observer.disconnect(); return; }
|
|
11
|
-
const panel = target.closest('[role="tabpanel"]');
|
|
12
|
-
const tab = panel && [...root.querySelectorAll('[role="tab"]')].find(button => button.getAttribute('aria-controls') === panel.id);
|
|
13
|
-
if (!tab) return;
|
|
14
|
-
if (panel.hidden) tab.click();
|
|
15
|
-
if (!panel.hidden) { target.scrollIntoView({ block: 'start' }); observer.disconnect(); }
|
|
16
|
-
};
|
|
17
|
-
const observer = new MutationObserver(open);
|
|
18
|
-
const activate = value => {
|
|
19
|
-
currentHash = value;
|
|
20
|
-
observer.disconnect();
|
|
21
|
-
if (!currentHash) return;
|
|
22
|
-
observer.observe(root, { subtree: true, childList: true, attributes: true, attributeFilter: ['role', 'id', 'hidden'] });
|
|
23
|
-
open();
|
|
24
|
-
};
|
|
25
|
-
const hash = () => activate(view.location.hash);
|
|
26
|
-
const click = event => {
|
|
27
|
-
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
28
|
-
const link = event.target.closest?.('a[href]');
|
|
29
|
-
if (!link || link.target && link.target !== '_self') return;
|
|
30
|
-
const target = new URL(link.href, view.location.href);
|
|
31
|
-
if (target.origin === view.location.origin && target.pathname === view.location.pathname && target.hash) activate(target.hash);
|
|
32
|
-
};
|
|
33
|
-
root.addEventListener('click', click);
|
|
34
|
-
view.addEventListener('hashchange', hash); hash();
|
|
35
|
-
return () => { observer.disconnect(); root.removeEventListener('click', click); view.removeEventListener('hashchange', hash); };
|
|
36
|
-
}
|