@pie-element/hotspot 11.1.1-next.1 → 11.1.1-next.101
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.json +997 -0
- package/CHANGELOG.md +2210 -0
- package/LICENSE.md +5 -0
- package/README.md +1 -0
- package/configure/CHANGELOG.json +682 -0
- package/configure/CHANGELOG.md +1947 -0
- package/configure/lib/DeleteWidget.js +64 -0
- package/configure/lib/DeleteWidget.js.map +1 -0
- package/configure/lib/button.js +42 -0
- package/configure/lib/button.js.map +1 -0
- package/configure/lib/buttons/circle.js +33 -0
- package/configure/lib/buttons/circle.js.map +1 -0
- package/configure/lib/buttons/polygon.js +39 -0
- package/configure/lib/buttons/polygon.js.map +1 -0
- package/configure/lib/buttons/rectangle.js +39 -0
- package/configure/lib/buttons/rectangle.js.map +1 -0
- package/configure/lib/defaults.js +155 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/hotspot-circle.js +192 -0
- package/configure/lib/hotspot-circle.js.map +1 -0
- package/configure/lib/hotspot-container.js +320 -0
- package/configure/lib/hotspot-container.js.map +1 -0
- package/configure/lib/hotspot-drawable.js +519 -0
- package/configure/lib/hotspot-drawable.js.map +1 -0
- package/configure/lib/hotspot-palette.js +107 -0
- package/configure/lib/hotspot-palette.js.map +1 -0
- package/configure/lib/hotspot-polygon.js +293 -0
- package/configure/lib/hotspot-polygon.js.map +1 -0
- package/configure/lib/hotspot-rectangle.js +190 -0
- package/configure/lib/hotspot-rectangle.js.map +1 -0
- package/configure/lib/icons.js +7 -0
- package/configure/lib/icons.js.map +1 -0
- package/configure/lib/image-konva.js +66 -0
- package/configure/lib/image-konva.js.map +1 -0
- package/configure/lib/index.js +198 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/root.js +331 -0
- package/configure/lib/root.js.map +1 -0
- package/configure/lib/shapes/circle.js +84 -0
- package/configure/lib/shapes/circle.js.map +1 -0
- package/configure/lib/shapes/index.js +50 -0
- package/configure/lib/shapes/index.js.map +1 -0
- package/configure/lib/shapes/polygon.js +82 -0
- package/configure/lib/shapes/polygon.js.map +1 -0
- package/configure/lib/shapes/rectagle.js +84 -0
- package/configure/lib/shapes/rectagle.js.map +1 -0
- package/configure/lib/shapes/utils.js +21 -0
- package/configure/lib/shapes/utils.js.map +1 -0
- package/configure/lib/upload-control.js +41 -0
- package/configure/lib/upload-control.js.map +1 -0
- package/configure/lib/utils.js +185 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +26 -0
- package/configure/src/DeleteWidget.jsx +51 -0
- package/configure/src/__tests__/DeleteWidget.test.jsx +366 -0
- package/configure/src/__tests__/button.test.jsx +198 -0
- package/configure/src/__tests__/hotspot-circle.test.jsx +259 -0
- package/configure/src/__tests__/hotspot-container.test.js +366 -0
- package/configure/src/__tests__/hotspot-drawable.test.js +271 -0
- package/configure/src/__tests__/hotspot-palette.test.jsx +71 -0
- package/configure/src/__tests__/image-konva.test.jsx +226 -0
- package/configure/src/__tests__/index.test.js +329 -0
- package/configure/src/__tests__/root.test.js +400 -0
- package/configure/src/__tests__/utils.test.js +241 -0
- package/configure/src/button.jsx +35 -0
- package/configure/src/buttons/circle.jsx +18 -0
- package/configure/src/buttons/polygon.jsx +29 -0
- package/configure/src/buttons/rectangle.jsx +29 -0
- package/configure/src/defaults.js +109 -0
- package/configure/src/hotspot-circle.jsx +183 -0
- package/configure/src/hotspot-container.jsx +330 -0
- package/configure/src/hotspot-drawable.jsx +527 -0
- package/configure/src/hotspot-palette.jsx +90 -0
- package/configure/src/hotspot-polygon.jsx +294 -0
- package/configure/src/hotspot-rectangle.jsx +169 -0
- package/configure/src/icons.js +5 -0
- package/configure/src/image-konva.jsx +63 -0
- package/configure/src/index.js +213 -0
- package/configure/src/root.jsx +342 -0
- package/configure/src/shapes/circle.js +81 -0
- package/configure/src/shapes/index.js +4 -0
- package/configure/src/shapes/polygon.js +81 -0
- package/configure/src/shapes/rectagle.js +82 -0
- package/configure/src/shapes/utils.js +16 -0
- package/configure/src/upload-control.jsx +33 -0
- package/configure/src/utils.js +210 -0
- package/controller/CHANGELOG.json +362 -0
- package/controller/CHANGELOG.md +1300 -0
- package/controller/lib/defaults.js +33 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +342 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +32 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +18 -0
- package/controller/src/__tests__/index.test.js +419 -0
- package/controller/src/__tests__/utils.test.js +5 -0
- package/controller/src/defaults.js +19 -0
- package/controller/src/index.js +330 -0
- package/controller/src/utils.js +29 -0
- package/docs/config-schema.json +2023 -0
- package/docs/config-schema.json.md +1495 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +122 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +11 -0
- package/docs/pie-schema.json +1204 -0
- package/docs/pie-schema.json.md +851 -0
- package/lib/hotspot/circle.js +160 -0
- package/lib/hotspot/circle.js.map +1 -0
- package/lib/hotspot/container.js +291 -0
- package/lib/hotspot/container.js.map +1 -0
- package/lib/hotspot/icons.js +8 -0
- package/lib/hotspot/icons.js.map +1 -0
- package/lib/hotspot/image-konva-tooltip.js +86 -0
- package/lib/hotspot/image-konva-tooltip.js.map +1 -0
- package/lib/hotspot/index.js +174 -0
- package/lib/hotspot/index.js.map +1 -0
- package/lib/hotspot/polygon.js +207 -0
- package/lib/hotspot/polygon.js.map +1 -0
- package/lib/hotspot/rectangle.js +178 -0
- package/lib/hotspot/rectangle.js.map +1 -0
- package/lib/index.js +214 -0
- package/lib/index.js.map +1 -0
- package/lib/session-updater.js +42 -0
- package/lib/session-updater.js.map +1 -0
- package/package.json +19 -57
- package/src/__tests__/container.test.jsx +58 -0
- package/src/__tests__/index.test.js +123 -0
- package/src/__tests__/session-updater.test.jsx +69 -0
- package/src/hotspot/__tests__/circle.test.jsx +464 -0
- package/src/hotspot/__tests__/container.test.jsx +546 -0
- package/src/hotspot/__tests__/image-konva-tooltip.test.jsx +510 -0
- package/src/hotspot/__tests__/index.test.jsx +64 -0
- package/src/hotspot/__tests__/polygon.test.jsx +502 -0
- package/src/hotspot/__tests__/rectangle.test.jsx +418 -0
- package/src/hotspot/circle.jsx +154 -0
- package/src/hotspot/container.jsx +297 -0
- package/src/hotspot/icons.js +7 -0
- package/src/hotspot/image-konva-tooltip.jsx +76 -0
- package/src/hotspot/index.jsx +179 -0
- package/src/hotspot/polygon.jsx +197 -0
- package/src/hotspot/rectangle.jsx +172 -0
- package/src/index.js +227 -0
- package/src/session-updater.js +29 -0
- package/dist/author/DeleteWidget.d.ts +0 -38
- package/dist/author/DeleteWidget.js +0 -46
- package/dist/author/button.d.ts +0 -31
- package/dist/author/button.js +0 -27
- package/dist/author/buttons/circle.d.ts +0 -18
- package/dist/author/buttons/circle.js +0 -25
- package/dist/author/buttons/polygon.d.ts +0 -18
- package/dist/author/buttons/polygon.js +0 -36
- package/dist/author/buttons/rectangle.d.ts +0 -18
- package/dist/author/buttons/rectangle.js +0 -36
- package/dist/author/defaults.d.ts +0 -157
- package/dist/author/defaults.js +0 -119
- package/dist/author/hotspot-circle.d.ts +0 -21
- package/dist/author/hotspot-circle.js +0 -124
- package/dist/author/hotspot-container.d.ts +0 -29
- package/dist/author/hotspot-container.js +0 -210
- package/dist/author/hotspot-drawable.d.ts +0 -31
- package/dist/author/hotspot-drawable.js +0 -312
- package/dist/author/hotspot-palette.d.ts +0 -14
- package/dist/author/hotspot-palette.js +0 -72
- package/dist/author/hotspot-polygon.d.ts +0 -38
- package/dist/author/hotspot-polygon.js +0 -200
- package/dist/author/hotspot-rectangle.d.ts +0 -20
- package/dist/author/hotspot-rectangle.js +0 -119
- package/dist/author/icons.d.ts +0 -9
- package/dist/author/icons.js +0 -4
- package/dist/author/image-konva.d.ts +0 -19
- package/dist/author/image-konva.js +0 -49
- package/dist/author/index.d.ts +0 -52
- package/dist/author/index.js +0 -143
- package/dist/author/root.d.ts +0 -15
- package/dist/author/root.js +0 -215
- package/dist/author/shapes/circle.d.ts +0 -18
- package/dist/author/shapes/circle.js +0 -47
- package/dist/author/shapes/index.d.ts +0 -12
- package/dist/author/shapes/polygon.d.ts +0 -19
- package/dist/author/shapes/polygon.js +0 -51
- package/dist/author/shapes/rectagle.d.ts +0 -18
- package/dist/author/shapes/rectagle.js +0 -57
- package/dist/author/shapes/utils.d.ts +0 -19
- package/dist/author/shapes/utils.js +0 -16
- package/dist/author/upload-control.d.ts +0 -29
- package/dist/author/upload-control.js +0 -28
- package/dist/author/utils.d.ts +0 -24
- package/dist/author/utils.js +0 -83
- package/dist/controller/defaults.d.ts +0 -35
- package/dist/controller/defaults.js +0 -29
- package/dist/controller/index.d.ts +0 -22
- package/dist/controller/index.js +0 -154
- package/dist/controller/utils.d.ts +0 -10
- package/dist/controller/utils.js +0 -13
- package/dist/delivery/hotspot/circle.d.ts +0 -19
- package/dist/delivery/hotspot/circle.js +0 -100
- package/dist/delivery/hotspot/container.d.ts +0 -16
- package/dist/delivery/hotspot/container.js +0 -150
- package/dist/delivery/hotspot/icons.d.ts +0 -10
- package/dist/delivery/hotspot/icons.js +0 -4
- package/dist/delivery/hotspot/image-konva-tooltip.d.ts +0 -19
- package/dist/delivery/hotspot/image-konva-tooltip.js +0 -66
- package/dist/delivery/hotspot/index.d.ts +0 -17
- package/dist/delivery/hotspot/index.js +0 -114
- package/dist/delivery/hotspot/polygon.d.ts +0 -21
- package/dist/delivery/hotspot/polygon.js +0 -108
- package/dist/delivery/hotspot/rectangle.d.ts +0 -19
- package/dist/delivery/hotspot/rectangle.js +0 -104
- package/dist/delivery/index.d.ts +0 -20
- package/dist/delivery/index.js +0 -107
- package/dist/delivery/session-updater.d.ts +0 -10
- package/dist/delivery/session-updater.js +0 -14
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -169
- package/dist/index.js +0 -2
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_DataView.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Hash.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_ListCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Map.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_MapCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Promise.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Set.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_SetCache.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Stack.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Uint8Array.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_WeakMap.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayEach.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayFilter.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayLikeKeys.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayPush.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arraySome.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assignValue.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assocIndexOf.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssign.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignValue.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseClone.js +0 -57
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseCreate.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsArguments.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqual.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqualDeep.js +0 -30
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsMap.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsNative.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsTypedArray.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeys.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeysIn.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTimes.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseUnary.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cacheHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneArrayBuffer.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneBuffer.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneDataView.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneRegExp.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneSymbol.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneTypedArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyObject.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbols.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbolsIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_coreJsData.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_defineProperty.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalArrays.js +0 -35
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalByTag.js +0 -35
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalObjects.js +0 -32
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getMapData.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getNative.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getPrototype.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbols.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbolsIn.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getTag.js +0 -23
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashGet.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashHas.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneByTag.js +0 -33
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneObject.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIndex.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isKeyable.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isMasked.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isPrototype.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheClear.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheDelete.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheGet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheClear.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheDelete.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheGet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapToArray.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeCreate.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeys.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeysIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nodeUtil.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overArg.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheAdd.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setToArray.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackGet.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackSet.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toSource.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/cloneDeep.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/eq.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArguments.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArray.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLike.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isBuffer.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js +0 -21
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEqual.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isFunction.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isLength.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isMap.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isTypedArray.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubArray.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubFalse.js +0 -6
package/lib/index.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _client = require("react-dom/client");
|
|
10
|
+
var _mathRendering = require("@pie-lib/math-rendering");
|
|
11
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
12
|
+
var _piePlayerEvents = require("@pie-framework/pie-player-events");
|
|
13
|
+
var _hotspot = _interopRequireDefault(require("./hotspot"));
|
|
14
|
+
var _sessionUpdater = require("./session-updater");
|
|
15
|
+
class Hotspot extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this._model = null;
|
|
19
|
+
this._session = null;
|
|
20
|
+
this._audioInitialized = false;
|
|
21
|
+
this.audioComplete = false;
|
|
22
|
+
this._root = null;
|
|
23
|
+
}
|
|
24
|
+
set model(m) {
|
|
25
|
+
this._model = m;
|
|
26
|
+
this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
|
|
27
|
+
this._audioInitialized = false;
|
|
28
|
+
this._render();
|
|
29
|
+
}
|
|
30
|
+
isComplete() {
|
|
31
|
+
if (!this._session || !this._session.answers) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const {
|
|
35
|
+
autoplayAudioEnabled,
|
|
36
|
+
completeAudioEnabled
|
|
37
|
+
} = this._model || {};
|
|
38
|
+
const elementContext = this;
|
|
39
|
+
|
|
40
|
+
// check audio completion if audio settings are enabled and audio actually exists
|
|
41
|
+
if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {
|
|
42
|
+
if (elementContext) {
|
|
43
|
+
const audio = elementContext.querySelector('audio');
|
|
44
|
+
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
45
|
+
|
|
46
|
+
// only require audio completion if audio exists and is inside the prompt
|
|
47
|
+
if (audio && isInsidePrompt) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!Array.isArray(this._session.answers)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return this._session.answers.length > 0;
|
|
56
|
+
}
|
|
57
|
+
set session(s) {
|
|
58
|
+
if (s && !s.answers) {
|
|
59
|
+
s.answers = [];
|
|
60
|
+
}
|
|
61
|
+
this._session = s;
|
|
62
|
+
this._render();
|
|
63
|
+
}
|
|
64
|
+
get session() {
|
|
65
|
+
return this._session;
|
|
66
|
+
}
|
|
67
|
+
onSelectChoice(data) {
|
|
68
|
+
(0, _sessionUpdater.updateSessionValue)(this._session, this._model, data);
|
|
69
|
+
this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
70
|
+
this._render();
|
|
71
|
+
}
|
|
72
|
+
_createAudioInfoToast() {
|
|
73
|
+
const info = document.createElement('div');
|
|
74
|
+
info.id = 'play-audio-info';
|
|
75
|
+
Object.assign(info.style, {
|
|
76
|
+
position: 'absolute',
|
|
77
|
+
top: 0,
|
|
78
|
+
width: '100%',
|
|
79
|
+
height: '100%',
|
|
80
|
+
display: 'flex',
|
|
81
|
+
justifyContent: 'center',
|
|
82
|
+
alignItems: 'center',
|
|
83
|
+
background: 'white',
|
|
84
|
+
zIndex: '1000',
|
|
85
|
+
cursor: 'pointer'
|
|
86
|
+
});
|
|
87
|
+
const img = document.createElement('img');
|
|
88
|
+
img.src = _renderUi.EnableAudioAutoplayImage;
|
|
89
|
+
img.alt = 'Click anywhere to enable audio autoplay';
|
|
90
|
+
img.width = 500;
|
|
91
|
+
img.height = 300;
|
|
92
|
+
info.appendChild(img);
|
|
93
|
+
return info;
|
|
94
|
+
}
|
|
95
|
+
connectedCallback() {
|
|
96
|
+
this._render();
|
|
97
|
+
|
|
98
|
+
// Observation: audio in Chrome will have the autoplay attribute,
|
|
99
|
+
// while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
|
|
100
|
+
// This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
|
|
101
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
102
|
+
mutationsList.forEach(mutation => {
|
|
103
|
+
if (mutation.type === 'childList') {
|
|
104
|
+
if (this._audioInitialized) return;
|
|
105
|
+
const audio = this.querySelector('audio');
|
|
106
|
+
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
107
|
+
if (!this._model) return;
|
|
108
|
+
if (!this._model.autoplayAudioEnabled) return;
|
|
109
|
+
if (audio && !isInsidePrompt) return;
|
|
110
|
+
if (!audio) return;
|
|
111
|
+
const info = this._createAudioInfoToast();
|
|
112
|
+
const container = this.querySelector('#main-container');
|
|
113
|
+
const enableAudio = () => {
|
|
114
|
+
if (this.querySelector('#play-audio-info')) {
|
|
115
|
+
audio.play();
|
|
116
|
+
container.removeChild(info);
|
|
117
|
+
}
|
|
118
|
+
document.removeEventListener('click', enableAudio);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
|
|
122
|
+
// FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
if (audio.paused && !this.querySelector('#play-audio-info')) {
|
|
125
|
+
// add info message as a toast to enable audio playback
|
|
126
|
+
container.appendChild(info);
|
|
127
|
+
document.addEventListener('click', enableAudio);
|
|
128
|
+
} else {
|
|
129
|
+
document.removeEventListener('click', enableAudio);
|
|
130
|
+
}
|
|
131
|
+
}, 500);
|
|
132
|
+
|
|
133
|
+
// we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
|
|
134
|
+
const handlePlaying = () => {
|
|
135
|
+
//timestamp when auto-played audio started playing
|
|
136
|
+
(0, _sessionUpdater.updateSessionMetadata)(this._session, {
|
|
137
|
+
audioStartTime: new Date().getTime()
|
|
138
|
+
});
|
|
139
|
+
const info = this.querySelector('#play-audio-info');
|
|
140
|
+
if (info) {
|
|
141
|
+
container.removeChild(info);
|
|
142
|
+
}
|
|
143
|
+
audio.removeEventListener('playing', handlePlaying);
|
|
144
|
+
};
|
|
145
|
+
audio.addEventListener('playing', handlePlaying);
|
|
146
|
+
|
|
147
|
+
// we need to listen for the ended event to update the isComplete state
|
|
148
|
+
const handleEnded = () => {
|
|
149
|
+
//timestamp when auto-played audio completed playing
|
|
150
|
+
(0, _sessionUpdater.updateSessionMetadata)(this._session, {
|
|
151
|
+
audioEndTime: new Date().getTime()
|
|
152
|
+
});
|
|
153
|
+
let {
|
|
154
|
+
audioStartTime,
|
|
155
|
+
audioEndTime,
|
|
156
|
+
waitTime
|
|
157
|
+
} = this._session;
|
|
158
|
+
if (!waitTime && audioStartTime && audioEndTime) {
|
|
159
|
+
// waitTime is elapsed time the user waited for auto-played audio to finish
|
|
160
|
+
this._session.waitTime = audioEndTime - audioStartTime;
|
|
161
|
+
}
|
|
162
|
+
this.audioComplete = true;
|
|
163
|
+
this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
164
|
+
audio.removeEventListener('ended', handleEnded);
|
|
165
|
+
};
|
|
166
|
+
audio.addEventListener('ended', handleEnded);
|
|
167
|
+
|
|
168
|
+
// store references to remove later
|
|
169
|
+
this._audio = audio;
|
|
170
|
+
this._handlePlaying = handlePlaying;
|
|
171
|
+
this._handleEnded = handleEnded;
|
|
172
|
+
this._enableAudio = enableAudio;
|
|
173
|
+
// set to true to prevent multiple initializations
|
|
174
|
+
this._audioInitialized = true;
|
|
175
|
+
observer.disconnect();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
observer.observe(this, {
|
|
180
|
+
childList: true,
|
|
181
|
+
subtree: true
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
_render() {
|
|
185
|
+
if (this._model && this._session) {
|
|
186
|
+
const el = /*#__PURE__*/_react.default.createElement(_hotspot.default, {
|
|
187
|
+
model: this._model,
|
|
188
|
+
session: this._session,
|
|
189
|
+
onSelectChoice: this.onSelectChoice.bind(this)
|
|
190
|
+
});
|
|
191
|
+
if (!this._root) {
|
|
192
|
+
this._root = (0, _client.createRoot)(this);
|
|
193
|
+
}
|
|
194
|
+
this._root.render(el);
|
|
195
|
+
queueMicrotask(() => {
|
|
196
|
+
(0, _mathRendering.renderMath)(this);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
disconnectedCallback() {
|
|
201
|
+
document.removeEventListener('click', this._enableAudio);
|
|
202
|
+
if (this._audio) {
|
|
203
|
+
this._audio.removeEventListener('playing', this._handlePlaying);
|
|
204
|
+
this._audio.removeEventListener('ended', this._handleEnded);
|
|
205
|
+
this._audio = null;
|
|
206
|
+
}
|
|
207
|
+
if (this._root) {
|
|
208
|
+
this._root.unmount();
|
|
209
|
+
this._root = null;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.default = Hotspot;
|
|
214
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +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 this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,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ACtByB,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;MACpB,IAAI,CAACzF,KAAK,GAAG,IAAI;IACnB;EACF;AACF;AAAC0F,OAAA,CAAAC,OAAA,GAAAlG,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateSessionMetadata = updateSessionMetadata;
|
|
7
|
+
exports.updateSessionValue = updateSessionValue;
|
|
8
|
+
function updateSessionValue(session, model, data) {
|
|
9
|
+
const {
|
|
10
|
+
id,
|
|
11
|
+
selected
|
|
12
|
+
} = data;
|
|
13
|
+
const {
|
|
14
|
+
multipleCorrect
|
|
15
|
+
} = model || {};
|
|
16
|
+
session.answers = session.answers || [];
|
|
17
|
+
if (!selected) {
|
|
18
|
+
session.answers = session.answers.filter(answer => answer.id !== id);
|
|
19
|
+
} else {
|
|
20
|
+
const item = {
|
|
21
|
+
id
|
|
22
|
+
};
|
|
23
|
+
if (multipleCorrect) {
|
|
24
|
+
session.answers.push(item);
|
|
25
|
+
} else {
|
|
26
|
+
session.answers = [item];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//update session metadata
|
|
30
|
+
session.selector = data.selector;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function updateSessionMetadata(session, metadata) {
|
|
34
|
+
session.audioStartTime = session.audioStartTime || metadata.audioStartTime; //timestamp when auto-played audio started playing
|
|
35
|
+
session.audioEndTime = session.audioEndTime || metadata.audioEndTime; //timestamp when auto-played audio completed playing
|
|
36
|
+
|
|
37
|
+
if (!session.waitTime && session.audioStartTime && session.audioEndTime) {
|
|
38
|
+
// waitTime is elapsed time the user waited for auto-played audio to finish
|
|
39
|
+
session.waitTime = session.audioEndTime - session.audioStartTime;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=session-updater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-updater.js","names":["updateSessionValue","session","model","data","id","selected","multipleCorrect","answers","filter","answer","item","push","selector","updateSessionMetadata","metadata","audioStartTime","audioEndTime","waitTime"],"sources":["../src/session-updater.js"],"sourcesContent":["export function updateSessionValue(session, model, data) {\n const { id, selected } = data;\n const { multipleCorrect } = model || {};\n session.answers = session.answers || [];\n\n if (!selected) {\n session.answers = session.answers.filter((answer) => answer.id !== id);\n } else {\n const item = { id };\n if (multipleCorrect) {\n session.answers.push(item);\n } else {\n session.answers = [item];\n }\n\n //update session metadata\n session.selector = data.selector;\n }\n}\n\nexport function updateSessionMetadata(session, metadata) {\n session.audioStartTime = session.audioStartTime || metadata.audioStartTime; //timestamp when auto-played audio started playing\n session.audioEndTime = session.audioEndTime || metadata.audioEndTime; //timestamp when auto-played audio completed playing\n\n if (!session.waitTime && session.audioStartTime && session.audioEndTime) {\n // waitTime is elapsed time the user waited for auto-played audio to finish\n session.waitTime = session.audioEndTime - session.audioStartTime;\n }\n}\n"],"mappings":";;;;;;;AAAO,SAASA,kBAAkBA,CAACC,OAAO,EAAEC,KAAK,EAAEC,IAAI,EAAE;EACvD,MAAM;IAAEC,EAAE;IAAEC;EAAS,CAAC,GAAGF,IAAI;EAC7B,MAAM;IAAEG;EAAgB,CAAC,GAAGJ,KAAK,IAAI,CAAC,CAAC;EACvCD,OAAO,CAACM,OAAO,GAAGN,OAAO,CAACM,OAAO,IAAI,EAAE;EAEvC,IAAI,CAACF,QAAQ,EAAE;IACbJ,OAAO,CAACM,OAAO,GAAGN,OAAO,CAACM,OAAO,CAACC,MAAM,CAAEC,MAAM,IAAKA,MAAM,CAACL,EAAE,KAAKA,EAAE,CAAC;EACxE,CAAC,MAAM;IACL,MAAMM,IAAI,GAAG;MAAEN;IAAG,CAAC;IACnB,IAAIE,eAAe,EAAE;MACnBL,OAAO,CAACM,OAAO,CAACI,IAAI,CAACD,IAAI,CAAC;IAC5B,CAAC,MAAM;MACLT,OAAO,CAACM,OAAO,GAAG,CAACG,IAAI,CAAC;IAC1B;;IAEA;IACAT,OAAO,CAACW,QAAQ,GAAGT,IAAI,CAACS,QAAQ;EAClC;AACF;AAEO,SAASC,qBAAqBA,CAACZ,OAAO,EAAEa,QAAQ,EAAE;EACvDb,OAAO,CAACc,cAAc,GAAGd,OAAO,CAACc,cAAc,IAAID,QAAQ,CAACC,cAAc,CAAC,CAAC;EAC5Ed,OAAO,CAACe,YAAY,GAAGf,OAAO,CAACe,YAAY,IAAIF,QAAQ,CAACE,YAAY,CAAC,CAAC;;EAEtE,IAAI,CAACf,OAAO,CAACgB,QAAQ,IAAIhB,OAAO,CAACc,cAAc,IAAId,OAAO,CAACe,YAAY,EAAE;IACvE;IACAf,OAAO,CAACgB,QAAQ,GAAGhB,OAAO,CAACe,YAAY,GAAGf,OAAO,CAACc,cAAc;EAClE;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,71 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot",
|
|
3
|
-
"
|
|
3
|
+
"repository": "pie-framework/pie-elements",
|
|
4
|
+
"version": "11.1.1-next.101+900426416",
|
|
4
5
|
"description": "",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
5
9
|
"dependencies": {
|
|
6
10
|
"@emotion/react": "^11.14.0",
|
|
7
11
|
"@emotion/style": "^0.8.0",
|
|
8
12
|
"@mui/icons-material": "^7.3.4",
|
|
9
13
|
"@mui/material": "^7.3.4",
|
|
10
|
-
"@pie-
|
|
11
|
-
"@pie-lib/
|
|
14
|
+
"@pie-framework/pie-player-events": "^0.1.0",
|
|
15
|
+
"@pie-lib/correct-answer-toggle": "4.0.5",
|
|
16
|
+
"@pie-lib/math-rendering": "5.1.0",
|
|
17
|
+
"@pie-lib/render-ui": "6.1.3",
|
|
12
18
|
"@pie-lib/test-utils": "2.0.2",
|
|
13
19
|
"konva": "8.3.0",
|
|
14
20
|
"prop-types": "^15.8.1",
|
|
15
|
-
"react
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"@pie-lib/editable-html-tip-tap": "2.1.2",
|
|
19
|
-
"@pie-element/shared-controller-utils": "0.1.1-next.1",
|
|
20
|
-
"@pie-element/shared-math-rendering-mathjax": "0.1.0",
|
|
21
|
-
"@pie-element/shared-player-events": "0.1.0",
|
|
22
|
-
"debug": "^4.1.1",
|
|
23
|
-
"lodash-es": "^4.17.21"
|
|
24
|
-
},
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"react": "^18.0.0",
|
|
27
|
-
"react-dom": "^18.0.0"
|
|
28
|
-
},
|
|
29
|
-
"exports": {
|
|
30
|
-
".": {
|
|
31
|
-
"types": "./dist/index.d.ts",
|
|
32
|
-
"default": "./dist/index.js"
|
|
33
|
-
},
|
|
34
|
-
"./delivery": {
|
|
35
|
-
"types": "./dist/delivery/index.d.ts",
|
|
36
|
-
"default": "./dist/delivery/index.js"
|
|
37
|
-
},
|
|
38
|
-
"./author": {
|
|
39
|
-
"types": "./dist/author/index.d.ts",
|
|
40
|
-
"default": "./dist/author/index.js"
|
|
41
|
-
},
|
|
42
|
-
"./controller": {
|
|
43
|
-
"types": "./dist/controller/index.d.ts",
|
|
44
|
-
"default": "./dist/controller/index.js"
|
|
45
|
-
},
|
|
46
|
-
"./controller.js": {
|
|
47
|
-
"types": "./dist/controller/index.d.ts",
|
|
48
|
-
"default": "./dist/controller/index.js"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"type": "module",
|
|
52
|
-
"main": "./dist/index.js",
|
|
53
|
-
"types": "./dist/index.d.ts",
|
|
54
|
-
"files": [
|
|
55
|
-
"dist"
|
|
56
|
-
],
|
|
57
|
-
"sideEffects": false,
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"vite": "^8.0.1",
|
|
60
|
-
"typescript": "^5.9.3",
|
|
61
|
-
"@vitejs/plugin-react": "^6.0.1",
|
|
62
|
-
"@types/react": "^18.2.0",
|
|
63
|
-
"@types/react-dom": "^18.2.0"
|
|
21
|
+
"react": "18.3.1",
|
|
22
|
+
"react-dom": "18.3.1",
|
|
23
|
+
"react-konva": "^18.2.14"
|
|
64
24
|
},
|
|
25
|
+
"author": "pie framework developers",
|
|
26
|
+
"license": "ISC",
|
|
27
|
+
"gitHead": "900426416a89663fa89f672b12b288b8211d8e20",
|
|
65
28
|
"scripts": {
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
29
|
+
"postpublish": "../../scripts/postpublish"
|
|
30
|
+
},
|
|
31
|
+
"main": "lib/index.js",
|
|
32
|
+
"module": "src/index.js"
|
|
71
33
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import Konva from 'konva';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import Container from '../hotspot/container';
|
|
7
|
+
import HotspotComponent from '../hotspot/index';
|
|
8
|
+
|
|
9
|
+
global.MutationObserver = class {
|
|
10
|
+
constructor(callback) {}
|
|
11
|
+
disconnect() {}
|
|
12
|
+
observe(element, initObject) {}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
Konva.isBrowser = false;
|
|
16
|
+
|
|
17
|
+
jest.mock('react-konva', () => {
|
|
18
|
+
const React = require('react');
|
|
19
|
+
return {
|
|
20
|
+
Stage: ({ children, ...props }) => React.createElement('div', { 'data-testid': 'stage', ...props }, children),
|
|
21
|
+
Layer: ({ children, ...props }) => React.createElement('div', { 'data-testid': 'layer', ...props }, children),
|
|
22
|
+
Rect: (props) => React.createElement('div', { 'data-testid': 'rect', ...props }),
|
|
23
|
+
Circle: (props) => React.createElement('div', { 'data-testid': 'circle', ...props }),
|
|
24
|
+
Line: (props) => React.createElement('div', { 'data-testid': 'line', ...props }),
|
|
25
|
+
Group: ({ children, ...props }) => React.createElement('div', { 'data-testid': 'group', ...props }, children),
|
|
26
|
+
Image: (props) => React.createElement('div', { 'data-testid': 'image', ...props }),
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('CorrectAnswerToggle', () => {
|
|
31
|
+
const model = {
|
|
32
|
+
mode: 'evaluate',
|
|
33
|
+
responseCorrect: false,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const createComponent = (props) => {
|
|
37
|
+
return render(
|
|
38
|
+
<HotspotComponent
|
|
39
|
+
model={{
|
|
40
|
+
...model,
|
|
41
|
+
...props,
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
it('does not render outside of evaluate mode', () => {
|
|
48
|
+
const { container } = createComponent({ mode: 'gather' });
|
|
49
|
+
const toggle = container.querySelector('[data-testid="correct-answer-toggle"]');
|
|
50
|
+
expect(toggle).toBeNull();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('does not render if the response is correct', () => {
|
|
54
|
+
const { container } = createComponent({ responseCorrect: true });
|
|
55
|
+
const toggle = container.querySelector('[data-testid="correct-answer-toggle"]');
|
|
56
|
+
expect(toggle).toBeNull();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';
|
|
4
|
+
import HotspotComponent from '../hotspot';
|
|
5
|
+
import Hotspot from '../index';
|
|
6
|
+
|
|
7
|
+
jest.mock('@pie-lib/math-rendering', () => ({ renderMath: jest.fn() }));
|
|
8
|
+
|
|
9
|
+
jest.mock('../index', () => {
|
|
10
|
+
class MockHTMLElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
this._root = null;
|
|
13
|
+
this._model = null;
|
|
14
|
+
this._session = null;
|
|
15
|
+
this._audioInitialized = false;
|
|
16
|
+
this.audioComplete = false;
|
|
17
|
+
this.dispatchEvent = jest.fn();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
__esModule: true,
|
|
23
|
+
default: class Hotspot extends MockHTMLElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
set model(m) {
|
|
29
|
+
this._model = m;
|
|
30
|
+
this.dispatchEvent(new (require('@pie-framework/pie-player-events').ModelSetEvent)(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
set session(s) {
|
|
34
|
+
this._session = s;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
isComplete() {
|
|
38
|
+
if (!this._session || !this._session.answers) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (!Array.isArray(this._session.answers)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return this._session.answers.length > 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
onSelectChoice({ id, selected }) {
|
|
48
|
+
const { SessionChangedEvent } = require('@pie-framework/pie-player-events');
|
|
49
|
+
const answers = this._session.answers || [];
|
|
50
|
+
|
|
51
|
+
if (selected) {
|
|
52
|
+
if (!answers.find(a => a.id === id)) {
|
|
53
|
+
this._session.answers = [...answers, { id }];
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
this._session.answers = answers.filter(a => a.id !== id);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const isComplete = this.isComplete();
|
|
60
|
+
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), isComplete));
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
jest.mock('react-konva', () => {
|
|
67
|
+
const React = require('react');
|
|
68
|
+
return {
|
|
69
|
+
Stage: ({ children, ...props }) => React.createElement('div', { 'data-testid': 'stage', ...props }, children),
|
|
70
|
+
Layer: ({ children, ...props }) => React.createElement('div', { 'data-testid': 'layer', ...props }, children),
|
|
71
|
+
Rect: (props) => React.createElement('div', { 'data-testid': 'rect', ...props }),
|
|
72
|
+
Circle: (props) => React.createElement('div', { 'data-testid': 'circle', ...props }),
|
|
73
|
+
Line: (props) => React.createElement('div', { 'data-testid': 'line', ...props }),
|
|
74
|
+
Group: ({ children, ...props }) => React.createElement('div', { 'data-testid': 'group', ...props }, children),
|
|
75
|
+
Image: (props) => React.createElement('div', { 'data-testid': 'image', ...props }),
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('hotspot', () => {
|
|
80
|
+
|
|
81
|
+
describe('events', () => {
|
|
82
|
+
describe('model', () => {
|
|
83
|
+
it('dispatches model set event', () => {
|
|
84
|
+
const el = new Hotspot();
|
|
85
|
+
el.tagName = 'hotspot-el';
|
|
86
|
+
el.model = {};
|
|
87
|
+
expect(el.dispatchEvent).toBeCalledWith(new ModelSetEvent('hotspot-el', false, true));
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('onSelectChoice', () => {
|
|
92
|
+
it('dispatches session changed event - add answer', () => {
|
|
93
|
+
const el = new Hotspot();
|
|
94
|
+
el.tagName = 'hotspot-el';
|
|
95
|
+
el.session = { answers: [] };
|
|
96
|
+
el.onSelectChoice({ id: '1', selected: true });
|
|
97
|
+
expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', true));
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('dispatches session changed event - remove answer', () => {
|
|
101
|
+
const el = new Hotspot();
|
|
102
|
+
el.tagName = 'hotspot-el';
|
|
103
|
+
el.session = { answers: [{ id: '1' }] };
|
|
104
|
+
el.onSelectChoice({ id: '1', selected: false });
|
|
105
|
+
expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', false));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('dispatches session changed event - add/remove answer', () => {
|
|
109
|
+
const el = new Hotspot();
|
|
110
|
+
el.tagName = 'hotspot-el';
|
|
111
|
+
el.session = { answers: [{ id: '1' }] };
|
|
112
|
+
el.onSelectChoice({ id: '2', selected: true });
|
|
113
|
+
expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', true));
|
|
114
|
+
|
|
115
|
+
el.onSelectChoice({ id: '1', selected: false });
|
|
116
|
+
expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', true));
|
|
117
|
+
|
|
118
|
+
el.onSelectChoice({ id: '2', selected: false });
|
|
119
|
+
expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', false));
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { updateSessionValue } from '../session-updater';
|
|
2
|
+
|
|
3
|
+
const modelCopy = {
|
|
4
|
+
shapes: {
|
|
5
|
+
rectangles: [
|
|
6
|
+
{
|
|
7
|
+
id: '1',
|
|
8
|
+
correct: true,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: '2',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: '3',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
polygons: [
|
|
18
|
+
{
|
|
19
|
+
id: '4',
|
|
20
|
+
correct: true,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: '5',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
configure: {},
|
|
28
|
+
multipleCorrect: true,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const sessionCopy = {
|
|
32
|
+
answers: [
|
|
33
|
+
{
|
|
34
|
+
id: '1',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: '2',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
describe('session-updater', () => {
|
|
43
|
+
beforeEach(() => {});
|
|
44
|
+
|
|
45
|
+
describe('updateSessionValue', () => {
|
|
46
|
+
const assert = (session, model, data, expected) => {
|
|
47
|
+
return () => {
|
|
48
|
+
updateSessionValue(session, model, data);
|
|
49
|
+
expect(session.answers).toEqual(expected);
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
describe('deselect', () => {
|
|
54
|
+
it('deselects shape', assert(sessionCopy, modelCopy, { id: '1', selected: false }, [{ id: '2' }]));
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('select hotspot', () => {
|
|
58
|
+
it(
|
|
59
|
+
'selects shape in multiple choice mode',
|
|
60
|
+
assert(sessionCopy, modelCopy, { id: '1', selected: true }, [{ id: '2' }, { id: '1' }]),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
it(
|
|
64
|
+
'selects shape in single choice mode',
|
|
65
|
+
assert(sessionCopy, { ...modelCopy, multipleCorrect: false }, { id: '1', selected: true }, [{ id: '1' }]),
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|