@uniflowed/core 0.0.0-alpha.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/index.js ADDED
@@ -0,0 +1,41 @@
1
+ // @flow
2
+ //
3
+ // Root entry point of `@uniflowed/core`.
4
+ //
5
+ // This module exists for discoverability only. It re-exports, by name, exactly
6
+ // the surface `uf_lib`'s Rust registry promises for the `@uniflowed/core`
7
+ // specifier — the test API and the config entry point. Everything else lives
8
+ // behind a subpath, and subpath imports are the supported entry points:
9
+ // `@uniflowed/core/native` is the one this package implements itself.
10
+ //
11
+ // The two re-exported surfaces are implemented in `@uniflowed/test` and
12
+ // `@uniflowed/config` and reached by specifier, not by relative path: each
13
+ // `packages/*` directory is published as its own npm package, so a relative
14
+ // path into a sibling names a file that exists in this repository and nowhere
15
+ // in an installed tree.
16
+ //
17
+ // There is deliberately no `export *` here. A star re-export forces a bundler
18
+ // to keep the whole module graph reachable from this file, and a whole-surface
19
+ // barrel could not exist anyway: several domains legitimately export the same
20
+ // name (`graphql`, `Image`, `Markdown`, `plan`, `Text`, `contract`, ...).
21
+
22
+ export type { TestBody, TestOptions } from "@uniflowed/test";
23
+ export {
24
+ afterAll,
25
+ afterEach,
26
+ beforeAll,
27
+ beforeEach,
28
+ describe,
29
+ expect,
30
+ fn,
31
+ it,
32
+ test,
33
+ } from "@uniflowed/test";
34
+
35
+ export type {
36
+ CapabilityJsHost,
37
+ RuleLevel,
38
+ TaskDefinition,
39
+ UniflowedConfig,
40
+ } from "@uniflowed/config";
41
+ export { defineConfig } from "@uniflowed/config";
@@ -0,0 +1,108 @@
1
+ // @flow
2
+ //
3
+ // Internal to `@uniflowed/core`.
4
+ //
5
+ // This module is deliberately absent from `package.json#exports`, so Node and
6
+ // every bundler that honours the exports map refuse to resolve
7
+ // `@uniflowed/core/internal/native-runtime`. Sibling modules reach it through a
8
+ // relative specifier, which the exports map does not gate.
9
+ //
10
+ // It exists so the "native runtime required" message is defined in exactly one
11
+ // place, and so the phantom carriers behind the package's opaque types share a
12
+ // single documented convention.
13
+
14
+ /**
15
+ * Specifier of the shipped subpath a binding belongs to, for example
16
+ * `@uniflowed/core/effect`.
17
+ */
18
+ export type ModuleSpecifier = string;
19
+
20
+ /**
21
+ * Phantom carrier for an opaque handle the native runtime owns.
22
+ *
23
+ * `Name` is a distinct string literal per handle, which keeps two unrelated
24
+ * handles from unifying even inside the module that defines them.
25
+ */
26
+ export type NativeHandle<Name extends string> = { readonly __ufNative: Name };
27
+
28
+ /**
29
+ * Phantom carrier for an opaque handle with an invariant type parameter.
30
+ *
31
+ * `T` sits behind a writable property, which is precisely what invariance
32
+ * means: `Handle<Dog>` is neither a subtype nor a supertype of `Handle<Animal>`.
33
+ */
34
+ export type NativeHandleInvariant<Name extends string, T> = {
35
+ readonly __ufNative: Name,
36
+ __ufValue: T,
37
+ };
38
+
39
+ /**
40
+ * Phantom carrier for an opaque handle with a covariant type parameter.
41
+ *
42
+ * `T` only ever appears in a return position, so `Handle<Dog>` stays assignable
43
+ * to `Handle<Animal>` — the guarantee a `+T` sigil makes to callers.
44
+ */
45
+ export type NativeHandleCovariant<Name extends string, out T> = {
46
+ readonly __ufNative: Name,
47
+ readonly __ufValue: () => T,
48
+ };
49
+
50
+ /**
51
+ * Phantom carrier for a handle with two covariant type parameters.
52
+ *
53
+ * Same guarantee as `NativeHandleCovariant`, for a handle that tracks two
54
+ * things at once — a fiber's success and failure types, say.
55
+ */
56
+ export type NativeHandleCovariant2<Name extends string, out A, out B> = {
57
+ readonly __ufNative: Name,
58
+ readonly __ufFirst: () => A,
59
+ readonly __ufSecond: () => B,
60
+ };
61
+
62
+ /**
63
+ * Phantom carrier for a handle with three covariant type parameters.
64
+ *
65
+ * An effect tracks what it produces, how it fails, and what it needs; each sits
66
+ * behind a function that returns it, which is what makes all three covariant
67
+ * rather than merely declared so.
68
+ */
69
+ export type NativeHandleCovariant3<Name extends string, out A, out B, out C> = {
70
+ readonly __ufNative: Name,
71
+ readonly __ufFirst: () => A,
72
+ readonly __ufSecond: () => B,
73
+ readonly __ufThird: () => C,
74
+ };
75
+
76
+ /**
77
+ * Raised when a `@uniflowed/*` binding is reached outside the uf native runtime.
78
+ *
79
+ * The message names both the subpath and the binding, so a caller sees
80
+ * `@uniflowed/core/effect: effect() requires the uf native runtime` rather than
81
+ * a generic failure.
82
+ */
83
+ export class NativeRuntimeRequiredError extends Error {
84
+ /** Subpath the binding belongs to, e.g. `@uniflowed/core/effect`. */
85
+ moduleSpecifier: ModuleSpecifier;
86
+ /** Binding that was reached, e.g. `effect` or `Dialog.Root`. */
87
+ binding: string;
88
+
89
+ constructor(moduleSpecifier: ModuleSpecifier, binding: string) {
90
+ super(`${moduleSpecifier}: ${binding}() requires the uf native runtime`);
91
+ this.name = "NativeRuntimeRequiredError";
92
+ this.moduleSpecifier = moduleSpecifier;
93
+ this.binding = binding;
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Raise `NativeRuntimeRequiredError` for one binding.
99
+ *
100
+ * Returns `empty`, Flow's bottom type, so a call site can `return` it from a
101
+ * function of any declared return type without weakening that type to `any` or
102
+ * `mixed`. Every shipped binding raises on *call*; importing a subpath stays
103
+ * free of side effects so bundlers can drop the modules an application never
104
+ * touches.
105
+ */
106
+ export function nativeRuntimeRequired(moduleSpecifier: ModuleSpecifier, binding: string): empty {
107
+ throw new NativeRuntimeRequiredError(moduleSpecifier, binding);
108
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@uniflowed/core",
3
+ "version": "0.0.0-alpha.2",
4
+ "description": "Shared native-runtime bridge for the Unified Toolchain for Flow (React).",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/ubugeeei-prod/uf.git",
11
+ "directory": "packages/core"
12
+ },
13
+ "exports": {
14
+ ".": "./index.js",
15
+ "./native": "./internal/native-runtime.js"
16
+ },
17
+ "files": [
18
+ "index.js",
19
+ "internal/*.js"
20
+ ],
21
+ "dependencies": {
22
+ "@uniflowed/config": "0.0.0-alpha.2",
23
+ "@uniflowed/test": "0.0.0-alpha.2"
24
+ }
25
+ }