@pie-players/pie-players-shared 0.3.72 → 0.3.74

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.
Files changed (123) hide show
  1. package/README.md +27 -1
  2. package/dist/components/vendor/nds/README.md +7 -5
  3. package/dist/config/profile.d.ts +0 -2
  4. package/dist/config/profile.js +2 -8
  5. package/dist/i18n/index.d.ts +2 -3
  6. package/dist/i18n/index.js +2 -3
  7. package/dist/i18n/messages/en-US.d.ts +10 -0
  8. package/dist/i18n/messages/en-US.js +12 -2
  9. package/dist/i18n/messages/nl-NL.d.ts +6 -0
  10. package/dist/i18n/messages/nl-NL.js +8 -2
  11. package/dist/i18n/provider.d.ts +4 -5
  12. package/dist/i18n/provider.js +4 -5
  13. package/dist/index.d.ts +4 -2
  14. package/dist/index.js +3 -1
  15. package/dist/instrumentation/index.d.ts +5 -4
  16. package/dist/instrumentation/index.js +5 -4
  17. package/dist/instrumentation/new-relic-agent.d.ts +20 -0
  18. package/dist/instrumentation/new-relic-agent.js +24 -0
  19. package/dist/instrumentation/providers/BaseInstrumentationProvider.d.ts +5 -4
  20. package/dist/instrumentation/providers/NewRelicInstrumentationProvider.d.ts +7 -7
  21. package/dist/instrumentation/providers/NewRelicInstrumentationProvider.js +21 -32
  22. package/dist/instrumentation/types.d.ts +7 -3
  23. package/dist/loader-config.d.ts +16 -6
  24. package/dist/loaders/controller-loading.d.ts +14 -0
  25. package/dist/loaders/controller-loading.js +12 -0
  26. package/dist/loaders/defaults.d.ts +10 -0
  27. package/dist/loaders/defaults.js +10 -0
  28. package/dist/loaders/element-loader.d.ts +20 -8
  29. package/dist/loaders/element-loader.js +102 -36
  30. package/dist/loaders/element-package-policy.d.ts +2 -0
  31. package/dist/loaders/element-package-policy.js +2 -1
  32. package/dist/loaders/esm-adapter.d.ts +18 -0
  33. package/dist/loaders/esm-adapter.js +617 -102
  34. package/dist/loaders/iife-adapter.d.ts +0 -5
  35. package/dist/loaders/iife-adapter.js +3 -9
  36. package/dist/loaders/index.d.ts +10 -3
  37. package/dist/loaders/index.js +8 -3
  38. package/dist/loaders/mathjax-version-conflict.d.ts +17 -0
  39. package/dist/loaders/mathjax-version-conflict.js +51 -0
  40. package/dist/loaders/module-shim.d.ts +12 -0
  41. package/dist/loaders/module-shim.js +12 -0
  42. package/dist/loaders/preloaded-alignment.d.ts +24 -0
  43. package/dist/loaders/preloaded-alignment.js +57 -0
  44. package/dist/loaders/preloaded-authored-tags.d.ts +26 -0
  45. package/dist/loaders/preloaded-authored-tags.js +69 -0
  46. package/dist/loaders/preloaded-registration.d.ts +56 -0
  47. package/dist/loaders/preloaded-registration.js +129 -0
  48. package/dist/media/index.d.ts +69 -0
  49. package/dist/media/index.js +194 -0
  50. package/dist/pie/authoring.d.ts +1 -1
  51. package/dist/pie/authoring.js +25 -18
  52. package/dist/pie/element-announcements.d.ts +39 -0
  53. package/dist/pie/element-announcements.js +67 -0
  54. package/dist/pie/element-observer.d.ts +3 -1
  55. package/dist/pie/element-observer.js +1 -0
  56. package/dist/pie/index.d.ts +6 -4
  57. package/dist/pie/index.js +6 -3
  58. package/dist/pie/initialization.js +13 -22
  59. package/dist/pie/initialize-element.d.ts +3 -0
  60. package/dist/pie/initialize-element.js +3 -4
  61. package/dist/pie/instrumentation-event-map.js +2 -9
  62. package/dist/pie/instrumentation-provider-resolution.d.ts +2 -1
  63. package/dist/pie/instrumentation-provider-resolution.js +0 -1
  64. package/dist/pie/item-session-contract.d.ts +47 -0
  65. package/dist/pie/item-session-contract.js +196 -9
  66. package/dist/pie/markup-math.d.ts +20 -0
  67. package/dist/pie/markup-math.js +118 -0
  68. package/dist/pie/math-rendering.d.ts +10 -21
  69. package/dist/pie/math-rendering.js +50 -35
  70. package/dist/pie/registry.d.ts +13 -1
  71. package/dist/pie/registry.js +39 -1
  72. package/dist/pie/resource-monitor.d.ts +6 -33
  73. package/dist/pie/resource-monitor.js +14 -213
  74. package/dist/pie/scoring.d.ts +11 -2
  75. package/dist/pie/scoring.js +18 -16
  76. package/dist/pie/session-commit.d.ts +121 -0
  77. package/dist/pie/session-commit.js +420 -0
  78. package/dist/pie/session-snapshot.d.ts +80 -0
  79. package/dist/pie/session-snapshot.js +166 -0
  80. package/dist/pie/tag-names.d.ts +1 -0
  81. package/dist/pie/tag-names.js +1 -0
  82. package/dist/pie/types.d.ts +4 -5
  83. package/dist/pie/types.js +1 -0
  84. package/dist/pie/updates.d.ts +2 -2
  85. package/dist/pie/updates.js +33 -15
  86. package/dist/pie/versioned-tag.d.ts +4 -0
  87. package/dist/pie/versioned-tag.js +4 -0
  88. package/dist/security/index.d.ts +2 -3
  89. package/dist/security/index.js +2 -3
  90. package/dist/security/sanitize-item-markup.d.ts +0 -2
  91. package/dist/security/sanitize-item-markup.js +0 -4
  92. package/dist/security/sanitize-svg-icon.d.ts +0 -2
  93. package/dist/security/sanitize-svg-icon.js +0 -5
  94. package/dist/security/wrap-overwide.d.ts +5 -0
  95. package/dist/security/wrap-overwide.js +16 -0
  96. package/dist/timed-media/policy.js +5 -16
  97. package/dist/types/index.d.ts +30 -311
  98. package/dist/types/index.js +0 -68
  99. package/dist/ui/attribute-coercion.d.ts +12 -0
  100. package/dist/ui/attribute-coercion.js +33 -0
  101. package/dist/ui/content-styles.d.ts +18 -16
  102. package/dist/ui/content-styles.js +67 -36
  103. package/dist/ui/overlay-containment.d.ts +31 -0
  104. package/dist/ui/overlay-containment.js +63 -0
  105. package/dist/ui/overlay-placement.d.ts +110 -0
  106. package/dist/ui/overlay-placement.js +222 -0
  107. package/dist/ui/pointer-gesture.d.ts +32 -0
  108. package/dist/ui/pointer-gesture.js +56 -0
  109. package/dist/ui/pointer-rotate.d.ts +29 -0
  110. package/dist/ui/pointer-rotate.js +39 -0
  111. package/package.json +21 -17
  112. package/dist/pie/component-context.d.ts +0 -21
  113. package/dist/pie/component-context.js +0 -29
  114. package/dist/pie/player-initializer.d.ts +0 -54
  115. package/dist/pie/player-initializer.js +0 -122
  116. package/dist/security/wrap-model-rich-content.d.ts +0 -1
  117. package/dist/security/wrap-model-rich-content.js +0 -40
  118. package/dist/server/npm-auth-env.d.ts +0 -13
  119. package/dist/server/npm-auth-env.js +0 -64
  120. package/dist/server/npm-registry.d.ts +0 -7
  121. package/dist/server/npm-registry.js +0 -59
  122. package/dist/ui/debug-panel-persistence.d.ts +0 -17
  123. package/dist/ui/debug-panel-persistence.js +0 -37
