@pie-element/hotspot 11.1.3 → 11.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/configure/CHANGELOG.md +13 -0
- package/configure/lib/index.js +4 -0
- package/configure/lib/index.js.map +1 -1
- package/configure/package.json +3 -3
- package/configure/src/index.js +5 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [11.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@11.1.4...@pie-element/hotspot@11.1.5) (2026-06-22)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
|
|
11
|
+
- handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
|
|
12
|
+
|
|
13
|
+
## [11.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@11.1.3...@pie-element/hotspot@11.1.4) (2026-06-17)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
18
|
+
|
|
6
19
|
## [11.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@11.1.2...@pie-element/hotspot@11.1.3) (2026-06-12)
|
|
7
20
|
|
|
8
21
|
### Bug Fixes
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@10.1.4...@pie-element/hotspot-configure@10.1.5) (2026-06-22)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
|
|
11
|
+
- handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
|
|
12
|
+
|
|
13
|
+
## [10.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@10.1.3...@pie-element/hotspot-configure@10.1.4) (2026-06-17)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
18
|
+
|
|
6
19
|
## [10.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@10.1.2...@pie-element/hotspot-configure@10.1.3) (2026-06-12)
|
|
7
20
|
|
|
8
21
|
### Bug Fixes
|
package/configure/lib/index.js
CHANGED
|
@@ -177,9 +177,13 @@ class HotspotConfigure extends HTMLElement {
|
|
|
177
177
|
}
|
|
178
178
|
this._root.render(element);
|
|
179
179
|
}
|
|
180
|
+
connectedCallback() {
|
|
181
|
+
this._render();
|
|
182
|
+
}
|
|
180
183
|
disconnectedCallback() {
|
|
181
184
|
if (this._root) {
|
|
182
185
|
this._root.unmount();
|
|
186
|
+
this._root = null;
|
|
183
187
|
}
|
|
184
188
|
}
|
|
185
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_debug","_pieConfigureEvents","_root","_defaults","log","debug","HotspotConfigure","HTMLElement","constructor","_defineProperty2","default","c","_configuration","_render","m","propertyType","_model","rectangles","polygons","circles","shapes","map","shape","correct","onModelChanged","colorType","color","prompt","rationale","teacherInstructions","dimensions","imageUrl","handler","dispatchEvent","InsertImageEvent","src","done","DeleteImageEvent","createDefaultModel","sensibleDefaults","configuration","bind","model","s","newConfiguration","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","dispatchModelUpdated","reset","resetValue","ModelUpdatedEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Root","onColorChanged","onImageUpload","onRationaleChanged","onConfigurationChanged","onPromptChanged","onUpdateImageDimension","imageSupport","add","insertImage","delete","onDeleteImage","uploadSoundSupport","onUpdateShapes","onModelChangedByConfig","onTeacherInstructionsChanged","createRoot","render","disconnectedCallback","unmount","exports","hotspotList","hotspotColor","outlineList","outlineColor"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Root from './root';\nimport sensibleDefaults from './defaults';\n\nconst log = debug('hotspot:configure');\n\nexport default class HotspotConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => ({\n ...sensibleDefaults.model,\n ...model,\n hotspotList: model.hotspotList || [model.hotspotColor] || sensibleDefaults.model.hotspotList,\n outlineList: model.outlineList || [model.outlineColor] || sensibleDefaults.model.outlineList,\n shapes: model.shapes || sensibleDefaults.model.shapes || {},\n });\n\n constructor() {\n super();\n this._root = null;\n this._model = HotspotConfigure.createDefaultModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n }\n\n set model(s) {\n this._model = HotspotConfigure.createDefaultModel(s);\n this._render();\n }\n\n set configuration(c) {\n const newConfiguration = {\n ...sensibleDefaults.configuration,\n ...c,\n };\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = m;\n this.dispatchModelUpdated(reset);\n this._render();\n }\n\n onConfigurationChanged = (c) => {\n this._configuration = c;\n this._render();\n };\n\n onModelChangedByConfig = (m, propertyType) => {\n const _model = m;\n\n if (propertyType === 'multipleCorrect') {\n const { rectangles = [], polygons = [], circles = [] } = _model.shapes || {};\n\n _model.shapes.rectangles = rectangles.map((shape) => ({ ...shape, correct: false }));\n _model.shapes.polygons = polygons.map((shape) => ({ ...shape, correct: false }));\n _model.shapes.circles = circles.map((shape) => ({ ...shape, correct: false }));\n }\n\n this.onModelChanged(_model);\n };\n\n onColorChanged = (colorType, color) => {\n this.onModelChanged({\n ...this._model,\n [colorType]: color,\n });\n };\n\n onPromptChanged = (prompt) => {\n this.onModelChanged({\n ...this._model,\n prompt,\n });\n };\n\n onRationaleChanged = (rationale) => {\n this.onModelChanged({\n ...this._model,\n rationale,\n });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.onModelChanged({\n ...this._model,\n teacherInstructions,\n });\n };\n\n onUpdateImageDimension = (dimensions) => {\n this.onModelChanged({\n ...this._model,\n dimensions,\n });\n };\n\n onUpdateShapes = (shapes) => {\n this.onModelChanged({\n ...this._model,\n shapes,\n });\n };\n\n onImageUpload = (imageUrl) => {\n this.onModelChanged({\n ...this._model,\n imageUrl,\n });\n };\n\n insertImage = (handler) => {\n this.dispatchEvent(new InsertImageEvent(handler));\n };\n\n onDeleteImage = (src, done) => {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n };\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render');\n let element = React.createElement(Root, {\n configuration: this._configuration,\n model: this._model,\n onColorChanged: this.onColorChanged,\n onImageUpload: this.onImageUpload,\n onRationaleChanged: this.onRationaleChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n onPromptChanged: this.onPromptChanged,\n onUpdateImageDimension: this.onUpdateImageDimension,\n imageSupport: {\n add: this.insertImage,\n delete: this.onDeleteImage,\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n onUpdateShapes: this.onUpdateShapes,\n onModelChangedByConfig: this.onModelChangedByConfig,\n onTeacherInstructionsChanged: this.onTeacherInstructionsChanged,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n\n disconnected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BA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACnF,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACoF,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAA7E,OAAA,GAAAJ,gBAAA;AAAA,IAAAG,gBAAA,CAAAC,OAAA,EA/LoBJ,gBAAgB,wBACP,CAACoC,KAAK,GAAG,CAAC,CAAC,MAAM;EAC3C,GAAGH,iBAAgB,CAACG,KAAK;EACzB,GAAGA,KAAK;EACR8C,WAAW,EAAE9C,KAAK,CAAC8C,WAAW,IAAI,CAAC9C,KAAK,CAAC+C,YAAY,CAAC,IAAIlD,iBAAgB,CAACG,KAAK,CAAC8C,WAAW;EAC5FE,WAAW,EAAEhD,KAAK,CAACgD,WAAW,IAAI,CAAChD,KAAK,CAACiD,YAAY,CAAC,IAAIpD,iBAAgB,CAACG,KAAK,CAACgD,WAAW;EAC5FtE,MAAM,EAAEsB,KAAK,CAACtB,MAAM,IAAImB,iBAAgB,CAACG,KAAK,CAACtB,MAAM,IAAI,CAAC;AAC5D,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_debug","_pieConfigureEvents","_root","_defaults","log","debug","HotspotConfigure","HTMLElement","constructor","_defineProperty2","default","c","_configuration","_render","m","propertyType","_model","rectangles","polygons","circles","shapes","map","shape","correct","onModelChanged","colorType","color","prompt","rationale","teacherInstructions","dimensions","imageUrl","handler","dispatchEvent","InsertImageEvent","src","done","DeleteImageEvent","createDefaultModel","sensibleDefaults","configuration","bind","model","s","newConfiguration","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","dispatchModelUpdated","reset","resetValue","ModelUpdatedEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Root","onColorChanged","onImageUpload","onRationaleChanged","onConfigurationChanged","onPromptChanged","onUpdateImageDimension","imageSupport","add","insertImage","delete","onDeleteImage","uploadSoundSupport","onUpdateShapes","onModelChangedByConfig","onTeacherInstructionsChanged","createRoot","render","connectedCallback","disconnectedCallback","unmount","exports","hotspotList","hotspotColor","outlineList","outlineColor"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Root from './root';\nimport sensibleDefaults from './defaults';\n\nconst log = debug('hotspot:configure');\n\nexport default class HotspotConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => ({\n ...sensibleDefaults.model,\n ...model,\n hotspotList: model.hotspotList || [model.hotspotColor] || sensibleDefaults.model.hotspotList,\n outlineList: model.outlineList || [model.outlineColor] || sensibleDefaults.model.outlineList,\n shapes: model.shapes || sensibleDefaults.model.shapes || {},\n });\n\n constructor() {\n super();\n this._root = null;\n this._model = HotspotConfigure.createDefaultModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n }\n\n set model(s) {\n this._model = HotspotConfigure.createDefaultModel(s);\n this._render();\n }\n\n set configuration(c) {\n const newConfiguration = {\n ...sensibleDefaults.configuration,\n ...c,\n };\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = m;\n this.dispatchModelUpdated(reset);\n this._render();\n }\n\n onConfigurationChanged = (c) => {\n this._configuration = c;\n this._render();\n };\n\n onModelChangedByConfig = (m, propertyType) => {\n const _model = m;\n\n if (propertyType === 'multipleCorrect') {\n const { rectangles = [], polygons = [], circles = [] } = _model.shapes || {};\n\n _model.shapes.rectangles = rectangles.map((shape) => ({ ...shape, correct: false }));\n _model.shapes.polygons = polygons.map((shape) => ({ ...shape, correct: false }));\n _model.shapes.circles = circles.map((shape) => ({ ...shape, correct: false }));\n }\n\n this.onModelChanged(_model);\n };\n\n onColorChanged = (colorType, color) => {\n this.onModelChanged({\n ...this._model,\n [colorType]: color,\n });\n };\n\n onPromptChanged = (prompt) => {\n this.onModelChanged({\n ...this._model,\n prompt,\n });\n };\n\n onRationaleChanged = (rationale) => {\n this.onModelChanged({\n ...this._model,\n rationale,\n });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.onModelChanged({\n ...this._model,\n teacherInstructions,\n });\n };\n\n onUpdateImageDimension = (dimensions) => {\n this.onModelChanged({\n ...this._model,\n dimensions,\n });\n };\n\n onUpdateShapes = (shapes) => {\n this.onModelChanged({\n ...this._model,\n shapes,\n });\n };\n\n onImageUpload = (imageUrl) => {\n this.onModelChanged({\n ...this._model,\n imageUrl,\n });\n };\n\n insertImage = (handler) => {\n this.dispatchEvent(new InsertImageEvent(handler));\n };\n\n onDeleteImage = (src, done) => {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n };\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render');\n let element = React.createElement(Root, {\n configuration: this._configuration,\n model: this._model,\n onColorChanged: this.onColorChanged,\n onImageUpload: this.onImageUpload,\n onRationaleChanged: this.onRationaleChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n onPromptChanged: this.onPromptChanged,\n onUpdateImageDimension: this.onUpdateImageDimension,\n imageSupport: {\n add: this.insertImage,\n delete: this.onDeleteImage,\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n onUpdateShapes: this.onUpdateShapes,\n onModelChangedByConfig: this.onModelChangedByConfig,\n onTeacherInstructionsChanged: this.onTeacherInstructionsChanged,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n\n connectedCallback() {\n this._render();\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAQA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,MAAMM,GAAG,GAAG,IAAAC,cAAK,EAAC,mBAAmB,CAAC;AAEvB,MAAMC,gBAAgB,SAASC,WAAW,CAAC;EASxDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,kCA8DgBC,CAAC,IAAK;MAC9B,IAAI,CAACC,cAAc,GAAGD,CAAC;MACvB,IAAI,CAACE,OAAO,CAAC,CAAC;IAChB,CAAC;IAAA,IAAAJ,gBAAA,CAAAC,OAAA,kCAEwB,CAACI,CAAC,EAAEC,YAAY,KAAK;MAC5C,MAAMC,MAAM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CAACtB,MAAM,IAAImB,iBAAgB,CAACG,KAAK,CAACtB,MAAM,IAAI,CAAC;AAC5D,CAAC,CAAC","ignoreList":[]}
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "10.1.
|
|
4
|
+
"version": "10.1.5",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"@mui/icons-material": "^7.3.4",
|
|
13
13
|
"@mui/material": "^7.3.4",
|
|
14
14
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
15
|
-
"@pie-lib/config-ui": "13.0.
|
|
16
|
-
"@pie-lib/editable-html-tip-tap": "2.1.
|
|
15
|
+
"@pie-lib/config-ui": "13.0.9",
|
|
16
|
+
"@pie-lib/editable-html-tip-tap": "2.1.7",
|
|
17
17
|
"debug": "^4.1.1",
|
|
18
18
|
"konva": "8.3.0",
|
|
19
19
|
"lodash-es": "^4.17.23",
|
package/configure/src/index.js
CHANGED
|
@@ -200,9 +200,14 @@ export default class HotspotConfigure extends HTMLElement {
|
|
|
200
200
|
this._root.render(element);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
connectedCallback() {
|
|
204
|
+
this._render();
|
|
205
|
+
}
|
|
206
|
+
|
|
203
207
|
disconnectedCallback() {
|
|
204
208
|
if (this._root) {
|
|
205
209
|
this._root.unmount();
|
|
210
|
+
this._root = null;
|
|
206
211
|
}
|
|
207
212
|
}
|
|
208
213
|
}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_mathRendering","_renderUi","_piePlayerEvents","_hotspot","_sessionUpdater","Hotspot","HTMLElement","constructor","_model","_session","_audioInitialized","audioComplete","_root","model","m","dispatchEvent","ModelSetEvent","tagName","toLowerCase","isComplete","_render","answers","autoplayAudioEnabled","completeAudioEnabled","elementContext","audio","querySelector","isInsidePrompt","closest","Array","isArray","length","session","s","onSelectChoice","data","updateSessionValue","SessionChangedEvent","_createAudioInfoToast","info","document","createElement","id","Object","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","observer","MutationObserver","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","setTimeout","paused","addEventListener","handlePlaying","updateSessionMetadata","audioStartTime","Date","getTime","handleEnded","audioEndTime","waitTime","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","el","React","HotspotComponent","bind","createRoot","render","queueMicrotask","renderMath","disconnectedCallback","unmount","exports","default"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { SessionChangedEvent, ModelSetEvent } from '@pie-framework/pie-player-events';\n\nimport HotspotComponent from './hotspot';\nimport { updateSessionValue, updateSessionMetadata } from './session-updater';\n\nexport default class Hotspot extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._audioInitialized = false;\n this.audioComplete = false;\n this._root = null;\n }\n\n set model(m) {\n this._model = m;\n\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));\n this._audioInitialized = false;\n this._render();\n }\n\n isComplete() {\n if (!this._session || !this._session.answers) {\n return false;\n }\n\n const { autoplayAudioEnabled, completeAudioEnabled } = this._model || {};\n const elementContext = this;\n\n // check audio completion if audio settings are enabled and audio actually exists\n if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!Array.isArray(this._session.answers)) {\n return false;\n }\n\n return this._session.answers.length > 0;\n }\n\n set session(s) {\n if (s && !s.answers) {\n s.answers = [];\n }\n\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n onSelectChoice(data) {\n updateSessionValue(this._session, this._model, data);\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));\n\n this._render();\n }\n\n _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer',\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._render();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n if (this._audioInitialized) return;\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n //timestamp when auto-played audio started playing\n updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n //timestamp when auto-played audio completed playing\n updateSessionMetadata(this._session, { audioEndTime: new Date().getTime() });\n\n let { audioStartTime, audioEndTime, waitTime } = this._session;\n if (!waitTime && audioStartTime && audioEndTime) {\n // waitTime is elapsed time the user waited for auto-played audio to finish\n this._session.waitTime = audioEndTime - audioStartTime;\n }\n\n this.audioComplete = true;\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));\n\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n // set to true to prevent multiple initializations\n this._audioInitialized = true;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n _render() {\n if (this._model && this._session) {\n const el = React.createElement(HotspotComponent, {\n model: this._model,\n session: this._session,\n onSelectChoice: this.onSelectChoice.bind(this),\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n queueMicrotask(() => {\n renderMath(this);\n });\n }\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n\n if (this._root) {\n this._root.unmount();\n }\n }\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E,IAAI,CAACL,MAAM;QAClBwB,OAAO,EAAE,IAAI,CAACvB,QAAQ;QACtByB,cAAc,EAAE,IAAI,CAACA,cAAc,CAAC6D,IAAI,CAAC,IAAI;MAC/C,CAAC,CAAC;MAEF,IAAI,CAAC,IAAI,CAACnF,KAAK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAAoF,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAACpF,KAAK,CAACqF,MAAM,CAACL,EAAE,CAAC;MACrBM,cAAc,CAAC,MAAM;QACnB,IAAAC,yBAAU,EAAC,IAAI,CAAC;MAClB,CAAC,CAAC;IACJ;EACF;EAEAC,oBAAoBA,CAAA,EAAG;IACrB5D,QAAQ,CAACgC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAACe,YAAY,CAAC;IAExD,IAAI,IAAI,CAACH,MAAM,EAAE;MACf,IAAI,CAACA,MAAM,CAACZ,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAACa,cAAc,CAAC;MAC/D,IAAI,CAACD,MAAM,CAACZ,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAACc,YAAY,CAAC;MAC3D,IAAI,CAACF,MAAM,GAAG,IAAI;IACpB;IAEA,IAAI,IAAI,CAACxE,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACyF,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAlG,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_mathRendering","_renderUi","_piePlayerEvents","_hotspot","_sessionUpdater","Hotspot","HTMLElement","constructor","_model","_session","_audioInitialized","audioComplete","_root","model","m","dispatchEvent","ModelSetEvent","tagName","toLowerCase","isComplete","_render","answers","autoplayAudioEnabled","completeAudioEnabled","elementContext","audio","querySelector","isInsidePrompt","closest","Array","isArray","length","session","s","onSelectChoice","data","updateSessionValue","SessionChangedEvent","_createAudioInfoToast","info","document","createElement","id","Object","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","observer","MutationObserver","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","setTimeout","paused","addEventListener","handlePlaying","updateSessionMetadata","audioStartTime","Date","getTime","handleEnded","audioEndTime","waitTime","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","el","React","HotspotComponent","bind","createRoot","render","queueMicrotask","renderMath","disconnectedCallback","unmount","exports","default"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { SessionChangedEvent, ModelSetEvent } from '@pie-framework/pie-player-events';\n\nimport HotspotComponent from './hotspot';\nimport { updateSessionValue, updateSessionMetadata } from './session-updater';\n\nexport default class Hotspot extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._audioInitialized = false;\n this.audioComplete = false;\n this._root = null;\n }\n\n set model(m) {\n this._model = m;\n\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));\n this._audioInitialized = false;\n this._render();\n }\n\n isComplete() {\n if (!this._session || !this._session.answers) {\n return false;\n }\n\n const { autoplayAudioEnabled, completeAudioEnabled } = this._model || {};\n const elementContext = this;\n\n // check audio completion if audio settings are enabled and audio actually exists\n if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!Array.isArray(this._session.answers)) {\n return false;\n }\n\n return this._session.answers.length > 0;\n }\n\n set session(s) {\n if (s && !s.answers) {\n s.answers = [];\n }\n\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n onSelectChoice(data) {\n updateSessionValue(this._session, this._model, data);\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));\n\n this._render();\n }\n\n _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer',\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._render();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n if (this._audioInitialized) return;\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n //timestamp when auto-played audio started playing\n updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n //timestamp when auto-played audio completed playing\n updateSessionMetadata(this._session, { audioEndTime: new Date().getTime() });\n\n let { audioStartTime, audioEndTime, waitTime } = this._session;\n if (!waitTime && audioStartTime && audioEndTime) {\n // waitTime is elapsed time the user waited for auto-played audio to finish\n this._session.waitTime = audioEndTime - audioStartTime;\n }\n\n this.audioComplete = true;\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));\n\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n // set to true to prevent multiple initializations\n this._audioInitialized = true;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n _render() {\n if (this._model && this._session) {\n const el = React.createElement(HotspotComponent, {\n model: this._model,\n session: this._session,\n onSelectChoice: this.onSelectChoice.bind(this),\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n queueMicrotask(() => {\n renderMath(this);\n });\n }\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,gBA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AK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAAoF,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAACpF,KAAK,CAACqF,MAAM,CAACL,EAAE,CAAC;MACrBM,cAAc,CAAC,MAAM;QACnB,IAAAC,yBAAU,EAAC,IAAI,CAAC;MAClB,CAAC,CAAC;IACJ;EACF;EAEAC,oBAAoBA,CAAA,EAAG;IACrB5D,QAAQ,CAACgC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAACe,YAAY,CAAC;IAExD,IAAI,IAAI,CAACH,MAAM,EAAE;MACf,IAAI,CAACA,MAAM,CAACZ,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAACa,cAAc,CAAC;MAC/D,IAAI,CAACD,MAAM,CAACZ,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAACc,YAAY,CAAC;MAC3D,IAAI,CAACF,MAAM,GAAG,IAAI;IACpB;IAEA,IAAI,IAAI,CAACxE,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACyF,OAAO,CAAC,CAAC;MACpB,IAAI,CAACzF,KAAK,GAAG,IAAI;IACnB;EACF;AACF;AAAC0F,OAAA,CAAAC,OAAA,GAAAlG,OAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot",
|
|
3
3
|
"repository": "pie-framework/pie-elements",
|
|
4
|
-
"version": "11.1.
|
|
4
|
+
"version": "11.1.5",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"author": "pie framework developers",
|
|
26
26
|
"license": "ISC",
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "f898c2bf045f66d34e66e8bb201950bfd00b2f0f",
|
|
28
28
|
"scripts": {
|
|
29
29
|
"postpublish": "../../scripts/postpublish"
|
|
30
30
|
},
|