@superbuilders/primer-tives 4.1.0 → 5.0.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/README.md +27 -7
- package/dist/client/auth/hosted-popup.d.ts.map +1 -1
- package/dist/client/choice-state.d.ts +2 -2
- package/dist/client/choice-state.d.ts.map +1 -1
- package/dist/client/extended-text-state.d.ts +2 -2
- package/dist/client/extended-text-state.d.ts.map +1 -1
- package/dist/client/feedback-state.d.ts +3 -2
- package/dist/client/feedback-state.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +162 -32
- package/dist/client/index.js.map +14 -14
- package/dist/client/match-state.d.ts +2 -2
- package/dist/client/match-state.d.ts.map +1 -1
- package/dist/client/order-state.d.ts +2 -2
- package/dist/client/order-state.d.ts.map +1 -1
- package/dist/client/pci-state.d.ts +2 -2
- package/dist/client/pci-state.d.ts.map +1 -1
- package/dist/client/session.d.ts.map +1 -1
- package/dist/client/start.d.ts +1 -0
- package/dist/client/start.d.ts.map +1 -1
- package/dist/client/text-entry-state.d.ts +2 -2
- package/dist/client/text-entry-state.d.ts.map +1 -1
- package/dist/client/transport.d.ts +6 -1
- package/dist/client/transport.d.ts.map +1 -1
- package/dist/client/types.d.ts +25 -2
- package/dist/client/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ bun add @superbuilders/primer-tives
|
|
|
19
19
|
|
|
20
20
|
## Version
|
|
21
21
|
|
|
22
|
-
The current SDK version is `
|
|
22
|
+
The current SDK version is `5.0.0`.
|
|
23
23
|
|
|
24
24
|
## Entrypoints
|
|
25
25
|
|
|
@@ -384,7 +384,12 @@ async function runPrimer(initialState: PrimerState): Promise<void> {
|
|
|
384
384
|
state = await renderAndSubmitInteraction(state)
|
|
385
385
|
break
|
|
386
386
|
case "feedback":
|
|
387
|
-
|
|
387
|
+
if (state.feedbackKind === "submitted") {
|
|
388
|
+
renderSubmittedFeedback(state.feedbackContent, state.assessmentOutcome, state.review)
|
|
389
|
+
}
|
|
390
|
+
if (state.feedbackKind === "timedOut") {
|
|
391
|
+
renderTimeoutFeedback(state.feedbackContent)
|
|
392
|
+
}
|
|
388
393
|
state = await state.advance()
|
|
389
394
|
break
|
|
390
395
|
case "errored":
|
|
@@ -588,7 +593,7 @@ Every interaction state includes:
|
|
|
588
593
|
| `stimulus` | Optional frame stimulus. |
|
|
589
594
|
| `interaction` | Full interaction contract object. |
|
|
590
595
|
| submit method | Kind-specific learner submission operation. |
|
|
591
|
-
| `timeout()` | Records that the learner timed out or the host chose to end the attempt without a submission. |
|
|
596
|
+
| `timeout()` | Records that the learner timed out or the host chose to end the attempt without a submission. A successful timeout resolves to timeout feedback before the next frame. |
|
|
592
597
|
|
|
593
598
|
Submission methods validate standard interaction payloads before runtime submission. Invalid standard submissions return `ErroredState` with `ErrInvalidSubmission`.
|
|
594
599
|
|
|
@@ -807,8 +812,13 @@ type AssessmentOutcome = {
|
|
|
807
812
|
value: AssessmentOutcomeValue
|
|
808
813
|
}
|
|
809
814
|
|
|
810
|
-
|
|
815
|
+
type FeedbackState<Pcis extends PciId = PciId> =
|
|
816
|
+
| SubmittedFeedbackState<Pcis>
|
|
817
|
+
| TimedOutFeedbackState<Pcis>
|
|
818
|
+
|
|
819
|
+
interface SubmittedFeedbackState<Pcis extends PciId = PciId> {
|
|
811
820
|
readonly phase: "feedback"
|
|
821
|
+
readonly feedbackKind: "submitted"
|
|
812
822
|
readonly body: ContentBlock[]
|
|
813
823
|
readonly stimulus: RendererStimulus | null
|
|
814
824
|
readonly interaction: RendererInteraction<Pcis>
|
|
@@ -818,9 +828,19 @@ interface FeedbackState<Pcis extends PciId = PciId> {
|
|
|
818
828
|
readonly review: InteractionReview<Pcis> | null
|
|
819
829
|
advance(): Promise<PrimerState<Pcis>>
|
|
820
830
|
}
|
|
831
|
+
|
|
832
|
+
interface TimedOutFeedbackState<Pcis extends PciId = PciId> {
|
|
833
|
+
readonly phase: "feedback"
|
|
834
|
+
readonly feedbackKind: "timedOut"
|
|
835
|
+
readonly body: ContentBlock[]
|
|
836
|
+
readonly stimulus: RendererStimulus | null
|
|
837
|
+
readonly interaction: RendererInteraction<Pcis>
|
|
838
|
+
readonly feedbackContent: ContentInline[]
|
|
839
|
+
advance(): Promise<PrimerState<Pcis>>
|
|
840
|
+
}
|
|
821
841
|
```
|
|
822
842
|
|
|
823
|
-
Feedback state is returned after a terminal learner submission.
|
|
843
|
+
Feedback state is returned after a terminal learner submission or timeout. Switch on `feedbackKind`. Submitted feedback includes the submitted value, `assessmentOutcome.value`, feedback content, and optional review data. Timeout feedback has no submitted value and no correctness outcome. Call `advance()` when the learner is ready to continue.
|
|
824
844
|
|
|
825
845
|
Repeated `advance()` calls while the first one is pending return the same pending result.
|
|
826
846
|
|
|
@@ -1100,7 +1120,7 @@ if (!validation.ok) {
|
|
|
1100
1120
|
|
|
1101
1121
|
## Review Types
|
|
1102
1122
|
|
|
1103
|
-
`
|
|
1123
|
+
`SubmittedFeedbackState.review` is `InteractionReview | null`. Timeout feedback does not carry review data because no submission was graded.
|
|
1104
1124
|
|
|
1105
1125
|
```ts
|
|
1106
1126
|
type InteractionReview<Pcis extends PciId = PciId> =
|
|
@@ -1134,7 +1154,7 @@ type ReviewScalarValue =
|
|
|
1134
1154
|
| { kind: "pair"; source: string; target: string }
|
|
1135
1155
|
```
|
|
1136
1156
|
|
|
1137
|
-
`review` is for renderer display and inspection. The assessment outcome lives on `
|
|
1157
|
+
`review` is for renderer display and inspection. The assessment outcome lives on `SubmittedFeedbackState.assessmentOutcome.value`.
|
|
1138
1158
|
|
|
1139
1159
|
## PCI Registry
|
|
1140
1160
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-popup.d.ts","sourceRoot":"","sources":["../../../src/client/auth/hosted-popup.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAMtE,KAAK,iBAAiB,GAAG;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAA;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;CAC7B,CAAA;
|
|
1
|
+
{"version":3,"file":"hosted-popup.d.ts","sourceRoot":"","sources":["../../../src/client/auth/hosted-popup.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAMtE,KAAK,iBAAiB,GAAG;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAA;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;CAC7B,CAAA;AA0PD,iBAAe,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAU1E;AAED,YAAY,EAAE,iBAAiB,EAAE,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { SessionContext } from "./session-context";
|
|
2
|
-
import type { PrimerState } from "./types";
|
|
2
|
+
import type { InteractionFeedback, PrimerState } from "./types";
|
|
3
3
|
import type { ContentBlock } from "../contracts/content";
|
|
4
4
|
import type { PciId } from "../contracts/pci";
|
|
5
5
|
import type { RendererChoice, RendererInteraction, RendererStimulus } from "../contracts/types";
|
|
6
6
|
declare function choiceState<Pcis extends PciId>(ctx: SessionContext<Pcis>, body: ContentBlock[], stimulus: RendererStimulus | null, interaction: Extract<RendererInteraction<Pcis>, {
|
|
7
7
|
type: "choice";
|
|
8
|
-
}>, options: RendererChoice[], maxChoices: number, minChoices: number): PrimerState<Pcis>;
|
|
8
|
+
}>, options: RendererChoice[], maxChoices: number, minChoices: number, feedback: InteractionFeedback | null): PrimerState<Pcis>;
|
|
9
9
|
export { choiceState };
|
|
10
10
|
//# sourceMappingURL=choice-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choice-state.d.ts","sourceRoot":"","sources":["../../src/client/choice-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;
|
|
1
|
+
{"version":3,"file":"choice-state.d.ts","sourceRoot":"","sources":["../../src/client/choice-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAKhG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAA;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAA;AACtE,OAAO,KAAK,EACX,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,6CAA6C,CAAA;AAGpD,iBAAS,WAAW,CAAC,IAAI,SAAS,KAAK,EACtC,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,EACzB,IAAI,EAAE,YAAY,EAAE,EACpB,QAAQ,EAAE,gBAAgB,GAAG,IAAI,EACjC,WAAW,EAAE,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,EACnE,OAAO,EAAE,cAAc,EAAE,EACzB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,mBAAmB,GAAG,IAAI,GAClC,WAAW,CAAC,IAAI,CAAC,CAuFnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { SessionContext } from "./session-context";
|
|
2
|
-
import type { PrimerState } from "./types";
|
|
2
|
+
import type { InteractionFeedback, PrimerState } from "./types";
|
|
3
3
|
import type { ContentBlock } from "../contracts/content";
|
|
4
4
|
import type { PciId } from "../contracts/pci";
|
|
5
5
|
import type { RendererStimulus, StandardRendererInteraction } from "../contracts/types";
|
|
6
6
|
declare function extendedTextState<Pcis extends PciId>(ctx: SessionContext<Pcis>, body: ContentBlock[], stimulus: RendererStimulus | null, interaction: Extract<StandardRendererInteraction, {
|
|
7
7
|
type: "extended-text";
|
|
8
|
-
}
|
|
8
|
+
}>, feedback: InteractionFeedback | null): PrimerState<Pcis>;
|
|
9
9
|
export { extendedTextState };
|
|
10
10
|
//# sourceMappingURL=extended-text-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extended-text-state.d.ts","sourceRoot":"","sources":["../../src/client/extended-text-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;
|
|
1
|
+
{"version":3,"file":"extended-text-state.d.ts","sourceRoot":"","sources":["../../src/client/extended-text-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAKhG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAA;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAA;AACtE,OAAO,KAAK,EACX,gBAAgB,EAChB,2BAA2B,EAC3B,MAAM,6CAA6C,CAAA;AAGpD,iBAAS,iBAAiB,CAAC,IAAI,SAAS,KAAK,EAC5C,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,EACzB,IAAI,EAAE,YAAY,EAAE,EACpB,QAAQ,EAAE,gBAAgB,GAAG,IAAI,EACjC,WAAW,EAAE,OAAO,CAAC,2BAA2B,EAAE;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC,EAC5E,QAAQ,EAAE,mBAAmB,GAAG,IAAI,GAClC,WAAW,CAAC,IAAI,CAAC,CAyKnB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -4,6 +4,7 @@ import type { ContentBlock, ContentInline } from "../contracts/content";
|
|
|
4
4
|
import type { PciId } from "../contracts/pci";
|
|
5
5
|
import type { InteractionReview } from "../contracts/review";
|
|
6
6
|
import type { RendererInteraction, RendererStimulus, RendererSubmission } from "../contracts/types";
|
|
7
|
-
declare function
|
|
8
|
-
|
|
7
|
+
declare function submittedFeedbackState<Pcis extends PciId>(ctx: SessionContext<Pcis>, body: ContentBlock[], stimulus: RendererStimulus | null, interaction: RendererInteraction<Pcis>, submission: RendererSubmission<Pcis>, assessmentOutcome: AssessmentOutcome, feedbackContent: ContentInline[], review: InteractionReview<Pcis> | null): PrimerState<Pcis>;
|
|
8
|
+
declare function timedOutFeedbackState<Pcis extends PciId>(ctx: SessionContext<Pcis>, body: ContentBlock[], stimulus: RendererStimulus | null, interaction: RendererInteraction<Pcis>, feedbackContent: ContentInline[]): PrimerState<Pcis>;
|
|
9
|
+
export { submittedFeedbackState, timedOutFeedbackState };
|
|
9
10
|
//# sourceMappingURL=feedback-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedback-state.d.ts","sourceRoot":"","sources":["../../src/client/feedback-state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAA;AAChG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAA;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAA;AACrF,OAAO,KAAK,EACX,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,6CAA6C,CAAA;
|
|
1
|
+
{"version":3,"file":"feedback-state.d.ts","sourceRoot":"","sources":["../../src/client/feedback-state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAA;AAChG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAA;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAA;AACrF,OAAO,KAAK,EACX,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,6CAA6C,CAAA;AAapD,iBAAS,sBAAsB,CAAC,IAAI,SAAS,KAAK,EACjD,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,EACzB,IAAI,EAAE,YAAY,EAAE,EACpB,QAAQ,EAAE,gBAAgB,GAAG,IAAI,EACjC,WAAW,EAAE,mBAAmB,CAAC,IAAI,CAAC,EACtC,UAAU,EAAE,kBAAkB,CAAC,IAAI,CAAC,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,eAAe,EAAE,aAAa,EAAE,EAChC,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC,GAAG,IAAI,GACpC,WAAW,CAAC,IAAI,CAAC,CAcnB;AAED,iBAAS,qBAAqB,CAAC,IAAI,SAAS,KAAK,EAChD,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,EACzB,IAAI,EAAE,YAAY,EAAE,EACpB,QAAQ,EAAE,gBAAgB,GAAG,IAAI,EACjC,WAAW,EAAE,mBAAmB,CAAC,IAAI,CAAC,EACtC,eAAe,EAAE,aAAa,EAAE,GAC9B,WAAW,CAAC,IAAI,CAAC,CAWnB;AAED,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,CAAA"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { PrimerOptions, PrimerOptionsWithAccessToken, PrimerOptionsWithManagedAuth } from "./start";
|
|
2
2
|
export { start } from "./start";
|
|
3
|
-
export type { AccessTokenStartState, AssessmentOutcome, AssessmentOutcomeValue, AuthConfigInvalidState, AuthUnavailableState, ChoiceState, CompletedState, ErroredState, ExtendedTextMultipleState, ExtendedTextSingleState, ExtendedTextState, FatalState, FeedbackState, InteractionState, ManagedStartState, MatchState, NonRetriableErroredState, NonSerializable, ObservationState, OrderState, PciInteractionState, PciPendingRenderProps, PciRenderProps, PciSubmittedRenderProps, PrimerState, RetriableErroredState, RuntimeState, SignInFailedState, SignInRequiredState, TextEntryState } from "./types";
|
|
3
|
+
export type { AccessTokenStartState, AssessmentOutcome, AssessmentOutcomeValue, AuthConfigInvalidState, AuthUnavailableState, ChoiceState, CompletedState, ErroredState, ExtendedTextMultipleState, ExtendedTextSingleState, ExtendedTextState, FatalState, FeedbackKind, FeedbackState, InteractionFeedback, InteractionState, ManagedStartState, MatchState, NonRetriableErroredState, NonSerializable, ObservationState, OrderState, PciInteractionState, PciPendingRenderProps, PciRenderProps, PciSubmittedRenderProps, PrimerState, RetriableErroredState, RuntimeState, SignInFailedState, SignInRequiredState, SubmittedFeedbackState, TextEntryState, TimedOutFeedbackState } from "./types";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,aAAa,EACb,4BAA4B,EAC5B,4BAA4B,EAC5B,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAA;AAEhE,YAAY,EACX,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,YAAY,EACZ,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,uBAAuB,EACvB,WAAW,EACX,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,MAAM,0CAA0C,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,aAAa,EACb,4BAA4B,EAC5B,4BAA4B,EAC5B,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAA;AAEhE,YAAY,EACX,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,YAAY,EACZ,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,uBAAuB,EACvB,WAAW,EACX,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,MAAM,0CAA0C,CAAA"}
|
package/dist/client/index.js
CHANGED
|
@@ -6956,7 +6956,10 @@ function readPopupMessage(event, popup, config, expectedOrigin) {
|
|
|
6956
6956
|
}
|
|
6957
6957
|
return { kind: "success", accessToken };
|
|
6958
6958
|
}
|
|
6959
|
-
|
|
6959
|
+
function supportsAsyncDisposableStack() {
|
|
6960
|
+
return typeof Reflect.get(globalThis, "AsyncDisposableStack") === "function";
|
|
6961
|
+
}
|
|
6962
|
+
async function waitForPopupMessageWithAsyncDisposableStack(popup, config, expectedOrigin) {
|
|
6960
6963
|
let __stack = [];
|
|
6961
6964
|
try {
|
|
6962
6965
|
const logger = config.logger;
|
|
@@ -7023,6 +7026,86 @@ async function waitForPopupMessage(popup, config, expectedOrigin) {
|
|
|
7023
7026
|
_promise && await _promise;
|
|
7024
7027
|
}
|
|
7025
7028
|
}
|
|
7029
|
+
function cleanupManualPopupWait(cleanups) {
|
|
7030
|
+
for (let index = cleanups.length - 1;index >= 0; index -= 1) {
|
|
7031
|
+
const cleanup = cleanups[index];
|
|
7032
|
+
if (cleanup === undefined) {
|
|
7033
|
+
continue;
|
|
7034
|
+
}
|
|
7035
|
+
cleanup();
|
|
7036
|
+
}
|
|
7037
|
+
}
|
|
7038
|
+
async function waitForPopupMessageWithManualCleanup(popup, config, expectedOrigin) {
|
|
7039
|
+
const logger = config.logger;
|
|
7040
|
+
const cleanups = [];
|
|
7041
|
+
cleanups.push(function closePopup() {
|
|
7042
|
+
popup.close();
|
|
7043
|
+
});
|
|
7044
|
+
const pending = new Promise(function waitForMessage(resolve, reject) {
|
|
7045
|
+
let settled = false;
|
|
7046
|
+
function finishWithError(error) {
|
|
7047
|
+
if (settled) {
|
|
7048
|
+
return;
|
|
7049
|
+
}
|
|
7050
|
+
settled = true;
|
|
7051
|
+
reject(error);
|
|
7052
|
+
}
|
|
7053
|
+
function finishWithToken(token) {
|
|
7054
|
+
if (settled) {
|
|
7055
|
+
return;
|
|
7056
|
+
}
|
|
7057
|
+
settled = true;
|
|
7058
|
+
logger.debug("hosted auth popup completed");
|
|
7059
|
+
resolve(token);
|
|
7060
|
+
}
|
|
7061
|
+
const timeoutId = globalThis.setTimeout(function timeout() {
|
|
7062
|
+
logger.error("hosted auth popup timed out");
|
|
7063
|
+
finishWithError(ErrAuthCancelled);
|
|
7064
|
+
}, DEFAULT_POPUP_TIMEOUT_MS);
|
|
7065
|
+
cleanups.push(function clearPopupTimeout() {
|
|
7066
|
+
globalThis.clearTimeout(timeoutId);
|
|
7067
|
+
});
|
|
7068
|
+
const closedPollId = globalThis.setInterval(function checkClosed() {
|
|
7069
|
+
if (!popup.closed) {
|
|
7070
|
+
return;
|
|
7071
|
+
}
|
|
7072
|
+
logger.error("hosted auth popup closed");
|
|
7073
|
+
finishWithError(ErrAuthCancelled);
|
|
7074
|
+
}, POPUP_POLL_MS);
|
|
7075
|
+
cleanups.push(function clearClosedPoll() {
|
|
7076
|
+
globalThis.clearInterval(closedPollId);
|
|
7077
|
+
});
|
|
7078
|
+
function handleMessage(event) {
|
|
7079
|
+
const result = readPopupMessage(event, popup, config, expectedOrigin);
|
|
7080
|
+
if (result.kind === "ignore") {
|
|
7081
|
+
return;
|
|
7082
|
+
}
|
|
7083
|
+
if (result.kind === "error") {
|
|
7084
|
+
logger.error({ error: result.error }, "hosted auth popup failed");
|
|
7085
|
+
finishWithError(result.error);
|
|
7086
|
+
return;
|
|
7087
|
+
}
|
|
7088
|
+
finishWithToken(result.accessToken);
|
|
7089
|
+
}
|
|
7090
|
+
globalThis.addEventListener("message", handleMessage);
|
|
7091
|
+
cleanups.push(function removeMessageListener() {
|
|
7092
|
+
globalThis.removeEventListener("message", handleMessage);
|
|
7093
|
+
});
|
|
7094
|
+
});
|
|
7095
|
+
return pending.then(function cleanupSuccess(token) {
|
|
7096
|
+
cleanupManualPopupWait(cleanups);
|
|
7097
|
+
return token;
|
|
7098
|
+
}, function cleanupFailure(error) {
|
|
7099
|
+
cleanupManualPopupWait(cleanups);
|
|
7100
|
+
throw error;
|
|
7101
|
+
});
|
|
7102
|
+
}
|
|
7103
|
+
async function waitForPopupMessage(popup, config, expectedOrigin) {
|
|
7104
|
+
if (supportsAsyncDisposableStack()) {
|
|
7105
|
+
return waitForPopupMessageWithAsyncDisposableStack(popup, config, expectedOrigin);
|
|
7106
|
+
}
|
|
7107
|
+
return waitForPopupMessageWithManualCleanup(popup, config, expectedOrigin);
|
|
7108
|
+
}
|
|
7026
7109
|
async function beginHostedPopup(config) {
|
|
7027
7110
|
const logger = config.logger;
|
|
7028
7111
|
const url = hostedAuthUrl(config);
|
|
@@ -7207,7 +7290,7 @@ import * as errors11 from "@superbuilders/errors";
|
|
|
7207
7290
|
|
|
7208
7291
|
// src/client/choice-state.ts
|
|
7209
7292
|
import * as errors5 from "@superbuilders/errors";
|
|
7210
|
-
function choiceState(ctx, body, stimulus, interaction, options, maxChoices, minChoices) {
|
|
7293
|
+
function choiceState(ctx, body, stimulus, interaction, options, maxChoices, minChoices, feedback) {
|
|
7211
7294
|
let submitPending;
|
|
7212
7295
|
let submitKey;
|
|
7213
7296
|
let timeoutPending;
|
|
@@ -7254,6 +7337,7 @@ function choiceState(ctx, body, stimulus, interaction, options, maxChoices, minC
|
|
|
7254
7337
|
body,
|
|
7255
7338
|
stimulus,
|
|
7256
7339
|
interaction,
|
|
7340
|
+
feedback,
|
|
7257
7341
|
options,
|
|
7258
7342
|
maxChoices,
|
|
7259
7343
|
minChoices,
|
|
@@ -7265,7 +7349,7 @@ function choiceState(ctx, body, stimulus, interaction, options, maxChoices, minC
|
|
|
7265
7349
|
|
|
7266
7350
|
// src/client/extended-text-state.ts
|
|
7267
7351
|
import * as errors6 from "@superbuilders/errors";
|
|
7268
|
-
function extendedTextState(ctx, body, stimulus, interaction) {
|
|
7352
|
+
function extendedTextState(ctx, body, stimulus, interaction, feedback) {
|
|
7269
7353
|
if (interaction.cardinality === "single") {
|
|
7270
7354
|
let submitText = function(value) {
|
|
7271
7355
|
const submission = { type: "extended-text", values: [value] };
|
|
@@ -7313,6 +7397,7 @@ function extendedTextState(ctx, body, stimulus, interaction) {
|
|
|
7313
7397
|
body,
|
|
7314
7398
|
stimulus,
|
|
7315
7399
|
interaction,
|
|
7400
|
+
feedback,
|
|
7316
7401
|
submitText,
|
|
7317
7402
|
timeout: timeout2,
|
|
7318
7403
|
toJSON: poisonToJSON
|
|
@@ -7366,6 +7451,7 @@ function extendedTextState(ctx, body, stimulus, interaction) {
|
|
|
7366
7451
|
body,
|
|
7367
7452
|
stimulus,
|
|
7368
7453
|
interaction: multi,
|
|
7454
|
+
feedback,
|
|
7369
7455
|
maxStrings: multi.maxStrings,
|
|
7370
7456
|
minStrings: multi.minStrings,
|
|
7371
7457
|
submitTexts,
|
|
@@ -7375,10 +7461,20 @@ function extendedTextState(ctx, body, stimulus, interaction) {
|
|
|
7375
7461
|
}
|
|
7376
7462
|
|
|
7377
7463
|
// src/client/feedback-state.ts
|
|
7378
|
-
function
|
|
7464
|
+
function createAdvance(ctx) {
|
|
7379
7465
|
let pending;
|
|
7466
|
+
return function advance() {
|
|
7467
|
+
if (pending) {
|
|
7468
|
+
return pending;
|
|
7469
|
+
}
|
|
7470
|
+
pending = ctx.execute({ kind: "observation" }, "observation");
|
|
7471
|
+
return pending;
|
|
7472
|
+
};
|
|
7473
|
+
}
|
|
7474
|
+
function submittedFeedbackState(ctx, body, stimulus, interaction, submission, assessmentOutcome, feedbackContent, review) {
|
|
7380
7475
|
return {
|
|
7381
7476
|
phase: "feedback",
|
|
7477
|
+
feedbackKind: "submitted",
|
|
7382
7478
|
body,
|
|
7383
7479
|
stimulus,
|
|
7384
7480
|
interaction,
|
|
@@ -7386,20 +7482,26 @@ function feedbackState(ctx, body, stimulus, interaction, submission, assessmentO
|
|
|
7386
7482
|
assessmentOutcome,
|
|
7387
7483
|
feedbackContent,
|
|
7388
7484
|
review,
|
|
7389
|
-
advance:
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7485
|
+
advance: createAdvance(ctx),
|
|
7486
|
+
toJSON: poisonToJSON
|
|
7487
|
+
};
|
|
7488
|
+
}
|
|
7489
|
+
function timedOutFeedbackState(ctx, body, stimulus, interaction, feedbackContent) {
|
|
7490
|
+
return {
|
|
7491
|
+
phase: "feedback",
|
|
7492
|
+
feedbackKind: "timedOut",
|
|
7493
|
+
body,
|
|
7494
|
+
stimulus,
|
|
7495
|
+
interaction,
|
|
7496
|
+
feedbackContent,
|
|
7497
|
+
advance: createAdvance(ctx),
|
|
7396
7498
|
toJSON: poisonToJSON
|
|
7397
7499
|
};
|
|
7398
7500
|
}
|
|
7399
7501
|
|
|
7400
7502
|
// src/client/match-state.ts
|
|
7401
7503
|
import * as errors7 from "@superbuilders/errors";
|
|
7402
|
-
function matchState(ctx, body, stimulus, interaction) {
|
|
7504
|
+
function matchState(ctx, body, stimulus, interaction, feedback) {
|
|
7403
7505
|
let submitPending;
|
|
7404
7506
|
let submitKey;
|
|
7405
7507
|
let timeoutPending;
|
|
@@ -7446,6 +7548,7 @@ function matchState(ctx, body, stimulus, interaction) {
|
|
|
7446
7548
|
body,
|
|
7447
7549
|
stimulus,
|
|
7448
7550
|
interaction,
|
|
7551
|
+
feedback,
|
|
7449
7552
|
sourceChoices: interaction.sourceChoices,
|
|
7450
7553
|
targetChoices: interaction.targetChoices,
|
|
7451
7554
|
minAssociations: interaction.minAssociations,
|
|
@@ -7476,7 +7579,7 @@ function observationState(ctx, body, stimulus) {
|
|
|
7476
7579
|
|
|
7477
7580
|
// src/client/order-state.ts
|
|
7478
7581
|
import * as errors8 from "@superbuilders/errors";
|
|
7479
|
-
function orderState(ctx, body, stimulus, interaction) {
|
|
7582
|
+
function orderState(ctx, body, stimulus, interaction, feedback) {
|
|
7480
7583
|
let submitPending;
|
|
7481
7584
|
let submitKey;
|
|
7482
7585
|
let timeoutPending;
|
|
@@ -7523,6 +7626,7 @@ function orderState(ctx, body, stimulus, interaction) {
|
|
|
7523
7626
|
body,
|
|
7524
7627
|
stimulus,
|
|
7525
7628
|
interaction,
|
|
7629
|
+
feedback,
|
|
7526
7630
|
choices: interaction.choices,
|
|
7527
7631
|
minChoices: interaction.minChoices,
|
|
7528
7632
|
maxChoices: interaction.maxChoices,
|
|
@@ -7534,7 +7638,7 @@ function orderState(ctx, body, stimulus, interaction) {
|
|
|
7534
7638
|
|
|
7535
7639
|
// src/client/pci-state.ts
|
|
7536
7640
|
import * as errors9 from "@superbuilders/errors";
|
|
7537
|
-
function pciInteractionState(ctx, body, stimulus, interaction) {
|
|
7641
|
+
function pciInteractionState(ctx, body, stimulus, interaction, feedback) {
|
|
7538
7642
|
let submitPending;
|
|
7539
7643
|
let submitKey;
|
|
7540
7644
|
let timeoutPending;
|
|
@@ -7579,6 +7683,7 @@ function pciInteractionState(ctx, body, stimulus, interaction) {
|
|
|
7579
7683
|
body,
|
|
7580
7684
|
stimulus,
|
|
7581
7685
|
interaction,
|
|
7686
|
+
feedback,
|
|
7582
7687
|
pciId,
|
|
7583
7688
|
properties,
|
|
7584
7689
|
submit,
|
|
@@ -7589,7 +7694,7 @@ function pciInteractionState(ctx, body, stimulus, interaction) {
|
|
|
7589
7694
|
|
|
7590
7695
|
// src/client/text-entry-state.ts
|
|
7591
7696
|
import * as errors10 from "@superbuilders/errors";
|
|
7592
|
-
function textEntryState(ctx, body, stimulus, interaction) {
|
|
7697
|
+
function textEntryState(ctx, body, stimulus, interaction, feedback) {
|
|
7593
7698
|
let submitPending;
|
|
7594
7699
|
let submitKey;
|
|
7595
7700
|
let timeoutPending;
|
|
@@ -7636,6 +7741,7 @@ function textEntryState(ctx, body, stimulus, interaction) {
|
|
|
7636
7741
|
body,
|
|
7637
7742
|
stimulus,
|
|
7638
7743
|
interaction,
|
|
7744
|
+
feedback,
|
|
7639
7745
|
submitText,
|
|
7640
7746
|
timeout,
|
|
7641
7747
|
toJSON: poisonToJSON
|
|
@@ -7668,7 +7774,7 @@ function makeSession(sc) {
|
|
|
7668
7774
|
function resolve(result) {
|
|
7669
7775
|
switch (result.outcome) {
|
|
7670
7776
|
case "advanced":
|
|
7671
|
-
return fromAdvanced(result.frame.body, result.frame.stimulus, result.frame.interaction);
|
|
7777
|
+
return fromAdvanced(result.frame.body, result.frame.stimulus, result.frame.interaction, result.frame.feedback);
|
|
7672
7778
|
case "submitted": {
|
|
7673
7779
|
const interaction = result.frame.interaction;
|
|
7674
7780
|
if (interaction === null) {
|
|
@@ -7681,9 +7787,26 @@ function makeSession(sc) {
|
|
|
7681
7787
|
};
|
|
7682
7788
|
}
|
|
7683
7789
|
if (result.assessmentOutcome.value === "revisionRequested") {
|
|
7684
|
-
|
|
7790
|
+
const feedback = {
|
|
7791
|
+
assessmentOutcome: result.assessmentOutcome,
|
|
7792
|
+
feedbackContent: result.feedbackContent
|
|
7793
|
+
};
|
|
7794
|
+
return fromAdvanced(result.frame.body, result.frame.stimulus, interaction, feedback);
|
|
7795
|
+
}
|
|
7796
|
+
return submittedFeedbackState(ctx, result.frame.body, result.frame.stimulus, interaction, result.submission, result.assessmentOutcome, result.feedbackContent, result.review);
|
|
7797
|
+
}
|
|
7798
|
+
case "timedOut": {
|
|
7799
|
+
const interaction = result.frame.interaction;
|
|
7800
|
+
if (interaction === null) {
|
|
7801
|
+
logger.error("timed out result without interaction");
|
|
7802
|
+
return {
|
|
7803
|
+
phase: "fatal",
|
|
7804
|
+
error: errors11.wrap(ErrBadRequest, "timed out result missing interaction"),
|
|
7805
|
+
retriable: false,
|
|
7806
|
+
toJSON: poisonToJSON
|
|
7807
|
+
};
|
|
7685
7808
|
}
|
|
7686
|
-
return
|
|
7809
|
+
return timedOutFeedbackState(ctx, result.frame.body, result.frame.stimulus, interaction, result.feedbackContent);
|
|
7687
7810
|
}
|
|
7688
7811
|
case "completed":
|
|
7689
7812
|
return { phase: "completed", toJSON: poisonToJSON };
|
|
@@ -7769,7 +7892,7 @@ function makeSession(sc) {
|
|
|
7769
7892
|
}
|
|
7770
7893
|
return false;
|
|
7771
7894
|
}
|
|
7772
|
-
function fromAdvanced(body, stimulus, interaction) {
|
|
7895
|
+
function fromAdvanced(body, stimulus, interaction, feedback) {
|
|
7773
7896
|
if (interaction === null) {
|
|
7774
7897
|
return observationState(ctx, body, stimulus);
|
|
7775
7898
|
}
|
|
@@ -7784,9 +7907,9 @@ function makeSession(sc) {
|
|
|
7784
7907
|
};
|
|
7785
7908
|
}
|
|
7786
7909
|
}
|
|
7787
|
-
return pendingInteractionState(body, stimulus, interaction);
|
|
7910
|
+
return pendingInteractionState(body, stimulus, interaction, feedback);
|
|
7788
7911
|
}
|
|
7789
|
-
function extendedTextInteractionState(body, stimulus, interaction) {
|
|
7912
|
+
function extendedTextInteractionState(body, stimulus, interaction, feedback) {
|
|
7790
7913
|
if (!("cardinality" in interaction)) {
|
|
7791
7914
|
logger.error("extended-text interaction is unsupported");
|
|
7792
7915
|
return {
|
|
@@ -7797,22 +7920,22 @@ function makeSession(sc) {
|
|
|
7797
7920
|
};
|
|
7798
7921
|
}
|
|
7799
7922
|
const extendedInteraction = interaction;
|
|
7800
|
-
return extendedTextState(ctx, body, stimulus, extendedInteraction);
|
|
7923
|
+
return extendedTextState(ctx, body, stimulus, extendedInteraction, feedback);
|
|
7801
7924
|
}
|
|
7802
|
-
function pendingInteractionState(body, stimulus, interaction) {
|
|
7925
|
+
function pendingInteractionState(body, stimulus, interaction, feedback) {
|
|
7803
7926
|
switch (interaction.type) {
|
|
7804
7927
|
case "choice":
|
|
7805
|
-
return choiceState(ctx, body, stimulus, interaction, interaction.options, interaction.maxChoices, interaction.minChoices);
|
|
7928
|
+
return choiceState(ctx, body, stimulus, interaction, interaction.options, interaction.maxChoices, interaction.minChoices, feedback);
|
|
7806
7929
|
case "text-entry":
|
|
7807
|
-
return textEntryState(ctx, body, stimulus, interaction);
|
|
7930
|
+
return textEntryState(ctx, body, stimulus, interaction, feedback);
|
|
7808
7931
|
case "extended-text":
|
|
7809
|
-
return extendedTextInteractionState(body, stimulus, interaction);
|
|
7932
|
+
return extendedTextInteractionState(body, stimulus, interaction, feedback);
|
|
7810
7933
|
case "order":
|
|
7811
|
-
return orderState(ctx, body, stimulus, interaction);
|
|
7934
|
+
return orderState(ctx, body, stimulus, interaction, feedback);
|
|
7812
7935
|
case "match":
|
|
7813
|
-
return matchState(ctx, body, stimulus, interaction);
|
|
7936
|
+
return matchState(ctx, body, stimulus, interaction, feedback);
|
|
7814
7937
|
case "portable-custom":
|
|
7815
|
-
return pciInteractionState(ctx, body, stimulus, interaction);
|
|
7938
|
+
return pciInteractionState(ctx, body, stimulus, interaction, feedback);
|
|
7816
7939
|
}
|
|
7817
7940
|
}
|
|
7818
7941
|
const ctx = { logger, execute, errored };
|
|
@@ -7823,7 +7946,7 @@ function makeSession(sc) {
|
|
|
7823
7946
|
import * as errors12 from "@superbuilders/errors";
|
|
7824
7947
|
|
|
7825
7948
|
// src/version.ts
|
|
7826
|
-
var SDK_VERSION = "
|
|
7949
|
+
var SDK_VERSION = "5.0.0";
|
|
7827
7950
|
var NPM_PACKAGE_URL = "https://www.npmjs.com/package/@superbuilders/primer-tives";
|
|
7828
7951
|
|
|
7829
7952
|
// src/client/transport.ts
|
|
@@ -8039,6 +8162,12 @@ function primerOrigin(origin) {
|
|
|
8039
8162
|
}
|
|
8040
8163
|
return DEFAULT_PRIMER_ORIGIN;
|
|
8041
8164
|
}
|
|
8165
|
+
function primerAuthOrigin(authOrigin, origin) {
|
|
8166
|
+
if (authOrigin !== undefined) {
|
|
8167
|
+
return authOrigin;
|
|
8168
|
+
}
|
|
8169
|
+
return origin;
|
|
8170
|
+
}
|
|
8042
8171
|
async function startRuntime(config, resolved) {
|
|
8043
8172
|
let reauthenticate = null;
|
|
8044
8173
|
if (resolved.clearCachedAccessToken !== undefined) {
|
|
@@ -8082,7 +8211,7 @@ function makeSignInFailedState(config, error) {
|
|
|
8082
8211
|
}
|
|
8083
8212
|
async function loginAndStart(config) {
|
|
8084
8213
|
const result = await beginHostedLogin({
|
|
8085
|
-
origin: config.
|
|
8214
|
+
origin: config.authOrigin,
|
|
8086
8215
|
publishableKey: config.publishableKey,
|
|
8087
8216
|
logger: config.logger
|
|
8088
8217
|
});
|
|
@@ -8107,6 +8236,7 @@ async function start(options) {
|
|
|
8107
8236
|
const config = {
|
|
8108
8237
|
publishableKey: options.publishableKey,
|
|
8109
8238
|
origin,
|
|
8239
|
+
authOrigin: primerAuthOrigin(options.authOrigin, origin),
|
|
8110
8240
|
fetch: options.fetch,
|
|
8111
8241
|
abort: options.abort,
|
|
8112
8242
|
logger,
|
|
@@ -8139,4 +8269,4 @@ export {
|
|
|
8139
8269
|
start
|
|
8140
8270
|
};
|
|
8141
8271
|
|
|
8142
|
-
//# debugId=
|
|
8272
|
+
//# debugId=9849F045A465657964756E2164756E21
|