@adrifer/winix 0.2.0-preview.1 → 0.2.0-preview.2
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/dist/core/types.d.ts +17 -0
- package/dist/sdk/index.d.ts +4 -4
- package/dist/sdk/index.js +2 -2
- package/package.json +1 -1
package/dist/core/types.d.ts
CHANGED
|
@@ -65,6 +65,23 @@ export type FragmentEntry = LazyFragment | Fragment | readonly FragmentEntry[];
|
|
|
65
65
|
* What a lazy fragment can resolve into.
|
|
66
66
|
*/
|
|
67
67
|
export type FragmentResult = FragmentEntry;
|
|
68
|
+
/**
|
|
69
|
+
* The return type allowed for *authoring callbacks* (`feature`/`profile`/`host`
|
|
70
|
+
* bodies). It is a `FragmentResult` OR nothing (`void`/`undefined`), because a
|
|
71
|
+
* callback may declare purely by effect through the injected namespaces and
|
|
72
|
+
* return nothing at all:
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* feature("dev", ({ home }) => { home.program("git"); }); // returns void
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* The runtime already treats a `undefined`/`null` return as "no returned
|
|
79
|
+
* content" and falls back to the collected effects (see
|
|
80
|
+
* `mergeEffectsAndReturn`); this type makes the public signatures match that
|
|
81
|
+
* behavior. `FragmentResult` itself stays strict for internal use where a
|
|
82
|
+
* concrete result is always present.
|
|
83
|
+
*/
|
|
84
|
+
export type AuthoringResult = FragmentResult | void;
|
|
68
85
|
/**
|
|
69
86
|
* A lazy fragment descriptor: holds the factory + args for deferred evaluation.
|
|
70
87
|
*/
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type WinixContext } from "./context.js";
|
|
2
|
-
import type { Fragment, FragmentFactory, PlatformFactory, ProfileFactory, PlatformLazyFragment, FragmentEntry,
|
|
2
|
+
import type { Fragment, FragmentFactory, PlatformFactory, ProfileFactory, PlatformLazyFragment, FragmentEntry, AuthoringResult, InputDef, InputWithOptions, WorkspaceDef, HostDef, EvalContext, NixExpr } from "../core/types.js";
|
|
3
3
|
export declare function setEvalContext(ctx: EvalContext): EvalContext | null;
|
|
4
4
|
export declare function restoreEvalContext(ctx: EvalContext | null): void;
|
|
5
5
|
export declare function clearEvalContext(): void;
|
|
6
6
|
export declare function getEvalContext(): EvalContext;
|
|
7
7
|
export declare function getOptionalEvalContext(): EvalContext | null;
|
|
8
8
|
export declare function platform<T extends unknown[]>(id: string, factory: (...args: T) => Fragment): PlatformFactory<T>;
|
|
9
|
-
export declare function feature<T extends unknown[]>(id: string, factory: (ctx: WinixContext, ...args: T) =>
|
|
10
|
-
export declare function profile<T extends unknown[]>(id: string, factory: (ctx: WinixContext, ...args: T) =>
|
|
9
|
+
export declare function feature<T extends unknown[]>(id: string, factory: (ctx: WinixContext, ...args: T) => AuthoringResult): FragmentFactory<T>;
|
|
10
|
+
export declare function profile<T extends unknown[]>(id: string, factory: (ctx: WinixContext, ...args: T) => AuthoringResult): ProfileFactory<T>;
|
|
11
11
|
export declare function profile(id: string, entries: FragmentEntry | readonly FragmentEntry[]): ProfileFactory<[]>;
|
|
12
12
|
export declare function host(name: string, platform: PlatformLazyFragment, fragments: readonly FragmentEntry[]): HostDef;
|
|
13
|
-
export declare function host(name: string, platform: PlatformLazyFragment, body: (ctx: WinixContext) =>
|
|
13
|
+
export declare function host(name: string, platform: PlatformLazyFragment, body: (ctx: WinixContext) => AuthoringResult): HostDef;
|
|
14
14
|
export declare function workspace(def: WorkspaceDef): WorkspaceDef;
|
|
15
15
|
export declare function input(url: string, opts?: Omit<InputWithOptions, "url">): InputWithOptions;
|
|
16
16
|
export declare function defineInputs<T extends Record<string, InputDef>>(inputs: T): T;
|
package/dist/sdk/index.js
CHANGED
|
@@ -58,7 +58,7 @@ export function feature(id, factory) {
|
|
|
58
58
|
__id: id,
|
|
59
59
|
__resolve: () => {
|
|
60
60
|
const ctx = createWinixContext();
|
|
61
|
-
let returned;
|
|
61
|
+
let returned = undefined;
|
|
62
62
|
const effects = withCollector(() => {
|
|
63
63
|
returned = factory(ctx, ...args);
|
|
64
64
|
});
|
|
@@ -93,7 +93,7 @@ export function host(name, platform, fragmentsOrBody) {
|
|
|
93
93
|
__id: `${name}:inline`,
|
|
94
94
|
__resolve: () => {
|
|
95
95
|
const ctx = createWinixContext();
|
|
96
|
-
let returned;
|
|
96
|
+
let returned = undefined;
|
|
97
97
|
const effects = withCollector(() => {
|
|
98
98
|
returned = body(ctx);
|
|
99
99
|
});
|
package/package.json
CHANGED