@prunellejs/icons 0.7.2 → 0.7.3
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/llms.txt +2 -1
- package/package.json +2 -2
- package/src/licence.ts +8 -5
- package/src/plugin.ts +5 -0
package/llms.txt
CHANGED
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
- `sets`: optional `Record<string, IconSet>` of custom in-memory sets keyed by prefix.
|
|
15
15
|
- `dirs`: optional `Record<string, string>` mapping prefixes to local `.svg` folders relative to app root (e.g. `{ brand: 'assets/brand' }`). `src/icons` is automatically mounted as `~icons/local/<name>` unless overridden; edited files reload in `prunelle dev`. A file is inlined as is: `prunelle check` warns `[icons/svg-script]` on a `<script>`, an `on*` attribute or a `javascript:` URL in one, and the root paint attributes are escaped.
|
|
16
|
+
- `credited`: optional `readonly string[]` of installed Iconify set prefixes whose licence terms the app has already satisfied (e.g. credited on the legal notice page), silencing `[icons/licence]`.
|
|
16
17
|
- Install Iconify icon packs as dev dependencies (e.g. `bun add -d @iconify-json/tabler`), then import `~icons/tabler/home`.
|
|
17
|
-
- CLI & checks: run `prunelle icons-find <words> [--set <prefix>] [--limit <n>]` instead of guessing names. `prunelle check` and `prunelle build` fail on missing/invalid icons and suggest closest matches; `prunelle check` warns `[icons/licence]` at the first import of
|
|
18
|
+
- CLI & checks: run `prunelle icons-find <words> [--set <prefix>] [--limit <n>]` instead of guessing names. `prunelle check` and `prunelle build` fail on missing/invalid icons and suggest closest matches; `prunelle check` warns `[icons/licence]` at the first import of any installed set outside the permissive allowlist (MIT, Apache-2.0, ISC, BSD, OFL, MPL, CC0, Unlicense).
|
|
18
19
|
|
|
19
20
|
## `<Icon>` Component
|
|
20
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prunellejs/icons",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Compile-time Iconify SVG icon plugin (~icons/<set>/<name>) for Prunelle",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"directory": "packages/plugin-icons"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"prunelle": "^0.7.
|
|
27
|
+
"prunelle": "^0.7.3"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/licence.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import type { SetInfo } from './sets'
|
|
4
4
|
|
|
5
|
-
const NON_COMMERCIAL_RE =
|
|
6
|
-
const COPYLEFT_RE = /^(?:A?GPL|LGPL)
|
|
7
|
-
const ATTRIBUTION_RE = /^CC-BY
|
|
5
|
+
const NON_COMMERCIAL_RE = /(?:^|[- ])NC(?:-|$| )/i
|
|
6
|
+
const COPYLEFT_RE = /^(?:A?GPL|LGPL)(?:-|\s|$)|(?:^|[- ])SA(?:-|$| )/i
|
|
7
|
+
const ATTRIBUTION_RE = /^CC[- ]BY(?:[- ]|$)/i
|
|
8
|
+
const PERMISSIVE_SPDX_RE = /^(?:MIT(?:-0)?|Apache-2\.0|ISC|0BSD|BSD-[A-Za-z0-9.-]+|OFL-[A-Za-z0-9.-]+|MPL-[A-Za-z0-9.-]+|CC0-[A-Za-z0-9.-]+|Unlicense)$/i
|
|
8
9
|
const FREE_ALTERNATIVE = 'or use a set under MIT or Apache-2.0'
|
|
9
10
|
|
|
10
11
|
/** Why the set `prefix` needs a look before its icons ship, as the detail and the fix of a warning; undefined when its licence asks nothing. */
|
|
@@ -20,6 +21,8 @@ export function licenceProblem(prefix: string, info: SetInfo | undefined): { det
|
|
|
20
21
|
if (COPYLEFT_RE.test(spdx))
|
|
21
22
|
return { detail: `${licence}, which asks that a work including its icons be shared under the same licence${ATTRIBUTION_RE.test(spdx) ? `, crediting ${author}` : ''}`, fix: `check the app may be, ${FREE_ALTERNATIVE}` }
|
|
22
23
|
if (ATTRIBUTION_RE.test(spdx))
|
|
23
|
-
return { detail: `${licence}, which asks for credit to ${author} wherever its icons show`, fix: `credit it
|
|
24
|
-
|
|
24
|
+
return { detail: `${licence}, which asks for credit to ${author} wherever its icons show`, fix: `credit it (for instance on the legal notice page) and list "${prefix}" in icons({ credited: [...] }), ${FREE_ALTERNATIVE}` }
|
|
25
|
+
if (PERMISSIVE_SPDX_RE.test(spdx))
|
|
26
|
+
return undefined
|
|
27
|
+
return { detail: `${licence}, which is not a known permissive licence`, fix: `check its terms and list "${prefix}" in icons({ credited: [...] }) once cleared, ${FREE_ALTERNATIVE}` }
|
|
25
28
|
}
|
package/src/plugin.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface IconsPluginOptions {
|
|
|
46
46
|
sets?: Record<string, IconSet> | undefined
|
|
47
47
|
/** Folders of `.svg` files read as sets, keyed by prefix, relative to the app root (e.g. `{ brand: 'assets/brand' }`). `src/icons` is the set `local` unless named here. */
|
|
48
48
|
dirs?: Record<string, string> | undefined
|
|
49
|
+
/** Installed Iconify set prefixes whose licence terms the app has already satisfied (e.g. credited on the legal notice page), silencing `[icons/licence]`. */
|
|
50
|
+
credited?: readonly string[] | undefined
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
interface PluginLookup extends IconLookup {
|
|
@@ -147,7 +149,10 @@ export function icons(options: IconsPluginOptions = {}): PrunellePlugin {
|
|
|
147
149
|
firstImport.set(prefix!, at)
|
|
148
150
|
}
|
|
149
151
|
}
|
|
152
|
+
const credited = new Set(options.credited ?? [])
|
|
150
153
|
for (const [prefix, at] of firstImport) {
|
|
154
|
+
if (credited.has(prefix))
|
|
155
|
+
continue
|
|
151
156
|
const licence = licenceProblem(prefix, await setInfo(prefix, ctx.root))
|
|
152
157
|
if (licence !== undefined)
|
|
153
158
|
ctx.warn(`${at}: warning: [icons/licence] ${licence.detail}: ${licence.fix}.`)
|