@human-synthesis/norns-core 0.0.4 → 0.0.5

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.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/src/uno.js +30 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@human-synthesis/norns-core",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Norns core — Svelte with CoffeeScript, Pug, and UnoCSS preconfigured",
5
5
  "license": "MIT",
6
6
  "author": "Human Synthesis",
@@ -25,6 +25,7 @@
25
25
  "vite": "^5.0.0 || ^6.0.0"
26
26
  },
27
27
  "dependencies": {
28
+ "@unocss/extractor-pug": "^0.65.0 || ^66.0.0",
28
29
  "acorn": "^8.14.0",
29
30
  "coffeescript": "^2.7.0",
30
31
  "magic-string": "^0.30.10",
package/src/uno.js CHANGED
@@ -7,17 +7,30 @@ import {
7
7
  transformerDirectives,
8
8
  transformerVariantGroup
9
9
  } from 'unocss';
10
+ import extractorPug from '@unocss/extractor-pug';
11
+
12
+ const NORN_PIPELINE = [
13
+ /\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/,
14
+ /\.(norn|coffee)($|\?)/
15
+ ];
10
16
 
11
17
  /**
12
- * Norns UnoCSS Vite plugin with a sensible preset stack.
18
+ * Norns UnoCSS Vite plugin.
13
19
  *
14
- * Includes transformerDirectives (so `@apply` works in `<style>` blocks)
15
- * and transformerVariantGroup (so `class="hover:(text-blue underline)"`
16
- * shorthand works).
20
+ * Defaults baked in for the Norns stack:
21
+ * - presets: Uno + Attributify + Icons + Typography
22
+ * - transformers: Directives (`@apply`) + VariantGroup
23
+ * - extractor: extractor-pug, so Pug class shorthand inside `.svelte` and
24
+ * `.norn` files is recognized
25
+ * - content pipeline includes `.norn` and `.coffee`
26
+ * - hmrTopLevelAwait: false to avoid a TDZ error in WebKit/Safari when
27
+ * `virtual:uno.css` is imported from a SvelteKit route module
17
28
  *
18
- * Defaults `hmrTopLevelAwait: false` to avoid a TDZ
19
- * "Cannot access 'component' before initialization" error in WebKit/Safari
20
- * when importing 'virtual:uno.css' from a SvelteKit layout/page module.
29
+ * **Naming caveat for shortcuts:** avoid names starting with a CSS
30
+ * pseudo-class prefix (`hover-`, `focus-`, `link-`, `active-`, `visited-`,
31
+ * `disabled-`, `checked-`, etc.) UnoCSS parses those as variant + utility,
32
+ * not as a shortcut name. Use `nav-link`, `lk-muted`, etc. instead of
33
+ * `link-muted`.
21
34
  *
22
35
  * @param {import('unocss/vite').VitePluginConfig} [options]
23
36
  */
@@ -25,6 +38,8 @@ export function nornsUno(options = {}) {
25
38
  const {
26
39
  presets = [],
27
40
  transformers = [],
41
+ extractors = [],
42
+ content = {},
28
43
  hmrTopLevelAwait = false,
29
44
  ...rest
30
45
  } = options;
@@ -37,6 +52,14 @@ export function nornsUno(options = {}) {
37
52
  ...presets
38
53
  ],
39
54
  transformers: [transformerDirectives(), transformerVariantGroup(), ...transformers],
55
+ extractors: [extractorPug(), ...extractors],
56
+ content: {
57
+ pipeline: {
58
+ include: NORN_PIPELINE,
59
+ ...(content.pipeline ?? {})
60
+ },
61
+ ...content
62
+ },
40
63
  hmrTopLevelAwait,
41
64
  ...rest
42
65
  });