@@ -16,79 +16,6 @@ export interface BaseEntity {
16
16
  createdAt?: Date;
17
17
  updatedAt?: Date;
18
18
  }
19
- export interface CollectionEntity extends BaseEntity {
20
- name: string;
21
- organization: string | OrganizationEntity;
22
- }
23
- export interface OrganizationEntity extends BaseEntity {
24
- name: string;
25
- defaultCollection?: string | CollectionEntity;
26
- }
27
- export interface UserEntity extends BaseEntity {
28
- email: string;
29
- name?: string;
30
- }
31
- export interface ClientEntity extends BaseEntity {
32
- name: string;
33
- secret: string;
34
- user: string | UserEntity;
35
- organization: string | OrganizationEntity;
36
- }
37
- export interface AssignmentEntity extends BaseEntity {
38
- organization: string | OrganizationEntity;
39
- }
40
- export interface SessionEntity extends BaseEntity {
41
- item: ItemEntity;
42
- assignment?: string | AssignmentEntity;
43
- organization?: string | OrganizationEntity;
44
- }
45
- export declare enum SessionEventType {
46
- SAVE = "save",
47
- MODEL = "model",
48
- SCORE = "score",
49
- MANUAL_SCORE = "manual-score"
50
- }
51
- export declare enum ScoreType {
52
- AUTO = "auto",
53
- MANUAL = "manual"
54
- }
55
- export interface SessionScore {
56
- points?: number;
57
- max?: number;
58
- type?: ScoreType;
59
- partialScoring?: boolean;
60
- message?: string;
61
- errors?: string[];
62
- }
63
- export interface SessionAutoScore extends SessionScore {
64
- elements?: any[];
65
- extraProps?: any;
66
- }
67
- export interface SessionManualScore extends SessionScore {
68
- }
69
- export interface SessionEventEntity extends BaseEntity {
70
- session: string | SessionEntity;
71
- type?: SessionEventType;
72
- saveEventId?: string;
73
- score?: number;
74
- }
75
- export declare enum ModeType {
76
- GATHER = "gather",
77
- VIEW = "view",
78
- EVALUATE = "evaluate"
79
- }
80
- export interface FlatSession {
81
- id: string;
82
- assignment: AssignmentEntity;
83
- item: string;
84
- data: any[];
85
- createdAt: Date;
86
- updatedAt: Date;
87
- mode: ModeType;
88
- autoScore: SessionAutoScore;
89
- manualScore: SessionManualScore;
90
- events: SessionEventEntity[];
91
- }
92
19
  export interface SemVerPrerelease {
93
20
  tag: string;
94
21
  version: number;
@@ -152,8 +79,8 @@ export interface ItemEntity extends VersionEntity, ConfigContainerEntity, Search
152
79
  /**
153
80
  * `null` as well as absent, because importers write it. JSON has no
154
81
  * `undefined`, so an item transformed from another format carries an explicit
155
- * `passage: null` for "no passage" — `isPassageEntity` has always tested for
156
- * null, so the runtime expected it while the type denied it. Excluding null
82
+ * `passage: null` for "no passage" — the runtime has always tested for
83
+ * null, so it expected it while the type denied it. Excluding null
157
84
  * only meant a host feeding real importer output through a typed path had to
158
85
  * cast it away.
159
86
  */
@@ -165,12 +92,6 @@ export interface ItemEntity extends VersionEntity, ConfigContainerEntity, Search
165
92
  configuration?: any;
166
93
  highlights?: Record<string, string[]>;
167
94
  }
