@kernlang/react 3.1.5 → 3.1.7

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.
@@ -0,0 +1,61 @@
1
+ export function isExpr(v) {
2
+ return typeof v === 'object' && v !== null && '__expr' in v;
3
+ }
4
+ export function addDefaultImport(ctx, source, name) {
5
+ const spec = ctx.imports.get(source) || {
6
+ namedImports: new Set(),
7
+ typeOnlyImports: new Set(),
8
+ };
9
+ spec.defaultImport = name;
10
+ ctx.imports.set(source, spec);
11
+ }
12
+ export function addNamedImport(ctx, source, name, typeOnly) {
13
+ const spec = ctx.imports.get(source) || {
14
+ namedImports: new Set(),
15
+ typeOnlyImports: new Set(),
16
+ };
17
+ if (typeOnly) {
18
+ spec.typeOnlyImports.add(name);
19
+ }
20
+ else {
21
+ spec.namedImports.add(name);
22
+ }
23
+ ctx.imports.set(source, spec);
24
+ }
25
+ export function exprCode(value, fallback) {
26
+ if (typeof value === 'object' && value !== null && '__expr' in value) {
27
+ return value.code;
28
+ }
29
+ if (typeof value === 'string' && value.length > 0)
30
+ return value;
31
+ return fallback;
32
+ }
33
+ export function emitImports(ctx) {
34
+ const lines = [];
35
+ for (const [source, spec] of [...ctx.imports.entries()].sort(([a], [b]) => a.localeCompare(b))) {
36
+ // Separate type-only imports from value imports
37
+ const typeImports = [...spec.typeOnlyImports].filter((n) => !spec.namedImports.has(n));
38
+ const valueImports = [...spec.namedImports];
39
+ // Emit type-only import statement if there are type imports and no value imports sharing the source
40
+ if (typeImports.length > 0 && valueImports.length === 0 && !spec.defaultImport) {
41
+ lines.push(`import type { ${typeImports.sort().join(', ')} } from '${source}';`);
42
+ }
43
+ else {
44
+ // Emit value import (with default if present)
45
+ const clauses = [];
46
+ if (spec.defaultImport)
47
+ clauses.push(spec.defaultImport);
48
+ if (valueImports.length > 0)
49
+ clauses.push(`{ ${valueImports.sort().join(', ')} }`);
50
+ if (clauses.length > 0) {
51
+ lines.push(`import ${clauses.join(', ')} from '${source}';`);
52
+ }
53
+ // Emit separate type-only import if both type and value imports exist
54
+ if (typeImports.length > 0) {
55
+ lines.push(`import type { ${typeImports.sort().join(', ')} } from '${source}';`);
56
+ }
57
+ }
58
+ }
59
+ return lines;
60
+ }
61
+ //# sourceMappingURL=nextjs-imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextjs-imports.js","sourceRoot":"","sources":["../src/nextjs-imports.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,MAAM,CAAC,CAAU;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,QAAQ,IAAI,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAQ,EAAE,MAAc,EAAE,IAAY;IACrE,MAAM,IAAI,GAAiB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI;QACpD,YAAY,EAAE,IAAI,GAAG,EAAU;QAC/B,eAAe,EAAE,IAAI,GAAG,EAAU;KACnC,CAAC;IACF,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC1B,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAQ,EAAE,MAAc,EAAE,IAAY,EAAE,QAAkB;IACvF,MAAM,IAAI,GAAiB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI;QACpD,YAAY,EAAE,IAAI,GAAG,EAAU;QAC/B,eAAe,EAAE,IAAI,GAAG,EAAU;KACnC,CAAC;IACF,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,GAAG,CAAC,OAAO,CAAC,G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;aAAM,CAAC;YACN,8CAA8C;YAC9C,MAAM,OAAO,GAAa,EAAE,CAAC;YAC7B,IAAI,IAAI,CAAC,aAAa;gBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACzD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,KAAK,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,UAAU,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,MAAM,IAAI,CAAC,CAAC;YAC/D,CAAC;YACD,sEAAsE;YACtE,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,KAAK,CAAC,IAAI,CAAC,iBAAiB,WAAW,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,MAAM,IAAI,CAAC,CAAC;YACnF,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IRNode } from '@kernlang/core';
2
+ import type { Ctx } from './nextjs-types.js';
3
+ export declare function renderNode(node: IRNode, ctx: Ctx, indent: string): void;
4
+ export declare function renderChildren(node: IRNode, ctx: Ctx, indent: string): void;