@kernlang/core 2.0.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.
Files changed (50) hide show
  1. package/LICENSE +661 -0
  2. package/dist/codegen-core.d.ts +30 -0
  3. package/dist/codegen-core.js +751 -0
  4. package/dist/codegen-core.js.map +1 -0
  5. package/dist/config.d.ts +69 -0
  6. package/dist/config.js +78 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/decompiler.d.ts +2 -0
  9. package/dist/decompiler.js +44 -0
  10. package/dist/decompiler.js.map +1 -0
  11. package/dist/errors.d.ts +12 -0
  12. package/dist/errors.js +40 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/index.d.ts +23 -0
  15. package/dist/index.js +28 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/parser.d.ts +4 -0
  18. package/dist/parser.js +380 -0
  19. package/dist/parser.js.map +1 -0
  20. package/dist/scanner.d.ts +40 -0
  21. package/dist/scanner.js +380 -0
  22. package/dist/scanner.js.map +1 -0
  23. package/dist/spec.d.ts +17 -0
  24. package/dist/spec.js +101 -0
  25. package/dist/spec.js.map +1 -0
  26. package/dist/styles-react.d.ts +3 -0
  27. package/dist/styles-react.js +20 -0
  28. package/dist/styles-react.js.map +1 -0
  29. package/dist/styles-tailwind.d.ts +8 -0
  30. package/dist/styles-tailwind.js +197 -0
  31. package/dist/styles-tailwind.js.map +1 -0
  32. package/dist/template-catalog.d.ts +26 -0
  33. package/dist/template-catalog.js +228 -0
  34. package/dist/template-catalog.js.map +1 -0
  35. package/dist/template-engine.d.ts +33 -0
  36. package/dist/template-engine.js +196 -0
  37. package/dist/template-engine.js.map +1 -0
  38. package/dist/types.d.ts +94 -0
  39. package/dist/types.js +11 -0
  40. package/dist/types.js.map +1 -0
  41. package/dist/utils.d.ts +12 -0
  42. package/dist/utils.js +62 -0
  43. package/dist/utils.js.map +1 -0
  44. package/dist/version-adapters.d.ts +76 -0
  45. package/dist/version-adapters.js +172 -0
  46. package/dist/version-adapters.js.map +1 -0
  47. package/dist/version-detect.d.ts +30 -0
  48. package/dist/version-detect.js +63 -0
  49. package/dist/version-detect.js.map +1 -0
  50. package/package.json +20 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Version Detection Utility
3
+ *
4
+ * Auto-detects Tailwind CSS and Next.js versions from the user's project
5
+ * by reading package.json dependencies.
6
+ */
7
+ import type { FrameworkVersions } from './config.js';
8
+ /**
9
+ * Parse a semver string and return the major version number.
10
+ * Returns 0 if the string is not a valid semver.
11
+ */
12
+ export declare function parseMajorVersion(version: string): number;
13
+ /**
14
+ * Detect framework versions from a parsed package.json object.
15
+ *
16
+ * Looks in both dependencies and devDependencies for:
17
+ * - tailwindcss -> tailwind version
18
+ * - next -> nextjs version
19
+ */
20
+ export declare function detectVersionsFromPackageJson(packageJson: Record<string, unknown>): FrameworkVersions;
21
+ /**
22
+ * Resolve the effective Tailwind major version.
23
+ * Defaults to 3 when unspecified (backward-compatible).
24
+ */
25
+ export declare function resolveTailwindMajor(versions: FrameworkVersions): 3 | 4;
26
+ /**
27
+ * Resolve the effective Next.js major version.
28
+ * Defaults to 14 when unspecified (most common production version).
29
+ */
30
+ export declare function resolveNextjsMajor(versions: FrameworkVersions): 13 | 14 | 15;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Version Detection Utility
3
+ *
4
+ * Auto-detects Tailwind CSS and Next.js versions from the user's project
5
+ * by reading package.json dependencies.
6
+ */
7
+ /**
8
+ * Parse a semver string and return the major version number.
9
+ * Returns 0 if the string is not a valid semver.
10
+ */
11
+ export function parseMajorVersion(version) {
12
+ const cleaned = version.replace(/^[\^~>=<]*/g, '').trim();
13
+ const major = parseInt(cleaned.split('.')[0], 10);
14
+ return isNaN(major) ? 0 : major;
15
+ }
16
+ /**
17
+ * Detect framework versions from a parsed package.json object.
18
+ *
19
+ * Looks in both dependencies and devDependencies for:
20
+ * - tailwindcss -> tailwind version
21
+ * - next -> nextjs version
22
+ */
23
+ export function detectVersionsFromPackageJson(packageJson) {
24
+ const versions = {};
25
+ const deps = (packageJson.dependencies ?? {});
26
+ const devDeps = (packageJson.devDependencies ?? {});
27
+ // Tailwind CSS
28
+ const twVersion = devDeps['tailwindcss'] ?? deps['tailwindcss'];
29
+ if (twVersion) {
30
+ versions.tailwind = twVersion;
31
+ }
32
+ // Next.js
33
+ const nextVersion = deps['next'] ?? devDeps['next'];
34
+ if (nextVersion) {
35
+ versions.nextjs = nextVersion;
36
+ }
37
+ return versions;
38
+ }
39
+ /**
40
+ * Resolve the effective Tailwind major version.
41
+ * Defaults to 3 when unspecified (backward-compatible).
42
+ */
43
+ export function resolveTailwindMajor(versions) {
44
+ if (!versions.tailwind)
45
+ return 3;
46
+ const major = parseMajorVersion(versions.tailwind);
47
+ return major >= 4 ? 4 : 3;
48
+ }
49
+ /**
50
+ * Resolve the effective Next.js major version.
51
+ * Defaults to 14 when unspecified (most common production version).
52
+ */
53
+ export function resolveNextjsMajor(versions) {
54
+ if (!versions.nextjs)
55
+ return 14;
56
+ const major = parseMajorVersion(versions.nextjs);
57
+ if (major >= 15)
58
+ return 15;
59
+ if (major <= 13)
60
+ return 13;
61
+ return 14;
62
+ }
63
+ //# sourceMappingURL=version-detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-detect.js","sourceRoot":"","sources":["../src/version-detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1D,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClC,CA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AO,EAAE,CAAC;AACZ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@kernlang/core",
3
+ "version": "2.0.0",
4
+ "description": "Kern core — parser, types, spec, config, style engines, codegen",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": "./dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "license": "AGPL-3.0",
15
+ "dependencies": {},
16
+ "scripts": {
17
+ "build": "tsc -b",
18
+ "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js --forceExit --config jest.config.js"
19
+ }
20
+ }