168
- export interface AssignmentSessionData {
169
- assignment: AssignmentEntity;
170
- sessions: FlatSession[];
171
- items: ItemEntity[];
172
- error?: string;
173
- }
174
95
  /**
175
96
  * Metadata specifically for interpretation by clients, typically containing
176
97
  * options that are relevant for the user interface. This is not indexed for search.
@@ -185,15 +106,6 @@ export interface SettingsMetaData {
185
106
  export interface SettingsMetaDataEntity {
186
107
  settings?: SettingsMetaData;
187
108
  }
188
- /**
189
- * A reference to an item with optionally a title, settings and metadata.
190
- */
191
- export interface QuestionEntity extends SearchMetaDataEntity, SettingsMetaDataEntity {
192
- id?: string;
193
- title?: string;
194
- itemVId: string;
195
- item?: ItemEntity;
196
- }
197
109
  export type RubricBlockView = "author" | "candidate" | "proctor" | "scorer" | "testConstructor" | "tutor";
198
110
  export interface RubricBlock {
199
111
  identifier?: string;
@@ -703,32 +615,6 @@ export interface ItemSettings {
703
615
  toolParameters?: Record<string, any>;
704
616
  [key: string]: any;
705
617
  }
706
- export interface SanctionedVersionEntity extends BaseEntity {
707
- organization?: string | OrganizationEntity;
708
- match: string;
709
- pie: string;
710
- version: string;
711
- }
712
- export declare enum SanctionedVersionChangeStatus {
713
- PENDING = "pending",
714
- IN_PROGRESS = "in_progress",
715
- COMPLETED = "completed",
716
- FAILED = "failed"
717
- }
718
- export interface SanctionedVersionChangeRequest {
719
- pie: string;
720
- match: string;
721
- version: string;
722
- }
723
- export interface SanctionedVersionChangeEntity extends BaseEntity {
724
- organization?: string | OrganizationEntity;
725
- createdBy: string | UserEntity;
726
- status: SanctionedVersionChangeStatus;
727
- requestedChanges: SanctionedVersionChangeRequest[];
728
- beforeState: SanctionedVersionEntity[];
729
- summary?: string;
730
- jobId: string;
731
- }
732
618
  export type PlayerMode = "gather" | "view" | "evaluate" | "author";
733
619
  export type PlayerRole = "student" | "instructor";
734
620
  export interface Env {
@@ -736,6 +622,27 @@ export interface Env {
736
622
  role: PlayerRole;
737
623
  partialScoring?: boolean;
738
624
  }
625
+ /** The `detail` of the `player-error` event `pie-item-player` dispatches. */
626
+ export interface PieItemPlayerErrorDetail {
627
+ /** The failure, e.g. `ITEM_PLAYER_LOAD_ERROR` or `PIE_CONTROLLER_RUNTIME_ERROR`. */
628
+ code: string;
629
+ message: string;
630
+ /**
631
+ * True when the item stays usable: a failed update leaves it as it was, and
632
+ * a failed controller falls back to the authored model. False when the
633
+ * player has no item to show.
634
+ */
635
+ recoverable: boolean;
636
+ /** On a load error, the loading step that failed, and the strategy and mode it loaded under. */
637
+ stage?: string;
638
+ strategy?: string;
639
+ mode?: string;
640
+ cause?: unknown;
641
+ /** On a controller error, the element's tag and id, and what the controller looked like. */
642
+ elementName?: string;
643
+ elementId?: string;
644
+ controllerShape?: string;
645
+ }
739
646
  export interface OutcomeResponse {
740
647
  id: string;
741
648
  element: string;
@@ -744,8 +651,14 @@ export interface OutcomeResponse {
744
651
  completed?: boolean;
745
652
  [key: string]: any;
746
653
  }
654
+ /**
655
+ * Persists `properties` into the stored session `id` of element `element`. The
656
+ * player passes it to `model()`, as `PieUpdateSession` in
657
+ * `@pie-element/shared-types` declares.
658
+ */
659
+ export type PieUpdateSession = (id: string, element: string, properties: Record<string, unknown>) => Promise<void>;
747
660
  export interface PieController {
748
- model(model: PieModel, sessionData: any[], env?: any): Promise<PieModel>;
661
+ model(model: PieModel, sessionData: any[], env?: any, updateSession?: PieUpdateSession): Promise<PieModel>;
749
662
  outcome(modelOrSessionData: PieModel | any[], sessionOrEnv?: any, env?: any): Promise<OutcomeResponse>;
750
663
  score: (config: object, session: object, env: object) => Promise<object>;
751
664
  createCorrectResponseSession: (config: object, env: object) => Promise<object>;
@@ -856,202 +769,8 @@ export declare class InsertSoundEvent extends CustomEvent<SoundHandler> {
856
769
  static TYPE: string;
857
770
  constructor(handler: SoundHandler);
858
771
  }
859
- export declare const isPassageEntity: (passage: string | PassageEntity | null | undefined) => passage is PassageEntity;
860
- export declare function isPrerelease(version: any): version is SemVer;
861
- export declare function formatVersion(semVer: SemVer): string;
862
772
  export interface PieElement extends HTMLElement {
863
773
  model: PieModel;
864
774
  configuration: any;
865
775
  session: any[];
866
776
  }
867
- export type SessionChangedDetail = {
868
- complete: boolean;
869
- component: any;
870
- };
871
- export declare class SessionChangedEvent extends CustomEvent<SessionChangedDetail> {
872
- readonly component: string;
873
- readonly complete: boolean;
874
- static TYPE: string;
875
- constructor(component: string, complete: boolean);
876
- }
877
- interface ItemCfg extends ConfigEntity {
878
- }
879
- interface ItemWPassageCfg {
880
- pie: ItemCfg;
881
- passage: ConfigEntity;
882
- }
883
- export interface LoadResponse {
884
- js: {
885
- view: string[];
886
- };
887
- item: ItemCfg | ItemWPassageCfg;
888
- session: {
889
- id: string;
890
- data: any[];
891
- };
892
- }
893
- export interface Tracker {
894
- track(message: string, ...args: any[]): void;
895
- start(label: string): void;
896
- end(label: string, metadata?: {
897
- [key: string]: any;
898
- }): void;
899
- }
900
- /**
901
- * Interface for storing tracker messages with timestamps
902
- */
903
- /**
904
- * Interface for storing tracker messages with timestamps
905
- */
906
- export interface TrackerMessage {
907
- timestamp: Date;
908
- message: string;
909
- args: any[];
910
- formattedMessage: string;
911
- }
912
- /**
913
- * Enhanced tracker that stores messages with timestamps
914
- */
915
- export interface EnhancedTracker extends Tracker {
916
- /**
917
- * Get all raw tracker messages ordered by timestamp (ascending)
918
- */
919
- getMessages(): TrackerMessage[];
920
- /**
921
- * Get a formatted multi-line representation of all tracker messages
922
- */
923
- getFormattedMessages(): string;
924
- }
925
- export interface ScoreResponse {
926
- session: FlatSession;
927
- score: SessionScore;
928
- empty?: boolean;
929
- [key: string]: any;
930
- }
931
- export interface VersionDiff {
932
- version: SemVer;
933
- previousVersion: SemVer | null;
934
- createdAt: Date;
935
- changes: {
936
- added: Record<string, any>;
937
- removed: Record<string, any>;
938
- modified: Record<string, {
939
- previous: any;
940
- current: any;
941
- }>;
942
- };
943
- changeCount: number;
944
- }
945
- export interface RoleToOrganizationsMapping {
946
- id?: string;
947
- role: string;
948
- organizations: OrganizationEntity[] | string[];
949
- createdAt?: Date;
950
- updatedAt?: Date;
951
- }
952
- export declare enum StandardType {
953
- ROOT = 0,
954
- SUBJECT = 1,
955
- LEVEL = 2,
956
- STANDARD = 3
957
- }
958
- export interface HierarchyInfo {
959
- root?: {
960
- id: string;
961
- guid: string;
962
- title: string;
963
- };
964
- subject?: {
965
- id: string;
966
- guid: string;
967
- title: string;
968
- };
969
- level?: {
970
- id: string;
971
- guid: string;
972
- title: string;
973
- grades: number[];
974
- };
975
- }
976
- export interface CmsLearningStandardEntity extends BaseEntity {
977
- guid: string;
978
- abbr?: string;
979
- type: StandardType;
980
- parentId?: string;
981
- parentGuid?: string;
982
- path?: string;
983
- depth: number;
984
- ancestors: string[];
985
- hierarchy?: HierarchyInfo;
986
- title?: string;
987
- description?: string;
988
- sequence?: string;
989
- orderIndex?: number;
990
- subjectArea?: string;
991
- subjectName?: string;
992
- category?: string;
993
- abType?: string;
994
- abLabel?: string;
995
- setName?: string;
996
- publication?: string;
997
- adopted?: string;
998
- grades: number[];
999
- gradeNames?: string[];
1000
- properties: Record<string, string>;
1001
- status?: "active" | "retired" | "deprecated";
1002
- lastModifiedAt?: Date;
1003
- replacesGuid?: string;
1004
- replacedByGuid?: string;
1005
- descriptionHtml?: string;
1006
- lastSyncedAt?: Date;
1007
- }
1008
- export interface ItemBankConfig {
1009
- collectionId: string;
1010
- subject?: string;
1011
- gradeLevels?: number[];
1012
- orderIndex: number;
1013
- }
1014
- export interface DOKDistribution {
1015
- dok1?: number;
1016
- dok2?: number;
1017
- dok3?: number;
1018
- dok4?: number;
1019
- }
1020
- export interface AssessmentGoal {
1021
- dokDistribution?: DOKDistribution;
1022
- constructedResponseCount?: number;
1023
- passageGoals?: string;
1024
- totalItemCount?: {
1025
- target?: number;
1026
- min?: number;
1027
- max?: number;
1028
- };
1029
- }
1030
- export interface StudioImportMetadata {
1031
- studioAssessmentProgramId?: string;
1032
- studioPublicId?: string;
1033
- importedAt?: Date;
1034
- }
1035
- export interface CmsBlueprintEntity extends BaseEntity {
1036
- name: string;
1037
- description?: string;
1038
- subject?: string;
1039
- standardSet?: string;
1040
- gradeLevels: number[];
1041
- states?: string[];
1042
- itemBankConfigs: ItemBankConfig[];
1043
- assessmentGoal?: AssessmentGoal;
1044
- claimFramework?: "SBAC" | "PARCC" | "STATE" | "CUSTOM";
1045
- claimTargets?: string[];
1046
- useSBACClusterTarget?: boolean;
1047
- clusters?: string[];
1048
- studioImportMetadata?: StudioImportMetadata;
1049
- originalPrompt?: string;
1050
- }
1051
- export interface CmsBlueprintItemEntity extends BaseEntity {
1052
- blueprintId: string;
1053
- standardGuid: string;
1054
- count: number;
1055
- details?: string;
1056
- assessmentId?: string;
1057
- }
@@ -1,28 +1,3 @@
1
- export var SessionEventType;
2
- (function (SessionEventType) {
3
- SessionEventType["SAVE"] = "save";
4
- SessionEventType["MODEL"] = "model";
5
- SessionEventType["SCORE"] = "score";
6
- SessionEventType["MANUAL_SCORE"] = "manual-score";
7
- })(SessionEventType || (SessionEventType = {}));
8
- export var ScoreType;
9
- (function (ScoreType) {
10
- ScoreType["AUTO"] = "auto";
11
- ScoreType["MANUAL"] = "manual";
12
- })(ScoreType || (ScoreType = {}));
13
- export var ModeType;
14
- (function (ModeType) {
15
- ModeType["GATHER"] = "gather";
16
- ModeType["VIEW"] = "view";
17
- ModeType["EVALUATE"] = "evaluate";
18
- })(ModeType || (ModeType = {}));
19
- export var SanctionedVersionChangeStatus;
20
- (function (SanctionedVersionChangeStatus) {
21
- SanctionedVersionChangeStatus["PENDING"] = "pending";
22
- SanctionedVersionChangeStatus["IN_PROGRESS"] = "in_progress";
23
- SanctionedVersionChangeStatus["COMPLETED"] = "completed";
24
- SanctionedVersionChangeStatus["FAILED"] = "failed";
25
- })(SanctionedVersionChangeStatus || (SanctionedVersionChangeStatus = {}));
26
1
  /**
27
2
  * During the loading of elements from PIE bundles, we do a trick where we make
28
3
  * editor components available as web components by appending this to the element name.
@@ -74,46 +49,3 @@ export class InsertSoundEvent extends CustomEvent {
74
49
  this.handler = handler;
75
50
  }
76
51
  }
77
- export const isPassageEntity = (passage) => typeof passage === "object" && passage !== null;
78
- export function isPrerelease(version) {
79
- return (typeof version === "object" &&
80
- version !== null &&
81
- typeof version.major === "number" &&
82
- typeof version.minor === "number" &&
83
- typeof version.patch === "number" &&
84
- !!version.prerelease && // Check if prerelease exists
85
- typeof version.prerelease.tag === "string" &&
86
- typeof version.prerelease.version === "number");
87
- }
88
- export function formatVersion(semVer) {
89
- if (!semVer)
90
- return "";
91
- const base = [semVer.major, semVer.minor, semVer.patch].join(".");
92
- if (isPrerelease(semVer) && semVer.prerelease) {
93
- const prerelease = [semVer.prerelease.tag, semVer.prerelease.version].join(".");
94
- return `${base}-${prerelease}`;
95
- }
96
- return base;
97
- }
98
- export class SessionChangedEvent extends CustomEvent {
99
- component;
100
- complete;
101
- static TYPE = "session-changed";
102
- constructor(component, complete) {
103
- super(SessionChangedEvent.TYPE, {
104
- bubbles: true,
105
- composed: true,
106
- detail: { complete, component },
107
- });
108
- this.component = component;
109
- this.complete = complete;
110
- }
111
- }
112
- // CMS Types (copied from @pie-api-aws/datastore to avoid importing server-only package)
113
- export var StandardType;
114
- (function (StandardType) {
115
- StandardType[StandardType["ROOT"] = 0] = "ROOT";
116
- StandardType[StandardType["SUBJECT"] = 1] = "SUBJECT";
117
- StandardType[StandardType["LEVEL"] = 2] = "LEVEL";
118
- StandardType[StandardType["STANDARD"] = 3] = "STANDARD";
119
- })(StandardType || (StandardType = {}));
@@ -1 +1,13 @@
1
1
  export declare function coerceBooleanLike(value: boolean | string | null | undefined, defaultValue?: boolean): boolean;
2
+ /**
3
+ * Reads a boolean attribute value: present is true and absent is false, as in
4
+ * HTML, except that the words `coerceBooleanLike` reads as false stay false.
5
+ */
6
+ export declare function coerceBooleanAttribute(value: string | null): boolean;
7
+ /**
8
+ * `customElement.extend` hook for a Svelte element with `type: "Boolean"`
9
+ * props. Svelte reads those by presence, so `show-bottom-border="false"` sets
10
+ * the prop to `true`; this passes Svelte a removed attribute whenever
11
+ * `coerceBooleanAttribute` reads the value as false.
12
+ */
13
+ export declare function coerceBooleanAttributes<Base extends CustomElementConstructor>(ElementClass: Base): Base;
@@ -17,3 +17,36 @@ export function coerceBooleanLike(value, defaultValue = false) {
17
17
  }
18
18
  return Boolean(normalizedValue);
19
19
  }
20
+ /**
21
+ * Reads a boolean attribute value: present is true and absent is false, as in
22
+ * HTML, except that the words `coerceBooleanLike` reads as false stay false.
23
+ */
24
+ export function coerceBooleanAttribute(value) {
25
+ return value !== null && coerceBooleanLike(value, true);
26
+ }
27
+ const isBooleanProp = (element, attribute) => {
28
+ const definitions = element.$$p_d;
29
+ if (!definitions)
30
+ return false;
31
+ return Object.entries(definitions).some(([prop, definition]) => definition.type === "Boolean" &&
32
+ (definition.attribute ?? prop.toLowerCase()) === attribute);
33
+ };
34
+ /**
35
+ * `customElement.extend` hook for a Svelte element with `type: "Boolean"`
36
+ * props. Svelte reads those by presence, so `show-bottom-border="false"` sets
37
+ * the prop to `true`; this passes Svelte a removed attribute whenever
38
+ * `coerceBooleanAttribute` reads the value as false.
39
+ */
40
+ export function coerceBooleanAttributes(ElementClass) {
41
+ const baseCallback = ElementClass.prototype.attributeChangedCallback;
42
+ return class extends ElementClass {
43
+ attributeChangedCallback(name, oldValue, newValue) {
44
+ const value = newValue !== null &&
45
+ isBooleanProp(this, name) &&
46
+ !coerceBooleanAttribute(newValue)
47
+ ? null
48
+ : newValue;
49
+ baseCallback?.call(this, name, oldValue, value);
50
+ }
51
+ };
52
+ }
@@ -19,7 +19,7 @@
19
19
  * plain `tsc`, so it cannot inline a stylesheet. Bundler-built player packages
20
20
  * import it with Vite's `?raw` and hand the text over.
21
21
  */
22
- export type ContentStylesResult = "installed" | "already-installed" | "opted-out" | "no-document";
22
+ export type ContentStylesResult = "installed" | "already-installed" | "host-supplied" | "opted-out" | "no-document";
23
23
  /**
24
24
  * True when the host declared `<html data-pie-content-styles="host">`, i.e. it
25
25
  * takes ownership of loading the stylesheet.
@@ -42,7 +42,16 @@ export declare function contentStylesOptedOut(): boolean;
42
42
  */
43
43
  export declare function contentStylesPresent(): boolean;
44
44
  /**
45
- * Installs `cssText` as a document-level stylesheet, once per document.
45
+ * Installs `cssText` as a document-level stylesheet, once per document, unless
46
+ * the host already supplies one.
47
+ *
48
+ * A host copy is recognised by the sentinel wherever it sits, including one
49
+ * confined to the host's player subtree with `@scope`. Such a host scoped its
50
+ * copy because the stylesheet's bare element selectors would otherwise reach
51
+ * its own UI, so a global copy from the player would reintroduce exactly that.
52
+ * A host copy can also land after this runs — a lazily injected `<style>`, a
53
+ * `<link>` still loading — so the installed copy keeps watching and removes
54
+ * itself when one appears, as it does when the host sets the opt-out late.
46
55
  *
47
56
  * The stylesheet is **prepended** to `<head>` and deliberately left out of a
48
57
  * cascade layer. Prepending reproduces the placement hosts were told to use by
@@ -60,22 +69,15 @@ export declare function contentStylesPresent(): boolean;
60
69
  */
61
70
  export declare function installContentStyles(cssText: string, source: string): ContentStylesResult;
62
71
  /**
63
- * Reports, once per page, the two ways content styling can go wrong. Neither is
64
- * detectable synchronously — a host copy may still be in flight as an async
65
- * `<link>` — so the check is deferred.
66
- *
67
- * - **Missing**: the host opted out and then loaded nothing, so authored content
68
- * renders unstyled. This is the failure the old host-import contract produced
69
- * silently.
70
- * - **Duplicated**: the host still imports `components.css` itself *and* the
71
- * player installed a copy. Rendering is correct while the two agree, but the
72
- * host's copy loads later and therefore wins ties at equal specificity — so a
73
- * host copy pinned to an older `@pie-players/pie-theme` silently overrides the
74
- * player's newer rules. Harmless today, a confusing override tomorrow.
72
+ * Reports, once per page, a host that opted out and then loaded no content
73
+ * stylesheet, so authored content renders unstyled — the failure the old
74
+ * host-import contract produced silently. Not detectable synchronously — a host
75
+ * copy may still be in flight as an async `<link>` — so the check is deferred.
75
76
  */
76
77
  export declare function auditContentStyles(source: string): void;
77
78
  /**
78
- * Test-only: clears the once-per-page warning latch and cancels any pending
79
- * deferred check, so a timer scheduled by one test cannot warn during the next.
79
+ * Test-only: clears the once-per-page warning latch, cancels any pending
80
+ * deferred check and stops watching for a host copy, so state from one test
81
+ * cannot act during the next.
80
82
  */
81
83
  export declare function resetContentStylesWarningForTesting(): void;