@pie-element/shared-types 0.2.0 → 0.2.1-next.20261011221311

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.
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Building blocks of an element's authoring configuration: the object a host passes to the
3
+ * `<tag>-config` custom element to decide which settings the author sees and how editors behave.
4
+ *
5
+ * Each element declares its own `<Name>Configuration` interface from these, and its JSON Schema is
6
+ * generated from that interface. Descriptions are carried over from the legacy `pie-elements`
7
+ * config schemas, so they appear in the generated schemas unchanged.
8
+ */
9
+ export interface ConfigureProp {
10
+ /** Indicates if the item has to be displayed in the Settings Panel */
11
+ settings?: boolean;
12
+ /** Indicates the label for the item that has to be displayed in the Settings Panel */
13
+ label?: string;
14
+ }
15
+ export interface ConfigurePropWithEnabled extends ConfigureProp {
16
+ /**
17
+ * Indicates the value of the item if it affects config-ui
18
+ * (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
19
+ */
20
+ enabled?: boolean;
21
+ }
22
+ export interface EditableHtmlButtonConfigure {
23
+ /** Indicates if the plugin is disabled or not */
24
+ disabled?: boolean;
25
+ }
26
+ export interface CustomPlugin {
27
+ /**
28
+ * The name of the custom event. It needs to be valid (only letters, numbers and "_" can be used).
29
+ * The event is emitted with the "PIE-" prefix.
30
+ */
31
+ event: string;
32
+ /** The alt for the custom button icon */
33
+ iconAlt: string;
34
+ /** The icon type. Currently, only "SVG" is supported. */
35
+ iconType: string;
36
+ /** The icon string. Currently, only SVG is supported, so it needs to be a valid svg. */
37
+ icon: string;
38
+ }
39
+ /** Toolbar plugins of an editable-html field, keyed by plugin name. */
40
+ export interface EditableHtmlConfigureProp {
41
+ math?: EditableHtmlButtonConfigure;
42
+ audio?: EditableHtmlButtonConfigure;
43
+ video?: EditableHtmlButtonConfigure;
44
+ image?: EditableHtmlButtonConfigure;
45
+ /**
46
+ * An array of objects that determine custom plugins.
47
+ * A custom plugin is an object which determines how the button will look like (icon) and the event
48
+ * name that will be triggered when the button gets pressed (event).
49
+ */
50
+ customPlugins?: CustomPlugin[];
51
+ blockquote?: EditableHtmlButtonConfigure;
52
+ h3?: EditableHtmlButtonConfigure;
53
+ characters?: EditableHtmlButtonConfigure;
54
+ bold?: EditableHtmlButtonConfigure;
55
+ html?: EditableHtmlButtonConfigure;
56
+ italic?: EditableHtmlButtonConfigure;
57
+ ol_list?: EditableHtmlButtonConfigure;
58
+ redo?: EditableHtmlButtonConfigure;
59
+ strikethrough?: EditableHtmlButtonConfigure;
60
+ sub?: EditableHtmlButtonConfigure;
61
+ sup?: EditableHtmlButtonConfigure;
62
+ table?: EditableHtmlButtonConfigure;
63
+ ul_list?: EditableHtmlButtonConfigure;
64
+ underline?: EditableHtmlButtonConfigure;
65
+ undo?: EditableHtmlButtonConfigure;
66
+ textAlign?: EditableHtmlButtonConfigure;
67
+ showParagraphs?: EditableHtmlButtonConfigure;
68
+ separateParagraphs?: EditableHtmlButtonConfigure;
69
+ pasteFormatting?: EditableHtmlButtonConfigure;
70
+ superscript?: EditableHtmlButtonConfigure;
71
+ subscript?: EditableHtmlButtonConfigure;
72
+ languageCharacters?: EditableHtmlButtonConfigure;
73
+ responseArea?: EditableHtmlButtonConfigure;
74
+ }
75
+ export interface EditableHtmlPluginConfigure extends ConfigureProp {
76
+ /** Configuration for editable-html */
77
+ inputConfiguration?: EditableHtmlConfigureProp;
78
+ }
79
+ export interface EditableHtmlPluginConfigureRequired extends EditableHtmlPluginConfigure {
80
+ /** Indicates if the item is required and the value cannot be empty */
81
+ required?: boolean;
82
+ }
83
+ /** Maximum image dimensions per editable field. Elements extend it with their own fields. */
84
+ export interface ConfigureMaxImageDimensionsProp {
85
+ /** Indicates the max dimension for images in teacher instructions */
86
+ teacherInstructions?: number;
87
+ /**
88
+ * Indicates the max dimension for images in prompt - this is also the default dimension for all
89
+ * other input fields if it's not specified
90
+ */
91
+ prompt?: number;
92
+ /** Indicates the max dimension for images in rationale */
93
+ rationale?: number;
94
+ }
95
+ export interface ConfigureMathMLProp {
96
+ /** Indicates if model should have mathML output instead of latex */
97
+ mmlOutput?: boolean;
98
+ /** Indicates if mathML that's already in model should be editable */
99
+ mmlEditing?: boolean;
100
+ }
101
+ export interface ConfigureLanguageOptionsProp {
102
+ /** Value of the language option */
103
+ value: string;
104
+ /** Label of the language option */
105
+ label: string;
106
+ }
107
+ export interface ConfigureLanguageOptions {
108
+ label: string;
109
+ options: ConfigureLanguageOptionsProp[];
110
+ }
111
+ /**
112
+ * Indicates the dimensions configuration for the authoring container.
113
+ * Note: Some items have a default minimum width because of their content, but if a lower minWidth is
114
+ * provided, it will be used.
115
+ */
116
+ export interface ContentDimensions {
117
+ maxHeight?: string | number;
118
+ maxWidth?: string | number;
119
+ minHeight?: string | number;
120
+ minWidth?: string | number;
121
+ }
122
+ /** Settings every configuration may carry; `validate()` receives them. */
123
+ export interface CommonConfigSettings {
124
+ /** Disable the settings panel */
125
+ settingsPanelDisabled?: boolean;
126
+ spellCheck?: ConfigurePropWithEnabled;
127
+ maxImageWidth?: ConfigureMaxImageDimensionsProp;
128
+ maxImageHeight?: ConfigureMaxImageDimensionsProp;
129
+ withRubric?: ConfigureProp;
130
+ language?: ConfigurePropWithEnabled;
131
+ languageChoices?: ConfigureLanguageOptions;
132
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Building blocks of an element's authoring configuration: the object a host passes to the
3
+ * `<tag>-config` custom element to decide which settings the author sees and how editors behave.
4
+ *
5
+ * Each element declares its own `<Name>Configuration` interface from these, and its JSON Schema is
6
+ * generated from that interface. Descriptions are carried over from the legacy `pie-elements`
7
+ * config schemas, so they appear in the generated schemas unchanged.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=authoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring.js","sourceRoot":"","sources":["../src/authoring.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG","sourcesContent":["/**\n * Building blocks of an element's authoring configuration: the object a host passes to the\n * `<tag>-config` custom element to decide which settings the author sees and how editors behave.\n *\n * Each element declares its own `<Name>Configuration` interface from these, and its JSON Schema is\n * generated from that interface. Descriptions are carried over from the legacy `pie-elements`\n * config schemas, so they appear in the generated schemas unchanged.\n */\n\nexport interface ConfigureProp {\n /** Indicates if the item has to be displayed in the Settings Panel */\n settings?: boolean;\n /** Indicates the label for the item that has to be displayed in the Settings Panel */\n label?: string;\n}\n\nexport interface ConfigurePropWithEnabled extends ConfigureProp {\n /**\n * Indicates the value of the item if it affects config-ui\n * (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)\n */\n enabled?: boolean;\n}\n\nexport interface EditableHtmlButtonConfigure {\n /** Indicates if the plugin is disabled or not */\n disabled?: boolean;\n}\n\nexport interface CustomPlugin {\n /**\n * The name of the custom event. It needs to be valid (only letters, numbers and \"_\" can be used).\n * The event is emitted with the \"PIE-\" prefix.\n */\n event: string;\n /** The alt for the custom button icon */\n iconAlt: string;\n /** The icon type. Currently, only \"SVG\" is supported. */\n iconType: string;\n /** The icon string. Currently, only SVG is supported, so it needs to be a valid svg. */\n icon: string;\n}\n\n/** Toolbar plugins of an editable-html field, keyed by plugin name. */\nexport interface EditableHtmlConfigureProp {\n math?: EditableHtmlButtonConfigure;\n audio?: EditableHtmlButtonConfigure;\n video?: EditableHtmlButtonConfigure;\n image?: EditableHtmlButtonConfigure;\n /**\n * An array of objects that determine custom plugins.\n * A custom plugin is an object which determines how the button will look like (icon) and the event\n * name that will be triggered when the button gets pressed (event).\n */\n customPlugins?: CustomPlugin[];\n blockquote?: EditableHtmlButtonConfigure;\n h3?: EditableHtmlButtonConfigure;\n characters?: EditableHtmlButtonConfigure;\n bold?: EditableHtmlButtonConfigure;\n html?: EditableHtmlButtonConfigure;\n italic?: EditableHtmlButtonConfigure;\n ol_list?: EditableHtmlButtonConfigure;\n redo?: EditableHtmlButtonConfigure;\n strikethrough?: EditableHtmlButtonConfigure;\n sub?: EditableHtmlButtonConfigure;\n sup?: EditableHtmlButtonConfigure;\n table?: EditableHtmlButtonConfigure;\n ul_list?: EditableHtmlButtonConfigure;\n underline?: EditableHtmlButtonConfigure;\n undo?: EditableHtmlButtonConfigure;\n textAlign?: EditableHtmlButtonConfigure;\n showParagraphs?: EditableHtmlButtonConfigure;\n separateParagraphs?: EditableHtmlButtonConfigure;\n pasteFormatting?: EditableHtmlButtonConfigure;\n superscript?: EditableHtmlButtonConfigure;\n subscript?: EditableHtmlButtonConfigure;\n languageCharacters?: EditableHtmlButtonConfigure;\n responseArea?: EditableHtmlButtonConfigure;\n}\n\nexport interface EditableHtmlPluginConfigure extends ConfigureProp {\n /** Configuration for editable-html */\n inputConfiguration?: EditableHtmlConfigureProp;\n}\n\nexport interface EditableHtmlPluginConfigureRequired extends EditableHtmlPluginConfigure {\n /** Indicates if the item is required and the value cannot be empty */\n required?: boolean;\n}\n\n/** Maximum image dimensions per editable field. Elements extend it with their own fields. */\nexport interface ConfigureMaxImageDimensionsProp {\n /** Indicates the max dimension for images in teacher instructions */\n teacherInstructions?: number;\n /**\n * Indicates the max dimension for images in prompt - this is also the default dimension for all\n * other input fields if it's not specified\n */\n prompt?: number;\n /** Indicates the max dimension for images in rationale */\n rationale?: number;\n}\n\nexport interface ConfigureMathMLProp {\n /** Indicates if model should have mathML output instead of latex */\n mmlOutput?: boolean;\n /** Indicates if mathML that's already in model should be editable */\n mmlEditing?: boolean;\n}\n\nexport interface ConfigureLanguageOptionsProp {\n /** Value of the language option */\n value: string;\n /** Label of the language option */\n label: string;\n}\n\nexport interface ConfigureLanguageOptions {\n label: string;\n options: ConfigureLanguageOptionsProp[];\n}\n\n/**\n * Indicates the dimensions configuration for the authoring container.\n * Note: Some items have a default minimum width because of their content, but if a lower minWidth is\n * provided, it will be used.\n */\nexport interface ContentDimensions {\n maxHeight?: string | number;\n maxWidth?: string | number;\n minHeight?: string | number;\n minWidth?: string | number;\n}\n\n/** Settings every configuration may carry; `validate()` receives them. */\nexport interface CommonConfigSettings {\n /** Disable the settings panel */\n settingsPanelDisabled?: boolean;\n spellCheck?: ConfigurePropWithEnabled;\n maxImageWidth?: ConfigureMaxImageDimensionsProp;\n maxImageHeight?: ConfigureMaxImageDimensionsProp;\n withRubric?: ConfigureProp;\n language?: ConfigurePropWithEnabled;\n languageChoices?: ConfigureLanguageOptions;\n}\n"]}
@@ -17,25 +17,6 @@ export interface PieDocsSourcePointer {
17
17
  */
18
18
  path?: string;
19
19
  }
20
- export interface PieDocsPropertyMetadata {
21
- title?: string;
22
- description?: string;
23
- notes?: string;
24
- type?: string;
25
- required?: boolean;
26
- enum?: Array<string | number | boolean | null>;
27
- minimum?: number;
28
- maximum?: number;
29
- minLength?: number;
30
- maxLength?: number;
31
- pattern?: string;
32
- itemType?: string;
33
- examples?: unknown[];
34
- }
35
- export interface PieDocsViewMetadata {
36
- pie?: Record<string, PieDocsPropertyMetadata>;
37
- config?: Record<string, PieDocsPropertyMetadata>;
38
- }
39
20
  export interface PieDocsViewContract {
40
21
  /**
41
22
  * Logical view id, for example: delivery, author, print.
@@ -49,15 +30,6 @@ export interface PieDocsViewContract {
49
30
  * Source pointer for author/configuration defaults.
50
31
  */
51
32
  config: PieDocsSourcePointer;
52
- /**
53
- * Optional view-specific notes.
54
- */
55
- description?: string;
56
- /**
57
- * Optional manual metadata to enrich generated docs with human context
58
- * and constraints. Paths should match flattened generated property paths.
59
- */
60
- metadata?: PieDocsViewMetadata;
61
33
  }
62
34
  export interface PieDocsContract {
63
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"docs-contract.js","sourceRoot":"","sources":["../src/docs-contract.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Contracts used by generated PIE documentation tooling.\n */\n\nexport type PieElementFramework = 'react' | 'svelte';\n\nexport interface PieDocsSourcePointer {\n /**\n * Source file path relative to the element package root.\n */\n file: string;\n\n /**\n * Export to read from the file. Defaults to `default`.\n */\n exportName?: string;\n\n /**\n * Dot-delimited path within the exported value.\n * Example: \"model\" or \"configuration.prompt\".\n */\n path?: string;\n}\n\nexport interface PieDocsPropertyMetadata {\n title?: string;\n description?: string;\n notes?: string;\n type?: string;\n required?: boolean;\n enum?: Array<string | number | boolean | null>;\n minimum?: number;\n maximum?: number;\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n itemType?: string;\n examples?: unknown[];\n}\n\nexport interface PieDocsViewMetadata {\n pie?: Record<string, PieDocsPropertyMetadata>;\n config?: Record<string, PieDocsPropertyMetadata>;\n}\n\nexport interface PieDocsViewContract {\n /**\n * Logical view id, for example: delivery, author, print.\n */\n view: string;\n\n /**\n * Source pointer for delivery model defaults.\n */\n pie: PieDocsSourcePointer;\n\n /**\n * Source pointer for author/configuration defaults.\n */\n config: PieDocsSourcePointer;\n\n /**\n * Optional view-specific notes.\n */\n description?: string;\n\n /**\n * Optional manual metadata to enrich generated docs with human context\n * and constraints. Paths should match flattened generated property paths.\n */\n metadata?: PieDocsViewMetadata;\n}\n\nexport interface PieDocsContract {\n /**\n * Globally unique PIE element id.\n * Example: \"multiple-choice\".\n */\n elementName: string;\n\n /**\n * npm package name.\n * Example: \"@pie-element/multiple-choice\".\n */\n packageName: string;\n\n framework: PieElementFramework;\n\n /**\n * Optional human summary. Used by Markdown header.\n */\n summary?: string;\n\n /**\n * Optional supported runtime modes.\n */\n supportedModes?: string[];\n\n views: PieDocsViewContract[];\n}\n\nexport interface PieDocsPropertyContract {\n path: string;\n type: string;\n required: boolean;\n defaultValue?: unknown;\n description?: string;\n}\n"]}
1
+ {"version":3,"file":"docs-contract.js","sourceRoot":"","sources":["../src/docs-contract.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Contracts used by generated PIE documentation tooling.\n */\n\nexport type PieElementFramework = 'react' | 'svelte';\n\nexport interface PieDocsSourcePointer {\n /**\n * Source file path relative to the element package root.\n */\n file: string;\n\n /**\n * Export to read from the file. Defaults to `default`.\n */\n exportName?: string;\n\n /**\n * Dot-delimited path within the exported value.\n * Example: \"model\" or \"configuration.prompt\".\n */\n path?: string;\n}\n\nexport interface PieDocsViewContract {\n /**\n * Logical view id, for example: delivery, author, print.\n */\n view: string;\n\n /**\n * Source pointer for delivery model defaults.\n */\n pie: PieDocsSourcePointer;\n\n /**\n * Source pointer for author/configuration defaults.\n */\n config: PieDocsSourcePointer;\n}\n\nexport interface PieDocsContract {\n /**\n * Globally unique PIE element id.\n * Example: \"multiple-choice\".\n */\n elementName: string;\n\n /**\n * npm package name.\n * Example: \"@pie-element/multiple-choice\".\n */\n packageName: string;\n\n framework: PieElementFramework;\n\n /**\n * Optional human summary. Used by Markdown header.\n */\n summary?: string;\n\n /**\n * Optional supported runtime modes.\n */\n supportedModes?: string[];\n\n views: PieDocsViewContract[];\n}\n\nexport interface PieDocsPropertyContract {\n path: string;\n type: string;\n required: boolean;\n defaultValue?: unknown;\n description?: string;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -3,5 +3,6 @@
3
3
  *
4
4
  * Framework-agnostic TypeScript types for PIE elements.
5
5
  */
6
+ export * from './authoring.js';
6
7
  export * from './docs-contract.js';
7
8
  export * from './types.js';
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Framework-agnostic TypeScript types for PIE elements.
5
5
  */
6
+ export * from './authoring.js';
6
7
  export * from './docs-contract.js';
7
8
  export * from './types.js';
8
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC","sourcesContent":["/**\n * PIE Shared Types\n *\n * Framework-agnostic TypeScript types for PIE elements.\n */\n\nexport * from './docs-contract.js';\nexport * from './types.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC","sourcesContent":["/**\n * PIE Shared Types\n *\n * Framework-agnostic TypeScript types for PIE elements.\n */\n\nexport * from './authoring.js';\nexport * from './docs-contract.js';\nexport * from './types.js';\n"]}
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Core PIE specification types
3
3
  */
4
+ import type { CommonConfigSettings } from './authoring.js';
4
5
  /**
5
6
  * Reference to a media asset and its playable encodings.
6
7
  *
@@ -199,10 +200,25 @@ export interface AccessibilityCatalog {
199
200
  cards: CatalogCard[];
200
201
  }
201
202
  export interface PieModel {
203
+ /** Identifier to identify the Pie Element in html markup, Must be unique within a pie item config. */
202
204
  id: string;
205
+ /** The html Element tag name: the key in the item config's `elements` map, e.g. "multiple-choice" */
203
206
  element: string;
207
+ /** QTI-aligned accessibility catalogs whose cards dock to content nodes by `data-catalog-idref` */
204
208
  accessibilityCatalogs?: AccessibilityCatalog[];
205
209
  }
210
+ /** Host-supplied CSS scoped to the element: `rules` is a stylesheet whose class names are listed in `names`. */
211
+ export interface ExtraCSSRules {
212
+ names?: string[];
213
+ rules?: string;
214
+ }
215
+ /** Images that replace the default audio play button. */
216
+ export interface CustomAudioButton {
217
+ /** image url for the play state */
218
+ playImage: string;
219
+ /** image url for the pause state */
220
+ pauseImage: string;
221
+ }
206
222
  export interface PieTheme {
207
223
  primary?: string;
208
224
  secondary?: string;
@@ -239,27 +255,6 @@ export interface OutcomeResult {
239
255
  export interface ValidationErrors {
240
256
  [key: string]: string;
241
257
  }
242
- export interface CommonConfigSettings {
243
- settingsPanelDisabled?: boolean;
244
- spellCheck?: ConfigureProp;
245
- maxImageWidth?: ConfigureProp;
246
- maxImageHeight?: ConfigureProp;
247
- withRubric?: ConfigureProp;
248
- language?: ConfigureProp;
249
- languageChoices?: ConfigureLanguageOptions;
250
- }
251
- export interface ConfigureProp {
252
- settings?: boolean;
253
- label?: string;
254
- enabled?: boolean;
255
- }
256
- export interface ConfigureLanguageOptions {
257
- label: string;
258
- options: {
259
- label: string;
260
- value: string;
261
- }[];
262
- }
263
258
  export interface PrintOptions {
264
259
  role: 'student' | 'instructor';
265
260
  mode?: PieEnvironment['mode'];
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiMH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAiB;IAClD,IAAI,IAAI,CAAC,OAAO,KAAK,eAAe,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAE7B,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AACpF,CAAC","sourcesContent":["/**\n * Core PIE specification types\n */\n\n/**\n * Reference to a media asset and its playable encodings.\n *\n * Structurally mirrors the `MediaAssetRef` in the pie-players\n * `media-asset-contract` PRD. The two definitions are deliberately kept as\n * separate declarations rather than a shared package dependency: this repo owns\n * the item-model side of the contract, pie-players owns the player side, and\n * both read the same authored JSON, so structural typing is sufficient for\n * interop. Fixture parity — not a package edge — is what pins them together.\n *\n * Sign-language catalog cards were the first consumer and use only the core\n * source fields. The optional presentation, track, and transcript metadata is\n * declared for broader consumers such as video stimuli; it remains meaningless\n * for a signing clip, where captions would duplicate the text already on screen.\n */\nexport interface MediaAssetRef {\n version: 1;\n id: string;\n kind: MediaKind;\n sources: MediaSource[];\n poster?: string;\n thumbnail?: string;\n durationSeconds?: number;\n tracks?: TextTrackRef[];\n transcript?: TranscriptRef;\n label?: string;\n description?: string;\n /**\n * Language of the asset itself, as authored metadata. Sign-language cards\n * leave it unset: the card's `language` already states the adaptation\n * language, and a second copy is a second thing to keep in agreement.\n */\n lang?: string;\n}\n\nexport type MediaKind = 'image' | 'audio' | 'video' | 'other';\n\n/** One playable encoding of a media asset. */\nexport interface MediaSource {\n src: string;\n /** MIME type, e.g. \"video/mp4\". */\n type?: string;\n width?: number;\n height?: number;\n bitrate?: number;\n}\n\n/** One authored text track associated with an audio or video asset. */\nexport interface TextTrackRef {\n src: string;\n kind: 'captions' | 'subtitles' | 'descriptions' | 'chapters' | 'metadata';\n lang: string;\n label: string;\n default?: boolean;\n}\n\n/** Inline or externally hosted transcript content for a media asset. */\nexport interface TranscriptRef {\n src?: string;\n html?: string;\n plainText?: string;\n lang?: string;\n}\n\n/** Learner-facing strings for the transcript controls of a media element. */\nexport interface MediaUiText {\n showTranscript: string;\n hideTranscript: string;\n viewTranscript: string;\n}\n\n/**\n * A time slice within a media asset, so one recording can serve several\n * content nodes. Mirrors QTI 3's Media Fragments URI usage.\n */\nexport interface MediaFragmentRange {\n startSeconds: number;\n endSeconds?: number;\n}\n\n/**\n * Payload for a `sign-language` catalog card: a signed translation of the\n * content node the card is docked to.\n */\nexport interface SignLanguageCardPayload {\n /**\n * Language tag for the signed translation — BCP 47, which admits ISO 639-3\n * subtags for languages with no 639-1/2 code. \"ase\" is ASL, matching QTI 3\n * `xml:lang`.\n *\n * This is the language of the *adaptation*, not the item's base content\n * language (AfA/PNP's `languageOfAdaptation`). The distinction is load\n * bearing: a Spanish item's signed alternate is LSM, not ASL, so `signLang`\n * must never be inferred from the item or assessment content language.\n *\n * Optional, and redundant on almost every card. The card's `language` states\n * the same code and is the only field pie-players resolves a card on —\n * resolution runs before anything knows the card is a signing card, so it can\n * only key on the generic field — and the player falls back to it when this is\n * absent. Author it only where the two differ: a card tagged with the item's\n * content language (`language: 'en-US'`, `signLang: 'ase'`) so resolution\n * reaches it by the default-language rung. The pie-api-aws importer emits\n * `language` alone.\n */\n signLang?: string;\n media: MediaAssetRef;\n fragment?: MediaFragmentRange;\n}\n\n/**\n * Payload for a `spoken` catalog card that is a recording rather than a script.\n *\n * QTI 3 treats recorded audio and synthesized speech as the same support: both\n * are `spoken`, so this is not a new accommodation, it is the other form the\n * existing one can take. A node commonly carries both this and a `content`\n * card in the same language — the script is both what the audio was generated\n * from and the fallback for when the audio cannot play; pie-players resolves\n * between them with `CatalogLookupOptions.form`.\n *\n * No `kind` discriminant, for the same reason `SignLanguageCardPayload` has\n * none: the card's `catalog` already says what this is.\n */\nexport interface SpokenAudioCardPayload {\n media: MediaAssetRef;\n fragment?: MediaFragmentRange;\n}\n\n/**\n * The structured forms a card's `payload` may take.\n *\n * Which one applies is decided by the card's `catalog`, so this union carries no\n * discriminant of its own — a second discriminant could contradict the first.\n * Consumers select a card by catalog type and then validate the payload\n * structurally, which they must do regardless: catalog data is authored,\n * wire-facing and untrusted.\n */\nexport type CatalogCardPayload = SignLanguageCardPayload | SpokenAudioCardPayload;\n\n/**\n * QTI-aligned accessibility catalog entry: one alternate representation of a\n * content node, docked to it by `data-catalog-idref`.\n *\n * Maps onto QTI 3's `qti-card`. `catalog` is QTI's `@support` and is the only\n * discriminant — there is deliberately no second `kind` field. `language` is the\n * card entry's `xml:lang`. QTI's single content slot is represented by exactly\n * one of two fields, never both, with nothing mirrored between them:\n *\n * - `content` — the string form, for alternates a string can express: SSML for\n * `spoken`, plain text for `simplified-language`.\n * - `payload` — the structured form, for what a string cannot express. Today\n * only a signing video.\n *\n * One generic payload slot rather than a field per accommodation\n * (`signLanguage`, `braille`, …), which is the shape pie-players canonicalises\n * and the shape this repo now follows. A field per accommodation makes every new\n * structured alternate a breaking widening of this type in every consumer that\n * reads cards, and it gives the same fact two names across repos — which\n * produced a real bug: a card carrying `signLanguage` rendered its video in the\n * player and was simultaneously reported as carrying no payload by the player's\n * \"what alternates exist\" path, because only one of the two read paths knew\n * about the alias.\n *\n * `catalog` is a bare `string` because the vocabulary is open-ended and unknown\n * tokens must be ignored rather than rejected. TypeScript therefore cannot\n * express \"a `sign-language` card must carry a payload\", so a\n * `{ catalog: 'sign-language', content: '<url>' }` object still satisfies this\n * type. That legacy bare-URL form is not supported: runtime validation on the\n * consuming side must reject it rather than render the URL as visible text.\n * Narrow with `isSignLanguageCard`.\n */\nexport interface CatalogCard {\n catalog: string;\n language?: string;\n content?: string;\n payload?: CatalogCardPayload;\n}\n\n/**\n * A `CatalogCard` narrowed to the signing case, where the payload is mandatory.\n *\n * Maps to QTI `qti-card support=\"sign-language\"`. This is a refinement of the\n * shared shape for authoring and narrowing, not a second card model: it adds\n * only what `CatalogCard` cannot state, which is that a signing card must carry\n * its payload and must not carry a bare URL in `content`.\n */\nexport interface SignLanguageCatalogCard extends CatalogCard {\n catalog: 'sign-language';\n payload: SignLanguageCardPayload;\n content?: never;\n}\n\n/**\n * Narrows a catalog card to its sign-language form.\n *\n * This is a structural narrowing guard, not a payload validator: it confirms\n * the card carries a signing payload with at least one media source. Full\n * payload validation — and the rule that an invalid payload is treated as\n * absent — belongs to the consuming player, per the sign-language PRD.\n *\n * Deliberately says nothing about `signLang`. It once required a non-empty one,\n * which would have rejected every card the pie-api-aws importer produces: the\n * adaptation language lives on the card's `language`, and a payload that omits\n * `signLang` is the normal shape rather than a malformed one.\n */\nexport function isSignLanguageCard(card: CatalogCard): card is SignLanguageCatalogCard {\n if (card.catalog !== 'sign-language') {\n return false;\n }\n\n const payload = card.payload;\n\n return Array.isArray(payload?.media?.sources) && payload.media.sources.length > 0;\n}\n\nexport interface AccessibilityCatalog {\n identifier: string;\n cards: CatalogCard[];\n}\n\n// Base PIE model (all elements extend this)\nexport interface PieModel {\n id: string;\n element: string; // Element tag, the key in the item config's `elements` map, e.g. \"multiple-choice\"\n accessibilityCatalogs?: AccessibilityCatalog[];\n}\n\n// Theme configuration (from DaisyUI or custom)\nexport interface PieTheme {\n primary?: string; // Primary brand color\n secondary?: string; // Secondary color\n accent?: string; // Accent color\n neutral?: string; // Neutral color\n 'base-100'?: string; // Base background color\n 'base-200'?: string; // Secondary background\n 'base-300'?: string; // Tertiary background\n 'base-content'?: string; // Base text color\n info?: string; // Info color\n success?: string; // Success/correct color\n warning?: string; // Warning color\n error?: string; // Error/incorrect color\n}\n\n// Environment configuration\nexport interface PieEnvironment {\n mode: 'gather' | 'view' | 'evaluate';\n role: 'student' | 'instructor';\n // Optional advanced features\n lockChoiceOrder?: boolean;\n partialScoring?: boolean;\n // Optional theme configuration\n theme?: PieTheme;\n}\n\n// Session data (student responses)\nexport interface PieSession {\n id?: string;\n [key: string]: unknown;\n}\n\n// View model (output from controller.model())\nexport interface ViewModel extends Record<string, unknown> {\n disabled: boolean;\n mode: PieEnvironment['mode'];\n}\n\n// Outcome result (output from controller.outcome())\nexport interface OutcomeResult {\n score: number; // 0-1 scale\n empty: boolean; // True if no response provided\n}\n\n// Validation result\nexport interface ValidationErrors {\n [key: string]: string;\n}\n\n// Common configuration settings\nexport interface CommonConfigSettings {\n settingsPanelDisabled?: boolean;\n spellCheck?: ConfigureProp;\n maxImageWidth?: ConfigureProp;\n maxImageHeight?: ConfigureProp;\n withRubric?: ConfigureProp;\n language?: ConfigureProp;\n languageChoices?: ConfigureLanguageOptions;\n}\n\nexport interface ConfigureProp {\n settings?: boolean;\n label?: string;\n enabled?: boolean;\n}\n\nexport interface ConfigureLanguageOptions {\n label: string;\n options: { label: string; value: string }[];\n}\n\n// Print options\nexport interface PrintOptions {\n role: 'student' | 'instructor';\n mode?: PieEnvironment['mode'];\n}\n\n/**\n * Persists `properties` into the stored session `id` of element `element`. A player passes it to\n * `model()`, which calls `updateSession(session.id, session.element, { shuffledValues })` to keep\n * the choice order it drew.\n */\nexport type PieUpdateSession = (\n id: string,\n element: string,\n properties: Partial<PieSession>\n) => Promise<void>;\n\n// Controller interface\nexport interface PieController {\n model(\n question: PieModel,\n session: PieSession | null,\n env: PieEnvironment,\n updateSession?: PieUpdateSession\n ): Promise<ViewModel>;\n\n outcome(model: PieModel, session: PieSession, env: PieEnvironment): Promise<OutcomeResult>;\n\n createDefaultModel(partial?: Partial<PieModel>): PieModel;\n\n validate(model: PieModel, config: CommonConfigSettings): ValidationErrors;\n\n createCorrectResponseSession(question: PieModel, env: PieEnvironment): PieSession;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmMH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAiB;IAClD,IAAI,IAAI,CAAC,OAAO,KAAK,eAAe,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAE7B,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AACpF,CAAC","sourcesContent":["/**\n * Core PIE specification types\n */\n\nimport type { CommonConfigSettings } from './authoring.js';\n\n/**\n * Reference to a media asset and its playable encodings.\n *\n * Structurally mirrors the `MediaAssetRef` in the pie-players\n * `media-asset-contract` PRD. The two definitions are deliberately kept as\n * separate declarations rather than a shared package dependency: this repo owns\n * the item-model side of the contract, pie-players owns the player side, and\n * both read the same authored JSON, so structural typing is sufficient for\n * interop. Fixture parity — not a package edge — is what pins them together.\n *\n * Sign-language catalog cards were the first consumer and use only the core\n * source fields. The optional presentation, track, and transcript metadata is\n * declared for broader consumers such as video stimuli; it remains meaningless\n * for a signing clip, where captions would duplicate the text already on screen.\n */\nexport interface MediaAssetRef {\n version: 1;\n id: string;\n kind: MediaKind;\n sources: MediaSource[];\n poster?: string;\n thumbnail?: string;\n durationSeconds?: number;\n tracks?: TextTrackRef[];\n transcript?: TranscriptRef;\n label?: string;\n description?: string;\n /**\n * Language of the asset itself, as authored metadata. Sign-language cards\n * leave it unset: the card's `language` already states the adaptation\n * language, and a second copy is a second thing to keep in agreement.\n */\n lang?: string;\n}\n\nexport type MediaKind = 'image' | 'audio' | 'video' | 'other';\n\n/** One playable encoding of a media asset. */\nexport interface MediaSource {\n src: string;\n /** MIME type, e.g. \"video/mp4\". */\n type?: string;\n width?: number;\n height?: number;\n bitrate?: number;\n}\n\n/** One authored text track associated with an audio or video asset. */\nexport interface TextTrackRef {\n src: string;\n kind: 'captions' | 'subtitles' | 'descriptions' | 'chapters' | 'metadata';\n lang: string;\n label: string;\n default?: boolean;\n}\n\n/** Inline or externally hosted transcript content for a media asset. */\nexport interface TranscriptRef {\n src?: string;\n html?: string;\n plainText?: string;\n lang?: string;\n}\n\n/** Learner-facing strings for the transcript controls of a media element. */\nexport interface MediaUiText {\n showTranscript: string;\n hideTranscript: string;\n viewTranscript: string;\n}\n\n/**\n * A time slice within a media asset, so one recording can serve several\n * content nodes. Mirrors QTI 3's Media Fragments URI usage.\n */\nexport interface MediaFragmentRange {\n startSeconds: number;\n endSeconds?: number;\n}\n\n/**\n * Payload for a `sign-language` catalog card: a signed translation of the\n * content node the card is docked to.\n */\nexport interface SignLanguageCardPayload {\n /**\n * Language tag for the signed translation — BCP 47, which admits ISO 639-3\n * subtags for languages with no 639-1/2 code. \"ase\" is ASL, matching QTI 3\n * `xml:lang`.\n *\n * This is the language of the *adaptation*, not the item's base content\n * language (AfA/PNP's `languageOfAdaptation`). The distinction is load\n * bearing: a Spanish item's signed alternate is LSM, not ASL, so `signLang`\n * must never be inferred from the item or assessment content language.\n *\n * Optional, and redundant on almost every card. The card's `language` states\n * the same code and is the only field pie-players resolves a card on —\n * resolution runs before anything knows the card is a signing card, so it can\n * only key on the generic field — and the player falls back to it when this is\n * absent. Author it only where the two differ: a card tagged with the item's\n * content language (`language: 'en-US'`, `signLang: 'ase'`) so resolution\n * reaches it by the default-language rung. The pie-api-aws importer emits\n * `language` alone.\n */\n signLang?: string;\n media: MediaAssetRef;\n fragment?: MediaFragmentRange;\n}\n\n/**\n * Payload for a `spoken` catalog card that is a recording rather than a script.\n *\n * QTI 3 treats recorded audio and synthesized speech as the same support: both\n * are `spoken`, so this is not a new accommodation, it is the other form the\n * existing one can take. A node commonly carries both this and a `content`\n * card in the same language — the script is both what the audio was generated\n * from and the fallback for when the audio cannot play; pie-players resolves\n * between them with `CatalogLookupOptions.form`.\n *\n * No `kind` discriminant, for the same reason `SignLanguageCardPayload` has\n * none: the card's `catalog` already says what this is.\n */\nexport interface SpokenAudioCardPayload {\n media: MediaAssetRef;\n fragment?: MediaFragmentRange;\n}\n\n/**\n * The structured forms a card's `payload` may take.\n *\n * Which one applies is decided by the card's `catalog`, so this union carries no\n * discriminant of its own — a second discriminant could contradict the first.\n * Consumers select a card by catalog type and then validate the payload\n * structurally, which they must do regardless: catalog data is authored,\n * wire-facing and untrusted.\n */\nexport type CatalogCardPayload = SignLanguageCardPayload | SpokenAudioCardPayload;\n\n/**\n * QTI-aligned accessibility catalog entry: one alternate representation of a\n * content node, docked to it by `data-catalog-idref`.\n *\n * Maps onto QTI 3's `qti-card`. `catalog` is QTI's `@support` and is the only\n * discriminant — there is deliberately no second `kind` field. `language` is the\n * card entry's `xml:lang`. QTI's single content slot is represented by exactly\n * one of two fields, never both, with nothing mirrored between them:\n *\n * - `content` — the string form, for alternates a string can express: SSML for\n * `spoken`, plain text for `simplified-language`.\n * - `payload` — the structured form, for what a string cannot express. Today\n * only a signing video.\n *\n * One generic payload slot rather than a field per accommodation\n * (`signLanguage`, `braille`, …), which is the shape pie-players canonicalises\n * and the shape this repo now follows. A field per accommodation makes every new\n * structured alternate a breaking widening of this type in every consumer that\n * reads cards, and it gives the same fact two names across repos — which\n * produced a real bug: a card carrying `signLanguage` rendered its video in the\n * player and was simultaneously reported as carrying no payload by the player's\n * \"what alternates exist\" path, because only one of the two read paths knew\n * about the alias.\n *\n * `catalog` is a bare `string` because the vocabulary is open-ended and unknown\n * tokens must be ignored rather than rejected. TypeScript therefore cannot\n * express \"a `sign-language` card must carry a payload\", so a\n * `{ catalog: 'sign-language', content: '<url>' }` object still satisfies this\n * type. That legacy bare-URL form is not supported: runtime validation on the\n * consuming side must reject it rather than render the URL as visible text.\n * Narrow with `isSignLanguageCard`.\n */\nexport interface CatalogCard {\n catalog: string;\n language?: string;\n content?: string;\n payload?: CatalogCardPayload;\n}\n\n/**\n * A `CatalogCard` narrowed to the signing case, where the payload is mandatory.\n *\n * Maps to QTI `qti-card support=\"sign-language\"`. This is a refinement of the\n * shared shape for authoring and narrowing, not a second card model: it adds\n * only what `CatalogCard` cannot state, which is that a signing card must carry\n * its payload and must not carry a bare URL in `content`.\n */\nexport interface SignLanguageCatalogCard extends CatalogCard {\n catalog: 'sign-language';\n payload: SignLanguageCardPayload;\n content?: never;\n}\n\n/**\n * Narrows a catalog card to its sign-language form.\n *\n * This is a structural narrowing guard, not a payload validator: it confirms\n * the card carries a signing payload with at least one media source. Full\n * payload validation — and the rule that an invalid payload is treated as\n * absent — belongs to the consuming player, per the sign-language PRD.\n *\n * Deliberately says nothing about `signLang`. It once required a non-empty one,\n * which would have rejected every card the pie-api-aws importer produces: the\n * adaptation language lives on the card's `language`, and a payload that omits\n * `signLang` is the normal shape rather than a malformed one.\n */\nexport function isSignLanguageCard(card: CatalogCard): card is SignLanguageCatalogCard {\n if (card.catalog !== 'sign-language') {\n return false;\n }\n\n const payload = card.payload;\n\n return Array.isArray(payload?.media?.sources) && payload.media.sources.length > 0;\n}\n\nexport interface AccessibilityCatalog {\n identifier: string;\n cards: CatalogCard[];\n}\n\n// Base PIE model (all elements extend this)\nexport interface PieModel {\n /** Identifier to identify the Pie Element in html markup, Must be unique within a pie item config. */\n id: string;\n /** The html Element tag name: the key in the item config's `elements` map, e.g. \"multiple-choice\" */\n element: string;\n /** QTI-aligned accessibility catalogs whose cards dock to content nodes by `data-catalog-idref` */\n accessibilityCatalogs?: AccessibilityCatalog[];\n}\n\n/** Host-supplied CSS scoped to the element: `rules` is a stylesheet whose class names are listed in `names`. */\nexport interface ExtraCSSRules {\n names?: string[];\n rules?: string;\n}\n\n/** Images that replace the default audio play button. */\nexport interface CustomAudioButton {\n /** image url for the play state */\n playImage: string;\n /** image url for the pause state */\n pauseImage: string;\n}\n\n// Theme configuration (from DaisyUI or custom)\nexport interface PieTheme {\n primary?: string; // Primary brand color\n secondary?: string; // Secondary color\n accent?: string; // Accent color\n neutral?: string; // Neutral color\n 'base-100'?: string; // Base background color\n 'base-200'?: string; // Secondary background\n 'base-300'?: string; // Tertiary background\n 'base-content'?: string; // Base text color\n info?: string; // Info color\n success?: string; // Success/correct color\n warning?: string; // Warning color\n error?: string; // Error/incorrect color\n}\n\n// Environment configuration\nexport interface PieEnvironment {\n mode: 'gather' | 'view' | 'evaluate';\n role: 'student' | 'instructor';\n // Optional advanced features\n lockChoiceOrder?: boolean;\n partialScoring?: boolean;\n // Optional theme configuration\n theme?: PieTheme;\n}\n\n// Session data (student responses)\nexport interface PieSession {\n id?: string;\n [key: string]: unknown;\n}\n\n// View model (output from controller.model())\nexport interface ViewModel extends Record<string, unknown> {\n disabled: boolean;\n mode: PieEnvironment['mode'];\n}\n\n// Outcome result (output from controller.outcome())\nexport interface OutcomeResult {\n score: number; // 0-1 scale\n empty: boolean; // True if no response provided\n}\n\n// Validation result\nexport interface ValidationErrors {\n [key: string]: string;\n}\n\n// Print options\nexport interface PrintOptions {\n role: 'student' | 'instructor';\n mode?: PieEnvironment['mode'];\n}\n\n/**\n * Persists `properties` into the stored session `id` of element `element`. A player passes it to\n * `model()`, which calls `updateSession(session.id, session.element, { shuffledValues })` to keep\n * the choice order it drew.\n */\nexport type PieUpdateSession = (\n id: string,\n element: string,\n properties: Partial<PieSession>\n) => Promise<void>;\n\n// Controller interface\nexport interface PieController {\n model(\n question: PieModel,\n session: PieSession | null,\n env: PieEnvironment,\n updateSession?: PieUpdateSession\n ): Promise<ViewModel>;\n\n outcome(model: PieModel, session: PieSession, env: PieEnvironment): Promise<OutcomeResult>;\n\n createDefaultModel(partial?: Partial<PieModel>): PieModel;\n\n validate(model: PieModel, config: CommonConfigSettings): ValidationErrors;\n\n createCorrectResponseSession(question: PieModel, env: PieEnvironment): PieSession;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/shared-types",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-next.20261011221311",
4
4
  "description": "Shared TypeScript types for PIE elements",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",