@ai-matrx/content-ir-react 0.7.1 → 0.8.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/CHANGELOG.md +61 -0
- package/dist/component-resolution.types-BS1ySIg-.d.cts +104 -0
- package/dist/component-resolution.types-BS1ySIg-.d.ts +104 -0
- package/dist/component-resolution.types-fvR92hW7.d.cts +142 -0
- package/dist/component-resolution.types-fvR92hW7.d.ts +142 -0
- package/dist/db-component.cjs +226 -0
- package/dist/db-component.cjs.map +1 -0
- package/dist/db-component.d.cts +267 -0
- package/dist/db-component.d.ts +267 -0
- package/dist/db-component.js +194 -0
- package/dist/db-component.js.map +1 -0
- package/dist/host-types-CZ_Bkp4R.d.ts +131 -0
- package/dist/host-types-DvGv8s9L.d.cts +131 -0
- package/dist/host.cjs +74 -0
- package/dist/host.cjs.map +1 -0
- package/dist/host.d.cts +24 -0
- package/dist/host.d.ts +24 -0
- package/dist/host.js +52 -0
- package/dist/host.js.map +1 -0
- package/dist/index.cjs +356 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +280 -672
- package/dist/index.d.ts +280 -672
- package/dist/index.js +316 -31
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +361 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +195 -0
- package/dist/react.d.ts +195 -0
- package/dist/react.js +344 -0
- package/dist/react.js.map +1 -0
- package/dist/resolver.cjs +327 -0
- package/dist/resolver.cjs.map +1 -0
- package/dist/resolver.d.cts +133 -0
- package/dist/resolver.d.ts +133 -0
- package/dist/resolver.js +304 -0
- package/dist/resolver.js.map +1 -0
- package/dist/route-C1XNcubB.d.ts +433 -0
- package/dist/route-C55jsF4B.d.cts +433 -0
- package/dist/route.cjs +259 -0
- package/dist/route.cjs.map +1 -0
- package/dist/route.d.cts +4 -0
- package/dist/route.d.ts +4 -0
- package/dist/route.js +247 -0
- package/dist/route.js.map +1 -0
- package/package.json +75 -2
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
8
29
|
|
|
9
|
-
|
|
30
|
+
// index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
ComponentResolver: () => ComponentResolver,
|
|
34
|
+
ContentIrRenderProvider: () => ContentIrRenderProvider,
|
|
35
|
+
DB_KIND_COMPONENT_KEY: () => DB_KIND_COMPONENT_KEY,
|
|
36
|
+
DbKindComponentErrorBoundary: () => DbKindComponentErrorBoundary,
|
|
37
|
+
DelegatedOutput: () => DelegatedOutput,
|
|
38
|
+
GENERIC_STRUCTURED_COMPONENT_KEY: () => GENERIC_STRUCTURED_COMPONENT_KEY,
|
|
39
|
+
GenericStructuredView: () => GenericStructuredView,
|
|
40
|
+
IR_PROVISIONAL_KEY: () => IR_PROVISIONAL_KEY,
|
|
41
|
+
IR_ROUTE_KEY: () => IR_ROUTE_KEY,
|
|
42
|
+
KindInstanceRender: () => KindInstanceRender,
|
|
43
|
+
NodeOutcomeView: () => NodeOutcomeView,
|
|
44
|
+
ProvisionalKindBoundary: () => ProvisionalKindBoundary,
|
|
45
|
+
ProvisionalKindFrame: () => ProvisionalKindFrame,
|
|
46
|
+
RunResultView: () => RunResultView,
|
|
47
|
+
applyIrKindRoute: () => applyIrKindRoute,
|
|
48
|
+
consoleErrorReporter: () => consoleErrorReporter,
|
|
49
|
+
createDbKindComponentCache: () => createDbKindComponentCache,
|
|
50
|
+
createKindRouteBinding: () => createKindRouteBinding,
|
|
51
|
+
envelopeFromPartialKind: () => envelopeFromPartialKind,
|
|
52
|
+
isDbKindComponentBodyPending: () => isDbKindComponentBodyPending,
|
|
53
|
+
isPartialReadyKind: () => isPartialReadyKind,
|
|
54
|
+
isProvisionalBlock: () => isProvisionalBlock,
|
|
55
|
+
isRecordValue: () => isRecordValue,
|
|
56
|
+
kindIsRoutable: () => kindIsRoutable,
|
|
57
|
+
kindServerDataFromStoredValue: () => kindServerDataFromStoredValue,
|
|
58
|
+
markKindPartialUnsafe: () => markKindPartialUnsafe,
|
|
59
|
+
readIrRouteMarker: () => readIrRouteMarker,
|
|
60
|
+
resetPartialUnsafeKinds: () => resetPartialUnsafeKinds,
|
|
61
|
+
resetSourcelessDbRowReports: () => resetSourcelessDbRowReports,
|
|
62
|
+
resolveAnnouncedKindLoading: () => resolveAnnouncedKindLoading,
|
|
63
|
+
resolveProvisionalKindRender: () => resolveProvisionalKindRender,
|
|
64
|
+
routeEnvOf: () => routeEnvOf,
|
|
65
|
+
useContentIrHost: () => useContentIrHost,
|
|
66
|
+
useContentIrHostOrNull: () => useContentIrHostOrNull,
|
|
67
|
+
useContentIrKindVersion: () => useContentIrKindVersion,
|
|
68
|
+
useKindRouteEnv: () => useKindRouteEnv
|
|
69
|
+
});
|
|
70
|
+
module.exports = __toCommonJS(index_exports);
|
|
10
71
|
|
|
11
72
|
// host/error-report.ts
|
|
12
73
|
var consoleErrorReporter = (report) => {
|
|
@@ -22,15 +83,19 @@ function routeEnvOf(host) {
|
|
|
22
83
|
platform: host.platform
|
|
23
84
|
};
|
|
24
85
|
}
|
|
25
|
-
|
|
86
|
+
|
|
87
|
+
// host/ContentIrProvider.tsx
|
|
88
|
+
var import_react = require("react");
|
|
89
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
90
|
+
var ContentIrHostContext = (0, import_react.createContext)(null);
|
|
26
91
|
function ContentIrRenderProvider({
|
|
27
92
|
host,
|
|
28
93
|
children
|
|
29
94
|
}) {
|
|
30
|
-
return /* @__PURE__ */
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentIrHostContext.Provider, { value: host, children });
|
|
31
96
|
}
|
|
32
97
|
function useContentIrHostOrNull() {
|
|
33
|
-
return
|
|
98
|
+
return (0, import_react.useContext)(ContentIrHostContext);
|
|
34
99
|
}
|
|
35
100
|
function useContentIrHost() {
|
|
36
101
|
const host = useContentIrHostOrNull();
|
|
@@ -43,7 +108,7 @@ function useContentIrHost() {
|
|
|
43
108
|
}
|
|
44
109
|
function useKindRouteEnv() {
|
|
45
110
|
const host = useContentIrHost();
|
|
46
|
-
return
|
|
111
|
+
return (0, import_react.useMemo)(() => routeEnvOf(host), [host]);
|
|
47
112
|
}
|
|
48
113
|
|
|
49
114
|
// resolver/component-resolver.ts
|
|
@@ -341,13 +406,19 @@ var ComponentResolver = class {
|
|
|
341
406
|
return this.warmPromise;
|
|
342
407
|
}
|
|
343
408
|
};
|
|
409
|
+
|
|
410
|
+
// route/kind-route.ts
|
|
411
|
+
var import_content_ir = require("@ai-matrx/content-ir");
|
|
344
412
|
var IR_ROUTE_KEY = "__ir_route";
|
|
345
413
|
var GENERIC_STRUCTURED_COMPONENT_KEY = "generic_structured";
|
|
346
414
|
var DB_KIND_COMPONENT_KEY = "db_kind_component";
|
|
347
415
|
function isDbSourceResolution(resolution) {
|
|
348
416
|
return resolution !== null && resolution.resolvedBy === "db" && resolution.source === "db" && resolution.isActive;
|
|
349
417
|
}
|
|
350
|
-
var
|
|
418
|
+
var SOURCELESS_DB_ROW_SLOT = /* @__PURE__ */ Symbol.for(
|
|
419
|
+
"ai-matrx.content-ir-react.sourceless-db-row-reports"
|
|
420
|
+
);
|
|
421
|
+
var reportedSourcelessDbRows = globalThis[SOURCELESS_DB_ROW_SLOT] ??= /* @__PURE__ */ new Set();
|
|
351
422
|
function reportDbRowWithoutSource(kind, env) {
|
|
352
423
|
const message = `[content-ir] kind_component for "${kind}" declares source='db' + is_active but has NO component_source \u2014 data defect; falling through to bundled rendering.`;
|
|
353
424
|
if (!reportedSourcelessDbRows.has(kind)) {
|
|
@@ -413,7 +484,7 @@ function routeToGeneric(block, reason) {
|
|
|
413
484
|
}
|
|
414
485
|
function applyIrKindRoute(block, env, options) {
|
|
415
486
|
if (options?.ownedTypes?.includes(block.type)) return block;
|
|
416
|
-
const envelope =
|
|
487
|
+
const envelope = (0, import_content_ir.readEnvelope)(block.metadata);
|
|
417
488
|
if (!envelope) return block;
|
|
418
489
|
const kind = envelope.root.kind;
|
|
419
490
|
if (!kind) return block;
|
|
@@ -462,19 +533,22 @@ function applyIrKindRoute(block, env, options) {
|
|
|
462
533
|
}
|
|
463
534
|
function kindServerDataFromStoredValue(value, env) {
|
|
464
535
|
if (!isRecord(value)) return null;
|
|
465
|
-
const kind =
|
|
536
|
+
const kind = (0, import_content_ir.readObjectKind)(value);
|
|
466
537
|
if (!kind) return null;
|
|
467
538
|
const def = env.kinds.getDefinition(kind);
|
|
468
539
|
if (!def?.toLegacyServerData) return null;
|
|
469
|
-
return def.toLegacyServerData(
|
|
540
|
+
return def.toLegacyServerData((0, import_content_ir.envelopeFromCompleteValue)(value, kind)) ?? null;
|
|
470
541
|
}
|
|
542
|
+
|
|
543
|
+
// route/partial-kind-route.ts
|
|
544
|
+
var import_content_ir2 = require("@ai-matrx/content-ir");
|
|
471
545
|
var IR_PROVISIONAL_KEY = "__ir_provisional";
|
|
472
546
|
function isProvisionalBlock(metadata) {
|
|
473
547
|
return metadata?.[IR_PROVISIONAL_KEY] === true;
|
|
474
548
|
}
|
|
475
549
|
function envelopeFromPartialKind(event) {
|
|
476
550
|
return {
|
|
477
|
-
v:
|
|
551
|
+
v: import_content_ir2.IR_VERSION,
|
|
478
552
|
// The partial channel is only ever produced by the Python detector; the
|
|
479
553
|
// envelope's `engine` union has no third member and inventing one would
|
|
480
554
|
// break every existing reader.
|
|
@@ -483,7 +557,10 @@ function envelopeFromPartialKind(event) {
|
|
|
483
557
|
root: event.root
|
|
484
558
|
};
|
|
485
559
|
}
|
|
486
|
-
var
|
|
560
|
+
var PARTIAL_UNSAFE_SLOT = /* @__PURE__ */ Symbol.for(
|
|
561
|
+
"ai-matrx.content-ir-react.partial-unsafe-kinds"
|
|
562
|
+
);
|
|
563
|
+
var partialUnsafeKinds = globalThis[PARTIAL_UNSAFE_SLOT] ??= /* @__PURE__ */ new Set();
|
|
487
564
|
function markKindPartialUnsafe(kind) {
|
|
488
565
|
partialUnsafeKinds.add(kind);
|
|
489
566
|
}
|
|
@@ -496,23 +573,24 @@ function isPartialReadyKind(kind, env) {
|
|
|
496
573
|
}
|
|
497
574
|
function resolveAnnouncedKindLoading(block, options) {
|
|
498
575
|
if (options?.streamActive === false) return null;
|
|
499
|
-
const event =
|
|
500
|
-
if (!
|
|
576
|
+
const event = (0, import_content_ir2.readPartialKindEvent)(block.metadata);
|
|
577
|
+
if (!(0, import_content_ir2.isProvisionalKind)(event)) return null;
|
|
501
578
|
const kind = event.root.kind;
|
|
502
579
|
if (!kind) return null;
|
|
503
|
-
const verified =
|
|
580
|
+
const verified = (0, import_content_ir2.readEnvelope)(block.metadata);
|
|
504
581
|
if (verified && verified.root.status === "complete") return null;
|
|
505
582
|
return { kind, envelope: envelopeFromPartialKind(event) };
|
|
506
583
|
}
|
|
507
584
|
function resolveProvisionalKindRender(block, env, options) {
|
|
508
585
|
if (options?.streamActive === false) return null;
|
|
509
|
-
const event =
|
|
510
|
-
if (!
|
|
586
|
+
const event = (0, import_content_ir2.readPartialKindEvent)(block.metadata);
|
|
587
|
+
if (!(0, import_content_ir2.isProvisionalKind)(event)) return null;
|
|
511
588
|
const kind = event.root.kind;
|
|
512
589
|
if (!isPartialReadyKind(kind, env)) return null;
|
|
513
|
-
const verified =
|
|
590
|
+
const verified = (0, import_content_ir2.readEnvelope)(block.metadata);
|
|
514
591
|
if (verified && verified.root.status === "complete") return null;
|
|
515
|
-
const { [
|
|
592
|
+
const { [import_content_ir2.IR_PARTIAL_KEY]: _partial, ...rest } = block.metadata ?? {};
|
|
593
|
+
void _partial;
|
|
516
594
|
const envelope = envelopeFromPartialKind(event);
|
|
517
595
|
const provisionalBlock = {
|
|
518
596
|
...block,
|
|
@@ -521,7 +599,7 @@ function resolveProvisionalKindRender(block, env, options) {
|
|
|
521
599
|
serverData: void 0,
|
|
522
600
|
metadata: {
|
|
523
601
|
...rest,
|
|
524
|
-
[
|
|
602
|
+
[import_content_ir2.IR_ENVELOPE_KEY]: envelope,
|
|
525
603
|
[IR_PROVISIONAL_KEY]: true
|
|
526
604
|
}
|
|
527
605
|
};
|
|
@@ -532,6 +610,23 @@ function resolveProvisionalKindRender(block, env, options) {
|
|
|
532
610
|
}
|
|
533
611
|
return { block: routed, kind, seq: event.seq, envelope };
|
|
534
612
|
}
|
|
613
|
+
|
|
614
|
+
// route/route-binding.ts
|
|
615
|
+
function createKindRouteBinding(env, options) {
|
|
616
|
+
const ownedTypes = options?.ownedTypes;
|
|
617
|
+
return {
|
|
618
|
+
applyIrKindRoute: (block) => applyIrKindRoute(block, env, ownedTypes ? { ownedTypes } : void 0),
|
|
619
|
+
kindServerDataFromStoredValue: (value) => kindServerDataFromStoredValue(value, env),
|
|
620
|
+
isPartialReadyKind: (kind) => isPartialReadyKind(kind, env),
|
|
621
|
+
resolveProvisionalKindRender: (block, streamOptions) => resolveProvisionalKindRender(block, env, {
|
|
622
|
+
...streamOptions,
|
|
623
|
+
...ownedTypes ? { ownedTypes } : null
|
|
624
|
+
})
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// react/use-kind-version.ts
|
|
629
|
+
var import_react2 = require("react");
|
|
535
630
|
var noopSubscribe = () => () => {
|
|
536
631
|
};
|
|
537
632
|
var zero = () => 0;
|
|
@@ -543,7 +638,7 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
543
638
|
"[content-ir-react] useContentIrKindVersion needs either a ContentIrRenderProvider above it or explicit `sources`."
|
|
544
639
|
);
|
|
545
640
|
}
|
|
546
|
-
const subscribe =
|
|
641
|
+
const subscribe = (0, import_react2.useCallback)(
|
|
547
642
|
(onStoreChange) => {
|
|
548
643
|
if (!kind || !resolved) return noopSubscribe();
|
|
549
644
|
const unsubKinds = resolved.kinds.subscribeKind(kind, onStoreChange);
|
|
@@ -558,7 +653,7 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
558
653
|
},
|
|
559
654
|
[resolved, kind]
|
|
560
655
|
);
|
|
561
|
-
const getSnapshot =
|
|
656
|
+
const getSnapshot = (0, import_react2.useCallback)(
|
|
562
657
|
() => kind && resolved ? (
|
|
563
658
|
// Both counters are monotonic, so the sum is monotonic — a change in
|
|
564
659
|
// either registry produces a new snapshot value for this kind.
|
|
@@ -566,8 +661,13 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
566
661
|
) : 0,
|
|
567
662
|
[resolved, kind]
|
|
568
663
|
);
|
|
569
|
-
return
|
|
664
|
+
return (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, zero);
|
|
570
665
|
}
|
|
666
|
+
|
|
667
|
+
// react/KindInstanceRender.tsx
|
|
668
|
+
var import_react3 = require("react");
|
|
669
|
+
var import_content_ir3 = require("@ai-matrx/content-ir");
|
|
670
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
571
671
|
function isRecordValue(value) {
|
|
572
672
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
573
673
|
}
|
|
@@ -586,10 +686,10 @@ function KindInstanceRender({
|
|
|
586
686
|
className
|
|
587
687
|
}) {
|
|
588
688
|
const host = useContentIrHost();
|
|
589
|
-
const [routingStatus, setRoutingStatus] =
|
|
689
|
+
const [routingStatus, setRoutingStatus] = (0, import_react3.useState)(
|
|
590
690
|
() => kindIsRoutable(kind, host) ? "routable" : "checking"
|
|
591
691
|
);
|
|
592
|
-
|
|
692
|
+
(0, import_react3.useEffect)(() => {
|
|
593
693
|
let cancelled = false;
|
|
594
694
|
let warmed = false;
|
|
595
695
|
const syncRoutingStatus = () => {
|
|
@@ -621,21 +721,25 @@ function KindInstanceRender({
|
|
|
621
721
|
content: JSON.stringify(value, null, 2),
|
|
622
722
|
language: "json",
|
|
623
723
|
metadata: {
|
|
624
|
-
[
|
|
724
|
+
[import_content_ir3.IR_ENVELOPE_KEY]: (0, import_content_ir3.envelopeFromCompleteValue)(value, kind)
|
|
625
725
|
}
|
|
626
726
|
} : null;
|
|
627
727
|
const frameClass = variant === "bare" ? void 0 : "rounded-md border border-border bg-card p-3";
|
|
628
728
|
if (routingStatus === "unroutable" && unroutableFallback !== void 0) {
|
|
629
|
-
return /* @__PURE__ */
|
|
729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: unroutableFallback });
|
|
630
730
|
}
|
|
631
731
|
const onTheFloor = block === null || routingStatus === "unroutable";
|
|
632
732
|
const notice = "This shape has no custom component yet, so it renders through the universal viewer \u2014 exactly what production shows today.";
|
|
633
|
-
return /* @__PURE__ */
|
|
634
|
-
showRoutingNote && routingStatus === "unroutable" ? host.renderNotice?.(notice) ?? /* @__PURE__ */
|
|
635
|
-
/* @__PURE__ */
|
|
733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: className ? `space-y-3 ${className}` : "space-y-3", children: [
|
|
734
|
+
showRoutingNote && routingStatus === "unroutable" ? host.renderNotice?.(notice) ?? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-amber-800 dark:text-amber-200", children: notice }) : null,
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: frameClass, children: onTheFloor ? host.renderValue({ value, kind }) : host.renderBlock(block) })
|
|
636
736
|
] });
|
|
637
737
|
}
|
|
638
|
-
|
|
738
|
+
|
|
739
|
+
// react/ProvisionalKindBoundary.tsx
|
|
740
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
741
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
742
|
+
var ProvisionalKindBoundaryInner = class extends import_react4.default.Component {
|
|
639
743
|
state = { failed: false };
|
|
640
744
|
static getDerivedStateFromError() {
|
|
641
745
|
return { failed: true };
|
|
@@ -659,20 +763,25 @@ var ProvisionalKindBoundaryInner = class extends React__default.default.Componen
|
|
|
659
763
|
};
|
|
660
764
|
function ProvisionalKindBoundary(props) {
|
|
661
765
|
const host = useContentIrHost();
|
|
662
|
-
return /* @__PURE__ */
|
|
766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProvisionalKindBoundaryInner, { ...props, reportError: host.reportError });
|
|
663
767
|
}
|
|
664
768
|
function ProvisionalKindFrame({ children }) {
|
|
665
769
|
const host = useContentIrHost();
|
|
666
770
|
const label = "Still arriving";
|
|
667
|
-
return /* @__PURE__ */
|
|
771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative", "aria-busy": "true", children: [
|
|
668
772
|
children,
|
|
669
|
-
/* @__PURE__ */
|
|
773
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "pointer-events-none absolute -top-2 right-4 z-10 select-none rounded-full bg-background px-1.5 leading-4", children: host.renderShimmer?.(label) ?? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-[10px] text-muted-foreground", children: label }) })
|
|
670
774
|
] });
|
|
671
775
|
}
|
|
776
|
+
|
|
777
|
+
// react/GenericStructuredView.tsx
|
|
778
|
+
var import_react5 = require("react");
|
|
779
|
+
var import_content_ir4 = require("@ai-matrx/content-ir");
|
|
780
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
672
781
|
function readStructuredValue(content, metadata) {
|
|
673
|
-
const envelope =
|
|
782
|
+
const envelope = (0, import_content_ir4.readEnvelope)(metadata);
|
|
674
783
|
if (envelope) {
|
|
675
|
-
return { value:
|
|
784
|
+
return { value: (0, import_content_ir4.reconstructRegionValue)(envelope), recovered: true };
|
|
676
785
|
}
|
|
677
786
|
try {
|
|
678
787
|
return { value: JSON.parse(content), recovered: true };
|
|
@@ -687,21 +796,25 @@ function GenericStructuredView({
|
|
|
687
796
|
className
|
|
688
797
|
}) {
|
|
689
798
|
const host = useContentIrHost();
|
|
690
|
-
const envelope =
|
|
799
|
+
const envelope = (0, import_content_ir4.readEnvelope)(metadata);
|
|
691
800
|
const status = envelope?.root.status ?? "complete";
|
|
692
801
|
const { value, recovered } = readStructuredValue(content, metadata);
|
|
693
|
-
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ?
|
|
802
|
+
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0, import_content_ir4.readObjectKind)(value) : null) ?? "";
|
|
694
803
|
const marker = readIrRouteMarker(metadata);
|
|
695
804
|
const note = marker?.reason === "inactive" ? "a custom view is registered but held inactive" : marker?.reason === "broken-instance" ? "this instance did not match the shape's schema" : marker?.reason === "unregistered" ? "this shape isn't registered on this platform" : "no custom view yet";
|
|
696
|
-
return /* @__PURE__ */
|
|
697
|
-
status === "streaming" ? streamingIndicator ?? /* @__PURE__ */
|
|
805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: className ? `my-2 min-w-0 ${className}` : "my-2 min-w-0", children: [
|
|
806
|
+
status === "streaming" ? streamingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mb-2 text-xs text-muted-foreground", children: "Still arriving\u2026" }) : null,
|
|
698
807
|
recovered ? host.renderValue({ value, ...kind ? { kind } : {}, note }) : (
|
|
699
808
|
// Zero-data-loss backstop: the region never parsed, so show the source
|
|
700
809
|
// verbatim rather than swallowing it.
|
|
701
|
-
/* @__PURE__ */
|
|
810
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", { className: "max-h-96 overflow-auto font-mono text-xs leading-relaxed text-muted-foreground", children: content })
|
|
702
811
|
)
|
|
703
812
|
] });
|
|
704
813
|
}
|
|
814
|
+
|
|
815
|
+
// react/RuntimeWrapperViews.tsx
|
|
816
|
+
var import_content_ir5 = require("@ai-matrx/content-ir");
|
|
817
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
705
818
|
function isRecord2(value) {
|
|
706
819
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
707
820
|
}
|
|
@@ -717,16 +830,16 @@ function DelegatedOutput({
|
|
|
717
830
|
}) {
|
|
718
831
|
const host = useContentIrHost();
|
|
719
832
|
if (output === null || output === void 0) {
|
|
720
|
-
return /* @__PURE__ */
|
|
833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyLabel });
|
|
721
834
|
}
|
|
722
835
|
if (!isRecord2(output)) {
|
|
723
|
-
return /* @__PURE__ */
|
|
836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: host.renderValue({ value: output }) });
|
|
724
837
|
}
|
|
725
|
-
const kind =
|
|
838
|
+
const kind = (0, import_content_ir5.readObjectKind)(output) ?? declaredKind;
|
|
726
839
|
if (!kind) {
|
|
727
|
-
return /* @__PURE__ */
|
|
840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: fallback?.(output) ?? host.renderValue({ value: output }) });
|
|
728
841
|
}
|
|
729
|
-
return /* @__PURE__ */
|
|
842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
730
843
|
KindInstanceRender,
|
|
731
844
|
{
|
|
732
845
|
kind,
|
|
@@ -740,10 +853,10 @@ function DelegatedOutput({
|
|
|
740
853
|
function NodeOutcomeView({ serverData, fallback }) {
|
|
741
854
|
const wrapper = readWrapperFrom(
|
|
742
855
|
serverData,
|
|
743
|
-
|
|
856
|
+
import_content_ir5.readNodeOutcomeValue
|
|
744
857
|
);
|
|
745
858
|
if (!wrapper) return null;
|
|
746
|
-
return /* @__PURE__ */
|
|
859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
747
860
|
DelegatedOutput,
|
|
748
861
|
{
|
|
749
862
|
output: wrapper.output,
|
|
@@ -755,17 +868,17 @@ function NodeOutcomeView({ serverData, fallback }) {
|
|
|
755
868
|
function RunResultView({ serverData, fallback }) {
|
|
756
869
|
const wrapper = readWrapperFrom(
|
|
757
870
|
serverData,
|
|
758
|
-
|
|
871
|
+
import_content_ir5.readRunResultValue
|
|
759
872
|
);
|
|
760
873
|
if (!wrapper) return null;
|
|
761
|
-
return /* @__PURE__ */
|
|
874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "space-y-2", children: wrapper.outputs.length > 0 ? wrapper.outputs.map((outcome) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
762
875
|
NodeOutcomeView,
|
|
763
876
|
{
|
|
764
877
|
serverData: { wrapper: outcome },
|
|
765
878
|
...fallback === void 0 ? {} : { fallback }
|
|
766
879
|
},
|
|
767
880
|
`${outcome.node_id}:${outcome.attempt}`
|
|
768
|
-
)) : /* @__PURE__ */
|
|
881
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
769
882
|
DelegatedOutput,
|
|
770
883
|
{
|
|
771
884
|
output: wrapper.output,
|
|
@@ -775,37 +888,190 @@ function RunResultView({ serverData, fallback }) {
|
|
|
775
888
|
) });
|
|
776
889
|
}
|
|
777
890
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
891
|
+
// db-component/db-kind-component-cache.ts
|
|
892
|
+
function isDbKindComponentBodyPending(resolution) {
|
|
893
|
+
return resolution.hasComponentSource && resolution.componentSource === null;
|
|
894
|
+
}
|
|
895
|
+
function isPlainObject(value) {
|
|
896
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
897
|
+
}
|
|
898
|
+
function createDbKindComponentCache(ports) {
|
|
899
|
+
const cache = /* @__PURE__ */ new Map();
|
|
900
|
+
const screamedKeys = /* @__PURE__ */ new Set();
|
|
901
|
+
const defaultPlatform = ports.platform ?? "web";
|
|
902
|
+
function cacheKey(kind, platform, role, updatedAt) {
|
|
903
|
+
return `${kind}${platform}${role}${updatedAt ?? ""}`;
|
|
904
|
+
}
|
|
905
|
+
function screamCompileFailure(key, kind, error, resolution, platform, role) {
|
|
906
|
+
const message = `[content-ir] DB kind component for "${kind}" failed to compile \u2014 rendering the generic structured viewer instead: ${error}`;
|
|
907
|
+
if (!screamedKeys.has(key)) {
|
|
908
|
+
screamedKeys.add(key);
|
|
909
|
+
console.error(message);
|
|
910
|
+
}
|
|
911
|
+
ports.reportError({ source: "content-ir", message, raw: { kind, error } });
|
|
912
|
+
ports.reportIncident?.({
|
|
913
|
+
kind,
|
|
914
|
+
errorType: "compile_error",
|
|
915
|
+
message,
|
|
916
|
+
platform,
|
|
917
|
+
role,
|
|
918
|
+
componentKey: resolution.componentKey,
|
|
919
|
+
componentUpdatedAt: resolution.updatedAt
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
function config(value, kind) {
|
|
923
|
+
if (isPlainObject(value)) return value;
|
|
924
|
+
if (value === null || value === void 0) return {};
|
|
925
|
+
const message = `[content-ir] kind_component.config for "${kind}" is not a JSON object (${typeof value}) \u2014 rendering with an empty config.`;
|
|
926
|
+
console.error(message);
|
|
927
|
+
ports.reportError({ source: "content-ir", message, raw: { kind } });
|
|
928
|
+
return {};
|
|
929
|
+
}
|
|
930
|
+
function resolveAllowedImports(rowConfig) {
|
|
931
|
+
const declared = rowConfig.allowed_imports;
|
|
932
|
+
if (Array.isArray(declared) && declared.every((entry) => typeof entry === "string")) {
|
|
933
|
+
return declared;
|
|
934
|
+
}
|
|
935
|
+
return ports.defaultAllowedImports();
|
|
936
|
+
}
|
|
937
|
+
function getOrCompile(kind, resolution, platform = defaultPlatform, role = "output") {
|
|
938
|
+
const key = cacheKey(kind, platform, role, resolution.updatedAt);
|
|
939
|
+
const cached = cache.get(key);
|
|
940
|
+
if (cached) return cached;
|
|
941
|
+
const source = resolution.componentSource;
|
|
942
|
+
if (!source || !source.trim()) {
|
|
943
|
+
const result2 = {
|
|
944
|
+
ok: false,
|
|
945
|
+
error: "db-source resolution has no component_source"
|
|
946
|
+
};
|
|
947
|
+
screamCompileFailure(key, kind, result2.error, resolution, platform, role);
|
|
948
|
+
cache.set(key, result2);
|
|
949
|
+
return result2;
|
|
950
|
+
}
|
|
951
|
+
const allowedImports = resolveAllowedImports(
|
|
952
|
+
config(resolution.config, kind)
|
|
953
|
+
);
|
|
954
|
+
const { Component: Component2, error } = ports.compile({ code: source, allowedImports });
|
|
955
|
+
if (!Component2 || error) {
|
|
956
|
+
const result2 = {
|
|
957
|
+
ok: false,
|
|
958
|
+
error: error ?? "compile produced no component"
|
|
959
|
+
};
|
|
960
|
+
screamCompileFailure(key, kind, result2.error, resolution, platform, role);
|
|
961
|
+
cache.set(key, result2);
|
|
962
|
+
return result2;
|
|
963
|
+
}
|
|
964
|
+
let transform = null;
|
|
965
|
+
if (resolution.propsTransform && resolution.propsTransform.trim()) {
|
|
966
|
+
const { Component: transformFn, error: transformError } = ports.compile({
|
|
967
|
+
code: resolution.propsTransform,
|
|
968
|
+
allowedImports: []
|
|
969
|
+
});
|
|
970
|
+
if (typeof transformFn === "function" && !transformError) {
|
|
971
|
+
transform = transformFn;
|
|
972
|
+
} else {
|
|
973
|
+
const message = `[content-ir] props_transform for kind "${kind}" failed to compile \u2014 value passes through untransformed: ${transformError ?? "no function produced"}`;
|
|
974
|
+
console.error(message);
|
|
975
|
+
ports.reportError({
|
|
976
|
+
source: "content-ir",
|
|
977
|
+
message,
|
|
978
|
+
raw: { kind, error: transformError }
|
|
979
|
+
});
|
|
980
|
+
ports.reportIncident?.({
|
|
981
|
+
kind,
|
|
982
|
+
errorType: "transform_error",
|
|
983
|
+
message,
|
|
984
|
+
platform,
|
|
985
|
+
role,
|
|
986
|
+
componentKey: resolution.componentKey,
|
|
987
|
+
componentUpdatedAt: resolution.updatedAt
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
const result = {
|
|
992
|
+
ok: true,
|
|
993
|
+
compiled: {
|
|
994
|
+
// The injected compiler types components as
|
|
995
|
+
// ComponentType<Record<string, unknown>>; the callsite always passes
|
|
996
|
+
// DbKindComponentRenderProps — the single deliberate narrowing where
|
|
997
|
+
// the generic compiler meets the kind contract.
|
|
998
|
+
Component: Component2,
|
|
999
|
+
transform
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
cache.set(key, result);
|
|
1003
|
+
return result;
|
|
1004
|
+
}
|
|
1005
|
+
function applyPropsTransform(kind, compiled, value) {
|
|
1006
|
+
if (!compiled.transform) return value;
|
|
1007
|
+
try {
|
|
1008
|
+
return compiled.transform(value);
|
|
1009
|
+
} catch (error) {
|
|
1010
|
+
const message = `[content-ir] props_transform for kind "${kind}" threw \u2014 using the untransformed value: ${error instanceof Error ? error.message : String(error)}`;
|
|
1011
|
+
console.error(message);
|
|
1012
|
+
ports.reportError({ source: "content-ir", message, raw: { kind } });
|
|
1013
|
+
ports.reportIncident?.({
|
|
1014
|
+
kind,
|
|
1015
|
+
errorType: "transform_error",
|
|
1016
|
+
message,
|
|
1017
|
+
stack: error instanceof Error ? error.stack ?? null : null,
|
|
1018
|
+
data: value
|
|
1019
|
+
});
|
|
1020
|
+
return value;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
function invalidate(kind, platform = defaultPlatform, role = "output") {
|
|
1024
|
+
const prefix = `${kind}${platform}${role}`;
|
|
1025
|
+
for (const key of [...cache.keys()]) {
|
|
1026
|
+
if (key.startsWith(prefix)) cache.delete(key);
|
|
1027
|
+
}
|
|
1028
|
+
for (const key of [...screamedKeys]) {
|
|
1029
|
+
if (key.startsWith(prefix)) screamedKeys.delete(key);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
function invalidateAll() {
|
|
1033
|
+
cache.clear();
|
|
1034
|
+
screamedKeys.clear();
|
|
1035
|
+
}
|
|
1036
|
+
const api = {
|
|
1037
|
+
getOrCompile,
|
|
1038
|
+
applyPropsTransform,
|
|
1039
|
+
config,
|
|
1040
|
+
invalidate,
|
|
1041
|
+
invalidateAll
|
|
1042
|
+
};
|
|
1043
|
+
ports.registerInvalidation?.(() => invalidateAll());
|
|
1044
|
+
return api;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
// db-component/DbKindComponentErrorBoundary.tsx
|
|
1048
|
+
var React2 = __toESM(require("react"), 1);
|
|
1049
|
+
var DbKindComponentErrorBoundary = class extends React2.Component {
|
|
1050
|
+
constructor(props) {
|
|
1051
|
+
super(props);
|
|
1052
|
+
this.state = { hasError: false, signalAtLastRender: props.resetSignal };
|
|
1053
|
+
}
|
|
1054
|
+
static getDerivedStateFromError() {
|
|
1055
|
+
return { hasError: true };
|
|
1056
|
+
}
|
|
1057
|
+
static getDerivedStateFromProps(props, state) {
|
|
1058
|
+
if (props.resetSignal === state.signalAtLastRender) return null;
|
|
1059
|
+
return { hasError: false, signalAtLastRender: props.resetSignal };
|
|
1060
|
+
}
|
|
1061
|
+
componentDidCatch(error, errorInfo) {
|
|
1062
|
+
const info = { componentStack: errorInfo.componentStack ?? null };
|
|
1063
|
+
if (this.props.onCaught) {
|
|
1064
|
+
this.props.onCaught(error, info);
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
console.error(
|
|
1068
|
+
`[content-ir] DB kind component for "${this.props.kind}" threw during render \u2014 showing the fallback:`,
|
|
1069
|
+
error
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
render() {
|
|
1073
|
+
if (this.state.hasError) return this.props.fallback;
|
|
1074
|
+
return this.props.children;
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
811
1077
|
//# sourceMappingURL=index.cjs.map
|