@human-synthesis/norns-core 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **AI-driven software architecture and development framework, based on Svelte.**
4
4
 
5
- Svelte preprocessor for the Norns stack: **Pug + Civet** in `.n` files. The `.c` extension is recognised as an alias for `.civet` — both compile through Civet. CoffeeScript is no longer supported.
5
+ Svelte preprocessor for the Norns stack: **Pug + Civet** in `.n` files. The `.c` extension is recognised as an alias for `.civet` — both compile through Civet.
6
6
 
7
7
  ## Stack
8
8
 
@@ -41,6 +41,10 @@ export default {
41
41
  - Pug class shorthand is rewritten so Tailwind variants (`.hover:bg-X`) and fractional values (`.gap-2.5`) work without escaping.
42
42
  - `+if` / `+elseif` / `+else` chains are rewritten to Svelte block syntax (`{#if}/{:else if}/{:else}/{/if}`).
43
43
 
44
+ ## Auto-imports — see the umbrella
45
+
46
+ The auto-import layer (helpers, components, project utilities, UI library presets) lives in [`@human-synthesis/norns`](https://github.com/human-synthesis/norns), not here. `norns-core` is the syntax preprocessor only — the import resolver needs Vite-plugin hooks the umbrella provides.
47
+
44
48
  ## License
45
49
 
46
50
  MIT © Daniel Teodoroiu / [Human Synthesis](https://humansynthesis.ai). Built on top of [Svelte](https://github.com/sveltejs/svelte) © Svelte Contributors, MIT licensed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@human-synthesis/norns-core",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Norns core — Svelte preprocessor for Civet, Pug, and .n files",
5
5
  "license": "MIT",
6
6
  "author": "Daniel Teodoroiu (https://humansynthesis.ai)",
package/src/preprocess.js CHANGED
@@ -267,7 +267,10 @@ function transformIfChains(content) {
267
267
  const elseIfRe = ELSEIF_RE_TPL(chainIndent);
268
268
  const elseRe = ELSE_RE_TPL(chainIndent);
269
269
 
270
- out.push(`${chainIndent}| {#if ${ifExpr}}`);
270
+ // Collect each branch's header + body, then recurse on the body so
271
+ // nested `+if`/`+else` chains resolve. Mirrors `transformSnippets`.
272
+ /** @type {{ header: string; body: string[] }[]} */
273
+ const branches = [{ header: `${chainIndent}| {#if ${ifExpr}}`, body: [] }];
271
274
  i++;
272
275
 
273
276
  while (i < lines.length) {
@@ -275,19 +278,22 @@ function transformIfChains(content) {
275
278
 
276
279
  const eIfM = cur.match(elseIfRe);
277
280
  if (eIfM) {
278
- out.push(`${chainIndent}| {:else if ${stripQuotes(eIfM[1])}}`);
281
+ branches.push({
282
+ header: `${chainIndent}| {:else if ${stripQuotes(eIfM[1])}}`,
283
+ body: []
284
+ });
279
285
  i++;
280
286
  continue;
281
287
  }
282
288
  const eM = cur.match(elseRe);
283
289
  if (eM) {
284
- out.push(`${chainIndent}| {:else}`);
290
+ branches.push({ header: `${chainIndent}| {:else}`, body: [] });
285
291
  i++;
286
292
  continue;
287
293
  }
288
294
 
289
295
  if (cur.trim() === '') {
290
- out.push(cur);
296
+ branches[branches.length - 1].body.push(cur);
291
297
  i++;
292
298
  continue;
293
299
  }
@@ -295,7 +301,8 @@ function transformIfChains(content) {
295
301
  const lineIndent = cur.match(/^(\s*)/)[1];
296
302
  if (lineIndent.length > chainIndent.length) {
297
303
  // Body line — de-indent by one level so it sits at the chain's level.
298
- out.push(cur.startsWith(indentDiff) ? cur.slice(indentDiff.length) : cur);
304
+ const deindented = cur.startsWith(indentDiff) ? cur.slice(indentDiff.length) : cur;
305
+ branches[branches.length - 1].body.push(deindented);
299
306
  i++;
300
307
  continue;
301
308
  }
@@ -303,6 +310,10 @@ function transformIfChains(content) {
303
310
  break;
304
311
  }
305
312
 
313
+ for (const b of branches) {
314
+ out.push(b.header);
315
+ if (b.body.length > 0) out.push(transformIfChains(b.body.join('\n')));
316
+ }
306
317
  out.push(`${chainIndent}| {/if}`);
307
318
  }
308
319
 
@@ -444,9 +455,6 @@ function nornDefaultLangs() {
444
455
  * - `count := $state 0` → `const count = $state(0)`
445
456
  * - `{ a, b = 0 } := $props()` → `const { a, b = 0 } = $props()`
446
457
  * - imports stay where written; if user writes them at top, output is fine
447
- *
448
- * No `var X; X = expr` split, so `nornCoffeeRuneFusion` and
449
- * `nornsCoffeeImportLift` aren't needed for Civet sources.
450
458
  */
451
459
  function nornsCivetScript() {
452
460
  return {
@@ -483,9 +491,6 @@ function nornsCivetScript() {
483
491
  * `let count = $state(0)` directly, so no rune-fusion or import-lift
484
492
  * passes are needed.
485
493
  *
486
- * CoffeeScript is no longer supported — `lang="coffee"` will fail. Use
487
- * `lang="civet"` (or omit lang and rely on the default).
488
- *
489
494
  * @param {import('svelte-preprocess').AutoPreprocessOptions} [options]
490
495
  */
491
496
  export function nornsPreprocess(options = {}) {