@ng-native/icons 0.2.0 → 0.4.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/dist/ng-icon.js +13 -4
- package/dist/ng-icon.js.map +1 -1
- package/dist/svg-elements.d.ts +3 -4
- package/dist/svg-elements.js +4 -14
- package/dist/svg-elements.js.map +1 -1
- package/dist/svg-props.d.ts +6 -0
- package/dist/svg-props.js +35 -9
- package/dist/svg-props.js.map +1 -1
- package/package.json +4 -3
package/dist/ng-icon.js
CHANGED
|
@@ -27,7 +27,7 @@ import { claimHost, HostEngine } from '@ng-native/fabric';
|
|
|
27
27
|
import { NgIconsToken } from '@ng-icons/core';
|
|
28
28
|
import { parseSvg } from "./parse-svg.js";
|
|
29
29
|
import { registerSvgComponents } from "./svg-elements.js";
|
|
30
|
-
import { SVG_ELEMENTS, nativeProps, styleAttributes, viewBoxProps } from "./svg-props.js";
|
|
30
|
+
import { PAINT, SVG_ELEMENTS, isTokenPaint, nativeProps, own, styleAttributes, viewBoxProps, } from "./svg-props.js";
|
|
31
31
|
import * as i0 from "@angular/core";
|
|
32
32
|
/** ng-icons stores icons under a camel-cased key, so `hero-book-open` finds `heroBookOpen`. */
|
|
33
33
|
function toPropertyName(name) {
|
|
@@ -74,8 +74,9 @@ export class NgIcon {
|
|
|
74
74
|
const key = toPropertyName(name);
|
|
75
75
|
// Reversed, because a nearer `provideIcons` should win over one further up the tree.
|
|
76
76
|
for (const set of [...this.icons].reverse()) {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const markup = own(set, key);
|
|
78
|
+
if (markup)
|
|
79
|
+
return markup;
|
|
79
80
|
}
|
|
80
81
|
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
81
82
|
console.warn(`[angular-native] no icon named ${name}. Pass it to provideIcons() from the set it ` +
|
|
@@ -119,7 +120,7 @@ export class NgIcon {
|
|
|
119
120
|
this.renderer.appendChild(this.host, group);
|
|
120
121
|
}
|
|
121
122
|
append(parent, node) {
|
|
122
|
-
const element = SVG_ELEMENTS
|
|
123
|
+
const element = own(SVG_ELEMENTS, node.tag);
|
|
123
124
|
if (!element)
|
|
124
125
|
return;
|
|
125
126
|
const shape = this.create(element, node);
|
|
@@ -140,6 +141,14 @@ export class NgIcon {
|
|
|
140
141
|
}),
|
|
141
142
|
};
|
|
142
143
|
const props = nativeProps(node.tag, attrs, { color: (value) => this.engine.color(value) });
|
|
144
|
+
// A paint that reads a custom property is settled by the cascade, with the tokens in scope
|
|
145
|
+
// for the shape, and follows them. It stays in `propList`, which says the shape has one.
|
|
146
|
+
const cascade = this.engine;
|
|
147
|
+
for (const paint of PAINT) {
|
|
148
|
+
if (!isTokenPaint(attrs[paint]) || !cascade.setBoundStyle?.(shape, paint, attrs[paint]))
|
|
149
|
+
continue;
|
|
150
|
+
delete props[paint];
|
|
151
|
+
}
|
|
143
152
|
for (const [prop, value] of Object.entries(props)) {
|
|
144
153
|
this.renderer.setProperty(shape, prop, value);
|
|
145
154
|
}
|
package/dist/ng-icon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-icon.js","sourceRoot":"","sources":["../src/ng-icon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,eAAe,GAEhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;;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B,WAAW,EAAE,mBAAmB;wBAChC,YAAY,EAAE,oBAAoB;wBAClC,SAAS,EAAE,iBAAiB;wBAC5B,eAAe,EAAE,uBAAuB;wBACxC,cAAc,EAAE,oCAAoC;wBACpD,qBAAqB,EAAE,0DAA0D;wBACjF,sBAAsB,EAAE,sBAAsB;qBAC/C;iBACF","sourcesContent":["/**\n * An icon, from the same `@ng-icons` packages a web app uses.\n *\n * An app imports `NgIcon`, provides the icons it uses with ng-icons' own `provideIcons`, and\n * writes `<ng-icon name=\"heroBookOpen\" [size]=\"28\" color=\"#ff9f0a\" />`. The imports are the same\n * ones a web app writes:\n *\n * ```ts\n * import { NgIcon } from '@ng-native/icons';\n * import { provideIcons } from '@ng-icons/core';\n * import { heroBookOpen } from '@ng-icons/heroicons/outline';\n * ```\n *\n * The icon *packages* are the reusable part: each set ships its icons as plain strings of SVG\n * markup, and `provideIcons` is ordinary dependency injection. What cannot be reused is\n * `@ng-icons/core`'s own `NgIcon`, which inserts that markup with `innerHTML` and sizes it with\n * CSS custom properties. This is the same component against react-native-svg's native views: the\n * markup is parsed, translated, and committed as real shapes.\n *\n * The two things ng-icons expresses in CSS become inputs here. `color` is set on the host, which\n * is what native paints a `currentColor` brush from - so a bound colour changes every stroke in\n * the icon without re-parsing it. `strokeWidth` fills in `var(--ng-icon__stroke-width, 1.5)`,\n * which is how the heroicons outline set carries its weight.\n */\nimport {\n Component,\n ElementRef,\n Renderer2,\n computed,\n effect,\n inject,\n input,\n numberAttribute,\n type Signal,\n} from '@angular/core';\nimport { claimHost, type EngineNode, HostEngine } from '@ng-native/fabric';\nimport { NgIconsToken } from '@ng-icons/core';\nimport { parseSvg, type SvgNode } from './parse-svg.ts';\nimport { registerSvgComponents } from './svg-elements.ts';\nimport { SVG_ELEMENTS, nativeProps, styleAttributes, viewBoxProps } from './svg-props.ts';\n\n/** ng-icons stores icons under a camel-cased key, so `hero-book-open` finds `heroBookOpen`. */\nfunction toPropertyName(name: string): string {\n return name\n .replace(/([^a-zA-Z0-9])+(.)?/g, (_, __, character: string | undefined) =>\n character ? character.toUpperCase() : '',\n )\n .replace(/[^a-zA-Z\\d]/g, '')\n .replace(/^([A-Z])/, (match) => match.toLowerCase());\n}\n\n@Component({\n selector: 'ng-icon',\n template: '',\n host: {\n '[style]': 'style()',\n '[color]': 'color()',\n '[bbWidth]': 'size()',\n '[bbHeight]': 'size()',\n '[minX]': 'viewBox().minX',\n '[minY]': 'viewBox().minY',\n '[vbWidth]': 'viewBox().vbWidth',\n '[vbHeight]': 'viewBox().vbHeight',\n '[align]': 'viewBox().align',\n '[meetOrSlice]': 'viewBox().meetOrSlice',\n '[accessible]': 'accessibilityLabel() !== undefined',\n '[accessibilityRole]': \"accessibilityLabel() === undefined ? undefined : 'image'\",\n '[accessibilityLabel]': 'accessibilityLabel()',\n },\n})\nexport class NgIcon {\n private readonly host = inject(ElementRef).nativeElement as EngineNode;\n private readonly renderer = inject(Renderer2);\n private readonly engine = inject(HostEngine);\n /** Every `provideIcons` in scope, innermost last, which is how ng-icons layers them. */\n private readonly icons = inject(NgIconsToken, { optional: true }) ?? [];\n\n /** The key the icon was provided under: `heroBookOpen`, or `hero-book-open`. */\n readonly name = input<string>();\n /** Markup, for an icon that comes from somewhere other than a provider. */\n readonly svg = input<string>();\n /**\n * Points, square. Icons are drawn from a `viewBox`, so this is the size on screen. A static\n * `size=\"32\"` is read as the number it spells.\n */\n readonly size = input(24, { transform: (value: number | string) => numberAttribute(value, 24) });\n /** What a `currentColor` stroke or fill paints as. Native resolves it, so binding is cheap. */\n readonly color = input<string>();\n /** Fills in `var(--ng-icon__stroke-width, …)`, which is how an outline set carries its weight. */\n readonly strokeWidth = input<number | string>();\n /** Absent leaves the icon out of the accessibility tree, which is right for a decorative one. */\n readonly accessibilityLabel = input<string>();\n\n protected readonly style = computed(() => ({ width: this.size(), height: this.size() }));\n\n private readonly markup: Signal<string | undefined> = computed(() => {\n const svg = this.svg();\n if (svg !== undefined) return svg;\n const name = this.name();\n if (name === undefined) return undefined;\n\n const key = toPropertyName(name);\n // Reversed, because a nearer `provideIcons` should win over one further up the tree.\n for (const set of [...this.icons].reverse()) {\n if (set[key]) return set[key];\n }\n if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n console.warn(\n `[angular-native] no icon named ${name}. Pass it to provideIcons() from the set it ` +\n `belongs to, the same way you would on the web.`,\n );\n }\n return undefined;\n });\n\n private readonly root = computed(() => {\n const markup = this.markup();\n return markup === undefined ? null : parseSvg(markup);\n });\n\n protected readonly viewBox = computed(() => viewBoxProps(this.root()?.attrs['viewBox']));\n\n constructor() {\n // Before the first shape is created, which is before this component's own commit.\n registerSvgComponents();\n // Claimed, and stripped of the attributes Angular wrote from static inputs: `name` is one of\n // ours *and* one of react-native-svg's, so leaving it there hands native an element name.\n claimHost(this.host);\n for (const input of Object.keys(\n (NgIcon as { ɵcmp?: { inputs?: object } }).ɵcmp?.inputs ?? {},\n )) {\n delete this.host.props[input];\n }\n // The shapes are created rather than templated: an icon's tree is data, and a template that\n // could express it would be a component per tag with a recursive switch between them.\n effect(() => this.draw());\n }\n\n private draw(): void {\n const root = this.root();\n for (const child of [...this.host.children]) this.renderer.removeChild(this.host, child);\n if (!root) return;\n\n // Everything hangs off one group carrying the root's presentation attributes, which is how\n // react-native-svg's own `Svg` does it: the svg view itself holds no paint, so a root that\n // says `stroke=\"currentColor\"` needs a group for its children to inherit from.\n const group = this.create('svg-g', root);\n for (const child of root.children) this.append(group, child);\n this.renderer.appendChild(this.host, group);\n }\n\n private append(parent: unknown, node: SvgNode): void {\n const element = SVG_ELEMENTS[node.tag];\n if (!element) return;\n const shape = this.create(element, node);\n for (const child of node.children) this.append(shape, child);\n this.renderer.appendChild(parent, shape);\n }\n\n private create(element: string, node: SvgNode): unknown {\n const shape = this.renderer.createElement(element) as EngineNode;\n // Created here rather than by a template, so nothing else will account for it: without this\n // the engine reports every shape as an element whose component was forgotten.\n claimHost(shape);\n const attrs = {\n ...node.attrs,\n // A `style` attribute is where ng-icons puts the stroke width, as a custom property.\n ...styleAttributes(node.attrs['style'] ?? '', {\n '--ng-icon__stroke-width': this.strokeWidth(),\n }),\n };\n const props = nativeProps(node.tag, attrs, { color: (value) => this.engine.color(value) });\n for (const [prop, value] of Object.entries(props)) {\n this.renderer.setProperty(shape, prop, value);\n }\n return shape;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ng-icon.js","sourceRoot":"","sources":["../src/ng-icon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,eAAe,GAEhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAgC,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,GAAG,EACH,eAAe,EACf,YAAY,GACb,MAAM,gBAAgB,CAAC;;AAExB,+FAA+F;AAC/F,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI;SACR,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,SAA6B,EAAE,EAAE,CACxE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CACzC;SACA,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;AACzD,CAAC;AAqBD,MAAM,OAAO,MAAM;IACA,IAAI,GAAG,MAAM,CAAC,UAAU,CA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oB;wBAClC,SAAS,EAAE,iBAAiB;wBAC5B,eAAe,EAAE,uBAAuB;wBACxC,cAAc,EAAE,oCAAoC;wBACpD,qBAAqB,EAAE,0DAA0D;wBACjF,sBAAsB,EAAE,sBAAsB;qBAC/C;iBACF","sourcesContent":["/**\n * An icon, from the same `@ng-icons` packages a web app uses.\n *\n * An app imports `NgIcon`, provides the icons it uses with ng-icons' own `provideIcons`, and\n * writes `<ng-icon name=\"heroBookOpen\" [size]=\"28\" color=\"#ff9f0a\" />`. The imports are the same\n * ones a web app writes:\n *\n * ```ts\n * import { NgIcon } from '@ng-native/icons';\n * import { provideIcons } from '@ng-icons/core';\n * import { heroBookOpen } from '@ng-icons/heroicons/outline';\n * ```\n *\n * The icon *packages* are the reusable part: each set ships its icons as plain strings of SVG\n * markup, and `provideIcons` is ordinary dependency injection. What cannot be reused is\n * `@ng-icons/core`'s own `NgIcon`, which inserts that markup with `innerHTML` and sizes it with\n * CSS custom properties. This is the same component against react-native-svg's native views: the\n * markup is parsed, translated, and committed as real shapes.\n *\n * The two things ng-icons expresses in CSS become inputs here. `color` is set on the host, which\n * is what native paints a `currentColor` brush from - so a bound colour changes every stroke in\n * the icon without re-parsing it. `strokeWidth` fills in `var(--ng-icon__stroke-width, 1.5)`,\n * which is how the heroicons outline set carries its weight.\n */\nimport {\n Component,\n ElementRef,\n Renderer2,\n computed,\n effect,\n inject,\n input,\n numberAttribute,\n type Signal,\n} from '@angular/core';\nimport { claimHost, type Engine, type EngineNode, HostEngine } from '@ng-native/fabric';\nimport { NgIconsToken } from '@ng-icons/core';\nimport { parseSvg, type SvgNode } from './parse-svg.ts';\nimport { registerSvgComponents } from './svg-elements.ts';\nimport {\n PAINT,\n SVG_ELEMENTS,\n isTokenPaint,\n nativeProps,\n own,\n styleAttributes,\n viewBoxProps,\n} from './svg-props.ts';\n\n/** ng-icons stores icons under a camel-cased key, so `hero-book-open` finds `heroBookOpen`. */\nfunction toPropertyName(name: string): string {\n return name\n .replace(/([^a-zA-Z0-9])+(.)?/g, (_, __, character: string | undefined) =>\n character ? character.toUpperCase() : '',\n )\n .replace(/[^a-zA-Z\\d]/g, '')\n .replace(/^([A-Z])/, (match) => match.toLowerCase());\n}\n\n@Component({\n selector: 'ng-icon',\n template: '',\n host: {\n '[style]': 'style()',\n '[color]': 'color()',\n '[bbWidth]': 'size()',\n '[bbHeight]': 'size()',\n '[minX]': 'viewBox().minX',\n '[minY]': 'viewBox().minY',\n '[vbWidth]': 'viewBox().vbWidth',\n '[vbHeight]': 'viewBox().vbHeight',\n '[align]': 'viewBox().align',\n '[meetOrSlice]': 'viewBox().meetOrSlice',\n '[accessible]': 'accessibilityLabel() !== undefined',\n '[accessibilityRole]': \"accessibilityLabel() === undefined ? undefined : 'image'\",\n '[accessibilityLabel]': 'accessibilityLabel()',\n },\n})\nexport class NgIcon {\n private readonly host = inject(ElementRef).nativeElement as EngineNode;\n private readonly renderer = inject(Renderer2);\n private readonly engine = inject(HostEngine);\n /** Every `provideIcons` in scope, innermost last, which is how ng-icons layers them. */\n private readonly icons = inject(NgIconsToken, { optional: true }) ?? [];\n\n /** The key the icon was provided under: `heroBookOpen`, or `hero-book-open`. */\n readonly name = input<string>();\n /** Markup, for an icon that comes from somewhere other than a provider. */\n readonly svg = input<string>();\n /**\n * Points, square. Icons are drawn from a `viewBox`, so this is the size on screen. A static\n * `size=\"32\"` is read as the number it spells.\n */\n readonly size = input(24, { transform: (value: number | string) => numberAttribute(value, 24) });\n /** What a `currentColor` stroke or fill paints as. Native resolves it, so binding is cheap. */\n readonly color = input<string>();\n /** Fills in `var(--ng-icon__stroke-width, …)`, which is how an outline set carries its weight. */\n readonly strokeWidth = input<number | string>();\n /** Absent leaves the icon out of the accessibility tree, which is right for a decorative one. */\n readonly accessibilityLabel = input<string>();\n\n protected readonly style = computed(() => ({ width: this.size(), height: this.size() }));\n\n private readonly markup: Signal<string | undefined> = computed(() => {\n const svg = this.svg();\n if (svg !== undefined) return svg;\n const name = this.name();\n if (name === undefined) return undefined;\n\n const key = toPropertyName(name);\n // Reversed, because a nearer `provideIcons` should win over one further up the tree.\n for (const set of [...this.icons].reverse()) {\n const markup = own(set, key);\n if (markup) return markup;\n }\n if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n console.warn(\n `[angular-native] no icon named ${name}. Pass it to provideIcons() from the set it ` +\n `belongs to, the same way you would on the web.`,\n );\n }\n return undefined;\n });\n\n private readonly root = computed(() => {\n const markup = this.markup();\n return markup === undefined ? null : parseSvg(markup);\n });\n\n protected readonly viewBox = computed(() => viewBoxProps(this.root()?.attrs['viewBox']));\n\n constructor() {\n // Before the first shape is created, which is before this component's own commit.\n registerSvgComponents();\n // Claimed, and stripped of the attributes Angular wrote from static inputs: `name` is one of\n // ours *and* one of react-native-svg's, so leaving it there hands native an element name.\n claimHost(this.host);\n for (const input of Object.keys(\n (NgIcon as { ɵcmp?: { inputs?: object } }).ɵcmp?.inputs ?? {},\n )) {\n delete this.host.props[input];\n }\n // The shapes are created rather than templated: an icon's tree is data, and a template that\n // could express it would be a component per tag with a recursive switch between them.\n effect(() => this.draw());\n }\n\n private draw(): void {\n const root = this.root();\n for (const child of [...this.host.children]) this.renderer.removeChild(this.host, child);\n if (!root) return;\n\n // Everything hangs off one group carrying the root's presentation attributes, which is how\n // react-native-svg's own `Svg` does it: the svg view itself holds no paint, so a root that\n // says `stroke=\"currentColor\"` needs a group for its children to inherit from.\n const group = this.create('svg-g', root);\n for (const child of root.children) this.append(group, child);\n this.renderer.appendChild(this.host, group);\n }\n\n private append(parent: unknown, node: SvgNode): void {\n const element = own(SVG_ELEMENTS, node.tag);\n if (!element) return;\n const shape = this.create(element, node);\n for (const child of node.children) this.append(shape, child);\n this.renderer.appendChild(parent, shape);\n }\n\n private create(element: string, node: SvgNode): unknown {\n const shape = this.renderer.createElement(element) as EngineNode;\n // Created here rather than by a template, so nothing else will account for it: without this\n // the engine reports every shape as an element whose component was forgotten.\n claimHost(shape);\n const attrs = {\n ...node.attrs,\n // A `style` attribute is where ng-icons puts the stroke width, as a custom property.\n ...styleAttributes(node.attrs['style'] ?? '', {\n '--ng-icon__stroke-width': this.strokeWidth(),\n }),\n };\n const props = nativeProps(node.tag, attrs, { color: (value) => this.engine.color(value) });\n // A paint that reads a custom property is settled by the cascade, with the tokens in scope\n // for the shape, and follows them. It stays in `propList`, which says the shape has one.\n const cascade = this.engine as Partial<Pick<Engine, 'setBoundStyle'>>;\n for (const paint of PAINT) {\n if (!isTokenPaint(attrs[paint]) || !cascade.setBoundStyle?.(shape, paint, attrs[paint]))\n continue;\n delete props[paint];\n }\n for (const [prop, value] of Object.entries(props)) {\n this.renderer.setProperty(shape, prop, value);\n }\n return shape;\n }\n}\n"]}
|
package/dist/svg-elements.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Teach the engine the shape elements and
|
|
3
|
-
* importing
|
|
4
|
-
*
|
|
5
|
-
* shapes directly.
|
|
2
|
+
* Teach the engine the shape elements and `ng-icon`, `NgIcon`'s own host, as the root. Called by
|
|
3
|
+
* `NgIcon`, so importing it is the whole setup - the same lesson as `AnimatedStyle`, which stopped
|
|
4
|
+
* needing a bootstrap provider for the same reason.
|
|
6
5
|
*
|
|
7
6
|
* A name the native side does not know renders as `UnimplementedNativeView` rather than erroring,
|
|
8
7
|
* so an app that has not installed `react-native-svg` sees blank boxes where its icons were.
|
package/dist/svg-elements.js
CHANGED
|
@@ -26,18 +26,11 @@ const SVG_VIEW_NAMES = {
|
|
|
26
26
|
'svg-rect': 'RNSVGRect',
|
|
27
27
|
'svg-line': 'RNSVGLine',
|
|
28
28
|
};
|
|
29
|
-
/**
|
|
30
|
-
* The roots: element name -> Fabric component, same iOS/Android split as the shapes above.
|
|
31
|
-
* `ng-icon` is `NgIcon`'s own host; a list because nothing stops two element names sharing one
|
|
32
|
-
* native view.
|
|
33
|
-
*/
|
|
34
|
-
const SVG_ROOT_NAMES = ['ng-icon'];
|
|
35
29
|
let registered = false;
|
|
36
30
|
/**
|
|
37
|
-
* Teach the engine the shape elements and
|
|
38
|
-
* importing
|
|
39
|
-
*
|
|
40
|
-
* shapes directly.
|
|
31
|
+
* Teach the engine the shape elements and `ng-icon`, `NgIcon`'s own host, as the root. Called by
|
|
32
|
+
* `NgIcon`, so importing it is the whole setup - the same lesson as `AnimatedStyle`, which stopped
|
|
33
|
+
* needing a bootstrap provider for the same reason.
|
|
41
34
|
*
|
|
42
35
|
* A name the native side does not know renders as `UnimplementedNativeView` rather than erroring,
|
|
43
36
|
* so an app that has not installed `react-native-svg` sees blank boxes where its icons were.
|
|
@@ -46,10 +39,7 @@ export function registerSvgComponents() {
|
|
|
46
39
|
if (registered)
|
|
47
40
|
return;
|
|
48
41
|
registered = true;
|
|
49
|
-
|
|
50
|
-
for (const root of SVG_ROOT_NAMES) {
|
|
51
|
-
registerViewName(root, rootViewName);
|
|
52
|
-
}
|
|
42
|
+
registerViewName('ng-icon', nativePlatform() === 'android' ? 'RNSVGSvgViewAndroid' : 'RNSVGSvgView');
|
|
53
43
|
for (const [element, viewName] of Object.entries(SVG_VIEW_NAMES)) {
|
|
54
44
|
registerViewName(element, viewName);
|
|
55
45
|
}
|
package/dist/svg-elements.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg-elements.js","sourceRoot":"","sources":["../src/svg-elements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,cAAc,GAA2B;IAC7C,OAAO,EAAE,YAAY;IACrB,UAAU,EAAE,WAAW;IACvB,YAAY,EAAE,aAAa;IAC3B,aAAa,EAAE,cAAc;IAC7B,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,WAAW;CACxB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"svg-elements.js","sourceRoot":"","sources":["../src/svg-elements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,cAAc,GAA2B;IAC7C,OAAO,EAAE,YAAY;IACrB,UAAU,EAAE,WAAW;IACvB,YAAY,EAAE,aAAa;IAC3B,aAAa,EAAE,cAAc;IAC7B,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,WAAW;CACxB,CAAC;AAEF,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,UAAU;QAAE,OAAO;IACvB,UAAU,GAAG,IAAI,CAAC;IAClB,gBAAgB,CACd,SAAS,EACT,cAAc,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,cAAc,CACxE,CAAC;IACF,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QACjE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;AACH,CAAC","sourcesContent":["/**\n * react-native-svg, driven directly.\n *\n * The same arrangement as react-native-screens in the router: the native side is a set of\n * codegen'd Fabric components, and their React wrappers are unreachable, so the engine is taught\n * the element names and the shapes are created with `createElement`. The app installs\n * `react-native-svg` for the native half; none of its JavaScript is imported.\n *\n * No decorators here: tests import this at runtime.\n */\nimport { nativePlatform, registerViewName } from '@ng-native/fabric';\n\n/**\n * Element name -> Fabric component. Lowercase, because the compiler drops a template with a\n * capitalized element name, and prefixed, because `path` and\n * `line` are words an app might reasonably want for a component of its own.\n *\n * The root is the one that differs per platform: iOS draws into `RNSVGSvgView`, Android into\n * `RNSVGSvgViewAndroid`, and react-native-svg keeps them as separate specs because their props\n * are not the same.\n */\nconst SVG_VIEW_NAMES: Record<string, string> = {\n 'svg-g': 'RNSVGGroup',\n 'svg-path': 'RNSVGPath',\n 'svg-circle': 'RNSVGCircle',\n 'svg-ellipse': 'RNSVGEllipse',\n 'svg-rect': 'RNSVGRect',\n 'svg-line': 'RNSVGLine',\n};\n\nlet registered = false;\n\n/**\n * Teach the engine the shape elements and `ng-icon`, `NgIcon`'s own host, as the root. Called by\n * `NgIcon`, so importing it is the whole setup - the same lesson as `AnimatedStyle`, which stopped\n * needing a bootstrap provider for the same reason.\n *\n * A name the native side does not know renders as `UnimplementedNativeView` rather than erroring,\n * so an app that has not installed `react-native-svg` sees blank boxes where its icons were.\n */\nexport function registerSvgComponents(): void {\n if (registered) return;\n registered = true;\n registerViewName(\n 'ng-icon',\n nativePlatform() === 'android' ? 'RNSVGSvgViewAndroid' : 'RNSVGSvgView',\n );\n for (const [element, viewName] of Object.entries(SVG_VIEW_NAMES)) {\n registerViewName(element, viewName);\n }\n}\n"]}
|
package/dist/svg-props.d.ts
CHANGED
|
@@ -24,11 +24,17 @@ export type Brush = null | {
|
|
|
24
24
|
} | {
|
|
25
25
|
readonly type: 2;
|
|
26
26
|
};
|
|
27
|
+
/** `table[key]`, but never off `Object.prototype`: a tag or attribute named `constructor` is unknown. */
|
|
28
|
+
export declare function own<T>(table: Readonly<Record<string, T>>, key: string): T | undefined;
|
|
27
29
|
/**
|
|
28
30
|
* Which element each SVG tag commits as. `polyline` and `polygon` are paths: react-native-svg has
|
|
29
31
|
* no component for either and converts their points to a `d`, so this does too.
|
|
30
32
|
*/
|
|
31
33
|
export declare const SVG_ELEMENTS: Record<string, string>;
|
|
34
|
+
/** The presentation attributes that are a paint. */
|
|
35
|
+
export declare const PAINT: ReadonlySet<string>;
|
|
36
|
+
/** Whether a paint is a `var()`, which only the cascade can settle. */
|
|
37
|
+
export declare const isTokenPaint: (value: string | undefined) => value is string;
|
|
32
38
|
export interface SvgContext {
|
|
33
39
|
/** The host's colour conversion, which a brush payload is the result of. */
|
|
34
40
|
color(value: string): unknown;
|
package/dist/svg-props.js
CHANGED
|
@@ -18,6 +18,10 @@ const LINECAP = { butt: 0, round: 1, square: 2 };
|
|
|
18
18
|
const LINEJOIN = { miter: 0, round: 1, bevel: 2 };
|
|
19
19
|
const FILL_RULE = { evenodd: 0, nonzero: 1 };
|
|
20
20
|
const URL_REFERENCE = /^url\(#(.+)\)$/;
|
|
21
|
+
/** `table[key]`, but never off `Object.prototype`: a tag or attribute named `constructor` is unknown. */
|
|
22
|
+
export function own(table, key) {
|
|
23
|
+
return Object.hasOwn(table, key) ? table[key] : undefined;
|
|
24
|
+
}
|
|
21
25
|
/**
|
|
22
26
|
* Which element each SVG tag commits as. `polyline` and `polygon` are paths: react-native-svg has
|
|
23
27
|
* no component for either and converts their points to a `d`, so this does too.
|
|
@@ -40,6 +44,26 @@ const GEOMETRY = {
|
|
|
40
44
|
rect: ['x', 'y', 'width', 'height', 'rx', 'ry'],
|
|
41
45
|
line: ['x1', 'y1', 'x2', 'y2'],
|
|
42
46
|
};
|
|
47
|
+
/** A shape's geometry, as written, and 0 for what react-native-svg defaults and it left out. */
|
|
48
|
+
function geometry(tag, attrs, props) {
|
|
49
|
+
for (const name of own(GEOMETRY, tag) ?? []) {
|
|
50
|
+
if (attrs[name] !== undefined)
|
|
51
|
+
props[name] = attrs[name];
|
|
52
|
+
}
|
|
53
|
+
for (const name of own(ZERO_BY_DEFAULT, tag) ?? [])
|
|
54
|
+
props[name] ??= 0;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The geometry each shape defaults to 0 when absent, as react-native-svg's `Rect`, `Circle`,
|
|
58
|
+
* `Ellipse` and `Line` do before they commit. Android's shape views read a missing length as null
|
|
59
|
+
* and crash drawing it, and design tools often leave out a `y="0"`.
|
|
60
|
+
*/
|
|
61
|
+
const ZERO_BY_DEFAULT = {
|
|
62
|
+
circle: ['cx', 'cy', 'r'],
|
|
63
|
+
ellipse: ['cx', 'cy', 'rx', 'ry'],
|
|
64
|
+
rect: ['x', 'y', 'width', 'height'],
|
|
65
|
+
line: ['x1', 'y1', 'x2', 'y2'],
|
|
66
|
+
};
|
|
43
67
|
/** SVG attribute -> native prop, for the presentation attributes shapes and groups share. */
|
|
44
68
|
const PRESENTATION = {
|
|
45
69
|
fill: 'fill',
|
|
@@ -56,6 +80,10 @@ const PRESENTATION = {
|
|
|
56
80
|
'clip-rule': 'clipRule',
|
|
57
81
|
opacity: 'opacity',
|
|
58
82
|
};
|
|
83
|
+
/** The presentation attributes that are a paint. */
|
|
84
|
+
export const PAINT = new Set(['fill', 'stroke']);
|
|
85
|
+
/** Whether a paint is a `var()`, which only the cascade can settle. */
|
|
86
|
+
export const isTokenPaint = (value) => value !== undefined && /^\s*var\(/i.test(value);
|
|
59
87
|
export function brushOf(value, context) {
|
|
60
88
|
if (value === 'none')
|
|
61
89
|
return null;
|
|
@@ -90,7 +118,8 @@ export function styleAttributes(style, variables) {
|
|
|
90
118
|
continue;
|
|
91
119
|
const name = declaration.slice(0, colon).trim();
|
|
92
120
|
const value = declaration.slice(colon + 1).trim();
|
|
93
|
-
|
|
121
|
+
// A paint's `var()` is kept as written: the cascade settles it, with the tokens in scope.
|
|
122
|
+
const resolved = resolveVar(value, variables) ?? (PAINT.has(name) ? value : undefined);
|
|
94
123
|
if (name && resolved !== undefined)
|
|
95
124
|
attrs[name] = resolved;
|
|
96
125
|
}
|
|
@@ -183,7 +212,7 @@ export function nativeProps(tag, attrs, context) {
|
|
|
183
212
|
const props = {};
|
|
184
213
|
const propList = [];
|
|
185
214
|
for (const [name, value] of Object.entries(attrs)) {
|
|
186
|
-
const prop = PRESENTATION
|
|
215
|
+
const prop = own(PRESENTATION, name);
|
|
187
216
|
if (!prop)
|
|
188
217
|
continue;
|
|
189
218
|
props[prop] = presentationValue(prop, value, context);
|
|
@@ -191,10 +220,7 @@ export function nativeProps(tag, attrs, context) {
|
|
|
191
220
|
}
|
|
192
221
|
if (propList.length > 0)
|
|
193
222
|
props['propList'] = propList;
|
|
194
|
-
|
|
195
|
-
if (attrs[name] !== undefined)
|
|
196
|
-
props[name] = attrs[name];
|
|
197
|
-
}
|
|
223
|
+
geometry(tag, attrs, props);
|
|
198
224
|
if (tag === 'polyline' || tag === 'polygon') {
|
|
199
225
|
props['d'] = pointsToPath(attrs['points'] ?? '', tag === 'polygon');
|
|
200
226
|
}
|
|
@@ -228,11 +254,11 @@ function presentationValue(prop, value, context) {
|
|
|
228
254
|
if (prop === 'fill' || prop === 'stroke')
|
|
229
255
|
return brushOf(value, context);
|
|
230
256
|
if (prop === 'strokeLinecap')
|
|
231
|
-
return LINECAP
|
|
257
|
+
return own(LINECAP, value) ?? 0;
|
|
232
258
|
if (prop === 'strokeLinejoin')
|
|
233
|
-
return LINEJOIN
|
|
259
|
+
return own(LINEJOIN, value) ?? 0;
|
|
234
260
|
if (prop === 'fillRule' || prop === 'clipRule')
|
|
235
|
-
return FILL_RULE
|
|
261
|
+
return own(FILL_RULE, value) ?? 1;
|
|
236
262
|
if (prop === 'strokeDasharray')
|
|
237
263
|
return value
|
|
238
264
|
.trim()
|
package/dist/svg-props.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg-props.js","sourceRoot":"","sources":["../src/svg-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,MAAM,OAAO,GAA2B,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AACzE,MAAM,QAAQ,GAA2B,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAC1E,MAAM,SAAS,GAA2B,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAErE,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAEvC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAA2B;IAClD,CAAC,EAAE,OAAO;IACV,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;IACpB,OAA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AAC1F,SAAS,SAAS,CAAC,IAAY,EAAE,KAAa;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AACxD,CAAC","sourcesContent":["/**\n * SVG attributes to the props react-native-svg's native views actually take.\n *\n * They are not the same thing, and the difference is the whole reason this file exists. `fill`\n * and `stroke` are not colours but *brushes*, a tagged struct that says whether the paint is a\n * colour, the view's own `color`, or a reference to a gradient. `stroke-linecap`, `stroke-linejoin`\n * and `fill-rule` are integers, not the keywords they are written as. And a shape has to declare\n * which props it set - `propList` - because anything absent is inherited from the group above it,\n * which is exactly how an icon whose root carries `stroke=\"currentColor\"` paints its paths.\n *\n * Send the attributes through unchanged and every one of those reads as nothing at all, with no\n * error: the shape draws in the default black, or does not draw.\n *\n * All of this is what react-native-svg does in JavaScript before its props reach native. Its\n * components are React, so this is the same translation rather than a call into it.\n */\n\n/** The paint on a shape: a colour, the view's own colour, or a reference to a gradient. */\nexport type Brush =\n | null\n | { readonly type: 0; readonly payload: unknown }\n | { readonly type: 1; readonly brushRef: string }\n | { readonly type: 2 };\n\nconst LINECAP: Record<string, number> = { butt: 0, round: 1, square: 2 };\nconst LINEJOIN: Record<string, number> = { miter: 0, round: 1, bevel: 2 };\nconst FILL_RULE: Record<string, number> = { evenodd: 0, nonzero: 1 };\n\nconst URL_REFERENCE = /^url\\(#(.+)\\)$/;\n\n/**\n * Which element each SVG tag commits as. `polyline` and `polygon` are paths: react-native-svg has\n * no component for either and converts their points to a `d`, so this does too.\n */\nexport const SVG_ELEMENTS: Record<string, string> = {\n g: 'svg-g',\n path: 'svg-path',\n circle: 'svg-circle',\n ellipse: 'svg-ellipse',\n rect: 'svg-rect',\n line: 'svg-line',\n polyline: 'svg-path',\n polygon: 'svg-path',\n};\n\n/** Geometry, per tag. Everything else on a shape is presentation and shared. */\nconst GEOMETRY: Record<string, readonly string[]> = {\n path: ['d'],\n circle: ['cx', 'cy', 'r'],\n ellipse: ['cx', 'cy', 'rx', 'ry'],\n rect: ['x', 'y', 'width', 'height', 'rx', 'ry'],\n line: ['x1', 'y1', 'x2', 'y2'],\n};\n\n/** SVG attribute -> native prop, for the presentation attributes shapes and groups share. */\nconst PRESENTATION: Record<string, string> = {\n fill: 'fill',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n stroke: 'stroke',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'stroke-linecap': 'strokeLinecap',\n 'stroke-linejoin': 'strokeLinejoin',\n 'stroke-dasharray': 'strokeDasharray',\n 'stroke-dashoffset': 'strokeDashoffset',\n 'stroke-miterlimit': 'strokeMiterlimit',\n 'clip-rule': 'clipRule',\n opacity: 'opacity',\n};\n\nexport interface SvgContext {\n /** The host's colour conversion, which a brush payload is the result of. */\n color(value: string): unknown;\n}\n\nexport function brushOf(value: string, context: SvgContext): Brush {\n if (value === 'none') return null;\n // Deliberately kept as a brush rather than resolved here: native paints it from the view's own\n // `color`, so a bound `[color]` on the icon changes every `currentColor` shape without a\n // re-parse.\n if (value === 'currentColor') return { type: 2 };\n const reference = URL_REFERENCE.exec(value);\n if (reference) return { type: 1, brushRef: reference[1]! };\n return { type: 0, payload: context.color(value) };\n}\n\n/** `M x,y L x,y ...`, which is what a polyline or polygon is once native sees it. */\nexport function pointsToPath(points: string, close: boolean): string {\n const numbers = points\n .trim()\n .split(/[\\s,]+/)\n .filter(Boolean);\n let path = '';\n for (let index = 0; index + 1 < numbers.length; index += 2) {\n path += `${index === 0 ? 'M' : 'L'}${numbers[index]},${numbers[index + 1]}`;\n }\n return close && path ? `${path}Z` : path;\n}\n\n/** `stroke-width:2;opacity:.5` as attributes, with `var(--name, fallback)` resolved. */\nexport function styleAttributes(\n style: string,\n variables: Readonly<Record<string, string | number | undefined>>,\n): Record<string, string> {\n const attrs: Record<string, string> = {};\n for (const declaration of style.split(';')) {\n const colon = declaration.indexOf(':');\n if (colon === -1) continue;\n const name = declaration.slice(0, colon).trim();\n const value = declaration.slice(colon + 1).trim();\n const resolved = resolveVar(value, variables);\n if (name && resolved !== undefined) attrs[name] = resolved;\n }\n return attrs;\n}\n\nfunction resolveVar(\n value: string,\n variables: Readonly<Record<string, string | number | undefined>>,\n): string | undefined {\n const match = /^var\\(\\s*(--[\\w-]+)\\s*(?:,\\s*([^)]*))?\\)$/.exec(value);\n if (!match) return value;\n const supplied = variables[match[1]!];\n if (supplied !== undefined) return String(supplied);\n return match[2]?.trim() || undefined;\n}\n\n/** The four numbers of a `viewBox`, as the props the svg view takes them as. */\nexport function viewBoxProps(viewBox: string | undefined): Record<string, unknown> {\n if (!viewBox) return {};\n const parts = viewBox.trim().replace(/,/g, ' ').split(/\\s+/).map(Number);\n if (parts.length !== 4 || parts.some(Number.isNaN)) return {};\n const [minX, minY, vbWidth, vbHeight] = parts;\n return { minX, minY, vbWidth, vbHeight, align: 'xMidYMid', meetOrSlice: 0 };\n}\n\nconst TRANSFORM = /([a-zA-Z]+)\\s*\\(([^)]*)\\)/g;\n\n/**\n * A `transform` attribute as a 2x3 matrix, which is the only form native takes.\n *\n * Rare in icon sets - one occurrence across bootstrap-icons and lucide, and that one is already a\n * `matrix()` - but a shape drawn in the wrong place is worse than one not drawn, so the other\n * three forms compose rather than being ignored.\n */\nexport function transformMatrix(transform: string): number[] | undefined {\n let matrix: number[] | undefined;\n TRANSFORM.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = TRANSFORM.exec(transform)) !== null) {\n const values = match[2]!\n .trim()\n .split(/[\\s,]+/)\n .map(Number);\n const next = matrixFor(match[1]!, values);\n if (next) matrix = matrix ? multiply(matrix, next) : next;\n }\n return matrix;\n}\n\n/** `translate(4)` and `scale(2)` mean something for the missing argument; `rotate(90)` means 0. */\nconst at = (values: number[], index: number, fallback: number) => values[index] ?? fallback;\n\nfunction matrixFor(name: string, values: number[]): number[] | undefined {\n const first = at(values, 0, 0);\n if (name === 'matrix') return values.length === 6 ? values : undefined;\n if (name === 'translate') return [1, 0, 0, 1, first, at(values, 1, 0)];\n if (name === 'scale') return [first, 0, 0, at(values, 1, first), 0, 0];\n if (name === 'rotate') return rotation(first, at(values, 1, 0), at(values, 2, 0));\n return undefined;\n}\n\nfunction rotation(degrees: number, cx: number, cy: number): number[] {\n const radians = (degrees * Math.PI) / 180;\n const cos = Math.cos(radians);\n const sin = Math.sin(radians);\n // Rotating about a point is the rotation with the point moved to the origin and back.\n return [cos, sin, -sin, cos, cx - cos * cx + sin * cy, cy - sin * cx - cos * cy];\n}\n\n/** `[a, b, c, d, tx, ty]`, in SVG's own order. */\nfunction multiply(left: number[], right: number[]): number[] {\n const [a1, b1, c1, d1, e1, f1] = left as [number, number, number, number, number, number];\n const [a2, b2, c2, d2, e2, f2] = right as [number, number, number, number, number, number];\n return [\n a1 * a2 + c1 * b2,\n b1 * a2 + d1 * b2,\n a1 * c2 + c1 * d2,\n b1 * c2 + d1 * d2,\n a1 * e2 + c1 * f2 + e1,\n b1 * e2 + d1 * f2 + f1,\n ];\n}\n\n/**\n * One element's native props.\n *\n * `propList` is the load-bearing part: it names the props this element set itself, and native\n * inherits everything else from the group above. Omit it and a path with no `fill` of its own\n * paints black instead of the colour its parent carries.\n */\nexport function nativeProps(\n tag: string,\n attrs: Readonly<Record<string, string>>,\n context: SvgContext,\n): Record<string, unknown> {\n const props: Record<string, unknown> = {};\n const propList: string[] = [];\n\n for (const [name, value] of Object.entries(attrs)) {\n const prop = PRESENTATION[name];\n if (!prop) continue;\n props[prop] = presentationValue(prop, value, context);\n propList.push(prop);\n }\n if (propList.length > 0) props['propList'] = propList;\n\n for (const name of GEOMETRY[tag] ?? []) {\n if (attrs[name] !== undefined) props[name] = attrs[name];\n }\n if (tag === 'polyline' || tag === 'polygon') {\n props['d'] = pointsToPath(attrs['points'] ?? '', tag === 'polygon');\n }\n if (attrs['transform']) {\n const matrix = transformMatrix(attrs['transform']);\n if (matrix) props['matrix'] = matrix;\n }\n return props;\n}\n\n/**\n * The props react-native-svg's Android view manager declares as `float` rather than `Dynamic`,\n * with the default it applies when the prop is absent.\n *\n * `Dynamic` reads whatever arrives, so an SVG attribute can stay the string it was written as -\n * which is what `strokeWidth` and every geometry attribute do. These five cannot: the Android\n * manager takes a `float` parameter, and a string reaching one throws `java.lang.String cannot be\n * cast to java.lang.Double` out of `setProperty` while the view is being created, which takes the\n * whole screen down. iOS never noticed, because folly's `dynamic` coerces a numeric string on the\n * way into a `Float` prop. react-native-svg's own JavaScript sends numbers here too, through\n * `extractOpacity`, so this is the same translation and not an Android workaround.\n */\nconst NUMERIC: Record<string, number> = {\n opacity: 1,\n fillOpacity: 1,\n strokeOpacity: 1,\n strokeDashoffset: 0,\n strokeMiterlimit: 4,\n};\n\nfunction presentationValue(prop: string, value: string, context: SvgContext): unknown {\n if (prop === 'fill' || prop === 'stroke') return brushOf(value, context);\n if (prop === 'strokeLinecap') return LINECAP[value] ?? 0;\n if (prop === 'strokeLinejoin') return LINEJOIN[value] ?? 0;\n if (prop === 'fillRule' || prop === 'clipRule') return FILL_RULE[value] ?? 1;\n if (prop === 'strokeDasharray')\n return value\n .trim()\n .split(/[\\s,]+/)\n .filter(Boolean);\n return prop in NUMERIC ? numberFor(prop, value) : value;\n}\n\n/** The attribute as the float Android's view manager takes, or the default it applies. */\nfunction numberFor(prop: string, value: string): number {\n const number = Number.parseFloat(value);\n return Number.isNaN(number) ? NUMERIC[prop]! : number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"svg-props.js","sourceRoot":"","sources":["../src/svg-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,MAAM,OAAO,GAA2B,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AACzE,MAAM,QAAQ,GAA2B,EAAE,KA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KAAK,UAAU;QAAE,OAAO,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAClF,IAAI,IAAI,KAAK,iBAAiB;QAC5B,OAAO,KAAK;aACT,IAAI,EAAE;aACN,KAAK,CAAC,QAAQ,CAAC;aACf,MAAM,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1D,CAAC;AAED,0FAA0F;AAC1F,SAAS,SAAS,CAAC,IAAY,EAAE,KAAa;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AACxD,CAAC","sourcesContent":["/**\n * SVG attributes to the props react-native-svg's native views actually take.\n *\n * They are not the same thing, and the difference is the whole reason this file exists. `fill`\n * and `stroke` are not colours but *brushes*, a tagged struct that says whether the paint is a\n * colour, the view's own `color`, or a reference to a gradient. `stroke-linecap`, `stroke-linejoin`\n * and `fill-rule` are integers, not the keywords they are written as. And a shape has to declare\n * which props it set - `propList` - because anything absent is inherited from the group above it,\n * which is exactly how an icon whose root carries `stroke=\"currentColor\"` paints its paths.\n *\n * Send the attributes through unchanged and every one of those reads as nothing at all, with no\n * error: the shape draws in the default black, or does not draw.\n *\n * All of this is what react-native-svg does in JavaScript before its props reach native. Its\n * components are React, so this is the same translation rather than a call into it.\n */\n\n/** The paint on a shape: a colour, the view's own colour, or a reference to a gradient. */\nexport type Brush =\n | null\n | { readonly type: 0; readonly payload: unknown }\n | { readonly type: 1; readonly brushRef: string }\n | { readonly type: 2 };\n\nconst LINECAP: Record<string, number> = { butt: 0, round: 1, square: 2 };\nconst LINEJOIN: Record<string, number> = { miter: 0, round: 1, bevel: 2 };\nconst FILL_RULE: Record<string, number> = { evenodd: 0, nonzero: 1 };\n\nconst URL_REFERENCE = /^url\\(#(.+)\\)$/;\n\n/** `table[key]`, but never off `Object.prototype`: a tag or attribute named `constructor` is unknown. */\nexport function own<T>(table: Readonly<Record<string, T>>, key: string): T | undefined {\n return Object.hasOwn(table, key) ? table[key] : undefined;\n}\n\n/**\n * Which element each SVG tag commits as. `polyline` and `polygon` are paths: react-native-svg has\n * no component for either and converts their points to a `d`, so this does too.\n */\nexport const SVG_ELEMENTS: Record<string, string> = {\n g: 'svg-g',\n path: 'svg-path',\n circle: 'svg-circle',\n ellipse: 'svg-ellipse',\n rect: 'svg-rect',\n line: 'svg-line',\n polyline: 'svg-path',\n polygon: 'svg-path',\n};\n\n/** Geometry, per tag. Everything else on a shape is presentation and shared. */\nconst GEOMETRY: Record<string, readonly string[]> = {\n path: ['d'],\n circle: ['cx', 'cy', 'r'],\n ellipse: ['cx', 'cy', 'rx', 'ry'],\n rect: ['x', 'y', 'width', 'height', 'rx', 'ry'],\n line: ['x1', 'y1', 'x2', 'y2'],\n};\n\n/** A shape's geometry, as written, and 0 for what react-native-svg defaults and it left out. */\nfunction geometry(\n tag: string,\n attrs: Readonly<Record<string, string>>,\n props: Record<string, unknown>,\n): void {\n for (const name of own(GEOMETRY, tag) ?? []) {\n if (attrs[name] !== undefined) props[name] = attrs[name];\n }\n for (const name of own(ZERO_BY_DEFAULT, tag) ?? []) props[name] ??= 0;\n}\n\n/**\n * The geometry each shape defaults to 0 when absent, as react-native-svg's `Rect`, `Circle`,\n * `Ellipse` and `Line` do before they commit. Android's shape views read a missing length as null\n * and crash drawing it, and design tools often leave out a `y=\"0\"`.\n */\nconst ZERO_BY_DEFAULT: Record<string, readonly string[]> = {\n circle: ['cx', 'cy', 'r'],\n ellipse: ['cx', 'cy', 'rx', 'ry'],\n rect: ['x', 'y', 'width', 'height'],\n line: ['x1', 'y1', 'x2', 'y2'],\n};\n\n/** SVG attribute -> native prop, for the presentation attributes shapes and groups share. */\nconst PRESENTATION: Record<string, string> = {\n fill: 'fill',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n stroke: 'stroke',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'stroke-linecap': 'strokeLinecap',\n 'stroke-linejoin': 'strokeLinejoin',\n 'stroke-dasharray': 'strokeDasharray',\n 'stroke-dashoffset': 'strokeDashoffset',\n 'stroke-miterlimit': 'strokeMiterlimit',\n 'clip-rule': 'clipRule',\n opacity: 'opacity',\n};\n\n/** The presentation attributes that are a paint. */\nexport const PAINT: ReadonlySet<string> = new Set(['fill', 'stroke']);\n\n/** Whether a paint is a `var()`, which only the cascade can settle. */\nexport const isTokenPaint = (value: string | undefined): value is string =>\n value !== undefined && /^\\s*var\\(/i.test(value);\n\nexport interface SvgContext {\n /** The host's colour conversion, which a brush payload is the result of. */\n color(value: string): unknown;\n}\n\nexport function brushOf(value: string, context: SvgContext): Brush {\n if (value === 'none') return null;\n // Deliberately kept as a brush rather than resolved here: native paints it from the view's own\n // `color`, so a bound `[color]` on the icon changes every `currentColor` shape without a\n // re-parse.\n if (value === 'currentColor') return { type: 2 };\n const reference = URL_REFERENCE.exec(value);\n if (reference) return { type: 1, brushRef: reference[1]! };\n return { type: 0, payload: context.color(value) };\n}\n\n/** `M x,y L x,y ...`, which is what a polyline or polygon is once native sees it. */\nexport function pointsToPath(points: string, close: boolean): string {\n const numbers = points\n .trim()\n .split(/[\\s,]+/)\n .filter(Boolean);\n let path = '';\n for (let index = 0; index + 1 < numbers.length; index += 2) {\n path += `${index === 0 ? 'M' : 'L'}${numbers[index]},${numbers[index + 1]}`;\n }\n return close && path ? `${path}Z` : path;\n}\n\n/** `stroke-width:2;opacity:.5` as attributes, with `var(--name, fallback)` resolved. */\nexport function styleAttributes(\n style: string,\n variables: Readonly<Record<string, string | number | undefined>>,\n): Record<string, string> {\n const attrs: Record<string, string> = {};\n for (const declaration of style.split(';')) {\n const colon = declaration.indexOf(':');\n if (colon === -1) continue;\n const name = declaration.slice(0, colon).trim();\n const value = declaration.slice(colon + 1).trim();\n // A paint's `var()` is kept as written: the cascade settles it, with the tokens in scope.\n const resolved = resolveVar(value, variables) ?? (PAINT.has(name) ? value : undefined);\n if (name && resolved !== undefined) attrs[name] = resolved;\n }\n return attrs;\n}\n\nfunction resolveVar(\n value: string,\n variables: Readonly<Record<string, string | number | undefined>>,\n): string | undefined {\n const match = /^var\\(\\s*(--[\\w-]+)\\s*(?:,\\s*([^)]*))?\\)$/.exec(value);\n if (!match) return value;\n const supplied = variables[match[1]!];\n if (supplied !== undefined) return String(supplied);\n return match[2]?.trim() || undefined;\n}\n\n/** The four numbers of a `viewBox`, as the props the svg view takes them as. */\nexport function viewBoxProps(viewBox: string | undefined): Record<string, unknown> {\n if (!viewBox) return {};\n const parts = viewBox.trim().replace(/,/g, ' ').split(/\\s+/).map(Number);\n if (parts.length !== 4 || parts.some(Number.isNaN)) return {};\n const [minX, minY, vbWidth, vbHeight] = parts;\n return { minX, minY, vbWidth, vbHeight, align: 'xMidYMid', meetOrSlice: 0 };\n}\n\nconst TRANSFORM = /([a-zA-Z]+)\\s*\\(([^)]*)\\)/g;\n\n/**\n * A `transform` attribute as a 2x3 matrix, which is the only form native takes.\n *\n * Rare in icon sets - one occurrence across bootstrap-icons and lucide, and that one is already a\n * `matrix()` - but a shape drawn in the wrong place is worse than one not drawn, so the other\n * three forms compose rather than being ignored.\n */\nexport function transformMatrix(transform: string): number[] | undefined {\n let matrix: number[] | undefined;\n TRANSFORM.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = TRANSFORM.exec(transform)) !== null) {\n const values = match[2]!\n .trim()\n .split(/[\\s,]+/)\n .map(Number);\n const next = matrixFor(match[1]!, values);\n if (next) matrix = matrix ? multiply(matrix, next) : next;\n }\n return matrix;\n}\n\n/** `translate(4)` and `scale(2)` mean something for the missing argument; `rotate(90)` means 0. */\nconst at = (values: number[], index: number, fallback: number) => values[index] ?? fallback;\n\nfunction matrixFor(name: string, values: number[]): number[] | undefined {\n const first = at(values, 0, 0);\n if (name === 'matrix') return values.length === 6 ? values : undefined;\n if (name === 'translate') return [1, 0, 0, 1, first, at(values, 1, 0)];\n if (name === 'scale') return [first, 0, 0, at(values, 1, first), 0, 0];\n if (name === 'rotate') return rotation(first, at(values, 1, 0), at(values, 2, 0));\n return undefined;\n}\n\nfunction rotation(degrees: number, cx: number, cy: number): number[] {\n const radians = (degrees * Math.PI) / 180;\n const cos = Math.cos(radians);\n const sin = Math.sin(radians);\n // Rotating about a point is the rotation with the point moved to the origin and back.\n return [cos, sin, -sin, cos, cx - cos * cx + sin * cy, cy - sin * cx - cos * cy];\n}\n\n/** `[a, b, c, d, tx, ty]`, in SVG's own order. */\nfunction multiply(left: number[], right: number[]): number[] {\n const [a1, b1, c1, d1, e1, f1] = left as [number, number, number, number, number, number];\n const [a2, b2, c2, d2, e2, f2] = right as [number, number, number, number, number, number];\n return [\n a1 * a2 + c1 * b2,\n b1 * a2 + d1 * b2,\n a1 * c2 + c1 * d2,\n b1 * c2 + d1 * d2,\n a1 * e2 + c1 * f2 + e1,\n b1 * e2 + d1 * f2 + f1,\n ];\n}\n\n/**\n * One element's native props.\n *\n * `propList` is the load-bearing part: it names the props this element set itself, and native\n * inherits everything else from the group above. Omit it and a path with no `fill` of its own\n * paints black instead of the colour its parent carries.\n */\nexport function nativeProps(\n tag: string,\n attrs: Readonly<Record<string, string>>,\n context: SvgContext,\n): Record<string, unknown> {\n const props: Record<string, unknown> = {};\n const propList: string[] = [];\n\n for (const [name, value] of Object.entries(attrs)) {\n const prop = own(PRESENTATION, name);\n if (!prop) continue;\n props[prop] = presentationValue(prop, value, context);\n propList.push(prop);\n }\n if (propList.length > 0) props['propList'] = propList;\n\n geometry(tag, attrs, props);\n if (tag === 'polyline' || tag === 'polygon') {\n props['d'] = pointsToPath(attrs['points'] ?? '', tag === 'polygon');\n }\n if (attrs['transform']) {\n const matrix = transformMatrix(attrs['transform']);\n if (matrix) props['matrix'] = matrix;\n }\n return props;\n}\n\n/**\n * The props react-native-svg's Android view manager declares as `float` rather than `Dynamic`,\n * with the default it applies when the prop is absent.\n *\n * `Dynamic` reads whatever arrives, so an SVG attribute can stay the string it was written as -\n * which is what `strokeWidth` and every geometry attribute do. These five cannot: the Android\n * manager takes a `float` parameter, and a string reaching one throws `java.lang.String cannot be\n * cast to java.lang.Double` out of `setProperty` while the view is being created, which takes the\n * whole screen down. iOS never noticed, because folly's `dynamic` coerces a numeric string on the\n * way into a `Float` prop. react-native-svg's own JavaScript sends numbers here too, through\n * `extractOpacity`, so this is the same translation and not an Android workaround.\n */\nconst NUMERIC: Record<string, number> = {\n opacity: 1,\n fillOpacity: 1,\n strokeOpacity: 1,\n strokeDashoffset: 0,\n strokeMiterlimit: 4,\n};\n\nfunction presentationValue(prop: string, value: string, context: SvgContext): unknown {\n if (prop === 'fill' || prop === 'stroke') return brushOf(value, context);\n if (prop === 'strokeLinecap') return own(LINECAP, value) ?? 0;\n if (prop === 'strokeLinejoin') return own(LINEJOIN, value) ?? 0;\n if (prop === 'fillRule' || prop === 'clipRule') return own(FILL_RULE, value) ?? 1;\n if (prop === 'strokeDasharray')\n return value\n .trim()\n .split(/[\\s,]+/)\n .filter(Boolean);\n return prop in NUMERIC ? numberFor(prop, value) : value;\n}\n\n/** The attribute as the float Android's view manager takes, or the default it applies. */\nfunction numberFor(prop: string, value: string): number {\n const number = Number.parseFloat(value);\n return Number.isNaN(number) ? NUMERIC[prop]! : number;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-native/icons",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "@ng-icons rendered as native react-native-svg shapes in Angular Native.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"main": "dist/index.js",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ng-native/fabric": "0.
|
|
20
|
+
"@ng-native/fabric": "0.4.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@angular/core": "^22.0.0",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"dist"
|
|
45
45
|
],
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@angular/core": "22.2.0"
|
|
47
|
+
"@angular/core": "22.2.0",
|
|
48
|
+
"@babel/core": "^7.29.7"
|
|
48
49
|
},
|
|
49
50
|
"exports": {
|
|
50
51
|
".": {
|