@presolve/framework 0.2.0-beta.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2026 Presolve contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Presolve
2
+
3
+ `@presolve/framework` is the public TypeScript authoring vocabulary for
4
+ Presolve applications. Generated projects install it under the local
5
+ `presolve` alias, preserving the canonical authoring import while using a
6
+ registry-safe scoped package identity. It supplies inert compiler intrinsics
7
+ and TypeScript declarations; the Presolve compiler is the sole authority that
8
+ gives those forms semantic meaning.
9
+
10
+ ```tsx
11
+ import { action, state, Component } from "presolve";
12
+
13
+ export class Counter extends Component {
14
+ count = state(0);
15
+
16
+ increment = action(() => { this.count++; });
17
+
18
+ render() { return <button onClick={this.increment}>{this.count}</button>; }
19
+ }
20
+ ```
21
+
22
+ Install `@presolve/cli` as a development dependency to build an application.
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@presolve/framework",
3
+ "version": "0.2.0-beta.1",
4
+ "description": "Presolve compiler authoring vocabulary for TypeScript.",
5
+ "license": "MIT OR Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/fierstdev/presolve.git",
9
+ "directory": "framework/packages/presolve"
10
+ },
11
+ "files": [
12
+ "src",
13
+ "README.md"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "tag": "beta"
18
+ },
19
+ "type": "module",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./src/index.d.ts",
23
+ "default": "./src/index.js"
24
+ }
25
+ },
26
+ "scripts": {
27
+ "test": "node --input-type=module -e \"import('./src/index.js').then(({state}) => { if (state(1) !== 1) throw new Error('state intrinsic must be inert'); })\""
28
+ }
29
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,101 @@
1
+ /** Compiler intrinsics with no framework runtime authority. */
2
+ export type PresolveClassDecorator = <TClass extends abstract new (...args: never[]) => object>(
3
+ value: TClass,
4
+ context: ClassDecoratorContext<TClass>
5
+ ) => TClass | void;
6
+ export type PresolveMethodDecorator = <
7
+ This,
8
+ Value extends (this: This, ...args: any[]) => unknown,
9
+ >(
10
+ value: Value,
11
+ context: ClassMethodDecoratorContext<This, Value>
12
+ ) => Value | void;
13
+ export type PresolveGetterDecorator = <This, Value>(
14
+ value: (this: This) => Value,
15
+ context: ClassGetterDecoratorContext<This, Value>
16
+ ) => ((this: This) => Value) | void;
17
+ export type PresolveFieldDecorator = <This, Value>(
18
+ value: undefined,
19
+ context: ClassFieldDecoratorContext<This, Value>
20
+ ) => void;
21
+
22
+ /** @deprecated Alpha compatibility decorator. V2 components extend `Component`. */
23
+ export declare function component(): PresolveClassDecorator;
24
+ /**
25
+ * Creates a V2 action instance field. The overload without a handler is
26
+ * retained solely for alpha decorator compatibility.
27
+ */
28
+ export declare function action<This, Args extends readonly unknown[], Value>(
29
+ handler: (this: This, ...args: Args) => Value
30
+ ): (this: This, ...args: Args) => Value;
31
+ /** @deprecated Alpha compatibility decorator. */
32
+ export declare function action(): PresolveMethodDecorator;
33
+ export declare function computed(): PresolveGetterDecorator;
34
+ /** Creates a V2 browser effect instance field. */
35
+ export declare function effect<This>(
36
+ handler: (this: This) => void | (() => void)
37
+ ): void;
38
+ /** @deprecated Alpha compatibility decorator. */
39
+ export declare function effect(): PresolveMethodDecorator;
40
+ export declare function state<T>(initialValue: T): T;
41
+
42
+ /**
43
+ * Manifest-backed browser environment access for decorator-free V2 source.
44
+ * Values are admitted only when a matching compiler environment manifest
45
+ * classifies the requested name as `PRESOLVE_PUBLIC_*`.
46
+ */
47
+ export declare const environment: {
48
+ public(name: string): string;
49
+ };
50
+
51
+ export declare function slot(): PresolveFieldDecorator;
52
+ export interface SlotContent {
53
+ readonly __presolveSlotContentBrand: unique symbol;
54
+ }
55
+
56
+ export declare function context(): PresolveFieldDecorator;
57
+ export type ContextDesignator = `${string}.${string}`;
58
+ export declare function provide(context: ContextDesignator): PresolveFieldDecorator;
59
+ export declare function consume(context: ContextDesignator): PresolveFieldDecorator;
60
+
61
+ export declare function form(): PresolveFieldDecorator;
62
+ /** A compiler-owned Form declaration marker; it is not a runtime controller. */
63
+ export interface Form {
64
+ readonly __presolveFormBrand: unique symbol;
65
+ }
66
+ export declare function serialize(
67
+ format: "json" | "form-data" | "url-encoded"
68
+ ): PresolveFieldDecorator;
69
+ export declare function field(form: string, path?: string): PresolveFieldDecorator;
70
+ export interface ValidationRule {
71
+ readonly __presolveValidationRuleBrand: unique symbol;
72
+ }
73
+ export declare function validate(rule: ValidationRule): PresolveFieldDecorator;
74
+ export declare function required(): ValidationRule;
75
+ export declare function submit(form: string): PresolveMethodDecorator;
76
+
77
+ export type ResourceState = "idle" | "pending" | "ready" | "failed" | "cancelled";
78
+ export interface Resource<Data, Error> {
79
+ readonly data: Data | null;
80
+ readonly error: Error | null;
81
+ readonly state: ResourceState;
82
+ readonly __presolveResourceBrand: unique symbol;
83
+ }
84
+ export declare function resource(endpoint: string): PresolveFieldDecorator;
85
+ export declare function loader(endpoint: string): PresolveFieldDecorator;
86
+ export declare function serverAction(endpoint: string): PresolveMethodDecorator;
87
+ export declare function opaque(
88
+ packageSpecifier: string,
89
+ exportName: string
90
+ ): PresolveMethodDecorator;
91
+
92
+ export declare abstract class Component<Props = {}> {}
93
+
94
+ declare global {
95
+ namespace JSX {
96
+ type Element = unknown;
97
+ interface IntrinsicElements {
98
+ [elementName: string]: unknown;
99
+ }
100
+ }
101
+ }
package/src/index.js ADDED
@@ -0,0 +1,25 @@
1
+ /** Compiler intrinsics: these declarations deliberately have no runtime authority. */
2
+ const identityClass = (value) => value;
3
+ const emptyField = () => undefined;
4
+
5
+ export class Component {}
6
+
7
+ export function component() { return identityClass; }
8
+ export function action() { return identityClass; }
9
+ export function computed() { return identityClass; }
10
+ export function effect() { return identityClass; }
11
+ export function state(value) { return value; }
12
+ export function slot() { return emptyField; }
13
+ export function context() { return emptyField; }
14
+ export function provide() { return emptyField; }
15
+ export function consume() { return emptyField; }
16
+ export function form() { return emptyField; }
17
+ export function serialize() { return emptyField; }
18
+ export function field() { return emptyField; }
19
+ export function validate() { return emptyField; }
20
+ export function required() { return Object.freeze({}); }
21
+ export function submit() { return identityClass; }
22
+ export function resource() { return emptyField; }
23
+ export function loader() { return emptyField; }
24
+ export function serverAction() { return identityClass; }
25
+ export function opaque() { return identityClass; }