ngwr 13.0.0 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ngwr-border-glow.mjs +12 -3
- package/fesm2022/ngwr-border-glow.mjs.map +1 -1
- package/fesm2022/ngwr-breadcrumbs.mjs +14 -3
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +6 -2
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +22 -16
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +5 -2
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +24 -18
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +6 -2
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-fuzzy-text.mjs +21 -4
- package/fesm2022/ngwr-fuzzy-text.mjs.map +1 -1
- package/fesm2022/ngwr-gradient-text.mjs +9 -2
- package/fesm2022/ngwr-gradient-text.mjs.map +1 -1
- package/fesm2022/ngwr-icon-adapters-feather.mjs +11 -0
- package/fesm2022/ngwr-icon-adapters-feather.mjs.map +1 -1
- package/fesm2022/ngwr-icon-adapters-lucide.mjs +22 -2
- package/fesm2022/ngwr-icon-adapters-lucide.mjs.map +1 -1
- package/fesm2022/ngwr-icon.mjs +474 -37
- package/fesm2022/ngwr-icon.mjs.map +1 -1
- package/fesm2022/ngwr-markdown.mjs +63 -11
- package/fesm2022/ngwr-markdown.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +36 -7
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-qr.mjs +38 -1
- package/fesm2022/ngwr-qr.mjs.map +1 -1
- package/fesm2022/ngwr-shiny-text.mjs +10 -3
- package/fesm2022/ngwr-shiny-text.mjs.map +1 -1
- package/fesm2022/ngwr-tabs.mjs +6 -2
- package/fesm2022/ngwr-tabs.mjs.map +1 -1
- package/fesm2022/ngwr-utils.mjs +107 -1
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/llms-full.txt +1 -1
- package/package.json +3 -3
- package/types/ngwr-breadcrumbs.d.ts +1 -0
- package/types/ngwr-fuzzy-text.d.ts +5 -0
- package/types/ngwr-icon-adapters-feather.d.ts +11 -0
- package/types/ngwr-icon.d.ts +42 -1
- package/types/ngwr-shiny-text.d.ts +1 -0
- package/types/ngwr-utils.d.ts +47 -1
- package/types/ngwr-version.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-icon.mjs","sources":["../../../projects/lib/icon/tokens/icon.token.ts","../../../projects/lib/icon/icon-registry.ts","../../../projects/lib/icon/icon.ts","../../../projects/lib/icon/utils/validate-icon.ts","../../../projects/lib/icon/providers/provide-wr-icons.ts","../../../projects/lib/icon/svg-icon.ts","../../../projects/lib/icon/ngwr-icon.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrIconDef } from '../interfaces';\n\n/**\n * Multi-provider token for registering icons with the icon registry.\n *\n * Use {@link provideWrIcons} instead of providing this token directly.\n *\n * @internal\n */\nexport const WR_ICONS = new InjectionToken<readonly WrIconDef[][]>('WR_ICONS');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Injectable, inject } from '@angular/core';\n\nimport type { WrIconDef } from './interfaces';\nimport { WR_ICONS } from './tokens';\n\n/**\n * One link in the icon-registry chain. {@link provideWrIcons} provides an\n * instance alongside its icons, so every injector level that registers icons\n * gets its own link whose parent is the next registering level above it.\n *\n * This exists because Angular does not merge `multi: true` providers across\n * injector levels — an element-level `provideWrIcons()` *replaces* the visible\n * `WR_ICONS` collection rather than adding to it. Reading only the closest\n * contribution silently hid every icon registered further up, which contradicts\n * the \"each call adds to the registry\" contract. Walking the chain restores it\n * for any number of levels.\n *\n * @internal\n */\n@Injectable()\nexport class WrIconRegistry {\n /** The next registering level up, if any. */\n private readonly parent = inject(WrIconRegistry, { skipSelf: true, optional: true });\n\n /** Icons registered at *this* level only. */\n private readonly own = inject(WR_ICONS, { self: true, optional: true }) ?? [];\n\n /**\n * Every icon visible from this level, nearest last so a local registration\n * wins over an identically named one further up.\n */\n resolve(): Map<string, WrIconDef> {\n const map = this.parent?.resolve() ?? new Map<string, WrIconDef>();\n for (const set of this.own) {\n for (const icon of set) map.set(icon.name, icon);\n }\n return map;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ElementRef, ViewEncapsulation, computed, effect, inject, input, isDevMode } from '@angular/core';\n\nimport { WrIconRegistry } from './icon-registry';\nimport type { WrIconDef, WrIconName } from './interfaces';\n\n/**\n * Renders a registered SVG icon.\n *\n * Icons must be registered via {@link provideWrIcons} before use —\n * either at the application root or on any ancestor component.\n *\n * @example\n * ```html\n * <wr-icon name=\"home\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/icon\n */\n@Component({\n selector: 'wr-icon',\n template: '',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-icon',\n '[attr.data-icon]': 'name()',\n },\n})\nexport class WrIcon {\n readonly name = input.required<WrIconName>();\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Every icon visible from this position, walked up the whole chain of\n * registering injector levels.\n *\n * Angular's `inject(WR_ICONS)` returns only the **closest** injector's\n * contribution — `multi` providers are not merged across levels — so a\n * component that registers its own icons used to shadow, not extend, what an\n * ancestor registered. {@link WrIconRegistry} is provided once per\n * registering level and links to its parent, so nesting any number of levels\n * now adds up, with the nearest registration winning a name collision.\n *\n * Optional: with no `provideWrIcons()` anywhere the map is simply empty and\n * every name reports as unregistered.\n */\n private readonly iconRegistry = inject(WrIconRegistry, { optional: true });\n\n private readonly registry = computed<ReadonlyMap<WrIconName, WrIconDef>>(\n () => (this.iconRegistry?.resolve() ?? new Map()) as ReadonlyMap<WrIconName, WrIconDef>\n );\n\n private readonly icon = computed(() => this.registry().get(this.name()));\n\n constructor() {\n effect(() => {\n const icon = this.icon();\n const name = this.name();\n\n if (!icon) {\n if (isDevMode()) {\n // Reported, never thrown. An exception here escapes into\n // `runEffectsInView`, which abandons the remaining effects of the\n // whole view — one unknown name would blank every `<wr-icon>` after\n // it while the console blamed only the first. Error level (not\n // `badgeLog`) so it survives a console filtered to errors.\n // eslint-disable-next-line no-console -- misconfiguration must be visible, but must not throw\n console.error(\n `[NGWR] No icon named \"${name}\" is registered. Did you forget to call provideWrIcons()? ` +\n `If the name IS registered, check the injector level: a component-level provideWrIcons() ` +\n `shadows icons registered on an ancestor component.`\n );\n }\n this.host.nativeElement.innerHTML = '';\n return;\n }\n\n this.host.nativeElement.innerHTML = icon.data;\n\n // Every hand-written inline SVG in the library carries aria-hidden;\n // registered icons went in without it, so a decorative glyph could be\n // announced — usually as a bare \"graphic\" beside the label it decorates.\n // Consumers that need a name put it on the interactive host instead.\n this.host.nativeElement.querySelector('svg')?.setAttribute('aria-hidden', 'true');\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrIconDef } from '../interfaces';\n\nconst VIEW_BOX_RE = /<svg\\b[^>]*\\bviewBox\\s*=/i;\nconst SVG_ROOT_RE = /<svg\\b/i;\n\n/**\n * Dev-mode sanity check for a registered icon.\n *\n * Warns about issues that prevent correct rendering — most importantly,\n * a missing `viewBox`, which causes the SVG not to scale to the icon\n * host's size.\n *\n * Production builds drop the call entirely via `isDevMode()` tree-shaking.\n *\n * @internal\n */\nexport function validateIcon(icon: WrIconDef): void {\n if (!SVG_ROOT_RE.test(icon.data)) {\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] Icon \"${icon.name}\" data does not contain an <svg> root element. ` +\n `Custom icons must be valid SVG markup.`\n );\n return;\n }\n\n if (!VIEW_BOX_RE.test(icon.data)) {\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] Icon \"${icon.name}\" has no viewBox attribute — it won't scale ` +\n `to the host size. Add viewBox=\"0 0 W H\" to the <svg> root.`\n );\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Provider, isDevMode } from '@angular/core';\n\nimport { WrIconRegistry } from '../icon-registry';\nimport type { WrIconDef } from '../interfaces';\nimport { WR_ICONS } from '../tokens';\nimport { validateIcon } from '../utils';\n\n/**\n * Registers a set of icons for use by `<wr-icon>`.\n *\n * Can be called multiple times — each call adds to the registry.\n * Works at both the application root and at the component level,\n * so a feature module or a single component can bring its own icons\n * without polluting the global config.\n *\n * In dev mode, each icon is validated for common issues (missing\n * `viewBox`, malformed root). Validation is dropped from production\n * builds via `isDevMode()` tree-shaking.\n *\n * @example\n * ```ts\n * // App-level registration\n * import { home, user, cog, provideWrIcons } from 'ngwr/icon';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideWrIcons([home, user, cog]),\n * ],\n * };\n * ```\n *\n * @example\n * ```ts\n * // Component-level registration\n * import { logoGithub, logoNpm, provideWrIcons, WrIconDef } from 'ngwr/icon';\n *\n * @Component({\n * selector: 'ngwr-header',\n * imports: [WrIcon],\n * providers: [provideWrIcons([logoGithub, logoNpm])],\n * template: `<wr-icon name=\"logo-github\" />`,\n * })\n * export class HeaderComponent {}\n * ```\n */\nexport function provideWrIcons(icons: WrIconDef[]): Provider[] {\n if (isDevMode()) {\n for (const icon of icons) validateIcon(icon);\n }\n return [\n { provide: WR_ICONS, useValue: icons, multi: true },\n // A registry link per registering level. Angular does not merge `multi`\n // providers across injectors, so without this chain an element-level\n // registration would shadow everything registered above it instead of\n // adding to it.\n WrIconRegistry,\n ];\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrIconDef } from './interfaces';\n\n/**\n * Wrap a raw SVG string in the {@link WrIconDef} envelope. Use this when\n * importing icons from sources that ship full `<svg>` files — Tabler,\n * Phosphor, Heroicons, Iconoir, Radix, Bootstrap Icons, your designer.\n *\n * Pair with a bundler's raw-SVG import (Vite's `?raw`, Webpack's\n * `raw-loader`, esbuild's `--loader:.svg=text`) so the SVG file becomes\n * a string at build time.\n *\n * For sets with a non-SVG shape (Lucide's IconNode tuples, Feather's\n * inner-only SVG), use the dedicated adapter under\n * `ngwr/icon/adapters/<set>` instead.\n *\n * @example\n * ```ts\n * import { svgIcon, provideWrIcons } from 'ngwr/icon';\n * // Vite: the `?raw` suffix returns the file as a string.\n * import plusSvg from '@tabler/icons/icons/plus.svg?raw';\n * import phosphorPlusSvg from '@phosphor-icons/core/assets/regular/plus.svg?raw';\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideWrIcons([\n * svgIcon('plus', plusSvg),\n * svgIcon('plus-phosphor', phosphorPlusSvg),\n * ]),\n * ],\n * });\n * ```\n */\nexport function svgIcon(name: string, svg: string): WrIconDef {\n return { name, data: svg };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAMH;;;;;;AAMG;AACI,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAyB,UAAU,CAAC;;AClB9E;;;;;AAKG;AAOH;;;;;;;;;;;;;AAaG;MAE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../../projects/lib/icon/tokens/icon.token.ts","../../../projects/lib/icon/icon-registry.ts","../../../projects/lib/icon/utils/sanitize-icon.ts","../../../projects/lib/icon/utils/validate-icon.ts","../../../projects/lib/icon/icon.ts","../../../projects/lib/icon/providers/provide-wr-icons.ts","../../../projects/lib/icon/svg-icon.ts","../../../projects/lib/icon/ngwr-icon.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrIconDef } from '../interfaces';\n\n/**\n * Multi-provider token for registering icons with the icon registry.\n *\n * Use {@link provideWrIcons} instead of providing this token directly.\n *\n * @internal\n */\nexport const WR_ICONS = new InjectionToken<readonly WrIconDef[][]>('WR_ICONS');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Injectable, inject } from '@angular/core';\n\nimport type { WrIconDef } from './interfaces';\nimport { WR_ICONS } from './tokens';\n\n/**\n * One link in the icon-registry chain. {@link provideWrIcons} provides an\n * instance alongside its icons, so every injector level that registers icons\n * gets its own link whose parent is the next registering level above it.\n *\n * This exists because Angular does not merge `multi: true` providers across\n * injector levels — an element-level `provideWrIcons()` *replaces* the visible\n * `WR_ICONS` collection rather than adding to it. Reading only the closest\n * contribution silently hid every icon registered further up, which contradicts\n * the \"each call adds to the registry\" contract. Walking the chain restores it\n * for any number of levels.\n *\n * @internal\n */\n@Injectable()\nexport class WrIconRegistry {\n /** The next registering level up, if any. */\n private readonly parent = inject(WrIconRegistry, { skipSelf: true, optional: true });\n\n /** Icons registered at *this* level only. */\n private readonly own = inject(WR_ICONS, { self: true, optional: true }) ?? [];\n\n /**\n * Every icon visible from this level, nearest last so a local registration\n * wins over an identically named one further up.\n */\n resolve(): Map<string, WrIconDef> {\n const map = this.parent?.resolve() ?? new Map<string, WrIconDef>();\n for (const set of this.own) {\n for (const icon of set) map.set(icon.name, icon);\n }\n return map;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\nconst XLINK_NS = 'http://www.w3.org/1999/xlink';\n\n/**\n * SVG elements an icon may be built from.\n *\n * Derived from the real sets rather than guessed: across the 12 459 SVG files\n * under `icon/_svg` (Lucide, Phosphor, Tabler, Heroicons), the whole of\n * `feather-icons`' `icons.json` and every `lucide` IconNode, only eight\n * elements ever appear — `svg`, `path`, `circle`, `line`, `rect`, `polyline`,\n * `polygon`, `ellipse`. The rest of this list is headroom for the icons a\n * consumer draws themselves: grouping, `<defs>` with gradients, a clip path, a\n * mask, a `<title>`, real `<text>`.\n *\n * What is deliberately absent is the entire scripting surface:\n *\n * - `<script>` — obvious, and the one vector `innerHTML` already refused;\n * - `<foreignObject>` — an XHTML escape hatch, so `<img onerror>` inside an\n * otherwise well-formed icon;\n * - `<image>` — its `onerror` fires on any unreachable `href`, which is the\n * cheapest handler to land, and no real icon set uses it;\n * - `<a>` — a `javascript:` href inside a glyph the user is invited to click;\n * - `<animate>` / `<set>` / `<animateTransform>` / `<animateMotion>` — SMIL can\n * retarget another element's `href` at a `javascript:` URL;\n * - `<style>` — arbitrary CSS in the app's origin, including `url()` requests;\n * - `<filter>` and the `fe*` primitives — `<feImage href>` is another external\n * fetch, and no icon set in the corpus filters.\n *\n * @internal\n */\nconst ELEMENTS: ReadonlySet<string> = new Set([\n 'svg',\n 'g',\n 'defs',\n 'symbol',\n 'use',\n 'title',\n 'desc',\n 'path',\n 'circle',\n 'ellipse',\n 'line',\n 'polyline',\n 'polygon',\n 'rect',\n 'text',\n 'tspan',\n 'textPath',\n 'linearGradient',\n 'radialGradient',\n 'stop',\n 'clipPath',\n 'mask',\n 'pattern',\n]);\n\n/**\n * Attributes an icon may carry, allowed on every element it is allowed on.\n *\n * An allowlist rather than a blocklist, so `onload`, `onerror`, `onclick` and\n * every other handler — including ones no browser has shipped yet — are gone by\n * construction rather than by enumeration.\n *\n * `style` is NOT here, and that is a decision rather than an oversight: not one\n * icon in the corpus uses it, and a `style` attribute is arbitrary CSS in the\n * app's origin. Anything a `style` would have done, a presentation attribute\n * does.\n *\n * @internal\n */\nconst ATTRIBUTES: ReadonlySet<string> = new Set([\n // geometry\n 'viewBox',\n 'preserveAspectRatio',\n 'transform',\n 'transform-origin',\n 'd',\n 'pathLength',\n 'cx',\n 'cy',\n 'r',\n 'rx',\n 'ry',\n 'x',\n 'y',\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'dx',\n 'dy',\n 'width',\n 'height',\n 'points',\n // paint servers, clips and masks\n 'gradientUnits',\n 'gradientTransform',\n 'spreadMethod',\n 'offset',\n 'fx',\n 'fy',\n 'fr',\n 'patternUnits',\n 'patternContentUnits',\n 'patternTransform',\n 'maskUnits',\n 'maskContentUnits',\n 'clipPathUnits',\n // presentation\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'stroke',\n 'stroke-width',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-opacity',\n 'opacity',\n 'color',\n 'clip-path',\n 'clip-rule',\n 'mask',\n 'paint-order',\n 'vector-effect',\n 'shape-rendering',\n 'stop-color',\n 'stop-opacity',\n 'display',\n 'visibility',\n 'overflow',\n 'isolation',\n 'mix-blend-mode',\n // text\n 'startOffset',\n 'textLength',\n 'lengthAdjust',\n 'text-anchor',\n 'dominant-baseline',\n 'alignment-baseline',\n 'baseline-shift',\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'letter-spacing',\n 'word-spacing',\n 'writing-mode',\n 'direction',\n // identity, accessibility and document plumbing\n 'id',\n 'class',\n 'role',\n 'aria-hidden',\n 'aria-label',\n 'aria-labelledby',\n 'aria-describedby',\n 'aria-roledescription',\n 'focusable',\n 'lang',\n 'version',\n 'baseProfile',\n 'xmlns',\n 'xmlns:xlink',\n 'xml:space',\n 'xml:lang',\n // resolved against ONLY_FRAGMENT below, never free-form\n 'href',\n 'xlink:href',\n]);\n\n/**\n * `href` may point at a fragment in the same document and nowhere else — that\n * is the whole legitimate use inside an icon (`<use href=\"#glyph\">`), and it\n * excludes `javascript:`, `data:` and every remote fetch in one rule.\n */\nconst FRAGMENT_ONLY: ReadonlySet<string> = new Set(['href', 'xlink:href']);\n\n/** A same-document fragment reference: `#id`, and nothing that is not one. */\nconst FRAGMENT_RE = /^#[^\\s]+$/;\n\n/**\n * `url(` inside a presentation attribute is a reference to a paint server, a\n * clip path or a mask. Those are fragment references too; a remote one is at\n * best a request the page did not ask for.\n */\nconst URL_FN_RE = /url\\(/i;\nconst URL_FRAGMENT_RE = /^url\\(\\s*(['\"]?)#[^\\s'\")]+\\1\\s*\\)$/i;\n\n/**\n * Icons are shallow — the deepest in the corpus nests three levels. The cap is\n * there so a hostile registration cannot recurse this function into a stack\n * overflow; content below it is dropped, not truncated silently, because\n * {@link WrIconStripReport} names what went.\n */\nconst MAX_DEPTH = 16;\n\n/**\n * What {@link sanitizeIcon} refused, for the dev-mode warning. Collecting is\n * opt-in so the render path does no bookkeeping in production.\n *\n * @internal\n */\ninterface WrIconStripReport {\n readonly elements: Set<string>;\n readonly attributes: Set<string>;\n}\n\n/**\n * Build a live `<svg>` element out of a registered icon's markup, keeping only\n * what an icon legitimately needs.\n *\n * `<wr-icon>` used to assign `icon.data` to `innerHTML`, which executes an\n * `onload` on the root, an `<image onerror>`, an `<img>` smuggled in after a\n * closed `</svg>`, and anything inside a `<foreignObject>` — with the app's own\n * origin, in a production build. The library already refuses exactly this next\n * door: `<wr-markdown>` escapes raw HTML because its input is untrusted by\n * construction and one `<img onerror>` is the whole cost of being wrong. Icon\n * data arrives from `provideWrIcons()`, which a multi-tenant app or a fetched\n * icon pack fills at runtime, so it is untrusted the same way.\n *\n * Three properties do the work, and none of them is a filter over known-bad\n * strings:\n *\n * 1. **Parsed inert, never inserted.** The markup is parsed into a document\n * with no browsing context, so nothing loads and nothing runs even before it\n * is inspected.\n * 2. **Only the first `<svg>` survives.** An icon IS an SVG element, so\n * everything beside the root is dropped — which is what makes\n * `</svg><img src=x onerror=…>` inert regardless of what the payload says,\n * and it is the same shape as the `feather()` shell escape.\n * 3. **Rebuilt, not filtered.** Every element and attribute that lands in the\n * document is one this file created from an allowlist. Nothing is\n * transferred from the parsed tree, so there is no attribute an unfamiliar\n * payload can smuggle past a matcher.\n *\n * A refused element takes its subtree with it rather than having its children\n * hoisted into its parent. Hoisting would preserve more of a hand-drawn icon\n * wrapped in something unsupported, and it is exactly the kind of cleverness\n * that makes \"what does the output contain\" depend on what the parser saw. The\n * blunt rule is the reviewable one, and the dev-mode warning names what went.\n *\n * `DomSanitizer.sanitize(SecurityContext.HTML, …)` is not an option here, which\n * is worth recording so it is not re-proposed: Angular's HTML allowlist\n * (`VOID_ELEMENTS`, `BLOCK_ELEMENTS`, `INLINE_ELEMENTS`) contains no SVG\n * element at all. Run against real Lucide, Feather and Heroicons icons it does\n * not merely drop presentation attributes — it returns the empty string.\n *\n * @returns the rebuilt element, or `null` when the data holds no `<svg>` root.\n * @internal\n */\nfunction sanitizeIcon(doc: Document, data: string, report?: WrIconStripReport): SVGElement | null {\n const source = parseInert(doc, data);\n return source ? copy(doc, source, report, 0) : null;\n}\n\n/**\n * Parse into a document that cannot run anything.\n *\n * `DOMParser` is the path every browser and the unit-test DOM take: it takes a\n * plain string, so it is not a Trusted Types sink, and its result has no\n * browsing context. It does not exist under SSR — `@angular/platform-server`\n * renders into domino — so the server falls back to a detached `<template>`,\n * whose content is a separate inert document for the same reason. That branch\n * is unreachable in a browser, which is what keeps the innerHTML write out of\n * the only place Trusted Types is enforced.\n *\n * Both parsers were checked to agree on the part that matters: the HTML\n * parser's foreign-content adjustment restores the camel case of `viewBox`,\n * `clipPath`, `linearGradient`, `gradientTransform`, `textPath` and puts\n * `xlink:href` in the xlink namespace.\n */\nfunction parseInert(doc: Document, data: string): Element | null {\n const parser = doc.defaultView?.DOMParser;\n if (parser) return firstSvg(new parser().parseFromString(data, 'text/html').body);\n\n const template = doc.createElement('template');\n template.innerHTML = data;\n return firstSvg(template.content);\n}\n\n/**\n * The first `<svg>` in document order, found by walking rather than by\n * `querySelector`.\n *\n * Two reasons, and the second is the one that matters. A control that decides\n * what may execute should not route that decision through a selector engine —\n * `localName === 'svg'` is a comparison anyone can check, and CSS parsing is a\n * layer with its own history. The first reason is merely that it is faster:\n * jsdom's engine costs 4 ms on a document this size, which the unit suite pays\n * on every rendered icon.\n */\nfunction firstSvg(root: Node): Element | null {\n const children = root.childNodes;\n for (let i = 0, n = children.length; i < n; i++) {\n const child = children[i];\n if (child.nodeType !== 1) continue;\n const element = child as Element;\n if (element.localName === 'svg') return element;\n const nested = firstSvg(element);\n if (nested) return nested;\n }\n return null;\n}\n\n/** Recreate one element, then its allowed children, in the live document. */\nfunction copy(doc: Document, source: Element, report: WrIconStripReport | undefined, depth: number): SVGElement {\n const el = doc.createElementNS(SVG_NS, source.localName);\n\n const attributes = source.attributes;\n for (let i = 0, n = attributes.length; i < n; i++) {\n const { name, value } = attributes[i];\n if (!isAllowedAttribute(name, value)) {\n report?.attributes.add(name);\n continue;\n }\n if (name === 'xlink:href') el.setAttributeNS(XLINK_NS, name, value);\n else el.setAttribute(name, value);\n }\n\n if (depth >= MAX_DEPTH) {\n // Named, not silent — the cap is the one rule here that can bite an icon\n // nobody meant as an attack, and a truncated glyph should say so.\n if (source.childNodes.length > 0) report?.elements.add(`… deeper than ${MAX_DEPTH} levels`);\n return el;\n }\n\n const children = source.childNodes;\n for (let i = 0, n = children.length; i < n; i++) {\n const child = children[i];\n // Text, so `<title>`, `<desc>` and `<text>` keep saying what they said.\n // Comments, CDATA and processing instructions are dropped: an icon has no\n // use for them and a comment is a place to hide a payload from a reader.\n if (child.nodeType === 3) {\n el.appendChild(doc.createTextNode(child.nodeValue ?? ''));\n continue;\n }\n if (child.nodeType !== 1) continue;\n\n const element = child as Element;\n if (!ELEMENTS.has(element.localName)) {\n report?.elements.add(element.localName);\n continue;\n }\n el.appendChild(copy(doc, element, report, depth + 1));\n }\n\n return el;\n}\n\nfunction isAllowedAttribute(name: string, value: string): boolean {\n // `data-*` is a styling and testing hook that can never be behavioural.\n if (name.startsWith('data-')) return true;\n if (!ATTRIBUTES.has(name)) return false;\n if (FRAGMENT_ONLY.has(name)) return FRAGMENT_RE.test(value.trim());\n if (URL_FN_RE.test(value)) return URL_FRAGMENT_RE.test(value.trim());\n return true;\n}\n\nexport { sanitizeIcon, type WrIconStripReport };\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrIconDef } from '../interfaces';\n\nconst VIEW_BOX_RE = /<svg\\b[^>]*\\bviewBox\\s*=/i;\nconst SVG_ROOT_RE = /<svg\\b/i;\n\n/**\n * Dev-mode sanity check for a registered icon — a **rendering** check, and\n * explicitly not a security control.\n *\n * It warns about the two things that make an icon come out wrong: no `<svg>`\n * root, and no `viewBox`, which stops the glyph scaling to the host. It reads\n * the string with two regexes and cannot tell a shape from a script — every\n * payload in the icon corpus passes it, because each one does carry an `<svg>`\n * root with a `viewBox`. It also runs only under `isDevMode()`, so it is absent\n * from the build an attacker would meet.\n *\n * What actually keeps hostile markup out of the DOM is {@link sanitizeIcon},\n * which runs on every render in every build: `<wr-icon>` rebuilds the glyph\n * from an allowlist instead of assigning to `innerHTML`. Anything this function\n * would have to reject is already gone by then, and the component says so in\n * dev mode when it drops something.\n *\n * Production builds drop the call entirely via `isDevMode()` tree-shaking.\n *\n * @internal\n */\nexport function validateIcon(icon: WrIconDef): void {\n if (!SVG_ROOT_RE.test(icon.data)) {\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] Icon \"${icon.name}\" data does not contain an <svg> root element. ` +\n `Custom icons must be valid SVG markup.`\n );\n return;\n }\n\n if (!VIEW_BOX_RE.test(icon.data)) {\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] Icon \"${icon.name}\" has no viewBox attribute — it won't scale ` +\n `to the host size. Add viewBox=\"0 0 W H\" to the <svg> root.`\n );\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DOCUMENT } from '@angular/common';\nimport { Component, ElementRef, ViewEncapsulation, computed, effect, inject, input, isDevMode } from '@angular/core';\n\nimport { WrIconRegistry } from './icon-registry';\nimport type { WrIconDef, WrIconName } from './interfaces';\nimport { type WrIconStripReport, sanitizeIcon } from './utils';\n\n/**\n * Renders a registered SVG icon.\n *\n * Icons must be registered via {@link provideWrIcons} before use —\n * either at the application root or on any ancestor component.\n *\n * @example\n * ```html\n * <wr-icon name=\"home\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/icon\n */\n@Component({\n selector: 'wr-icon',\n template: '',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-icon',\n '[attr.data-icon]': 'name()',\n },\n})\nexport class WrIcon {\n readonly name = input.required<WrIconName>();\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly doc = inject(DOCUMENT);\n\n /**\n * Every icon visible from this position, walked up the whole chain of\n * registering injector levels.\n *\n * Angular's `inject(WR_ICONS)` returns only the **closest** injector's\n * contribution — `multi` providers are not merged across levels — so a\n * component that registers its own icons used to shadow, not extend, what an\n * ancestor registered. {@link WrIconRegistry} is provided once per\n * registering level and links to its parent, so nesting any number of levels\n * now adds up, with the nearest registration winning a name collision.\n *\n * Optional: with no `provideWrIcons()` anywhere the map is simply empty and\n * every name reports as unregistered.\n */\n private readonly iconRegistry = inject(WrIconRegistry, { optional: true });\n\n private readonly registry = computed<ReadonlyMap<WrIconName, WrIconDef>>(\n () => (this.iconRegistry?.resolve() ?? new Map()) as ReadonlyMap<WrIconName, WrIconDef>\n );\n\n private readonly icon = computed(() => this.registry().get(this.name()));\n\n constructor() {\n effect(() => {\n const icon = this.icon();\n const name = this.name();\n\n if (!icon) {\n if (isDevMode()) {\n // Reported, never thrown. An exception here escapes into\n // `runEffectsInView`, which abandons the remaining effects of the\n // whole view — one unknown name would blank every `<wr-icon>` after\n // it while the console blamed only the first. Error level (not\n // `badgeLog`) so it survives a console filtered to errors.\n // eslint-disable-next-line no-console -- misconfiguration must be visible, but must not throw\n console.error(\n `[NGWR] No icon named \"${name}\" is registered. Did you forget to call provideWrIcons()? ` +\n `If the name IS registered, check the injector level: a component-level provideWrIcons() ` +\n `shadows icons registered on an ancestor component.`\n );\n }\n this.clear();\n return;\n }\n\n // Rebuilt from an allowlist rather than assigned to `innerHTML`, which\n // ran an `onload` on the root, an `<image onerror>`, an `<img>` smuggled\n // in after a closed `</svg>` and anything inside a `<foreignObject>` —\n // in production builds, with the app's own origin. `provideWrIcons()`\n // data is untrusted the same way `<wr-markdown>`'s input is: a tenant\n // logo or a fetched icon pack is a normal way to fill it. Building nodes\n // also keeps `<wr-icon>` clear of Trusted Types, which refuses the\n // `innerHTML` write outright.\n const report = isDevMode() ? { elements: new Set<string>(), attributes: new Set<string>() } : undefined;\n const svg = sanitizeIcon(this.doc, icon.data, report);\n\n if (!svg) {\n if (isDevMode()) {\n // eslint-disable-next-line no-console -- misconfiguration must be visible, but must not throw\n console.error(\n `[NGWR] Icon \"${name}\" has no <svg> root element and cannot be rendered. ` +\n `Custom icons must be valid SVG markup.`\n );\n }\n this.clear();\n return;\n }\n\n // Every hand-written inline SVG in the library carries aria-hidden;\n // registered icons went in without it, so a decorative glyph could be\n // announced — usually as a bare \"graphic\" beside the label it decorates.\n // Consumers that need a name put it on the interactive host instead.\n svg.setAttribute('aria-hidden', 'true');\n\n this.clear();\n this.host.nativeElement.appendChild(svg);\n\n if (report) this.reportStripped(name, icon, report);\n });\n }\n\n /**\n * `replaceChildren()` would say this in one call, but domino — the DOM\n * `@angular/platform-server` renders into — does not implement it, and\n * `innerHTML = ''` is the write Trusted Types refuses.\n */\n private clear(): void {\n const el = this.host.nativeElement;\n while (el.firstChild) el.removeChild(el.firstChild);\n }\n\n /**\n * Say what the allowlist removed, once per registered icon.\n *\n * A silently stripped icon is the failure mode this rebuild could introduce:\n * a consumer's own glyph renders blank or wrong and nothing anywhere says\n * why. Keyed on the definition object, so a page with fifty instances of the\n * same icon warns once and an icon nobody renders never warns at all.\n */\n private reportStripped(name: string, icon: WrIconDef, report: WrIconStripReport): void {\n if (WrIcon.reported.has(icon)) return;\n if (report.elements.size === 0 && report.attributes.size === 0) return;\n WrIcon.reported.add(icon);\n\n const removed = [\n report.elements.size ? `elements: ${[...report.elements].join(', ')}` : '',\n report.attributes.size ? `attributes: ${[...report.attributes].join(', ')}` : '',\n ].filter(Boolean);\n\n // eslint-disable-next-line no-console -- a stripped icon must not be silent\n console.warn(\n `[NGWR] Icon \"${name}\" was rendered without part of its markup — ${removed.join('; ')}. ` +\n `Registered icon data is treated as untrusted and rebuilt from an allowlist of SVG ` +\n `shape, paint and text elements, so event handlers, <script>, <style>, <image>, ` +\n `<foreignObject>, <a>, SMIL animation and non-fragment hrefs never reach the DOM.`\n );\n }\n\n private static readonly reported = new WeakSet<WrIconDef>();\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Provider, isDevMode } from '@angular/core';\n\nimport { WrIconRegistry } from '../icon-registry';\nimport type { WrIconDef } from '../interfaces';\nimport { WR_ICONS } from '../tokens';\nimport { validateIcon } from '../utils';\n\n/**\n * Registers a set of icons for use by `<wr-icon>`.\n *\n * Can be called multiple times — each call adds to the registry.\n * Works at both the application root and at the component level,\n * so a feature module or a single component can bring its own icons\n * without polluting the global config.\n *\n * In dev mode, each icon is validated for common issues (missing\n * `viewBox`, malformed root). Validation is dropped from production\n * builds via `isDevMode()` tree-shaking, and it is a rendering check rather\n * than a security one — see {@link validateIcon}.\n *\n * Icon `data` is treated as **untrusted** at render: `<wr-icon>` rebuilds the\n * glyph from an allowlist instead of writing the string to `innerHTML`, so a\n * set fetched at runtime or supplied by a tenant cannot execute in the app's\n * origin. Dev mode names anything the allowlist removed.\n *\n * @example\n * ```ts\n * // App-level registration\n * import { home, user, cog, provideWrIcons } from 'ngwr/icon';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideWrIcons([home, user, cog]),\n * ],\n * };\n * ```\n *\n * @example\n * ```ts\n * // Component-level registration\n * import { logoGithub, logoNpm, provideWrIcons, WrIconDef } from 'ngwr/icon';\n *\n * @Component({\n * selector: 'ngwr-header',\n * imports: [WrIcon],\n * providers: [provideWrIcons([logoGithub, logoNpm])],\n * template: `<wr-icon name=\"logo-github\" />`,\n * })\n * export class HeaderComponent {}\n * ```\n */\nexport function provideWrIcons(icons: WrIconDef[]): Provider[] {\n if (isDevMode()) {\n for (const icon of icons) validateIcon(icon);\n }\n return [\n { provide: WR_ICONS, useValue: icons, multi: true },\n // A registry link per registering level. Angular does not merge `multi`\n // providers across injectors, so without this chain an element-level\n // registration would shadow everything registered above it instead of\n // adding to it.\n WrIconRegistry,\n ];\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrIconDef } from './interfaces';\n\n/**\n * Wrap a raw SVG string in the {@link WrIconDef} envelope. Use this when\n * importing icons from sources that ship full `<svg>` files — Tabler,\n * Phosphor, Heroicons, Iconoir, Radix, Bootstrap Icons, your designer.\n *\n * Pair with a bundler's raw-SVG import (Vite's `?raw`, Webpack's\n * `raw-loader`, esbuild's `--loader:.svg=text`) so the SVG file becomes\n * a string at build time.\n *\n * For sets with a non-SVG shape (Lucide's IconNode tuples, Feather's\n * inner-only SVG), use the dedicated adapter under\n * `ngwr/icon/adapters/<set>` instead.\n *\n * @example\n * ```ts\n * import { svgIcon, provideWrIcons } from 'ngwr/icon';\n * // Vite: the `?raw` suffix returns the file as a string.\n * import plusSvg from '@tabler/icons/icons/plus.svg?raw';\n * import phosphorPlusSvg from '@phosphor-icons/core/assets/regular/plus.svg?raw';\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideWrIcons([\n * svgIcon('plus', plusSvg),\n * svgIcon('plus-phosphor', phosphorPlusSvg),\n * ]),\n * ],\n * });\n * ```\n *\n * **`svg` is treated as untrusted.** It is a string, so it is a natural place\n * for a tenant's uploaded logo or an icon pack fetched from an API to end up,\n * and `<wr-icon>` used to write it to `innerHTML`. It no longer does: the glyph\n * is rebuilt from an allowlist of SVG shape, paint and text elements, so\n * `<script>`, `<style>`, `<image>`, `<foreignObject>`, `<a>`, SMIL animation,\n * every `on*` handler, `style` attributes and non-fragment `href`s are dropped\n * before anything reaches the DOM. In dev mode the component names what it\n * removed, so a legitimate icon that loses something says so out loud.\n */\nexport function svgIcon(name: string, svg: string): WrIconDef {\n return { name, data: svg };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAMH;;;;;;AAMG;AACI,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAyB,UAAU,CAAC;;AClB9E;;;;;AAKG;AAOH;;;;;;;;;;;;;AAaG;MAEU,cAAc,CAAA;;AAER,IAAA,MAAM,GAAG,MAAM,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;AAGnE,IAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AAE7E;;;AAGG;IACH,OAAO,GAAA;AACL,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,EAA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oBACZ,aAAa,EAAE,iBAAiB,CAAC,IAAI;AACrC,oBAAA,IAAI,EAAE;AACJ,wBAAA,KAAK,EAAE,SAAS;AAChB,wBAAA,kBAAkB,EAAE,QAAQ;AAC7B,qBAAA;AACF,iBAAA;;;ACnCD;;;;;AAKG;AASH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CG;AACG,SAAU,cAAc,CAAC,KAAkB,EAAA;IAC/C,IAAI,SAAS,EAAE,EAAE;QACf,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,YAAY,CAAC,IAAI,CAAC;IAC9C;IACA,OAAO;QACL,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;;;;;QAKnD,cAAc;KACf;AACH;;ACtEA;;;;;AAKG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCG;AACG,SAAU,OAAO,CAAC,IAAY,EAAE,GAAW,EAAA;AAC/C,IAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;AAC5B;;AClDA;;AAEG;;;;"}
|
|
@@ -455,11 +455,44 @@ const ESCAPABLE = /[!-/:-@[-`{-~]/;
|
|
|
455
455
|
const SCHEME_RE = /^([a-z][a-z0-9+.-]*):/i;
|
|
456
456
|
const ALLOWED_SCHEMES = new Set(['http', 'https', 'mailto', 'tel', 'ftp']);
|
|
457
457
|
const DATA_IMAGE_RE = /^data:image\/(?:png|jpe?g|gif|webp|avif);base64,[a-z0-9+/=]+$/i;
|
|
458
|
-
|
|
458
|
+
// `[^<>\s]` and not `[^>\s]`: CommonMark defines autolink content as
|
|
459
|
+
// `[^<>\x00-\x20]*`, so `<` ends it by spec — and admitting it is what made this
|
|
460
|
+
// quadratic. On `<http://a<http://a<…` the scheme matches, the class swallows the
|
|
461
|
+
// rest of the document looking for `>`, then backtracks a character at a time, once
|
|
462
|
+
// per `<`. 160 KB took 1.7 s. `ANGLE_DEST_RE` and `EMAIL_AUTOLINK_RE` beside it
|
|
463
|
+
// already exclude `<`; this one was the outlier. The only input that now parses
|
|
464
|
+
// differently is `<http://a<b>`, which no other parser reads as a link either.
|
|
465
|
+
const AUTOLINK_RE = /^<((?:https?|mailto|tel):[^<>\s]+)>/i;
|
|
459
466
|
/** `<destination>` — markdown's way of putting a space in a URL. */
|
|
460
467
|
const ANGLE_DEST_RE = /^<([^<>]*)>(?:\s+["'(](.*)["')])?$/;
|
|
461
468
|
/** CommonMark's own cap on a link label, which is also what bounds the scan. */
|
|
462
469
|
const MAX_LABEL_LENGTH = 999;
|
|
470
|
+
/**
|
|
471
|
+
* How deep parentheses may nest inside `[a](…)` before the destination is refused
|
|
472
|
+
* outright — counted from the `(` that opens it, so 31 nested pairs inside.
|
|
473
|
+
*
|
|
474
|
+
* This is a bound on WORK, not on taste, and it is the only thing standing
|
|
475
|
+
* between a paragraph and a frozen tab. The destination scan walks forward for a
|
|
476
|
+
* balancing `)`, and an unclosed destination sends it to the end of the line; one
|
|
477
|
+
* `[a](x` costs nothing, but `'[a](x'.repeat(16384)` — 80 KB on a single line —
|
|
478
|
+
* makes every one of the 16384 openers walk the whole remainder, which measured
|
|
479
|
+
* 936 ms at 80 KB and 3.9 s at 160 KB, synchronously inside a `computed` during
|
|
480
|
+
* change detection. A `~4x` cost per doubling of the input: quadratic, on a
|
|
481
|
+
* component whose documented input is a comment or a model's output.
|
|
482
|
+
*
|
|
483
|
+
* The cap fixes it because a scan can only keep going by NOT finding its closer,
|
|
484
|
+
* and every later `[…](` it walks past contributes an unmatched `(` of its own —
|
|
485
|
+
* so after 32 of them the scan stops, no opener's walk can cover more than the
|
|
486
|
+
* next 32 openers, and the total is linear in the document. (A `)` that would
|
|
487
|
+
* bring the count back down is the closer, and ends the scan anyway.) The number
|
|
488
|
+
* is cmark's: `manual_scan_link_url` refuses at the same depth, for the same
|
|
489
|
+
* reason.
|
|
490
|
+
*
|
|
491
|
+
* What it costs: a destination with 32 or more nested `(` is no longer a link and
|
|
492
|
+
* renders as text. No URL looks like that — the deep end of the real world is a
|
|
493
|
+
* Wikipedia `..._(disambiguation)`, which is one pair.
|
|
494
|
+
*/
|
|
495
|
+
const MAX_DESTINATION_NESTING = 32;
|
|
463
496
|
const BARE_URL_RE = /^https?:\/\/[^\s<>[\]()]*(?:\([^\s<>()]*\)[^\s<>[\]()]*)*/i;
|
|
464
497
|
const EMAIL_AUTOLINK_RE = /^<([^\s@<>]+@[^\s@<>.]+\.[^\s@<>]+)>/;
|
|
465
498
|
/**
|
|
@@ -538,13 +571,26 @@ function inlines(source, depth, outer) {
|
|
|
538
571
|
}
|
|
539
572
|
}
|
|
540
573
|
if (char === '\n') {
|
|
541
|
-
// Two trailing spaces are markdown's hard break
|
|
542
|
-
//
|
|
543
|
-
//
|
|
544
|
-
//
|
|
545
|
-
//
|
|
546
|
-
//
|
|
547
|
-
|
|
574
|
+
// Two trailing spaces are markdown's hard break, and the question is asked
|
|
575
|
+
// of the SOURCE rather than of `text` — twice now, this one line has been
|
|
576
|
+
// where paragraph parsing went quadratic.
|
|
577
|
+
//
|
|
578
|
+
// `/[ ]{2,}$/.test(text)` was the first version: no start anchor, so it
|
|
579
|
+
// retries from every position of the accumulated paragraph. A CPU profile
|
|
580
|
+
// of a 161 KB document put 3306 ms of 3378 ms of total self-time in it.
|
|
581
|
+
// `text.endsWith(' ')` replaced it and is quadratic for a different
|
|
582
|
+
// reason: `text` is built by `+=`, so it is a rope, and every read of its
|
|
583
|
+
// tail flattens the whole thing — 160,000 short lines cost 1980 ms of
|
|
584
|
+
// copying against 7 ms for the same loop without the test. Ordinary prose
|
|
585
|
+
// reaches that shape; nothing has to be malformed.
|
|
586
|
+
//
|
|
587
|
+
// Reading `source` instead answers the same question in constant time, and
|
|
588
|
+
// it IS the same question: while `text` is non-empty its last character is
|
|
589
|
+
// always `source[i - 1]` (every branch that appends appends exactly the
|
|
590
|
+
// character it consumed), and when it is empty the preceding characters
|
|
591
|
+
// belong to a construct that just closed — none of which can end in a
|
|
592
|
+
// space, since a closing fence, `)`, `>` or emphasis marker is never one.
|
|
593
|
+
const hard = source[i - 1] === ' ' && source[i - 2] === ' ';
|
|
548
594
|
if (hard) {
|
|
549
595
|
text = text.replace(/[ ]+$/, '');
|
|
550
596
|
flush();
|
|
@@ -675,12 +721,13 @@ function codeSpanValue(raw) {
|
|
|
675
721
|
/**
|
|
676
722
|
* `[label](href "title")` starting at `source[at] === '['`.
|
|
677
723
|
*
|
|
678
|
-
*
|
|
724
|
+
* Three bounds, all load-bearing. The label scan stops at
|
|
679
725
|
* {@link MAX_LABEL_LENGTH}, which is CommonMark's own limit, and a scan that
|
|
680
726
|
* reaches the end of the source without meeting a single `]` records the fact in
|
|
681
727
|
* the context — from then on every later `[` answers in constant time. Without
|
|
682
728
|
* that, `'['.repeat(100000)` spent 8 seconds on the main thread, inside a
|
|
683
|
-
* `computed`.
|
|
729
|
+
* `computed`. The third is {@link MAX_DESTINATION_NESTING}, on the destination
|
|
730
|
+
* scan, and it is the one that makes the whole function linear.
|
|
684
731
|
*/
|
|
685
732
|
function matchLink(source, at, ctx) {
|
|
686
733
|
if (at >= ctx.noBracket.from)
|
|
@@ -738,8 +785,13 @@ function matchLink(source, at, ctx) {
|
|
|
738
785
|
i++;
|
|
739
786
|
continue;
|
|
740
787
|
}
|
|
741
|
-
if (char === '(')
|
|
788
|
+
if (char === '(') {
|
|
742
789
|
parens++;
|
|
790
|
+
// Giving up HERE is what makes the scan linear rather than quadratic — see
|
|
791
|
+
// {@link MAX_DESTINATION_NESTING}.
|
|
792
|
+
if (parens > MAX_DESTINATION_NESTING)
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
743
795
|
if (char === ')') {
|
|
744
796
|
parens--;
|
|
745
797
|
if (parens === 0) {
|