@40rty/ams-sdk 0.3.0 → 0.3.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/index.js +285 -11
- package/dist/types/sdk/src/host/host-modules.d.ts +7 -0
- package/dist/types/sdk/src/index.d.ts +1 -0
- package/dist/types/sdk/src/preview/SpacefrontPreviewProvider.d.ts +65 -0
- package/dist/types/sdk/src/preview/index.d.ts +1 -0
- package/dist/types/spacestation/src/catalog/shape-tokens.d.ts +2 -0
- package/dist/types/spacestation/src/catalog/wire/index.d.ts +1 -1
- package/dist/types/spacestation/src/catalog/wire/package-release.d.ts +16 -0
- package/dist/types/spacestation/src/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -218,6 +218,7 @@ __export(src_exports3, {
|
|
|
218
218
|
SiblingProductSchema: () => SiblingProductSchema,
|
|
219
219
|
SpaceBugSchema: () => SpaceBugSchema,
|
|
220
220
|
SpacefrontCanvas: () => SpacefrontCanvas,
|
|
221
|
+
SpacefrontPreviewProvider: () => SpacefrontPreviewProvider,
|
|
221
222
|
SpecSchema: () => SpecSchema,
|
|
222
223
|
StateSnapshotFrameSchema: () => StateSnapshotFrameSchema,
|
|
223
224
|
SuggestionActionSchema: () => SuggestionActionSchema,
|
|
@@ -274,6 +275,7 @@ __export(src_exports3, {
|
|
|
274
275
|
buildPdpCompanionsConfig: () => buildPdpCompanionsConfig,
|
|
275
276
|
buildWipeVariants: () => buildWipeVariants,
|
|
276
277
|
canonicalOptionValue: () => canonicalOptionValue,
|
|
278
|
+
carriesShapeToken: () => carriesShapeToken,
|
|
277
279
|
cartLineMatchesSelections: () => cartLineMatchesSelections,
|
|
278
280
|
cartLinesForProduct: () => cartLinesForProduct,
|
|
279
281
|
catalogComponent: () => catalogComponent,
|
|
@@ -384,6 +386,7 @@ __export(src_exports3, {
|
|
|
384
386
|
orderedVideoSources: () => orderedVideoSources,
|
|
385
387
|
packRows: () => packRows,
|
|
386
388
|
parseBcp47Locale: () => parseBcp47Locale,
|
|
389
|
+
parseReleasePreview: () => parseReleasePreview,
|
|
387
390
|
pickCartAddAction: () => pickCartAddAction,
|
|
388
391
|
pickCollectionAction: () => pickCollectionAction,
|
|
389
392
|
pickProductCardAction: () => pickProductCardAction,
|
|
@@ -432,6 +435,7 @@ __export(src_exports3, {
|
|
|
432
435
|
registeredPresenceFactForms: () => registeredPresenceFactForms,
|
|
433
436
|
registeredPresenceForms: () => registeredPresenceForms,
|
|
434
437
|
registeredPresenceSourceForms: () => registeredPresenceSourceForms,
|
|
438
|
+
releasePreviewSourceId: () => releasePreviewSourceId,
|
|
435
439
|
renderInline: () => renderInline,
|
|
436
440
|
rendersNothing: () => rendersNothing,
|
|
437
441
|
reportedAxisValues: () => reportedAxisValues,
|
|
@@ -1515,6 +1519,7 @@ __export(src_exports, {
|
|
|
1515
1519
|
arrivalToParams: () => arrivalToParams,
|
|
1516
1520
|
bareComponentType: () => bareComponentType,
|
|
1517
1521
|
canonicalOptionValue: () => canonicalOptionValue,
|
|
1522
|
+
carriesShapeToken: () => carriesShapeToken,
|
|
1518
1523
|
catalogFromWire: () => catalogFromWire,
|
|
1519
1524
|
catalogToWire: () => catalogToWire,
|
|
1520
1525
|
collectElementEntityRefs: () => collectElementEntityRefs,
|
|
@@ -1547,6 +1552,7 @@ __export(src_exports, {
|
|
|
1547
1552
|
normalizeAttributeField: () => normalizeAttributeField,
|
|
1548
1553
|
normalizeRefs: () => normalizeRefs,
|
|
1549
1554
|
packRows: () => packRows,
|
|
1555
|
+
parseReleasePreview: () => parseReleasePreview,
|
|
1550
1556
|
placeBlocks: () => placeBlocks,
|
|
1551
1557
|
placedEntityRefsOf: () => placedEntityRefsOf,
|
|
1552
1558
|
projectCollection: () => projectCollection,
|
|
@@ -1556,6 +1562,7 @@ __export(src_exports, {
|
|
|
1556
1562
|
reducePatch: () => reducePatch,
|
|
1557
1563
|
registerPageKindSchema: () => registerPageKindSchema,
|
|
1558
1564
|
registeredPageKinds: () => registeredPageKinds,
|
|
1565
|
+
releasePreviewSourceId: () => releasePreviewSourceId,
|
|
1559
1566
|
rendersNothing: () => rendersNothing,
|
|
1560
1567
|
reportedAxisValues: () => reportedAxisValues,
|
|
1561
1568
|
requiredTopLevelProps: () => requiredTopLevelProps,
|
|
@@ -2723,6 +2730,15 @@ function rendersNothing(spec, catalog, aliases) {
|
|
|
2723
2730
|
return true;
|
|
2724
2731
|
}
|
|
2725
2732
|
|
|
2733
|
+
// ../spacestation/src/catalog/shape-tokens.ts
|
|
2734
|
+
var SHAPE_TOKEN = /<(?![/!])[^<>=]*\s[^<>=]*(?<!\/)>/;
|
|
2735
|
+
function carriesShapeToken(value) {
|
|
2736
|
+
if (typeof value === "string") return SHAPE_TOKEN.test(value);
|
|
2737
|
+
if (Array.isArray(value)) return value.some(carriesShapeToken);
|
|
2738
|
+
if (typeof value === "object" && value !== null) return Object.values(value).some(carriesShapeToken);
|
|
2739
|
+
return false;
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2726
2742
|
// ../spacestation/src/layout/apply-patch.ts
|
|
2727
2743
|
function arrayAdd(arr, key, value) {
|
|
2728
2744
|
if (key === "-") {
|
|
@@ -3234,6 +3250,8 @@ var PackageReleaseSchema = z24.object({
|
|
|
3234
3250
|
label: z24.string().min(1).max(120),
|
|
3235
3251
|
/** The package's own version, as its repository states it — shown in the console. */
|
|
3236
3252
|
version: z24.string().min(1).max(40),
|
|
3253
|
+
/** What this release changed, in the publisher's words (`forty publish --message`) — shown in the console's version list. */
|
|
3254
|
+
description: z24.string().min(1).max(500).optional(),
|
|
3237
3255
|
catalog: WireCatalogSchema,
|
|
3238
3256
|
/** Component manifests by path under `catalogs/`, e.g. `catalogs/product/productGrid.md`. */
|
|
3239
3257
|
manifests: z24.record(z24.string().regex(/^catalogs\/.+\.md$/, "a manifest path is catalogs/<\u2026>.md"), z24.string()),
|
|
@@ -3275,6 +3293,14 @@ function draftSourceId(sourceId, spaceSlug, developer) {
|
|
|
3275
3293
|
function isDraftSource(sourceId) {
|
|
3276
3294
|
return sourceId.includes(DRAFT_SEPARATOR);
|
|
3277
3295
|
}
|
|
3296
|
+
function releasePreviewSourceId(sourceId, release) {
|
|
3297
|
+
return `${sourceId}${DRAFT_SEPARATOR}release${release}`;
|
|
3298
|
+
}
|
|
3299
|
+
function parseReleasePreview(id) {
|
|
3300
|
+
const match = /^(.+)--release([1-9][0-9]*)$/.exec(id);
|
|
3301
|
+
if (match === null || isDraftSource(match[1])) return void 0;
|
|
3302
|
+
return { sourceId: match[1], release: Number(match[2]) };
|
|
3303
|
+
}
|
|
3278
3304
|
|
|
3279
3305
|
// ../spacestation/src/projection/projection.ts
|
|
3280
3306
|
import { z as z25 } from "zod";
|
|
@@ -9300,8 +9326,8 @@ function collectLayoutGids(layout, catalog) {
|
|
|
9300
9326
|
}
|
|
9301
9327
|
function collectEntitySurfaceKinds(layout, catalog) {
|
|
9302
9328
|
const focus2 = /* @__PURE__ */ new Set();
|
|
9303
|
-
const
|
|
9304
|
-
if (!layout || !layout.elements) return { focus: focus2, list };
|
|
9329
|
+
const list2 = /* @__PURE__ */ new Set();
|
|
9330
|
+
if (!layout || !layout.elements) return { focus: focus2, list: list2 };
|
|
9305
9331
|
for (const el of Object.values(layout.elements)) {
|
|
9306
9332
|
if (!el || typeof el !== "object") continue;
|
|
9307
9333
|
const t = el.type;
|
|
@@ -9311,10 +9337,10 @@ function collectEntitySurfaceKinds(layout, catalog) {
|
|
|
9311
9337
|
if (!entry || !entry.propsSchema) continue;
|
|
9312
9338
|
for (const { meta } of resolvedTopLevelProps(entry.propsSchema)) {
|
|
9313
9339
|
if (meta.max === 1) focus2.add(meta.resolverKey);
|
|
9314
|
-
else
|
|
9340
|
+
else list2.add(meta.resolverKey);
|
|
9315
9341
|
}
|
|
9316
9342
|
}
|
|
9317
|
-
return { focus: focus2, list };
|
|
9343
|
+
return { focus: focus2, list: list2 };
|
|
9318
9344
|
}
|
|
9319
9345
|
function readNavigateDestination(chip) {
|
|
9320
9346
|
if (chip.type !== "navigate") return null;
|
|
@@ -11198,11 +11224,255 @@ function primedEntitiesFor(resolverKey) {
|
|
|
11198
11224
|
return byKey === void 0 ? {} : byKey;
|
|
11199
11225
|
}
|
|
11200
11226
|
|
|
11227
|
+
// src/preview/SpacefrontPreviewProvider.tsx
|
|
11228
|
+
import * as React31 from "react";
|
|
11229
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
11230
|
+
var NOOP = () => {
|
|
11231
|
+
};
|
|
11232
|
+
var ASYNC_NOOP = () => Promise.resolve();
|
|
11233
|
+
var VIEW = { page: { kind: "home" }, layout: EMPTY_SPEC, shell: EMPTY_SHELL };
|
|
11234
|
+
var PreviewContext = React31.createContext(null);
|
|
11235
|
+
function usePreview() {
|
|
11236
|
+
const value = React31.useContext(PreviewContext);
|
|
11237
|
+
if (value === null) throw new Error("preview runtime used outside <SpacefrontPreviewProvider>");
|
|
11238
|
+
return value;
|
|
11239
|
+
}
|
|
11240
|
+
function list(value) {
|
|
11241
|
+
return value === void 0 ? [] : value;
|
|
11242
|
+
}
|
|
11243
|
+
function orNull(value) {
|
|
11244
|
+
return value === void 0 ? null : value;
|
|
11245
|
+
}
|
|
11246
|
+
function derive(scene, sessionId) {
|
|
11247
|
+
const turns = list(scene.turns);
|
|
11248
|
+
const error = orNull(scene.error);
|
|
11249
|
+
const messages = turns.map((t, index) => ({
|
|
11250
|
+
index,
|
|
11251
|
+
messageId: `turn-${index}`,
|
|
11252
|
+
visitorText: t.ask,
|
|
11253
|
+
view: VIEW,
|
|
11254
|
+
streams: { prose: t.answer, actions: [], signals: [] },
|
|
11255
|
+
committedAt: "1970-01-01T00:00:00.000Z"
|
|
11256
|
+
}));
|
|
11257
|
+
const p = orNull(scene.pending);
|
|
11258
|
+
const pending2 = p === null ? null : {
|
|
11259
|
+
index: turns.length,
|
|
11260
|
+
messageId: `turn-${turns.length}`,
|
|
11261
|
+
visitorText: p.ask,
|
|
11262
|
+
status: "streaming",
|
|
11263
|
+
streams: { prose: p.answer === void 0 ? "" : p.answer, actions: [], signals: [] },
|
|
11264
|
+
reasoning: []
|
|
11265
|
+
};
|
|
11266
|
+
const chat = turns.flatMap((t, i) => [
|
|
11267
|
+
{ role: "user", text: t.ask, id: `turn-${i}` },
|
|
11268
|
+
{ role: "assistant", text: t.answer, id: `turn-${i}` }
|
|
11269
|
+
]);
|
|
11270
|
+
if (p !== null) chat.push({ role: "user", text: p.ask, id: `turn-${turns.length}` });
|
|
11271
|
+
const labels = list(scene.suggestions);
|
|
11272
|
+
const suggestions = labels.length === 0 ? null : {
|
|
11273
|
+
type: "suggestion_cards",
|
|
11274
|
+
actions: labels.map((label, i) => ({ id: `chip-${i}`, label, type: "message", payload: { text: label } }))
|
|
11275
|
+
};
|
|
11276
|
+
const turnId = `turn-${Math.max(0, turns.length - (p === null ? 1 : 0))}`;
|
|
11277
|
+
const elements = [];
|
|
11278
|
+
const scan = orNull(scene.scan);
|
|
11279
|
+
if (scan !== null) {
|
|
11280
|
+
elements.push({
|
|
11281
|
+
id: "scan",
|
|
11282
|
+
turnId,
|
|
11283
|
+
kind: "source",
|
|
11284
|
+
sourceKind: "product",
|
|
11285
|
+
found: true,
|
|
11286
|
+
total: scan.total,
|
|
11287
|
+
refs: scan.images.map((imageUrl, i) => ({ id: `scan-${i}`, imageUrl }))
|
|
11288
|
+
});
|
|
11289
|
+
}
|
|
11290
|
+
for (const f of list(scene.facts)) {
|
|
11291
|
+
elements.push({ id: `fact-${f.label}`, turnId, kind: "fact", label: f.label, value: f.value, tier: "session", provenance: "inferred" });
|
|
11292
|
+
}
|
|
11293
|
+
if (scene.voice !== void 0 && scene.voice !== "") elements.push({ id: "voice", turnId, kind: "voice", text: scene.voice, register: "lead" });
|
|
11294
|
+
const scanning = scan === null ? null : {
|
|
11295
|
+
thumbnails: scan.images.map((url, i) => ({ id: `scan-${i}`, url })),
|
|
11296
|
+
count: scan.total === void 0 ? scan.images.length : scan.total,
|
|
11297
|
+
...scan.query === void 0 ? {} : { queryHint: scan.query }
|
|
11298
|
+
};
|
|
11299
|
+
return { sessionId, isRunning: p !== null && error === null, error, turns, messages, pending: pending2, chat, suggestions, elements, scanning };
|
|
11300
|
+
}
|
|
11301
|
+
var RUNTIME = {
|
|
11302
|
+
useTurn: () => {
|
|
11303
|
+
const d = usePreview();
|
|
11304
|
+
const last = d.pending !== null ? d.pending.visitorText : d.turns.length > 0 ? d.turns[d.turns.length - 1].ask : "";
|
|
11305
|
+
return { index: d.messages.length, turnId: d.pending?.messageId, status: d.pending !== null ? "streaming" : "done", userMessage: last };
|
|
11306
|
+
},
|
|
11307
|
+
// A conditional return type cannot be implemented without a cast.
|
|
11308
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
11309
|
+
useStream: ((name) => {
|
|
11310
|
+
const d = usePreview();
|
|
11311
|
+
if (name !== "prose") return [];
|
|
11312
|
+
if (d.pending !== null) return d.pending.streams.prose;
|
|
11313
|
+
return d.turns.length > 0 ? d.turns[d.turns.length - 1].answer : "";
|
|
11314
|
+
}),
|
|
11315
|
+
useDisplayedLayout: () => EMPTY_SPEC,
|
|
11316
|
+
useFourtyShell: () => EMPTY_SHELL,
|
|
11317
|
+
useAgentDriven: () => false,
|
|
11318
|
+
useReasoning: () => [],
|
|
11319
|
+
useSessionState: () => {
|
|
11320
|
+
const d = usePreview();
|
|
11321
|
+
return {
|
|
11322
|
+
sessionId: d.sessionId,
|
|
11323
|
+
isRunning: d.isRunning,
|
|
11324
|
+
error: d.error,
|
|
11325
|
+
reconnecting: false,
|
|
11326
|
+
reconnectAttempt: 0,
|
|
11327
|
+
reconnectMaxAttempts: 0,
|
|
11328
|
+
responseText: "",
|
|
11329
|
+
reasoningText: "",
|
|
11330
|
+
facts: {},
|
|
11331
|
+
messages: d.chat,
|
|
11332
|
+
seedLayout: null
|
|
11333
|
+
};
|
|
11334
|
+
},
|
|
11335
|
+
useSessionId: () => usePreview().sessionId,
|
|
11336
|
+
useSessionMessages: () => usePreview().chat,
|
|
11337
|
+
useFacts: () => ({}),
|
|
11338
|
+
useVisitorName: () => ({ name: null, setName: NOOP }),
|
|
11339
|
+
useConversationMessages: () => usePreview().messages,
|
|
11340
|
+
usePendingMessage: () => usePreview().pending,
|
|
11341
|
+
useCurrentMessageIndex: () => {
|
|
11342
|
+
const d = usePreview();
|
|
11343
|
+
return d.pending === null && d.messages.length > 0 ? d.messages.length - 1 : null;
|
|
11344
|
+
},
|
|
11345
|
+
useSelectMessage: () => NOOP,
|
|
11346
|
+
useExplicitTurnSelection: () => ({ turnId: null, seq: 0 }),
|
|
11347
|
+
useHistoryNav: () => ({ canGoBack: false, canGoForward: false, goBack: NOOP, goForward: NOOP, totalTurns: usePreview().messages.length, currentIndex: null }),
|
|
11348
|
+
useCanvasBack: () => ({ canGoBack: false, goBack: NOOP }),
|
|
11349
|
+
useCanvasViewBack: () => ({ canGoBack: false, goBack: NOOP }),
|
|
11350
|
+
useCanvasForward: () => ({ canGoForward: false, goForward: NOOP }),
|
|
11351
|
+
useConversationState: () => {
|
|
11352
|
+
const d = usePreview();
|
|
11353
|
+
return { hasCommittedTurns: d.messages.length > 0, isStreaming: d.pending !== null, userMessageCount: d.messages.length + (d.pending === null ? 0 : 1) };
|
|
11354
|
+
},
|
|
11355
|
+
useSuggestionsWithDefaults: () => usePreview().suggestions,
|
|
11356
|
+
useComposerPlaceholder: () => null,
|
|
11357
|
+
useComposerPlaceholderRotation: () => [],
|
|
11358
|
+
useLayout: () => null,
|
|
11359
|
+
useFocalEntityId: () => null,
|
|
11360
|
+
useInteraction: () => {
|
|
11361
|
+
const session = useFourtySession();
|
|
11362
|
+
return {
|
|
11363
|
+
sendMessage: (text2) => session.sendMessage(text2),
|
|
11364
|
+
sendSignal: NOOP,
|
|
11365
|
+
uploadAttachment: () => Promise.reject(new Error("No uploads in a preview")),
|
|
11366
|
+
stopGeneration: NOOP,
|
|
11367
|
+
abortGeneration: NOOP,
|
|
11368
|
+
clearSignals: NOOP,
|
|
11369
|
+
clearSession: ASYNC_NOOP,
|
|
11370
|
+
forgetVisitor: ASYNC_NOOP,
|
|
11371
|
+
newConversation: ASYNC_NOOP,
|
|
11372
|
+
switchConversation: ASYNC_NOOP
|
|
11373
|
+
};
|
|
11374
|
+
},
|
|
11375
|
+
useConversations: () => [],
|
|
11376
|
+
useHasLeftSeedHome: () => {
|
|
11377
|
+
const d = usePreview();
|
|
11378
|
+
return d.messages.length > 0 || d.pending !== null;
|
|
11379
|
+
}
|
|
11380
|
+
};
|
|
11381
|
+
var PRESENCE = {
|
|
11382
|
+
useScanning: () => usePreview().scanning,
|
|
11383
|
+
usePresenceElements: () => usePreview().elements,
|
|
11384
|
+
usePresenceMaterialized: () => /* @__PURE__ */ new Set(),
|
|
11385
|
+
usePresenceLiveTurn: () => usePreview().pending?.messageId
|
|
11386
|
+
};
|
|
11387
|
+
function SpacefrontPreviewProvider({ scene, onSend, children }) {
|
|
11388
|
+
const [sessionId] = React31.useState(() => `preview-${Math.random().toString(36).slice(2)}`);
|
|
11389
|
+
const derived = React31.useMemo(() => derive(scene, sessionId), [scene, sessionId]);
|
|
11390
|
+
const onSendRef = React31.useRef(onSend);
|
|
11391
|
+
onSendRef.current = onSend;
|
|
11392
|
+
const draft = React31.useMemo(() => {
|
|
11393
|
+
let text2 = "";
|
|
11394
|
+
const listeners12 = /* @__PURE__ */ new Set();
|
|
11395
|
+
return {
|
|
11396
|
+
store: { subscribe: (fn) => {
|
|
11397
|
+
listeners12.add(fn);
|
|
11398
|
+
return () => {
|
|
11399
|
+
listeners12.delete(fn);
|
|
11400
|
+
};
|
|
11401
|
+
}, get: () => text2 },
|
|
11402
|
+
set: (next) => {
|
|
11403
|
+
text2 = next;
|
|
11404
|
+
listeners12.forEach((fn) => fn());
|
|
11405
|
+
}
|
|
11406
|
+
};
|
|
11407
|
+
}, []);
|
|
11408
|
+
const session = React31.useMemo(() => {
|
|
11409
|
+
const send = (text2) => {
|
|
11410
|
+
draft.set("");
|
|
11411
|
+
onSendRef.current?.(text2);
|
|
11412
|
+
};
|
|
11413
|
+
const sendAction = (action) => {
|
|
11414
|
+
const text2 = action.payload !== void 0 && typeof action.payload.text === "string" ? action.payload.text : action.label;
|
|
11415
|
+
send(text2);
|
|
11416
|
+
};
|
|
11417
|
+
return {
|
|
11418
|
+
sessionId,
|
|
11419
|
+
spaceKey: "preview",
|
|
11420
|
+
isRunning: derived.isRunning,
|
|
11421
|
+
isSubmitting: false,
|
|
11422
|
+
error: derived.error,
|
|
11423
|
+
reconnecting: false,
|
|
11424
|
+
reconnectAttempt: 0,
|
|
11425
|
+
reconnectMaxAttempts: 0,
|
|
11426
|
+
responseText: derived.pending === null ? "" : derived.pending.streams.prose,
|
|
11427
|
+
reasoningText: "",
|
|
11428
|
+
messages: derived.chat,
|
|
11429
|
+
suggestions: derived.suggestions,
|
|
11430
|
+
webmcpConfig: {},
|
|
11431
|
+
pendingSignals: [],
|
|
11432
|
+
currentProgress: null,
|
|
11433
|
+
openingPrompt: null,
|
|
11434
|
+
composerDraftStore: draft.store,
|
|
11435
|
+
setComposerDraft: draft.set,
|
|
11436
|
+
sendMessage: send,
|
|
11437
|
+
sendSignal: NOOP,
|
|
11438
|
+
sendImmediateSignal: NOOP,
|
|
11439
|
+
stopGeneration: NOOP,
|
|
11440
|
+
abortGeneration: NOOP,
|
|
11441
|
+
clearSignals: NOOP,
|
|
11442
|
+
clearSession: NOOP,
|
|
11443
|
+
forgetVisitor: ASYNC_NOOP,
|
|
11444
|
+
shareCanvas: () => Promise.resolve(null),
|
|
11445
|
+
recentConversations: [],
|
|
11446
|
+
newConversation: NOOP,
|
|
11447
|
+
switchConversation: NOOP,
|
|
11448
|
+
clearSuggestions: NOOP,
|
|
11449
|
+
clearError: NOOP,
|
|
11450
|
+
uploadAttachment: () => Promise.reject(new Error("No uploads in a preview")),
|
|
11451
|
+
dispatchSignal: NOOP,
|
|
11452
|
+
subscribeSignals: () => NOOP,
|
|
11453
|
+
dispatchSuggestionAction: sendAction
|
|
11454
|
+
};
|
|
11455
|
+
}, [sessionId, derived, draft]);
|
|
11456
|
+
const question = orNull(scene.question);
|
|
11457
|
+
const qId = question === null ? null : question.id;
|
|
11458
|
+
const qText = question === null ? "" : question.text;
|
|
11459
|
+
const qReplies = question === null ? "" : list(question.replies).join("\0");
|
|
11460
|
+
const raised = React31.useRef(0);
|
|
11461
|
+
React31.useEffect(() => {
|
|
11462
|
+
if (qId === null) return;
|
|
11463
|
+
raised.current += 1;
|
|
11464
|
+
const id = `${qId}-${raised.current}`;
|
|
11465
|
+
raiseStanding(AGENT_ASK_SIGNAL, id, { ask: qText, suggestions: qReplies === "" ? [] : qReplies.split("\0") }, sessionId);
|
|
11466
|
+
return () => resolveStanding(id, sessionId);
|
|
11467
|
+
}, [qId, qText, qReplies, sessionId]);
|
|
11468
|
+
return /* @__PURE__ */ jsx20(PreviewContext.Provider, { value: derived, children: /* @__PURE__ */ jsx20(FourtySessionContext.Provider, { value: session, children: /* @__PURE__ */ jsx20(FourtyRuntimeProvider, { value: RUNTIME, children: /* @__PURE__ */ jsx20(PresenceRuntimeProvider, { value: PRESENCE, children }) }) }) });
|
|
11469
|
+
}
|
|
11470
|
+
|
|
11201
11471
|
// src/host/Spacefront.tsx
|
|
11202
|
-
import { useEffect as
|
|
11472
|
+
import { useEffect as useEffect21, useState as useState23 } from "react";
|
|
11203
11473
|
|
|
11204
11474
|
// package.json
|
|
11205
|
-
var version = "0.3.
|
|
11475
|
+
var version = "0.3.2";
|
|
11206
11476
|
|
|
11207
11477
|
// src/host/host-modules.ts
|
|
11208
11478
|
import * as react from "react";
|
|
@@ -11263,11 +11533,11 @@ function loadEngine(apiUrl) {
|
|
|
11263
11533
|
}
|
|
11264
11534
|
|
|
11265
11535
|
// src/host/Spacefront.tsx
|
|
11266
|
-
import { jsx as
|
|
11536
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
11267
11537
|
function Spacefront(props) {
|
|
11268
|
-
const [engine, setEngine] =
|
|
11269
|
-
const [failure, setFailure] =
|
|
11270
|
-
|
|
11538
|
+
const [engine, setEngine] = useState23(null);
|
|
11539
|
+
const [failure, setFailure] = useState23(null);
|
|
11540
|
+
useEffect21(() => {
|
|
11271
11541
|
let live = true;
|
|
11272
11542
|
loadEngine(props.apiUrl).then(
|
|
11273
11543
|
(loaded) => {
|
|
@@ -11285,7 +11555,7 @@ function Spacefront(props) {
|
|
|
11285
11555
|
if (failure !== null) throw failure;
|
|
11286
11556
|
if (engine === null) return null;
|
|
11287
11557
|
const EngineRoot = engine.EngineRoot;
|
|
11288
|
-
return /* @__PURE__ */
|
|
11558
|
+
return /* @__PURE__ */ jsx21(EngineRoot, { ...props });
|
|
11289
11559
|
}
|
|
11290
11560
|
|
|
11291
11561
|
// src/npm.ts
|
|
@@ -11502,6 +11772,7 @@ export {
|
|
|
11502
11772
|
SpaceBugSchema,
|
|
11503
11773
|
Spacefront,
|
|
11504
11774
|
SpacefrontCanvas,
|
|
11775
|
+
SpacefrontPreviewProvider,
|
|
11505
11776
|
SpecSchema,
|
|
11506
11777
|
StateSnapshotFrameSchema,
|
|
11507
11778
|
SuggestionActionSchema,
|
|
@@ -11558,6 +11829,7 @@ export {
|
|
|
11558
11829
|
buildPdpCompanionsConfig,
|
|
11559
11830
|
buildWipeVariants,
|
|
11560
11831
|
canonicalOptionValue,
|
|
11832
|
+
carriesShapeToken,
|
|
11561
11833
|
cartLineMatchesSelections,
|
|
11562
11834
|
cartLinesForProduct,
|
|
11563
11835
|
catalogComponent,
|
|
@@ -11669,6 +11941,7 @@ export {
|
|
|
11669
11941
|
orderedVideoSources,
|
|
11670
11942
|
packRows,
|
|
11671
11943
|
parseBcp47Locale,
|
|
11944
|
+
parseReleasePreview,
|
|
11672
11945
|
pickCartAddAction,
|
|
11673
11946
|
pickCollectionAction,
|
|
11674
11947
|
pickProductCardAction,
|
|
@@ -11717,6 +11990,7 @@ export {
|
|
|
11717
11990
|
registeredPresenceFactForms,
|
|
11718
11991
|
registeredPresenceForms,
|
|
11719
11992
|
registeredPresenceSourceForms,
|
|
11993
|
+
releasePreviewSourceId,
|
|
11720
11994
|
renderInline,
|
|
11721
11995
|
rendersNothing,
|
|
11722
11996
|
reportedAxisValues,
|
|
@@ -442,6 +442,7 @@ export declare const HOST_MODULES: {
|
|
|
442
442
|
resetServerState: typeof sdk.resetServerState;
|
|
443
443
|
primedEntities: typeof sdk.primedEntities;
|
|
444
444
|
primedEntitiesFor: typeof sdk.primedEntitiesFor;
|
|
445
|
+
SpacefrontPreviewProvider: typeof sdk.SpacefrontPreviewProvider;
|
|
445
446
|
UIElementSchema: zod.ZodObject<{
|
|
446
447
|
type: zod.ZodString;
|
|
447
448
|
props: zod.ZodDefault<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
@@ -1140,6 +1141,7 @@ export declare const HOST_MODULES: {
|
|
|
1140
1141
|
derivedSourceFilled: typeof spacestation.derivedSourceFilled;
|
|
1141
1142
|
isElementUnfilled: typeof spacestation.isElementUnfilled;
|
|
1142
1143
|
rendersNothing: typeof spacestation.rendersNothing;
|
|
1144
|
+
carriesShapeToken: typeof spacestation.carriesShapeToken;
|
|
1143
1145
|
derivePropsDoc: typeof spacestation.derivePropsDoc;
|
|
1144
1146
|
WireSchemaSchema: zod.ZodType<spacestation.WireSchema, zod.ZodTypeDef, spacestation.WireSchema>;
|
|
1145
1147
|
WireCatalogSchema: zod.ZodRecord<zod.ZodString, zod.ZodObject<{
|
|
@@ -1329,6 +1331,7 @@ export declare const HOST_MODULES: {
|
|
|
1329
1331
|
sourceId: zod.ZodEffects<zod.ZodString, string, string>;
|
|
1330
1332
|
label: zod.ZodString;
|
|
1331
1333
|
version: zod.ZodString;
|
|
1334
|
+
description: zod.ZodOptional<zod.ZodString>;
|
|
1332
1335
|
catalog: zod.ZodRecord<zod.ZodString, zod.ZodObject<{
|
|
1333
1336
|
type: zod.ZodString;
|
|
1334
1337
|
propsSchema: zod.ZodOptional<zod.ZodType<spacestation.WireSchema, zod.ZodTypeDef, spacestation.WireSchema>>;
|
|
@@ -1542,6 +1545,7 @@ export declare const HOST_MODULES: {
|
|
|
1542
1545
|
}>;
|
|
1543
1546
|
manifests: Record<string, string>;
|
|
1544
1547
|
config?: Record<string, unknown> | undefined;
|
|
1548
|
+
description?: string | undefined;
|
|
1545
1549
|
bundle?: {
|
|
1546
1550
|
js: string;
|
|
1547
1551
|
css: string;
|
|
@@ -1604,6 +1608,7 @@ export declare const HOST_MODULES: {
|
|
|
1604
1608
|
}>;
|
|
1605
1609
|
manifests: Record<string, string>;
|
|
1606
1610
|
config?: Record<string, unknown> | undefined;
|
|
1611
|
+
description?: string | undefined;
|
|
1607
1612
|
bundle?: {
|
|
1608
1613
|
js: string;
|
|
1609
1614
|
css: string;
|
|
@@ -1636,6 +1641,8 @@ export declare const HOST_MODULES: {
|
|
|
1636
1641
|
}>;
|
|
1637
1642
|
draftSourceId: typeof spacestation.draftSourceId;
|
|
1638
1643
|
isDraftSource: typeof spacestation.isDraftSource;
|
|
1644
|
+
releasePreviewSourceId: typeof spacestation.releasePreviewSourceId;
|
|
1645
|
+
parseReleasePreview: typeof spacestation.parseReleasePreview;
|
|
1639
1646
|
LateBoundValueSchema: zod.ZodObject<{
|
|
1640
1647
|
fact: zod.ZodLiteral<true>;
|
|
1641
1648
|
}, "strip", zod.ZodTypeAny, {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/** One answered turn: what the visitor asked, the agent's prose (inline markdown). */
|
|
3
|
+
export interface PreviewTurn {
|
|
4
|
+
ask: string;
|
|
5
|
+
answer: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A frozen moment of a session, for rendering shell components without an
|
|
9
|
+
* engine: docs playgrounds, design reviews, visual tests. Every field is
|
|
10
|
+
* optional; an empty scene is a fresh session.
|
|
11
|
+
*/
|
|
12
|
+
export interface PreviewScene {
|
|
13
|
+
turns?: PreviewTurn[];
|
|
14
|
+
/** A turn in flight: the agent is working (`isRunning`), with `answer` streamed so far. */
|
|
15
|
+
pending?: {
|
|
16
|
+
ask: string;
|
|
17
|
+
answer?: string;
|
|
18
|
+
} | null;
|
|
19
|
+
/** The session error line (`session.error`). */
|
|
20
|
+
error?: string | null;
|
|
21
|
+
/** Suggestion chip labels. */
|
|
22
|
+
suggestions?: string[];
|
|
23
|
+
/** Records the agent is reading while it works — presence thumbs and a count. */
|
|
24
|
+
scan?: {
|
|
25
|
+
images: string[];
|
|
26
|
+
total?: number;
|
|
27
|
+
query?: string;
|
|
28
|
+
} | null;
|
|
29
|
+
/** What the agent understood about the visitor — presence facts. */
|
|
30
|
+
facts?: {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}[];
|
|
34
|
+
/** The agent's one-line voice in the presence band. */
|
|
35
|
+
voice?: string;
|
|
36
|
+
/** A standing question (the `agent_ask` signal); `replies` empty = confirm only. */
|
|
37
|
+
question?: {
|
|
38
|
+
id: string;
|
|
39
|
+
text: string;
|
|
40
|
+
replies?: string[];
|
|
41
|
+
} | null;
|
|
42
|
+
}
|
|
43
|
+
export interface SpacefrontPreviewProviderProps {
|
|
44
|
+
scene: PreviewScene;
|
|
45
|
+
/** The visitor sent a message, tapped a chip or answered the question. */
|
|
46
|
+
onSend?: (text: string) => void;
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Renders AMS shell components (`SpacefrontIsland`, `SpacefrontThreadPanel`,
|
|
51
|
+
* `SpacefrontPresence`, your own built on the sdk hooks) against a scripted
|
|
52
|
+
* session instead of an engine — no network, no space, no API key. It fills the
|
|
53
|
+
* same three seams `<Spacefront>` does (session, runtime, presence), so the
|
|
54
|
+
* components under it run unmodified.
|
|
55
|
+
*
|
|
56
|
+
* Controlled: pass the `scene` to show; `onSend` hears every visitor message,
|
|
57
|
+
* chip tap and question reply — answer it by passing the next scene.
|
|
58
|
+
*
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <SpacefrontPreviewProvider scene={{ turns: [{ ask: 'A gift?', answer: 'Try **the beanie**.' }] }}>
|
|
61
|
+
* <SpacefrontIsland />
|
|
62
|
+
* </SpacefrontPreviewProvider>
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function SpacefrontPreviewProvider({ scene, onSend, children }: SpacefrontPreviewProviderProps): React.ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SpacefrontPreviewProvider, type SpacefrontPreviewProviderProps, type PreviewScene, type PreviewTurn, } from './SpacefrontPreviewProvider';
|
|
@@ -2,4 +2,4 @@ export { WireSchemaSchema, type WireSchema, type WireResolved } from './wire-sch
|
|
|
2
2
|
export { schemaToWire, UnsupportedSchemaError } from './schema-to-wire';
|
|
3
3
|
export { schemaFromWire } from './schema-from-wire';
|
|
4
4
|
export { WireCatalogSchema, WireCatalogEntrySchema, catalogToWire, catalogFromWire, type WireCatalog, type WireCatalogEntry, } from './catalog-wire';
|
|
5
|
-
export { PackageReleaseSchema, draftSourceId, isDraftSource, type PackageRelease } from './package-release';
|
|
5
|
+
export { PackageReleaseSchema, draftSourceId, isDraftSource, releasePreviewSourceId, parseReleasePreview, type PackageRelease } from './package-release';
|
|
@@ -15,6 +15,8 @@ export declare const PackageReleaseSchema: z.ZodObject<{
|
|
|
15
15
|
label: z.ZodString;
|
|
16
16
|
/** The package's own version, as its repository states it — shown in the console. */
|
|
17
17
|
version: z.ZodString;
|
|
18
|
+
/** What this release changed, in the publisher's words (`forty publish --message`) — shown in the console's version list. */
|
|
19
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
20
|
catalog: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
19
21
|
type: z.ZodString;
|
|
20
22
|
propsSchema: z.ZodOptional<z.ZodType<import("./wire-schema").WireSchema, z.ZodTypeDef, import("./wire-schema").WireSchema>>;
|
|
@@ -253,6 +255,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
|
|
|
253
255
|
}>;
|
|
254
256
|
manifests: Record<string, string>;
|
|
255
257
|
config?: Record<string, unknown> | undefined;
|
|
258
|
+
description?: string | undefined;
|
|
256
259
|
bundle?: {
|
|
257
260
|
js: string;
|
|
258
261
|
css: string;
|
|
@@ -315,6 +318,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
|
|
|
315
318
|
}>;
|
|
316
319
|
manifests: Record<string, string>;
|
|
317
320
|
config?: Record<string, unknown> | undefined;
|
|
321
|
+
description?: string | undefined;
|
|
318
322
|
bundle?: {
|
|
319
323
|
js: string;
|
|
320
324
|
css: string;
|
|
@@ -349,3 +353,15 @@ export type PackageRelease = z.infer<typeof PackageReleaseSchema>;
|
|
|
349
353
|
export declare function draftSourceId(sourceId: string, spaceSlug: string, developer: string): string;
|
|
350
354
|
/** A package may not be published under a name that reads as a draft's. */
|
|
351
355
|
export declare function isDraftSource(sourceId: string): boolean;
|
|
356
|
+
/**
|
|
357
|
+
* ONE STORED RELEASE of a package, looked at without making it live — the
|
|
358
|
+
* console's Preview on an older version. Not a draft: nothing is written. The
|
|
359
|
+
* preview credential names this id, and the api registers the release under it
|
|
360
|
+
* in memory when a session asks for it (`ensureReleasePreview`).
|
|
361
|
+
*/
|
|
362
|
+
export declare function releasePreviewSourceId(sourceId: string, release: number): string;
|
|
363
|
+
/** The package and release a preview id names — `undefined` for anything else, a draft included. */
|
|
364
|
+
export declare function parseReleasePreview(id: string): {
|
|
365
|
+
sourceId: string;
|
|
366
|
+
release: number;
|
|
367
|
+
} | undefined;
|
|
@@ -27,9 +27,10 @@ export { requiredTopLevelProps, isEmptyPropValue, isOptionalTopLevelProp } from
|
|
|
27
27
|
export { findFunctionPropPaths } from './catalog/function-props';
|
|
28
28
|
export { expandPath, normalizeRefs, derivedSourceFilled, type ExpandedPath } from './catalog/hydration-paths';
|
|
29
29
|
export { isElementUnfilled, rendersNothing } from './catalog/element-filled';
|
|
30
|
+
export { carriesShapeToken } from './catalog/shape-tokens';
|
|
30
31
|
export { applySinglePatch } from './layout/apply-patch';
|
|
31
32
|
export { derivePropsDoc } from './catalog/derive-props-doc';
|
|
32
|
-
export { WireSchemaSchema, WireCatalogSchema, WireCatalogEntrySchema, schemaToWire, schemaFromWire, catalogToWire, catalogFromWire, UnsupportedSchemaError, PackageReleaseSchema, draftSourceId, isDraftSource, type PackageRelease, type WireSchema, type WireCatalog, type WireCatalogEntry, } from './catalog/wire';
|
|
33
|
+
export { WireSchemaSchema, WireCatalogSchema, WireCatalogEntrySchema, schemaToWire, schemaFromWire, catalogToWire, catalogFromWire, UnsupportedSchemaError, PackageReleaseSchema, draftSourceId, isDraftSource, releasePreviewSourceId, parseReleasePreview, type PackageRelease, type WireSchema, type WireCatalog, type WireCatalogEntry, } from './catalog/wire';
|
|
33
34
|
export { LateBoundValueSchema, DirectiveValueSchema, ProjectionDirectiveSchema, ProjectionPreferencesSchema, ProjectionSetPayloadSchema, PROJECTION_SET_SIGNAL, isLateBound, isActiveDirective, projectCollection, type LateBoundValue, type DirectiveValue, type ProjectionDirective, type ProjectionPreferences, type ProjectionSetPayload, type ProjectionAccessors, } from './projection/projection';
|
|
34
35
|
export { VIEW_FOCUS_ELEMENT_SIGNAL, FocusElementPayloadSchema, type FocusElementPayload, } from './focus/focus';
|
|
35
36
|
export { VIEW_EXTEND_SIGNAL, VIEW_EXHAUSTED_SIGNAL, ViewExtendPayloadSchema, CONTINUATION_ENABLED, type ViewExtendPayload, } from './view/continuation';
|