@expressive/mvc 0.87.0 → 0.88.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.
package/dist/caught.js DELETED
@@ -1,64 +0,0 @@
1
- //#region src/caught.ts
2
- const about = (cause) => {
3
- const text = cause instanceof Error ? cause.message : String(cause);
4
- return text ? `: ${text}` : ".";
5
- };
6
- /**
7
- * Reported to `State.on({ catch })` handlers instead of being thrown or logged.
8
- * Unhandled, a `warning` goes to `console.warn`; anything else escapes uncaught.
9
- */
10
- var Caught = class Caught extends Error {
11
- name = "Caught";
12
- /** Non-urgent - unhandled, it logs as a warning. */
13
- warning = false;
14
- constructor(state, message, key, cause) {
15
- super(message, arguments.length > 3 ? { cause } : void 0);
16
- this.key = key;
17
- Object.defineProperty(this, "state", { value: state });
18
- }
19
- /** A `catch` handler logging what would otherwise escape uncaught; warnings and destroyed writes pass on. */
20
- static log(error) {
21
- if (error.warning || error instanceof Caught.Destroyed) return error;
22
- console.error(error);
23
- }
24
- /** A write to a destroyed state - thrown to the writer unless a handler takes it. */
25
- static Destroyed = class Destroyed extends Caught {
26
- name = "Caught.Destroyed";
27
- constructor(state, key) {
28
- super(state, `Tried to update ${state}.${key} but state is destroyed.`, key);
29
- }
30
- };
31
- /** A state constructed but never activated. */
32
- static Inactive = class Inactive extends Caught {
33
- name = "Caught.Inactive";
34
- warning = true;
35
- constructor(state) {
36
- super(state, `${state} was constructed but never activated.`);
37
- }
38
- };
39
- /** A getter threw while refreshing; `cause` is what it threw. */
40
- static Getter = class Getter extends Caught {
41
- name = "Caught.Getter";
42
- constructor(state, key, cause) {
43
- super(state, `An exception was thrown while refreshing ${state.constructor}.${key}${about(cause)}`, key, cause);
44
- }
45
- };
46
- /** An async initializer rejected; `cause` is the rejection. */
47
- static Init = class Init extends Caught {
48
- name = "Caught.Init";
49
- constructor(state, cause) {
50
- super(state, `Async error in constructor for ${state.constructor}${about(cause)}`, void 0, cause);
51
- }
52
- };
53
- /** An effect or listener threw during a dispatch flush; `cause` is what it threw. */
54
- static Effect = class Effect extends Caught {
55
- name = "Caught.Effect";
56
- constructor(state, cause) {
57
- super(state, `An exception was thrown by an effect of ${state.constructor}${about(cause)}`, void 0, cause);
58
- }
59
- };
60
- };
61
-
62
- //#endregion
63
- export { Caught };
64
- //# sourceMappingURL=caught.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"caught.js","names":[],"sources":["../src/caught.ts"],"sourcesContent":["import type { State } from './state';\n\nconst about = (cause: unknown) => {\n const text = cause instanceof Error ? cause.message : String(cause);\n return text ? `: ${text}` : '.';\n};\n\n/**\n * Reported to `State.on({ catch })` handlers instead of being thrown or logged.\n * Unhandled, a `warning` goes to `console.warn`; anything else escapes uncaught.\n */\nclass Caught extends Error {\n readonly name: string = 'Caught';\n\n /** Non-urgent - unhandled, it logs as a warning. */\n readonly warning: boolean = false;\n\n declare readonly state: State;\n\n constructor(\n state: State,\n message: string,\n readonly key?: string,\n cause?: unknown\n ) {\n super(message, arguments.length > 3 ? { cause } : undefined);\n Object.defineProperty(this, 'state', { value: state });\n }\n\n /** A `catch` handler logging what would otherwise escape uncaught; warnings and destroyed writes pass on. */\n static log(error: Caught): Caught | void {\n if (error.warning || error instanceof Caught.Destroyed) return error;\n console.error(error);\n }\n\n /** A write to a destroyed state - thrown to the writer unless a handler takes it. */\n static Destroyed = class Destroyed extends Caught {\n readonly name = 'Caught.Destroyed';\n\n constructor(state: State, key: string) {\n super(state, `Tried to update ${state}.${key} but state is destroyed.`, key);\n }\n };\n\n /** A state constructed but never activated. */\n static Inactive = class Inactive extends Caught {\n readonly name = 'Caught.Inactive';\n readonly warning = true;\n\n constructor(state: State) {\n super(state, `${state} was constructed but never activated.`);\n }\n };\n\n /** A getter threw while refreshing; `cause` is what it threw. */\n static Getter = class Getter extends Caught {\n readonly name = 'Caught.Getter';\n\n constructor(state: State, key: string, cause: unknown) {\n super(state, `An exception was thrown while refreshing ${state.constructor}.${key}${about(cause)}`, key, cause);\n }\n };\n\n /** An async initializer rejected; `cause` is the rejection. */\n static Init = class Init extends Caught {\n readonly name = 'Caught.Init';\n\n constructor(state: State, cause: unknown) {\n super(state, `Async error in constructor for ${state.constructor}${about(cause)}`, undefined, cause);\n }\n };\n\n /** An effect or listener threw during a dispatch flush; `cause` is what it threw. */\n static Effect = class Effect extends Caught {\n readonly name = 'Caught.Effect';\n\n constructor(state: State, cause: unknown) {\n super(state, `An exception was thrown by an effect of ${state.constructor}${about(cause)}`, undefined, cause);\n }\n };\n}\n\ndeclare namespace Caught {\n type Destroyed = InstanceType<typeof Caught.Destroyed>;\n type Inactive = InstanceType<typeof Caught.Inactive>;\n type Getter = InstanceType<typeof Caught.Getter>;\n type Init = InstanceType<typeof Caught.Init>;\n type Effect = InstanceType<typeof Caught.Effect>;\n}\n\nexport { Caught };\n"],"mappings":";AAEA,MAAM,SAAS,UAAmB;CAChC,MAAM,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACnE,QAAO,OAAO,KAAK,SAAS;;;;;;AAO9B,IAAM,SAAN,MAAM,eAAe,MAAM;CACzB,AAAS,OAAe;;CAGxB,AAAS,UAAmB;CAI5B,YACE,OACA,SACA,AAAS,KACT,OACA;AACA,QAAM,SAAS,UAAU,SAAS,IAAI,EAAE,OAAO,GAAG,OAAU;EAHnD;AAIT,SAAO,eAAe,MAAM,SAAS,EAAE,OAAO,OAAO,CAAC;;;CAIxD,OAAO,IAAI,OAA8B;AACvC,MAAI,MAAM,WAAW,iBAAiB,OAAO,UAAW,QAAO;AAC/D,UAAQ,MAAM,MAAM;;;CAItB,OAAO,YAAY,MAAM,kBAAkB,OAAO;EAChD,AAAS,OAAO;EAEhB,YAAY,OAAc,KAAa;AACrC,SAAM,OAAO,mBAAmB,MAAM,GAAG,IAAI,2BAA2B,IAAI;;;;CAKhF,OAAO,WAAW,MAAM,iBAAiB,OAAO;EAC9C,AAAS,OAAO;EAChB,AAAS,UAAU;EAEnB,YAAY,OAAc;AACxB,SAAM,OAAO,GAAG,MAAM,uCAAuC;;;;CAKjE,OAAO,SAAS,MAAM,eAAe,OAAO;EAC1C,AAAS,OAAO;EAEhB,YAAY,OAAc,KAAa,OAAgB;AACrD,SAAM,OAAO,4CAA4C,MAAM,YAAY,GAAG,MAAM,MAAM,MAAM,IAAI,KAAK,MAAM;;;;CAKnH,OAAO,OAAO,MAAM,aAAa,OAAO;EACtC,AAAS,OAAO;EAEhB,YAAY,OAAc,OAAgB;AACxC,SAAM,OAAO,kCAAkC,MAAM,cAAc,MAAM,MAAM,IAAI,QAAW,MAAM;;;;CAKxG,OAAO,SAAS,MAAM,eAAe,OAAO;EAC1C,AAAS,OAAO;EAEhB,YAAY,OAAc,OAAgB;AACxC,SAAM,OAAO,2CAA2C,MAAM,cAAc,MAAM,MAAM,IAAI,QAAW,MAAM"}
package/dist/runtime.d.ts DELETED
@@ -1,72 +0,0 @@
1
- import { hot_d_exports } from "./hot.js";
2
- import { Component } from "./component.js";
3
-
4
- //#region src/runtime.d.ts
5
- /**
6
- * Per-adapter interpretation manifest. Each adapter augments this interface to
7
- * declare how it renders; the first member is `node` - the element type produced
8
- * by `Component.render` (surfaced as `Component.Node`) - alongside `intrinsics`,
9
- * the host's tag map (surfaced as `JSX.IntrinsicElements`).
10
- *
11
- * ```ts
12
- * declare module '@expressive/mvc/runtime' {
13
- * interface Host {
14
- * node: React.ReactNode;
15
- * intrinsics: React.JSX.IntrinsicElements;
16
- * }
17
- * }
18
- * ```
19
- *
20
- * Only one adapter is expected per compilation; two augmenting the same member
21
- * with different types in the same build would conflict - by design.
22
- */
23
- interface Host {}
24
- /**
25
- * Host runtime, registered by an adapter (e.g. `@expressive/react`) as an
26
- * import side effect. One host per build - a second registration with a
27
- * different runtime throws.
28
- *
29
- * Members are ambient host capabilities: plain functions the host uniquely
30
- * owns, callable outside render - element mechanics always, plus optional
31
- * extras that fall back sanely when absent. Hook-shaped (render-resident)
32
- * capabilities do not belong here; those live with the adapter.
33
- */
34
- interface HostRuntime {
35
- childrenOf(children: unknown): Component.Node[];
36
- isElement(node: unknown): boolean;
37
- jsx(type: unknown, props: object, key?: unknown): Component.Node;
38
- jsxDEV?(type: unknown, props: object, key?: unknown, isStatic?: boolean, source?: object, self?: unknown): Component.Node;
39
- jsxs(type: unknown, props: object, key?: unknown): Component.Node;
40
- propsOf(node: unknown): Record<string, unknown>;
41
- typeOf(node: unknown): unknown;
42
- Fragment: unknown;
43
- }
44
- /**
45
- * Agnostic Fragment sentinel. The runtime entries translate it to the host's
46
- * Fragment on element creation; `typeOf` translates back, so identity checks
47
- * against this value hold for fragments from either pragma.
48
- */
49
- declare const Fragment: unique symbol;
50
- /**
51
- * Register the host runtime. Idempotent for the same runtime - re-registering
52
- * picks up members added since (e.g. an optional dev seam). Element mechanics
53
- * the host leaves unset keep defaults that throw a setup-pointing error;
54
- * `jsxDEV` is routed around at the call site instead.
55
- */
56
- declare function host(runtime: HostRuntime): void;
57
- declare function jsx(type: unknown, props: object, key?: unknown): Component.Node;
58
- declare function jsxs(type: unknown, props: object, key?: unknown): Component.Node;
59
- /** Dev-transpiled element creation. Hosts without a `jsxDEV` of their own fall
60
- * back to the production entries (prod-only host under a dev build). */
61
- declare function jsxDEV(type: unknown, props: object, key?: unknown, isStatic?: boolean, source?: object, self?: unknown): Component.Node;
62
- /** Flatten `children` to an array of nodes, per the host's semantics. */
63
- declare function childrenOf(children: unknown): Component.Node[];
64
- /** Is `node` a host element? */
65
- declare function isElement(node: unknown): boolean;
66
- /** Element type of `node`; host Fragments surface as the agnostic `Fragment`. */
67
- declare function typeOf(node: unknown): unknown;
68
- /** Props carried by element `node`. */
69
- declare function propsOf(node: unknown): Record<string, unknown>;
70
- //#endregion
71
- export { Fragment, Host, HostRuntime, childrenOf, host, hot_d_exports as hot, isElement, jsx, jsxDEV, jsxs, propsOf, typeOf };
72
- //# sourceMappingURL=runtime.d.ts.map
package/dist/runtime.js DELETED
@@ -1,70 +0,0 @@
1
- import { hot_exports } from "./hot.js";
2
-
3
- //#region src/runtime.ts
4
- /**
5
- * Agnostic Fragment sentinel. The runtime entries translate it to the host's
6
- * Fragment on element creation; `typeOf` translates back, so identity checks
7
- * against this value hold for fragments from either pragma.
8
- */
9
- const Fragment = Symbol.for("@expressive/mvc.Fragment");
10
- /** Default for seams only a registered host can provide. */
11
- function absent() {
12
- throw new Error("No JSX host is registered for @expressive/mvc. Import a host adapter (e.g. '@expressive/react') before anything renders - typically as the first import of your application entry module.");
13
- }
14
- const HOST = {
15
- childrenOf: absent,
16
- isElement: absent,
17
- jsx: absent,
18
- jsxs: absent,
19
- propsOf: absent,
20
- typeOf: absent,
21
- Fragment
22
- };
23
- let registered;
24
- /**
25
- * Register the host runtime. Idempotent for the same runtime - re-registering
26
- * picks up members added since (e.g. an optional dev seam). Element mechanics
27
- * the host leaves unset keep defaults that throw a setup-pointing error;
28
- * `jsxDEV` is routed around at the call site instead.
29
- */
30
- function host(runtime) {
31
- if (registered && registered !== runtime) throw new Error("A different JSX host is already registered for @expressive/mvc. Only one host adapter may be active per build.");
32
- registered = runtime;
33
- Object.assign(HOST, runtime);
34
- }
35
- /** Translate the agnostic Fragment sentinel to the host's Fragment. */
36
- function hostType(type) {
37
- return type === Fragment ? HOST.Fragment : type;
38
- }
39
- function jsx(type, props, key) {
40
- return HOST.jsx(hostType(type), props, key);
41
- }
42
- function jsxs(type, props, key) {
43
- return HOST.jsxs(hostType(type), props, key);
44
- }
45
- /** Dev-transpiled element creation. Hosts without a `jsxDEV` of their own fall
46
- * back to the production entries (prod-only host under a dev build). */
47
- function jsxDEV(type, props, key, isStatic, source, self) {
48
- return HOST.jsxDEV ? HOST.jsxDEV(hostType(type), props, key, isStatic, source, self) : isStatic ? jsxs(type, props, key) : jsx(type, props, key);
49
- }
50
- /** Flatten `children` to an array of nodes, per the host's semantics. */
51
- function childrenOf(children) {
52
- return HOST.childrenOf(children);
53
- }
54
- /** Is `node` a host element? */
55
- function isElement(node) {
56
- return HOST.isElement(node);
57
- }
58
- /** Element type of `node`; host Fragments surface as the agnostic `Fragment`. */
59
- function typeOf(node) {
60
- const type = HOST.typeOf(node);
61
- return type === HOST.Fragment ? Fragment : type;
62
- }
63
- /** Props carried by element `node`. */
64
- function propsOf(node) {
65
- return HOST.propsOf(node);
66
- }
67
-
68
- //#endregion
69
- export { Fragment, childrenOf, host, hot_exports as hot, isElement, jsx, jsxDEV, jsxs, propsOf, typeOf };
70
- //# sourceMappingURL=runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.js","names":[],"sources":["../src/runtime.ts"],"sourcesContent":["import type { Component } from './component';\n\n/**\n * Per-adapter interpretation manifest. Each adapter augments this interface to\n * declare how it renders; the first member is `node` - the element type produced\n * by `Component.render` (surfaced as `Component.Node`) - alongside `intrinsics`,\n * the host's tag map (surfaced as `JSX.IntrinsicElements`).\n *\n * ```ts\n * declare module '@expressive/mvc/runtime' {\n * interface Host {\n * node: React.ReactNode;\n * intrinsics: React.JSX.IntrinsicElements;\n * }\n * }\n * ```\n *\n * Only one adapter is expected per compilation; two augmenting the same member\n * with different types in the same build would conflict - by design.\n */\nexport interface Host { }\n\n/**\n * Host runtime, registered by an adapter (e.g. `@expressive/react`) as an\n * import side effect. One host per build - a second registration with a\n * different runtime throws.\n *\n * Members are ambient host capabilities: plain functions the host uniquely\n * owns, callable outside render - element mechanics always, plus optional\n * extras that fall back sanely when absent. Hook-shaped (render-resident)\n * capabilities do not belong here; those live with the adapter.\n */\nexport interface HostRuntime {\n childrenOf(children: unknown): Component.Node[];\n isElement(node: unknown): boolean;\n jsx(type: unknown, props: object, key?: unknown): Component.Node;\n jsxDEV?(type: unknown, props: object, key?: unknown, isStatic?: boolean, source?: object, self?: unknown): Component.Node;\n jsxs(type: unknown, props: object, key?: unknown): Component.Node;\n propsOf(node: unknown): Record<string, unknown>;\n typeOf(node: unknown): unknown;\n Fragment: unknown;\n}\n\n/**\n * Agnostic Fragment sentinel. The runtime entries translate it to the host's\n * Fragment on element creation; `typeOf` translates back, so identity checks\n * against this value hold for fragments from either pragma.\n */\nexport const Fragment = Symbol.for('@expressive/mvc.Fragment');\n\n/** Default for seams only a registered host can provide. */\nfunction absent(): never {\n throw new Error(\n 'No JSX host is registered for @expressive/mvc. ' +\n \"Import a host adapter (e.g. '@expressive/react') before anything renders - \" +\n 'typically as the first import of your application entry module.'\n );\n}\n\nconst HOST: HostRuntime = {\n childrenOf: absent,\n isElement: absent,\n jsx: absent,\n jsxs: absent,\n propsOf: absent,\n typeOf: absent,\n Fragment\n};\n\nlet registered: HostRuntime | undefined;\n\n/**\n * Register the host runtime. Idempotent for the same runtime - re-registering\n * picks up members added since (e.g. an optional dev seam). Element mechanics\n * the host leaves unset keep defaults that throw a setup-pointing error;\n * `jsxDEV` is routed around at the call site instead.\n */\nexport function host(runtime: HostRuntime) {\n if (registered && registered !== runtime)\n throw new Error(\n 'A different JSX host is already registered for @expressive/mvc. ' +\n 'Only one host adapter may be active per build.'\n );\n\n registered = runtime;\n Object.assign(HOST, runtime);\n}\n\n/** Translate the agnostic Fragment sentinel to the host's Fragment. */\nfunction hostType(type: unknown): unknown {\n return type === Fragment ? HOST.Fragment : type;\n}\n\nexport function jsx(type: unknown, props: object, key?: unknown): Component.Node {\n return HOST.jsx(hostType(type), props, key);\n}\n\nexport function jsxs(type: unknown, props: object, key?: unknown): Component.Node {\n return HOST.jsxs(hostType(type), props, key);\n}\n\n/** Dev-transpiled element creation. Hosts without a `jsxDEV` of their own fall\n * back to the production entries (prod-only host under a dev build). */\nexport function jsxDEV(\n type: unknown,\n props: object,\n key?: unknown,\n isStatic?: boolean,\n source?: object,\n self?: unknown\n): Component.Node {\n return HOST.jsxDEV\n ? HOST.jsxDEV(hostType(type), props, key, isStatic, source, self)\n : isStatic\n ? jsxs(type, props, key)\n : jsx(type, props, key);\n}\n\n/** Flatten `children` to an array of nodes, per the host's semantics. */\nexport function childrenOf(children: unknown): Component.Node[] {\n return HOST.childrenOf(children);\n}\n\n/** Is `node` a host element? */\nexport function isElement(node: unknown): boolean {\n return HOST.isElement(node);\n}\n\n/** Element type of `node`; host Fragments surface as the agnostic `Fragment`. */\nexport function typeOf(node: unknown): unknown {\n const type = HOST.typeOf(node);\n return type === HOST.Fragment ? Fragment : type;\n}\n\n/** Props carried by element `node`. */\nexport function propsOf(node: unknown): Record<string, unknown> {\n return HOST.propsOf(node);\n}\n\nexport * as hot from './hot';\n"],"mappings":";;;;;;;;AAgDA,MAAa,WAAW,OAAO,IAAI,2BAA2B;;AAG9D,SAAS,SAAgB;AACvB,OAAM,IAAI,MACR,4LAGD;;AAGH,MAAM,OAAoB;CACxB,YAAY;CACZ,WAAW;CACX,KAAK;CACL,MAAM;CACN,SAAS;CACT,QAAQ;CACR;CACD;AAED,IAAI;;;;;;;AAQJ,SAAgB,KAAK,SAAsB;AACzC,KAAI,cAAc,eAAe,QAC/B,OAAM,IAAI,MACR,iHAED;AAEH,cAAa;AACb,QAAO,OAAO,MAAM,QAAQ;;;AAI9B,SAAS,SAAS,MAAwB;AACxC,QAAO,SAAS,WAAW,KAAK,WAAW;;AAG7C,SAAgB,IAAI,MAAe,OAAe,KAA+B;AAC/E,QAAO,KAAK,IAAI,SAAS,KAAK,EAAE,OAAO,IAAI;;AAG7C,SAAgB,KAAK,MAAe,OAAe,KAA+B;AAChF,QAAO,KAAK,KAAK,SAAS,KAAK,EAAE,OAAO,IAAI;;;;AAK9C,SAAgB,OACd,MACA,OACA,KACA,UACA,QACA,MACgB;AAChB,QAAO,KAAK,SACR,KAAK,OAAO,SAAS,KAAK,EAAE,OAAO,KAAK,UAAU,QAAQ,KAAK,GAC/D,WACE,KAAK,MAAM,OAAO,IAAI,GACtB,IAAI,MAAM,OAAO,IAAI;;;AAI7B,SAAgB,WAAW,UAAqC;AAC9D,QAAO,KAAK,WAAW,SAAS;;;AAIlC,SAAgB,UAAU,MAAwB;AAChD,QAAO,KAAK,UAAU,KAAK;;;AAI7B,SAAgB,OAAO,MAAwB;CAC7C,MAAM,OAAO,KAAK,OAAO,KAAK;AAC9B,QAAO,SAAS,KAAK,WAAW,WAAW;;;AAI7C,SAAgB,QAAQ,MAAwC;AAC9D,QAAO,KAAK,QAAQ,KAAK"}