@koppajs/koppajs-core 3.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.
@@ -0,0 +1,82 @@
1
+ import type { ComponentInstance, ComponentSource, HTMLElementWithInstance, IModule, IPlugin } from '../types';
2
+ /**
3
+ * Runtime type guard for the ComponentSource contract.
4
+ *
5
+ * Validates that an object conforms to the ComponentSource interface by
6
+ * checking for REQUIRED fields only. Optional fields are not validated
7
+ * (absence is acceptable), and unknown extra fields are ignored.
8
+ *
9
+ * ## Contract Validation Rules:
10
+ *
11
+ * **REQUIRED** (must be present and be strings):
12
+ * - `template` - HTML template string
13
+ * - `script` - JavaScript controller code string
14
+ * - `style` - CSS style string
15
+ *
16
+ * **OPTIONAL** (not validated, absence is acceptable):
17
+ * - `scriptMap`, `type`, `deps`, `structAttr`
18
+ *
19
+ * **IGNORED** (extra fields are allowed and not validated):
20
+ * - Any additional properties are permitted for forward compatibility
21
+ *
22
+ * @param ext - The object to test
23
+ * @returns True if the object satisfies the ComponentSource contract
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * // Valid minimal ComponentSource
28
+ * isComponentSource({ template: '', script: '', style: '' }) // true
29
+ *
30
+ * // Valid with optional fields
31
+ * isComponentSource({ template: '', script: '', style: '', deps: null }) // true
32
+ *
33
+ * // Valid with extra fields (ignored)
34
+ * isComponentSource({ template: '', script: '', style: '', debug: true }) // true
35
+ *
36
+ * // Invalid - missing required field
37
+ * isComponentSource({ template: '', script: '' }) // false
38
+ *
39
+ * // Invalid - wrong type
40
+ * isComponentSource({ template: 123, script: '', style: '' }) // false
41
+ * ```
42
+ */
43
+ export declare function isComponentSource(ext: unknown): ext is ComponentSource;
44
+ /**
45
+ * Determines whether the given object is a valid Plugin.
46
+ *
47
+ * @param ext - The object to test
48
+ * @returns True if the object has a `setup` function and no `attach` method
49
+ */
50
+ export declare function isPlugin(ext: unknown): ext is IPlugin;
51
+ /**
52
+ * Determines whether the given object is a valid Module.
53
+ *
54
+ * @param ext - The object to test
55
+ * @returns True if the object has an `attach` function and no `setup` method
56
+ */
57
+ export declare function isModule(ext: unknown): ext is IModule;
58
+ /**
59
+ * Checks whether a DOM element has the `instance` slot (may be undefined).
60
+ *
61
+ * @param el - The value to check
62
+ * @returns True if el is an HTMLElement and carries an `instance` property
63
+ */
64
+ export declare function isHTMLElementWithInstance(el: unknown): el is HTMLElementWithInstance;
65
+ /**
66
+ * Checks whether a DOM element has a *set* component instance.
67
+ *
68
+ * @param el - The value to check
69
+ * @returns True if el is HTMLElementWithInstance and instance is defined
70
+ */
71
+ export declare function hasComponentInstance(el: unknown): el is HTMLElementWithInstance & {
72
+ instance: ComponentInstance;
73
+ };
74
+ /**
75
+ * Validates that a RegExp match array represents a valid loop definition.
76
+ *
77
+ * Used for syntax like `item in collection`.
78
+ *
79
+ * @param match - The result of RegExp.match()
80
+ * @returns True if the match has exactly three elements and valid capture groups
81
+ */
82
+ export declare function isValidLoopMatch(match: RegExpMatchArray | null): match is [string, string, string];
package/package.json ADDED
@@ -0,0 +1,107 @@
1
+ {
2
+ "name": "@koppajs/koppajs-core",
3
+ "version": "3.0.0",
4
+ "type": "module",
5
+ "types": "./dist/index.d.ts",
6
+ "main": "./dist/index.cjs.js",
7
+ "module": "./dist/index.es.js",
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "CHANGELOG.md",
12
+ "LICENSE",
13
+ "package.json"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.es.js",
19
+ "require": "./dist/index.cjs.js"
20
+ }
21
+ },
22
+ "sideEffects": false,
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/koppajs/koppajs-core"
26
+ },
27
+ "description": "Koppa.js is a lightweight, high-performance frontend framework designed for building modern web applications without relying on a virtual DOM. It offers a modular architecture, reactivity, and seamless integration with TypeScript and Vite.",
28
+ "keywords": [
29
+ "koppa",
30
+ "koppajs",
31
+ "koppa.js",
32
+ "frontend",
33
+ "framework",
34
+ "ui-framework",
35
+ "typescript",
36
+ "vite",
37
+ "reactivity",
38
+ "single-file-components",
39
+ "modular",
40
+ "lightweight",
41
+ "high-performance",
42
+ "web-development",
43
+ "javascript"
44
+ ],
45
+ "author": "Bastian Bensch",
46
+ "license": "Apache-2.0",
47
+ "homepage": "https://koppajs.org",
48
+ "scripts": {
49
+ "generate:types": "tsc --project config/tsconfig.types.json",
50
+ "copy:dts": "node scripts/copy-dts.js",
51
+ "clean": "rimraf dist coverage",
52
+ "deepclean": "rimraf node_modules dist",
53
+ "nuke": "rimraf node_modules dist",
54
+ "nuke:all": "rimraf node_modules dist pnpm-lock.yaml",
55
+ "pretypecheck": "rimraf dist",
56
+ "typecheck": "tsc --project config/tsconfig.json",
57
+ "build": "pnpm run typecheck && vite build --config config/vite.config.ts && pnpm generate:types && pnpm run copy:dts",
58
+ "rebuild": "pnpm run clean && pnpm run build",
59
+ "test": "vitest --config config/vitest.config.ts --run",
60
+ "test:coverage": "vitest --config config/vitest.config.ts --coverage",
61
+ "test:watch": "vitest --config config/vitest.config.ts --watch",
62
+ "test:ci": "vitest --config config/vitest.config.ts --run --coverage",
63
+ "lint:scripts": "pnpm eslint . --config config/eslint.config.mjs --fix",
64
+ "lint": "pnpm run lint:scripts",
65
+ "format:scripts": "prettier --ignore-path config/.prettierignore --config config/prettier.config.mjs --write .",
66
+ "format": "pnpm run format:scripts",
67
+ "dump:ai": "node scripts/project-dump.mjs"
68
+ },
69
+ "packageManager": "pnpm@10.24.0",
70
+ "engines": {
71
+ "node": ">=20",
72
+ "pnpm": ">=10.24.0"
73
+ },
74
+ "devDependencies": {
75
+ "@commitlint/cli": "^20.1.0",
76
+ "@commitlint/config-conventional": "^20.0.0",
77
+ "@eslint/js": "^9.39.1",
78
+ "@types/jsdom": "^27.0.0",
79
+ "@types/node": "^24.10.1",
80
+ "@typescript-eslint/eslint-plugin": "^8.48.1",
81
+ "@typescript-eslint/parser": "^8.48.1",
82
+ "@vitest/coverage-v8": "^4.0.15",
83
+ "commitlint": "^20.1.0",
84
+ "eslint": "^9.39.1",
85
+ "eslint-config-prettier": "^10.1.8",
86
+ "eslint-plugin-prettier": "^5.5.4",
87
+ "husky": "^9.1.7",
88
+ "jsdom": "^27.4.0",
89
+ "lint-staged": "^16.2.7",
90
+ "prettier": "^3.7.3",
91
+ "rimraf": "^6.1.2",
92
+ "terser": "^5.44.1",
93
+ "typescript": "^5.7.2",
94
+ "vite": "^7.2.6",
95
+ "vite-tsconfig-paths": "^5.1.4",
96
+ "vitest": "^4.0.15",
97
+ "fflate": "^0.8.2"
98
+ },
99
+ "overrides": {
100
+ "glob": "^11.0.0"
101
+ },
102
+ "pnpm": {
103
+ "onlyBuiltDependencies": [
104
+ "esbuild"
105
+ ]
106
+ }
107
+ }