@cosmicds/vue-toolkit 0.2.3 → 0.2.4

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/dist/index.umd.js CHANGED
@@ -8099,6 +8099,30 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.map-container{height:100%;width:100%;
8099
8099
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
8100
8100
 
8101
8101
 
8102
+ /***/ }),
8103
+
8104
+ /***/ 628:
8105
+ /***/ ((module, __webpack_exports__, __webpack_require__) => {
8106
+
8107
+ "use strict";
8108
+ __webpack_require__.r(__webpack_exports__);
8109
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8110
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
8111
+ /* harmony export */ });
8112
+ /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(601);
8113
+ /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
8114
+ /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(314);
8115
+ /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
8116
+ // Imports
8117
+
8118
+
8119
+ var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
8120
+ // Module
8121
+ ___CSS_LOADER_EXPORT___.push([module.id, `.rating-root{display:flex;flex-direction:column;gap:10px;align-items:center;padding:5px}.rating-icon-row{display:flex;flex-direction:row;gap:10px;padding:20px;justify-content:center}.rating{transition:color .1s}.selected{border-radius:50%;box-shadow:0 0 0 5px silver}.rating-notification{border-radius:5px;font-size:calc(var(--default-font-size)*1.1);padding:1em;color:#fff}.rating-notification.success{background-color:#9a009a}.rating-notification.error{background-color:#b30000}.comments-box{width:75%}.v-card-actions{display:var(--footer-visible)}.close-button{display:inline}.v-card-text{width:100%}.close-button{position:absolute;top:5px;right:5px}.rating-title{padding:5px 10px}`, ""]);
8122
+ // Exports
8123
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
8124
+
8125
+
8102
8126
  /***/ }),
8103
8127
 
8104
8128
  /***/ 671:
@@ -22960,6 +22984,22 @@ var update = add("dc8709b6", content, true, {"sourceMap":false,"shadowMode":fals
22960
22984
 
22961
22985
  /***/ }),
22962
22986
 
22987
+ /***/ 426:
22988
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
22989
+
22990
+ // style-loader: Adds some css to the DOM by adding a <style> tag
22991
+
22992
+ // load the styles
22993
+ var content = __webpack_require__(628);
22994
+ if(content.__esModule) content = content.default;
22995
+ if(typeof content === 'string') content = [[module.id, content, '']];
22996
+ if(content.locals) module.exports = content.locals;
22997
+ // add the styles to the DOM
22998
+ var add = (__webpack_require__(548)/* ["default"] */ .A)
22999
+ var update = add("93d4a2a8", content, true, {"sourceMap":false,"shadowMode":false});
23000
+
23001
+ /***/ }),
23002
+
22963
23003
  /***/ 293:
22964
23004
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
22965
23005
 
@@ -23409,6 +23449,7 @@ __webpack_require__.d(__webpack_exports__, {
23409
23449
  BackgroundImageset: () => (/* reexport */ BackgroundImageset),
23410
23450
  CreditLogos: () => (/* reexport */ CreditLogos),
23411
23451
  D2R: () => (/* reexport */ D2R),
23452
+ DEFAULT_RATING_COLORS: () => (/* reexport */ DEFAULT_RATING_COLORS),
23412
23453
  DefaultMiniCredits: () => (/* reexport */ DefaultMiniCredits),
23413
23454
  FundingAcknowledgment: () => (/* reexport */ FundingAcknowledgment),
23414
23455
  Gallery: () => (/* reexport */ Gallery),
@@ -23417,8 +23458,10 @@ __webpack_require__.d(__webpack_exports__, {
23417
23458
  LocationSelector: () => (/* reexport */ LocationSelector),
23418
23459
  MINIDS_BASE_URL: () => (/* reexport */ MINIDS_BASE_URL),
23419
23460
  MiniDSBase: () => (/* reexport */ MiniDSBase),
23420
- R2D: () => (/* reexport */ utils_R2D),
23461
+ R2D: () => (/* reexport */ R2D),
23462
+ UserExperience: () => (/* reexport */ UserExperience),
23421
23463
  skyBackgroundImagesets: () => (/* reexport */ skyBackgroundImagesets),
23464
+ submitUserExperienceRating: () => (/* reexport */ submitUserExperienceRating),
23422
23465
  wwtHUD: () => (/* reexport */ wwtHUD)
23423
23466
  });
23424
23467
 
@@ -33251,2140 +33294,158 @@ var CreditLogosvue_type_style_index_0_id_24887e9a_lang_css = __webpack_require__
33251
33294
  const CreditLogos_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(CreditLogosvue_type_script_lang_ts, [['render',CreditLogosvue_type_template_id_24887e9a_ts_true_render]])
33252
33295
 
33253
33296
  /* harmony default export */ const CreditLogos = (CreditLogos_exports_);
33254
- ;// CONCATENATED MODULE: ./node_modules/ts-loader/index.js??clonedRuleSet-83.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/wwtHUD.vue?vue&type=template&id=5867328d&ts=true
33255
-
33256
- var wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_1 = { id: "wwt-hud" };
33257
- var wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_2 = /*#__PURE__*/ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("h3", null, " Camera settings ", -1);
33258
- var wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_3 = /*#__PURE__*/ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("h3", null, " Imagesets ", -1);
33259
- var _hoisted_4 = /*#__PURE__*/ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("h3", null, " Clock ", -1);
33260
- var _hoisted_5 = { key: 0 };
33261
- function wwtHUDvue_type_template_id_5867328d_ts_true_render(_ctx, _cache, $props, $setup, $data, $options) {
33262
- return ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
33263
- style: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeStyle)(_ctx.cssVars)
33264
- }, [
33265
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_1, [
33266
- wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_2,
33267
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " RA: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtRARad) + " (" + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtRADeg) + ") ", 1),
33268
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Dec: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtDecRad) + " (" + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtDecDeg) + ") ", 1),
33269
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Roll: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtRollRad), 1),
33270
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Zoom: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtZoomDeg), 1),
33271
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Mode: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.mode), 1),
33272
- wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_3,
33273
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Bkg: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.bkgImage), 1),
33274
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Fg: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.fgImg) + " (op: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtForegroundOpacity) + " ) ", 1),
33275
- _hoisted_4,
33276
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Time: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtCurrentTime), 1),
33277
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Rate: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtClockRate), 1),
33278
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Location: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtLocation), 1),
33279
- (Object.keys(_ctx.otherVariables).length > 0)
33280
- ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("h3", _hoisted_5, " User defined vars "))
33281
- : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true),
33282
- ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(true), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)(external_commonjs_vue_commonjs2_vue_root_Vue_.Fragment, null, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderList)(_ctx.otherVariables, function (value, key) {
33283
- return ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("p", { key: key }, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(key) + ": " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(value), 1));
33284
- }), 128)),
33285
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderSlot)(_ctx.$slots, "default")
33286
- ])
33287
- ], 4));
33297
+ ;// CONCATENATED MODULE: ./node_modules/ts-loader/index.js??clonedRuleSet-83.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/UserExperience.vue?vue&type=template&id=7b3028df&ts=true
33298
+
33299
+ var UserExperiencevue_type_template_id_7b3028df_ts_true_hoisted_1 = { class: "rating-title" };
33300
+ var UserExperiencevue_type_template_id_7b3028df_ts_true_hoisted_2 = { class: "rating-icon-row" };
33301
+ function UserExperiencevue_type_template_id_7b3028df_ts_true_render(_ctx, _cache, $props, $setup, $data, $options) {
33302
+ var _component_v_spacer = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("v-spacer");
33303
+ var _component_v_btn = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("v-btn");
33304
+ var _component_FontAwesomeIcon = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("FontAwesomeIcon");
33305
+ var _component_v_hover = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("v-hover");
33306
+ var _component_VTextarea = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("VTextarea");
33307
+ var _component_v_expand_transition = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("v-expand-transition");
33308
+ var _component_v_form = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("v-form");
33309
+ var _component_v_card_text = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("v-card-text");
33310
+ var _component_v_card = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("v-card");
33311
+ return ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createBlock)(_component_v_card, {
33312
+ class: "rating-root",
33313
+ color: _ctx.color,
33314
+ style: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeStyle)(_ctx.css)
33315
+ }, {
33316
+ title: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withCtx)(function () { return [
33317
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", UserExperiencevue_type_template_id_7b3028df_ts_true_hoisted_1, [
33318
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("span", null, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.question), 1),
33319
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createVNode)(_component_v_spacer),
33320
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createVNode)(_component_v_btn, {
33321
+ density: "compact",
33322
+ class: "close-button",
33323
+ icon: "mdi-close",
33324
+ onClick: _cache[0] || (_cache[0] = function ($event) { return (_ctx.$emit('dismiss', _ctx.currentRating, _ctx.comments)); })
33325
+ })
33326
+ ])
33327
+ ]; }),
33328
+ actions: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withCtx)(function () { return [
33329
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderSlot)(_ctx.$slots, "footer")
33330
+ ]; }),
33331
+ default: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withCtx)(function () { return [
33332
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createVNode)(_component_v_card_text, null, {
33333
+ default: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withCtx)(function () { return [
33334
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createVNode)(_component_v_form, {
33335
+ onSubmit: _cache[3] || (_cache[3] = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withModifiers)(function ($event) { return (_ctx.$emit('finish', _ctx.currentRating, _ctx.comments)); }, ["prevent"]))
33336
+ }, {
33337
+ default: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withCtx)(function () { return [
33338
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", UserExperiencevue_type_template_id_7b3028df_ts_true_hoisted_2, [
33339
+ ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(true), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)(external_commonjs_vue_commonjs2_vue_root_Vue_.Fragment, null, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderList)(_ctx.ratings, function (rating) {
33340
+ return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderSlot)(_ctx.$slots, "default", { rating: rating }, function () { return [
33341
+ ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createBlock)(_component_v_hover, { key: rating }, {
33342
+ default: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withCtx)(function (_a) {
33343
+ var isHovering = _a.isHovering, props = _a.props;
33344
+ return [
33345
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createVNode)(_component_FontAwesomeIcon, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.mergeProps)(props, {
33346
+ size: _ctx.iconSize,
33347
+ class: ['rating', rating, { 'hovered': isHovering }, { 'selected': rating === _ctx.currentRating }],
33348
+ icon: _ctx.ratingIcons[rating][0],
33349
+ color: (isHovering || rating === _ctx.currentRating) ? _ctx.ratingIcons[rating][1] : _ctx.baseColor,
33350
+ onClick: function ($event) { return (_ctx.currentRating = rating); }
33351
+ }), null, 16, ["size", "class", "icon", "color", "onClick"])
33352
+ ];
33353
+ }),
33354
+ _: 2
33355
+ }, 1024))
33356
+ ]; });
33357
+ }), 256))
33358
+ ]),
33359
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createVNode)(_component_v_expand_transition, null, {
33360
+ default: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withCtx)(function () { return [
33361
+ (_ctx.showComments)
33362
+ ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createBlock)(_component_VTextarea, {
33363
+ key: 0,
33364
+ modelValue: _ctx.comments,
33365
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = function ($event) { return ((_ctx.comments) = $event); }),
33366
+ class: "comments-box text-body-2",
33367
+ placeholder: _ctx.commentPlaceholder,
33368
+ "auto-grow": "",
33369
+ "max-rows": "4",
33370
+ density: "compact",
33371
+ width: "100%",
33372
+ onKeydown: _cache[2] || (_cache[2] = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withModifiers)(function () { }, ["stop"]))
33373
+ }, null, 8, ["modelValue", "placeholder"]))
33374
+ : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)
33375
+ ]; }),
33376
+ _: 1
33377
+ }),
33378
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createVNode)(_component_v_expand_transition, null, {
33379
+ default: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withCtx)(function () { return [
33380
+ (_ctx.currentRating || _ctx.showComments)
33381
+ ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createBlock)(_component_v_btn, {
33382
+ key: 0,
33383
+ type: "submit",
33384
+ width: "fit-content",
33385
+ color: "success"
33386
+ }, {
33387
+ default: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withCtx)(function () { return [
33388
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createTextVNode)(" Submit ")
33389
+ ]; }),
33390
+ _: 1
33391
+ }))
33392
+ : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)
33393
+ ]; }),
33394
+ _: 1
33395
+ })
33396
+ ]; }),
33397
+ _: 3
33398
+ })
33399
+ ]; }),
33400
+ _: 3
33401
+ })
33402
+ ]; }),
33403
+ _: 3
33404
+ }, 8, ["color", "style"]));
33288
33405
  }
33289
33406
 
33290
- ;// CONCATENATED MODULE: ./src/components/wwtHUD.vue?vue&type=template&id=5867328d&ts=true
33291
-
33292
- // EXTERNAL MODULE: external {"amd":"@wwtelescope/engine","commonjs2":"@wwtelescope/engine","commonjs":"@wwtelescope/engine","root":"wwtlib"}
33293
- var engine_root_wwtlib_ = __webpack_require__(380);
33294
- ;// CONCATENATED MODULE: ./node_modules/ts-loader/index.js??clonedRuleSet-83.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/wwtHUD.vue?vue&type=script&lang=ts
33295
-
33407
+ ;// CONCATENATED MODULE: ./src/components/UserExperience.vue?vue&type=template&id=7b3028df&ts=true
33296
33408
 
33409
+ ;// CONCATENATED MODULE: ./src/utils.ts
33297
33410
 
33411
+ var D2R = Math.PI / 180;
33298
33412
  var R2D = 180 / Math.PI;
33299
- /* harmony default export */ const wwtHUDvue_type_script_lang_ts = ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.defineComponent)({
33300
- name: 'wwtHUD',
33301
- extends: index_umd.WWTAwareComponent,
33302
- props: {
33303
- // location: center {x, y} in percent
33304
- location: {
33305
- type: Object,
33306
- default: function () { return ({ top: '50%', left: '50%' }); }
33307
- },
33308
- offsetCenter: {
33309
- // example: {x: 0.5, y: 0.5} for transform: translate(-50%, -50%)
33310
- type: Object,
33311
- default: function () { return ({ x: .5, y: .5 }); }
33312
- },
33313
- otherVariables: {
33314
- type: Object,
33315
- default: function () { return ({}); }
33316
- },
33317
- // styling props
33318
- fontSize: {
33319
- type: String,
33320
- default: '1em'
33321
- },
33322
- backgroundColor: {
33323
- type: String || null,
33324
- default: 'rgba(0, 0, 0, 0.5)'
33325
- },
33326
- textShadow: {
33327
- type: String || null,
33328
- default: '0 0 5px black'
33329
- },
33330
- },
33331
- computed: {
33332
- wwtSettings: function () {
33333
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
33334
- // @ts-ignore
33335
- return engine_root_wwtlib_.Settings.get_active();
33336
- },
33337
- wwtControl: function () {
33338
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
33339
- // @ts-ignore
33340
- return engine_root_wwtlib_.WWTControl.singleton;
33341
- },
33342
- wwtScriptInterface: function () {
33343
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
33344
- // @ts-ignore
33345
- return engine_root_wwtlib_.ScriptInterface.singleton;
33346
- },
33347
- cssVars: function () {
33348
- var _a, _b, _c, _d;
33349
- return {
33350
- '--hud-top': (_a = this.location.top) !== null && _a !== void 0 ? _a : 'auto',
33351
- '--hud-left': (_b = this.location.left) !== null && _b !== void 0 ? _b : 'auto',
33352
- '--hud-bottom': (_c = this.location.bottom) !== null && _c !== void 0 ? _c : 'auto',
33353
- '--hud-right': (_d = this.location.right) !== null && _d !== void 0 ? _d : 'auto',
33354
- '--font-size': this.fontSize,
33355
- '--background-color': this.backgroundColor || 'transparent',
33356
- '--text-shadow': this.textShadow || 'none',
33357
- '--offset-center-x': "-".concat(this.offsetCenter.x * 100, "%"),
33358
- '--offset-center-y': "-".concat(this.offsetCenter.y * 100, "%"),
33413
+ var API_BASE_URL = "https://api.cosmicds.cfa.harvard.edu";
33414
+ var MINIDS_BASE_URL = "".concat(API_BASE_URL, "/minids");
33415
+ var DEFAULT_RATING_COLORS = ["red", "orange", "lightgreen", "green"];
33416
+ function submitUserExperienceRating(info, apiKey, url) {
33417
+ return __awaiter(this, void 0, void 0, function () {
33418
+ var body, destination;
33419
+ return __generator(this, function (_a) {
33420
+ body = {
33421
+ // eslint-disable-next-line @typescript-eslint/naming-convention
33422
+ story_name: info.story_name,
33423
+ uuid: info.uuid,
33359
33424
  };
33360
- },
33361
- wwtRADeg: function () {
33362
- return this.wwtRARad * R2D;
33363
- },
33364
- wwtDecDeg: function () {
33365
- return this.wwtDecRad * R2D;
33366
- },
33367
- bkgImage: function () {
33368
- var _a;
33369
- return (_a = this.wwtBackgroundImageset) === null || _a === void 0 ? void 0 : _a.get_name();
33370
- },
33371
- fgImg: function () {
33372
- var _a;
33373
- return (_a = this.wwtForegroundImageset) === null || _a === void 0 ? void 0 : _a.get_name();
33374
- },
33375
- mode: function () {
33376
- if (this.bkgImage == "3D Solar System View") {
33377
- return '3D';
33378
- }
33379
- if (this.wwtSettings.get_galacticMode()) {
33380
- return 'Sky (galactic)';
33425
+ if (info.comments) {
33426
+ body.comments = info.comments;
33381
33427
  }
33382
- if (this.wwtSettings.get_localHorizonMode()) {
33383
- return 'Sky (local horizon)';
33428
+ if (info.rating) {
33429
+ body.rating == info.rating;
33384
33430
  }
33385
- return 'Sky (equatorial)';
33386
- },
33387
- wwtLocation: function () {
33388
- return {
33389
- lat: this.wwtSettings.get_locationLat(),
33390
- lon: this.wwtSettings.get_locationLng(),
33391
- alt: this.wwtSettings.get_locationAltitude(),
33392
- };
33393
- },
33394
- },
33395
- }));
33396
-
33397
- ;// CONCATENATED MODULE: ./src/components/wwtHUD.vue?vue&type=script&lang=ts
33398
-
33399
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-75.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-75.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-75.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-75.use[3]!./node_modules/less-loader/dist/cjs.js??clonedRuleSet-75.use[4]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/wwtHUD.vue?vue&type=style&index=0&id=5867328d&lang=less
33400
- var wwtHUDvue_type_style_index_0_id_5867328d_lang_less = __webpack_require__(293);
33401
- ;// CONCATENATED MODULE: ./src/components/wwtHUD.vue?vue&type=style&index=0&id=5867328d&lang=less
33402
-
33403
- ;// CONCATENATED MODULE: ./src/components/wwtHUD.vue
33404
-
33405
-
33406
-
33407
-
33408
- ;
33409
-
33410
-
33411
- const wwtHUD_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(wwtHUDvue_type_script_lang_ts, [['render',wwtHUDvue_type_template_id_5867328d_ts_true_render]])
33412
-
33413
- /* harmony default export */ const wwtHUD = (wwtHUD_exports_);
33414
- ;// CONCATENATED MODULE: ./src/background.ts
33415
- var BackgroundImageset = /** @class */ (function () {
33416
- function BackgroundImageset(displayName, imagesetName) {
33417
- this.displayName = displayName;
33418
- this.imagesetName = imagesetName;
33419
- }
33420
- return BackgroundImageset;
33421
- }());
33422
-
33423
- var skyBackgroundImagesets = [
33424
- new BackgroundImageset("Optical (Terapixel DSS)", "Digitized Sky Survey (Color)"),
33425
- new BackgroundImageset("Low-frequency radio (VLSS)", "VLSS: VLA Low-frequency Sky Survey (Radio)"),
33426
- new BackgroundImageset("Infrared (2MASS)", "2Mass: Imagery (Infrared)"),
33427
- new BackgroundImageset("Infrared (SFD dust map)", "SFD Dust Map (Infrared)"),
33428
- new BackgroundImageset("Ultraviolet (GALEX)", "GALEX (Ultraviolet)"),
33429
- new BackgroundImageset("X-Ray (ROSAT RASS)", "RASS: ROSAT All Sky Survey (X-ray)"),
33430
- new BackgroundImageset("Gamma Rays (FERMI LAT 8-year)", "Fermi LAT 8-year (gamma)"),
33431
- ];
33432
-
33433
- ;// CONCATENATED MODULE: ./node_modules/ts-loader/index.js??clonedRuleSet-83.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Gallery.vue?vue&type=template&id=4cc30028&ts=true
33434
-
33435
-
33436
- var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_1 = { class: "default-activator-title noselect" };
33437
- var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_2 = ["src"];
33438
- var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_3 = { class: "gallery-header" };
33439
- var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_4 = { class: "gallery-title" };
33440
- var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_5 = { class: "gallery-content" };
33441
- var _hoisted_6 = ["onClick"];
33442
- var _hoisted_7 = ["src"];
33443
- var _hoisted_8 = { class: "place-name noselect" };
33444
- function Galleryvue_type_template_id_4cc30028_ts_true_render(_ctx, _cache, $props, $setup, $data, $options) {
33445
- var _component_font_awesome_icon = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("font-awesome-icon");
33446
- return ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
33447
- class: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeClass)(['gallery-root', { 'open': _ctx.open }])
33448
- }, [
33449
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", {
33450
- class: "just-holding-events",
33451
- onClick: _cache[2] || (_cache[2] = function ($event) { return (_ctx.open = true); }),
33452
- onKeyup: _cache[3] || (_cache[3] = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withKeys)(function ($event) { return (_ctx.open = true); }, ["enter"])),
33453
- tabindex: "0"
33454
- }, [
33455
- (!_ctx.open)
33456
- ? (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderSlot)(_ctx.$slots, "closed", { key: 0 }, function () {
33457
- var _a, _b;
33458
- return [
33459
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", {
33460
- class: "default-activator blurred",
33461
- onClick: _cache[0] || (_cache[0] = function ($event) { return (_ctx.open = true); }),
33462
- onKeyup: _cache[1] || (_cache[1] = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withKeys)(function ($event) { return (_ctx.open = true); }, ["enter"]))
33463
- }, [
33464
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("span", Galleryvue_type_template_id_4cc30028_ts_true_hoisted_1, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.closedText), 1),
33465
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("img", {
33466
- class: "noselect",
33467
- src: _ctx.places[_ctx.previewIndex] ? ((_b = (_a = _ctx.getImageset(_ctx.places[_ctx.previewIndex])) === null || _a === void 0 ? void 0 : _a.get_thumbnailUrl()) !== null && _b !== void 0 ? _b : '') : ''
33468
- }, null, 8, Galleryvue_type_template_id_4cc30028_ts_true_hoisted_2)
33469
- ], 32)
33470
- ];
33431
+ destination = url !== null && url !== void 0 ? url : "".concat(API_BASE_URL, "/stories/user-experience");
33432
+ return [2 /*return*/, fetch(destination, {
33433
+ method: "PUT",
33434
+ body: JSON.stringify(body),
33435
+ headers: {
33436
+ // eslint-disable-next-line @typescript-eslint/naming-convention
33437
+ "Authorization": apiKey,
33438
+ // eslint-disable-next-line @typescript-eslint/naming-convention
33439
+ "Content-Type": "application/json",
33440
+ },
33471
33441
  })
33472
- : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)
33473
- ], 32),
33474
- (_ctx.open)
33475
- ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
33476
- key: 0,
33477
- style: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeStyle)(_ctx.cssVars),
33478
- class: "gallery blurred"
33479
- }, [
33480
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", Galleryvue_type_template_id_4cc30028_ts_true_hoisted_3, [
33481
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("span", Galleryvue_type_template_id_4cc30028_ts_true_hoisted_4, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.title), 1),
33482
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createVNode)(_component_font_awesome_icon, {
33483
- class: "gallery-close",
33484
- icon: "times",
33485
- size: "lg",
33486
- onClick: _cache[4] || (_cache[4] = function ($event) { return (_ctx.open = false); }),
33487
- onKeyup: _cache[5] || (_cache[5] = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withKeys)(function ($event) { return (_ctx.open = false); }, ["enter"])),
33488
- tabindex: "0"
33489
- })
33490
- ]),
33491
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", Galleryvue_type_template_id_4cc30028_ts_true_hoisted_5, [
33492
- ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(true), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)(external_commonjs_vue_commonjs2_vue_root_Vue_.Fragment, null, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderList)(_ctx.places.entries(), function (_a) {
33493
- var _b, _c;
33494
- var _d = __read(_a, 2), index = _d[0], place = _d[1];
33495
- return ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
33496
- key: index,
33497
- class: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeClass)(['gallery-item', { 'selected': _ctx.highlightLastOnly ? _ctx.selectedPlace === place : _ctx.selectedPlaces.includes(place) }]),
33498
- onClick: function ($event) { return (_ctx.selectPlace(place)); }
33499
- }, [
33500
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("img", {
33501
- class: "noselect",
33502
- src: (_c = (_b = _ctx.getImageset(place)) === null || _b === void 0 ? void 0 : _b.get_thumbnailUrl()) !== null && _c !== void 0 ? _c : ''
33503
- }, null, 8, _hoisted_7),
33504
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("span", _hoisted_8, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(place.get_name()), 1)
33505
- ], 10, _hoisted_6));
33506
- }), 128))
33507
- ])
33508
- ], 4))
33509
- : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)
33510
- ], 2));
33511
- }
33512
-
33513
- ;// CONCATENATED MODULE: ./src/components/Gallery.vue?vue&type=template&id=4cc30028&ts=true
33514
-
33515
- ;// CONCATENATED MODULE: ./node_modules/vue-demi/lib/index.mjs
33516
-
33517
-
33518
- var lib_isVue2 = false
33519
- var isVue3 = true
33520
- var Vue2 = (/* unused pure expression or super */ null && (undefined))
33521
-
33522
- function install() {}
33523
-
33524
- function lib_set(target, key, val) {
33525
- if (Array.isArray(target)) {
33526
- target.length = Math.max(target.length, key)
33527
- target.splice(key, 1, val)
33528
- return val
33529
- }
33530
- target[key] = val
33531
- return val
33532
- }
33533
-
33534
- function del(target, key) {
33535
- if (Array.isArray(target)) {
33536
- target.splice(key, 1)
33537
- return
33538
- }
33539
- delete target[key]
33540
- }
33541
-
33542
-
33543
-
33544
-
33545
- ;// CONCATENATED MODULE: ./node_modules/pinia/dist/pinia.mjs
33546
- /*!
33547
- * pinia v2.1.7
33548
- * (c) 2023 Eduardo San Martin Morote
33549
- * @license MIT
33550
- */
33551
-
33552
-
33553
-
33554
- /**
33555
- * setActivePinia must be called to handle SSR at the top of functions like
33556
- * `fetch`, `setup`, `serverPrefetch` and others
33557
- */
33558
- let activePinia;
33559
- /**
33560
- * Sets or unsets the active pinia. Used in SSR and internally when calling
33561
- * actions and getters
33562
- *
33563
- * @param pinia - Pinia instance
33564
- */
33565
- // @ts-expect-error: cannot constrain the type of the return
33566
- const setActivePinia = (pinia) => (activePinia = pinia);
33567
- /**
33568
- * Get the currently active pinia if there is any.
33569
- */
33570
- const getActivePinia = () => (hasInjectionContext() && inject(piniaSymbol)) || activePinia;
33571
- const piniaSymbol = (( false) ? 0 : /* istanbul ignore next */ Symbol());
33572
-
33573
- function isPlainObject(
33574
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33575
- o) {
33576
- return (o &&
33577
- typeof o === 'object' &&
33578
- Object.prototype.toString.call(o) === '[object Object]' &&
33579
- typeof o.toJSON !== 'function');
33442
+ .catch(function (error) {
33443
+ console.error(error);
33444
+ return null;
33445
+ })];
33446
+ });
33447
+ });
33580
33448
  }
33581
- // type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]> }
33582
- // TODO: can we change these to numbers?
33583
- /**
33584
- * Possible types for SubscriptionCallback
33585
- */
33586
- var MutationType;
33587
- (function (MutationType) {
33588
- /**
33589
- * Direct mutation of the state:
33590
- *
33591
- * - `store.name = 'new name'`
33592
- * - `store.$state.name = 'new name'`
33593
- * - `store.list.push('new item')`
33594
- */
33595
- MutationType["direct"] = "direct";
33596
- /**
33597
- * Mutated the state with `$patch` and an object
33598
- *
33599
- * - `store.$patch({ name: 'newName' })`
33600
- */
33601
- MutationType["patchObject"] = "patch object";
33602
- /**
33603
- * Mutated the state with `$patch` and a function
33604
- *
33605
- * - `store.$patch(state => state.name = 'newName')`
33606
- */
33607
- MutationType["patchFunction"] = "patch function";
33608
- // maybe reset? for $state = {} and $reset
33609
- })(MutationType || (MutationType = {}));
33610
-
33611
- const IS_CLIENT = typeof window !== 'undefined';
33612
- /**
33613
- * Should we add the devtools plugins.
33614
- * - only if dev mode or forced through the prod devtools flag
33615
- * - not in test
33616
- * - only if window exists (could change in the future)
33617
- */
33618
- const USE_DEVTOOLS = (/* unused pure expression or super */ null && ( false && 0));
33619
-
33620
- /*
33621
- * FileSaver.js A saveAs() FileSaver implementation.
33622
- *
33623
- * Originally by Eli Grey, adapted as an ESM module by Eduardo San Martin
33624
- * Morote.
33625
- *
33626
- * License : MIT
33627
- */
33628
- // The one and only way of getting global scope in all environments
33629
- // https://stackoverflow.com/q/3277182/1008999
33630
- const _global = /*#__PURE__*/ (() => typeof window === 'object' && window.window === window
33631
- ? window
33632
- : typeof self === 'object' && self.self === self
33633
- ? self
33634
- : typeof global === 'object' && global.global === global
33635
- ? global
33636
- : typeof globalThis === 'object'
33637
- ? globalThis
33638
- : { HTMLElement: null })();
33639
- function bom(blob, { autoBom = false } = {}) {
33640
- // prepend BOM for UTF-8 XML and text/* types (including HTML)
33641
- // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
33642
- if (autoBom &&
33643
- /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
33644
- return new Blob([String.fromCharCode(0xfeff), blob], { type: blob.type });
33645
- }
33646
- return blob;
33647
- }
33648
- function download(url, name, opts) {
33649
- const xhr = new XMLHttpRequest();
33650
- xhr.open('GET', url);
33651
- xhr.responseType = 'blob';
33652
- xhr.onload = function () {
33653
- saveAs(xhr.response, name, opts);
33654
- };
33655
- xhr.onerror = function () {
33656
- console.error('could not download file');
33657
- };
33658
- xhr.send();
33659
- }
33660
- function corsEnabled(url) {
33661
- const xhr = new XMLHttpRequest();
33662
- // use sync to avoid popup blocker
33663
- xhr.open('HEAD', url, false);
33664
- try {
33665
- xhr.send();
33666
- }
33667
- catch (e) { }
33668
- return xhr.status >= 200 && xhr.status <= 299;
33669
- }
33670
- // `a.click()` doesn't work for all browsers (#465)
33671
- function click(node) {
33672
- try {
33673
- node.dispatchEvent(new MouseEvent('click'));
33674
- }
33675
- catch (e) {
33676
- const evt = document.createEvent('MouseEvents');
33677
- evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
33678
- node.dispatchEvent(evt);
33679
- }
33680
- }
33681
- const _navigator =
33682
- typeof navigator === 'object' ? navigator : { userAgent: '' };
33683
- // Detect WebView inside a native macOS app by ruling out all browsers
33684
- // We just need to check for 'Safari' because all other browsers (besides Firefox) include that too
33685
- // https://www.whatismybrowser.com/guides/the-latest-user-agent/macos
33686
- const isMacOSWebView = /*#__PURE__*/ (() => /Macintosh/.test(_navigator.userAgent) &&
33687
- /AppleWebKit/.test(_navigator.userAgent) &&
33688
- !/Safari/.test(_navigator.userAgent))();
33689
- const saveAs = !IS_CLIENT
33690
- ? () => { } // noop
33691
- : // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program
33692
- typeof HTMLAnchorElement !== 'undefined' &&
33693
- 'download' in HTMLAnchorElement.prototype &&
33694
- !isMacOSWebView
33695
- ? downloadSaveAs
33696
- : // Use msSaveOrOpenBlob as a second approach
33697
- 'msSaveOrOpenBlob' in _navigator
33698
- ? msSaveAs
33699
- : // Fallback to using FileReader and a popup
33700
- fileSaverSaveAs;
33701
- function downloadSaveAs(blob, name = 'download', opts) {
33702
- const a = document.createElement('a');
33703
- a.download = name;
33704
- a.rel = 'noopener'; // tabnabbing
33705
- // TODO: detect chrome extensions & packaged apps
33706
- // a.target = '_blank'
33707
- if (typeof blob === 'string') {
33708
- // Support regular links
33709
- a.href = blob;
33710
- if (a.origin !== location.origin) {
33711
- if (corsEnabled(a.href)) {
33712
- download(blob, name, opts);
33713
- }
33714
- else {
33715
- a.target = '_blank';
33716
- click(a);
33717
- }
33718
- }
33719
- else {
33720
- click(a);
33721
- }
33722
- }
33723
- else {
33724
- // Support blobs
33725
- a.href = URL.createObjectURL(blob);
33726
- setTimeout(function () {
33727
- URL.revokeObjectURL(a.href);
33728
- }, 4e4); // 40s
33729
- setTimeout(function () {
33730
- click(a);
33731
- }, 0);
33732
- }
33733
- }
33734
- function msSaveAs(blob, name = 'download', opts) {
33735
- if (typeof blob === 'string') {
33736
- if (corsEnabled(blob)) {
33737
- download(blob, name, opts);
33738
- }
33739
- else {
33740
- const a = document.createElement('a');
33741
- a.href = blob;
33742
- a.target = '_blank';
33743
- setTimeout(function () {
33744
- click(a);
33745
- });
33746
- }
33747
- }
33748
- else {
33749
- // @ts-ignore: works on windows
33750
- navigator.msSaveOrOpenBlob(bom(blob, opts), name);
33751
- }
33752
- }
33753
- function fileSaverSaveAs(blob, name, opts, popup) {
33754
- // Open a popup immediately do go around popup blocker
33755
- // Mostly only available on user interaction and the fileReader is async so...
33756
- popup = popup || open('', '_blank');
33757
- if (popup) {
33758
- popup.document.title = popup.document.body.innerText = 'downloading...';
33759
- }
33760
- if (typeof blob === 'string')
33761
- return download(blob, name, opts);
33762
- const force = blob.type === 'application/octet-stream';
33763
- const isSafari = /constructor/i.test(String(_global.HTMLElement)) || 'safari' in _global;
33764
- const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
33765
- if ((isChromeIOS || (force && isSafari) || isMacOSWebView) &&
33766
- typeof FileReader !== 'undefined') {
33767
- // Safari doesn't allow downloading of blob URLs
33768
- const reader = new FileReader();
33769
- reader.onloadend = function () {
33770
- let url = reader.result;
33771
- if (typeof url !== 'string') {
33772
- popup = null;
33773
- throw new Error('Wrong reader.result type');
33774
- }
33775
- url = isChromeIOS
33776
- ? url
33777
- : url.replace(/^data:[^;]*;/, 'data:attachment/file;');
33778
- if (popup) {
33779
- popup.location.href = url;
33780
- }
33781
- else {
33782
- location.assign(url);
33783
- }
33784
- popup = null; // reverse-tabnabbing #460
33785
- };
33786
- reader.readAsDataURL(blob);
33787
- }
33788
- else {
33789
- const url = URL.createObjectURL(blob);
33790
- if (popup)
33791
- popup.location.assign(url);
33792
- else
33793
- location.href = url;
33794
- popup = null; // reverse-tabnabbing #460
33795
- setTimeout(function () {
33796
- URL.revokeObjectURL(url);
33797
- }, 4e4); // 40s
33798
- }
33799
- }
33800
-
33801
- /**
33802
- * Shows a toast or console.log
33803
- *
33804
- * @param message - message to log
33805
- * @param type - different color of the tooltip
33806
- */
33807
- function toastMessage(message, type) {
33808
- const piniaMessage = '🍍 ' + message;
33809
- if (typeof __VUE_DEVTOOLS_TOAST__ === 'function') {
33810
- // No longer available :(
33811
- __VUE_DEVTOOLS_TOAST__(piniaMessage, type);
33812
- }
33813
- else if (type === 'error') {
33814
- console.error(piniaMessage);
33815
- }
33816
- else if (type === 'warn') {
33817
- console.warn(piniaMessage);
33818
- }
33819
- else {
33820
- console.log(piniaMessage);
33821
- }
33822
- }
33823
- function isPinia(o) {
33824
- return '_a' in o && 'install' in o;
33825
- }
33826
-
33827
- /**
33828
- * This file contain devtools actions, they are not Pinia actions.
33829
- */
33830
- // ---
33831
- function checkClipboardAccess() {
33832
- if (!('clipboard' in navigator)) {
33833
- toastMessage(`Your browser doesn't support the Clipboard API`, 'error');
33834
- return true;
33835
- }
33836
- }
33837
- function checkNotFocusedError(error) {
33838
- if (error instanceof Error &&
33839
- error.message.toLowerCase().includes('document is not focused')) {
33840
- toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', 'warn');
33841
- return true;
33842
- }
33843
- return false;
33844
- }
33845
- async function actionGlobalCopyState(pinia) {
33846
- if (checkClipboardAccess())
33847
- return;
33848
- try {
33849
- await navigator.clipboard.writeText(JSON.stringify(pinia.state.value));
33850
- toastMessage('Global state copied to clipboard.');
33851
- }
33852
- catch (error) {
33853
- if (checkNotFocusedError(error))
33854
- return;
33855
- toastMessage(`Failed to serialize the state. Check the console for more details.`, 'error');
33856
- console.error(error);
33857
- }
33858
- }
33859
- async function actionGlobalPasteState(pinia) {
33860
- if (checkClipboardAccess())
33861
- return;
33862
- try {
33863
- loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText()));
33864
- toastMessage('Global state pasted from clipboard.');
33865
- }
33866
- catch (error) {
33867
- if (checkNotFocusedError(error))
33868
- return;
33869
- toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, 'error');
33870
- console.error(error);
33871
- }
33872
- }
33873
- async function actionGlobalSaveState(pinia) {
33874
- try {
33875
- saveAs(new Blob([JSON.stringify(pinia.state.value)], {
33876
- type: 'text/plain;charset=utf-8',
33877
- }), 'pinia-state.json');
33878
- }
33879
- catch (error) {
33880
- toastMessage(`Failed to export the state as JSON. Check the console for more details.`, 'error');
33881
- console.error(error);
33882
- }
33883
- }
33884
- let fileInput;
33885
- function getFileOpener() {
33886
- if (!fileInput) {
33887
- fileInput = document.createElement('input');
33888
- fileInput.type = 'file';
33889
- fileInput.accept = '.json';
33890
- }
33891
- function openFile() {
33892
- return new Promise((resolve, reject) => {
33893
- fileInput.onchange = async () => {
33894
- const files = fileInput.files;
33895
- if (!files)
33896
- return resolve(null);
33897
- const file = files.item(0);
33898
- if (!file)
33899
- return resolve(null);
33900
- return resolve({ text: await file.text(), file });
33901
- };
33902
- // @ts-ignore: TODO: changed from 4.3 to 4.4
33903
- fileInput.oncancel = () => resolve(null);
33904
- fileInput.onerror = reject;
33905
- fileInput.click();
33906
- });
33907
- }
33908
- return openFile;
33909
- }
33910
- async function actionGlobalOpenStateFile(pinia) {
33911
- try {
33912
- const open = getFileOpener();
33913
- const result = await open();
33914
- if (!result)
33915
- return;
33916
- const { text, file } = result;
33917
- loadStoresState(pinia, JSON.parse(text));
33918
- toastMessage(`Global state imported from "${file.name}".`);
33919
- }
33920
- catch (error) {
33921
- toastMessage(`Failed to import the state from JSON. Check the console for more details.`, 'error');
33922
- console.error(error);
33923
- }
33924
- }
33925
- function loadStoresState(pinia, state) {
33926
- for (const key in state) {
33927
- const storeState = pinia.state.value[key];
33928
- // store is already instantiated, patch it
33929
- if (storeState) {
33930
- Object.assign(storeState, state[key]);
33931
- }
33932
- else {
33933
- // store is not instantiated, set the initial state
33934
- pinia.state.value[key] = state[key];
33935
- }
33936
- }
33937
- }
33938
-
33939
- function formatDisplay(display) {
33940
- return {
33941
- _custom: {
33942
- display,
33943
- },
33944
- };
33945
- }
33946
- const PINIA_ROOT_LABEL = '🍍 Pinia (root)';
33947
- const PINIA_ROOT_ID = '_root';
33948
- function formatStoreForInspectorTree(store) {
33949
- return isPinia(store)
33950
- ? {
33951
- id: PINIA_ROOT_ID,
33952
- label: PINIA_ROOT_LABEL,
33953
- }
33954
- : {
33955
- id: store.$id,
33956
- label: store.$id,
33957
- };
33958
- }
33959
- function formatStoreForInspectorState(store) {
33960
- if (isPinia(store)) {
33961
- const storeNames = Array.from(store._s.keys());
33962
- const storeMap = store._s;
33963
- const state = {
33964
- state: storeNames.map((storeId) => ({
33965
- editable: true,
33966
- key: storeId,
33967
- value: store.state.value[storeId],
33968
- })),
33969
- getters: storeNames
33970
- .filter((id) => storeMap.get(id)._getters)
33971
- .map((id) => {
33972
- const store = storeMap.get(id);
33973
- return {
33974
- editable: false,
33975
- key: id,
33976
- value: store._getters.reduce((getters, key) => {
33977
- getters[key] = store[key];
33978
- return getters;
33979
- }, {}),
33980
- };
33981
- }),
33982
- };
33983
- return state;
33984
- }
33985
- const state = {
33986
- state: Object.keys(store.$state).map((key) => ({
33987
- editable: true,
33988
- key,
33989
- value: store.$state[key],
33990
- })),
33991
- };
33992
- // avoid adding empty getters
33993
- if (store._getters && store._getters.length) {
33994
- state.getters = store._getters.map((getterName) => ({
33995
- editable: false,
33996
- key: getterName,
33997
- value: store[getterName],
33998
- }));
33999
- }
34000
- if (store._customProperties.size) {
34001
- state.customProperties = Array.from(store._customProperties).map((key) => ({
34002
- editable: true,
34003
- key,
34004
- value: store[key],
34005
- }));
34006
- }
34007
- return state;
34008
- }
34009
- function formatEventData(events) {
34010
- if (!events)
34011
- return {};
34012
- if (Array.isArray(events)) {
34013
- // TODO: handle add and delete for arrays and objects
34014
- return events.reduce((data, event) => {
34015
- data.keys.push(event.key);
34016
- data.operations.push(event.type);
34017
- data.oldValue[event.key] = event.oldValue;
34018
- data.newValue[event.key] = event.newValue;
34019
- return data;
34020
- }, {
34021
- oldValue: {},
34022
- keys: [],
34023
- operations: [],
34024
- newValue: {},
34025
- });
34026
- }
34027
- else {
34028
- return {
34029
- operation: formatDisplay(events.type),
34030
- key: formatDisplay(events.key),
34031
- oldValue: events.oldValue,
34032
- newValue: events.newValue,
34033
- };
34034
- }
34035
- }
34036
- function formatMutationType(type) {
34037
- switch (type) {
34038
- case MutationType.direct:
34039
- return 'mutation';
34040
- case MutationType.patchFunction:
34041
- return '$patch';
34042
- case MutationType.patchObject:
34043
- return '$patch';
34044
- default:
34045
- return 'unknown';
34046
- }
34047
- }
34048
-
34049
- // timeline can be paused when directly changing the state
34050
- let isTimelineActive = true;
34051
- const componentStateTypes = (/* unused pure expression or super */ null && ([]));
34052
- const MUTATIONS_LAYER_ID = 'pinia:mutations';
34053
- const INSPECTOR_ID = 'pinia';
34054
- const { assign: assign$1 } = Object;
34055
- /**
34056
- * Gets the displayed name of a store in devtools
34057
- *
34058
- * @param id - id of the store
34059
- * @returns a formatted string
34060
- */
34061
- const getStoreType = (id) => '🍍 ' + id;
34062
- /**
34063
- * Add the pinia plugin without any store. Allows displaying a Pinia plugin tab
34064
- * as soon as it is added to the application.
34065
- *
34066
- * @param app - Vue application
34067
- * @param pinia - pinia instance
34068
- */
34069
- function registerPiniaDevtools(app, pinia) {
34070
- setupDevtoolsPlugin({
34071
- id: 'dev.esm.pinia',
34072
- label: 'Pinia 🍍',
34073
- logo: 'https://pinia.vuejs.org/logo.svg',
34074
- packageName: 'pinia',
34075
- homepage: 'https://pinia.vuejs.org',
34076
- componentStateTypes,
34077
- app,
34078
- }, (api) => {
34079
- if (typeof api.now !== 'function') {
34080
- toastMessage('You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.');
34081
- }
34082
- api.addTimelineLayer({
34083
- id: MUTATIONS_LAYER_ID,
34084
- label: `Pinia 🍍`,
34085
- color: 0xe5df88,
34086
- });
34087
- api.addInspector({
34088
- id: INSPECTOR_ID,
34089
- label: 'Pinia 🍍',
34090
- icon: 'storage',
34091
- treeFilterPlaceholder: 'Search stores',
34092
- actions: [
34093
- {
34094
- icon: 'content_copy',
34095
- action: () => {
34096
- actionGlobalCopyState(pinia);
34097
- },
34098
- tooltip: 'Serialize and copy the state',
34099
- },
34100
- {
34101
- icon: 'content_paste',
34102
- action: async () => {
34103
- await actionGlobalPasteState(pinia);
34104
- api.sendInspectorTree(INSPECTOR_ID);
34105
- api.sendInspectorState(INSPECTOR_ID);
34106
- },
34107
- tooltip: 'Replace the state with the content of your clipboard',
34108
- },
34109
- {
34110
- icon: 'save',
34111
- action: () => {
34112
- actionGlobalSaveState(pinia);
34113
- },
34114
- tooltip: 'Save the state as a JSON file',
34115
- },
34116
- {
34117
- icon: 'folder_open',
34118
- action: async () => {
34119
- await actionGlobalOpenStateFile(pinia);
34120
- api.sendInspectorTree(INSPECTOR_ID);
34121
- api.sendInspectorState(INSPECTOR_ID);
34122
- },
34123
- tooltip: 'Import the state from a JSON file',
34124
- },
34125
- ],
34126
- nodeActions: [
34127
- {
34128
- icon: 'restore',
34129
- tooltip: 'Reset the state (with "$reset")',
34130
- action: (nodeId) => {
34131
- const store = pinia._s.get(nodeId);
34132
- if (!store) {
34133
- toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, 'warn');
34134
- }
34135
- else if (typeof store.$reset !== 'function') {
34136
- toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, 'warn');
34137
- }
34138
- else {
34139
- store.$reset();
34140
- toastMessage(`Store "${nodeId}" reset.`);
34141
- }
34142
- },
34143
- },
34144
- ],
34145
- });
34146
- api.on.inspectComponent((payload, ctx) => {
34147
- const proxy = (payload.componentInstance &&
34148
- payload.componentInstance.proxy);
34149
- if (proxy && proxy._pStores) {
34150
- const piniaStores = payload.componentInstance.proxy._pStores;
34151
- Object.values(piniaStores).forEach((store) => {
34152
- payload.instanceData.state.push({
34153
- type: getStoreType(store.$id),
34154
- key: 'state',
34155
- editable: true,
34156
- value: store._isOptionsAPI
34157
- ? {
34158
- _custom: {
34159
- value: toRaw(store.$state),
34160
- actions: [
34161
- {
34162
- icon: 'restore',
34163
- tooltip: 'Reset the state of this store',
34164
- action: () => store.$reset(),
34165
- },
34166
- ],
34167
- },
34168
- }
34169
- : // NOTE: workaround to unwrap transferred refs
34170
- Object.keys(store.$state).reduce((state, key) => {
34171
- state[key] = store.$state[key];
34172
- return state;
34173
- }, {}),
34174
- });
34175
- if (store._getters && store._getters.length) {
34176
- payload.instanceData.state.push({
34177
- type: getStoreType(store.$id),
34178
- key: 'getters',
34179
- editable: false,
34180
- value: store._getters.reduce((getters, key) => {
34181
- try {
34182
- getters[key] = store[key];
34183
- }
34184
- catch (error) {
34185
- // @ts-expect-error: we just want to show it in devtools
34186
- getters[key] = error;
34187
- }
34188
- return getters;
34189
- }, {}),
34190
- });
34191
- }
34192
- });
34193
- }
34194
- });
34195
- api.on.getInspectorTree((payload) => {
34196
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
34197
- let stores = [pinia];
34198
- stores = stores.concat(Array.from(pinia._s.values()));
34199
- payload.rootNodes = (payload.filter
34200
- ? stores.filter((store) => '$id' in store
34201
- ? store.$id
34202
- .toLowerCase()
34203
- .includes(payload.filter.toLowerCase())
34204
- : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase()))
34205
- : stores).map(formatStoreForInspectorTree);
34206
- }
34207
- });
34208
- api.on.getInspectorState((payload) => {
34209
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
34210
- const inspectedStore = payload.nodeId === PINIA_ROOT_ID
34211
- ? pinia
34212
- : pinia._s.get(payload.nodeId);
34213
- if (!inspectedStore) {
34214
- // this could be the selected store restored for a different project
34215
- // so it's better not to say anything here
34216
- return;
34217
- }
34218
- if (inspectedStore) {
34219
- payload.state = formatStoreForInspectorState(inspectedStore);
34220
- }
34221
- }
34222
- });
34223
- api.on.editInspectorState((payload, ctx) => {
34224
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
34225
- const inspectedStore = payload.nodeId === PINIA_ROOT_ID
34226
- ? pinia
34227
- : pinia._s.get(payload.nodeId);
34228
- if (!inspectedStore) {
34229
- return toastMessage(`store "${payload.nodeId}" not found`, 'error');
34230
- }
34231
- const { path } = payload;
34232
- if (!isPinia(inspectedStore)) {
34233
- // access only the state
34234
- if (path.length !== 1 ||
34235
- !inspectedStore._customProperties.has(path[0]) ||
34236
- path[0] in inspectedStore.$state) {
34237
- path.unshift('$state');
34238
- }
34239
- }
34240
- else {
34241
- // Root access, we can omit the `.value` because the devtools API does it for us
34242
- path.unshift('state');
34243
- }
34244
- isTimelineActive = false;
34245
- payload.set(inspectedStore, path, payload.state.value);
34246
- isTimelineActive = true;
34247
- }
34248
- });
34249
- api.on.editComponentState((payload) => {
34250
- if (payload.type.startsWith('🍍')) {
34251
- const storeId = payload.type.replace(/^🍍\s*/, '');
34252
- const store = pinia._s.get(storeId);
34253
- if (!store) {
34254
- return toastMessage(`store "${storeId}" not found`, 'error');
34255
- }
34256
- const { path } = payload;
34257
- if (path[0] !== 'state') {
34258
- return toastMessage(`Invalid path for store "${storeId}":\n${path}\nOnly state can be modified.`);
34259
- }
34260
- // rewrite the first entry to be able to directly set the state as
34261
- // well as any other path
34262
- path[0] = '$state';
34263
- isTimelineActive = false;
34264
- payload.set(store, path, payload.state.value);
34265
- isTimelineActive = true;
34266
- }
34267
- });
34268
- });
34269
- }
34270
- function addStoreToDevtools(app, store) {
34271
- if (!componentStateTypes.includes(getStoreType(store.$id))) {
34272
- componentStateTypes.push(getStoreType(store.$id));
34273
- }
34274
- setupDevtoolsPlugin({
34275
- id: 'dev.esm.pinia',
34276
- label: 'Pinia 🍍',
34277
- logo: 'https://pinia.vuejs.org/logo.svg',
34278
- packageName: 'pinia',
34279
- homepage: 'https://pinia.vuejs.org',
34280
- componentStateTypes,
34281
- app,
34282
- settings: {
34283
- logStoreChanges: {
34284
- label: 'Notify about new/deleted stores',
34285
- type: 'boolean',
34286
- defaultValue: true,
34287
- },
34288
- // useEmojis: {
34289
- // label: 'Use emojis in messages ⚡️',
34290
- // type: 'boolean',
34291
- // defaultValue: true,
34292
- // },
34293
- },
34294
- }, (api) => {
34295
- // gracefully handle errors
34296
- const now = typeof api.now === 'function' ? api.now.bind(api) : Date.now;
34297
- store.$onAction(({ after, onError, name, args }) => {
34298
- const groupId = runningActionId++;
34299
- api.addTimelineEvent({
34300
- layerId: MUTATIONS_LAYER_ID,
34301
- event: {
34302
- time: now(),
34303
- title: '🛫 ' + name,
34304
- subtitle: 'start',
34305
- data: {
34306
- store: formatDisplay(store.$id),
34307
- action: formatDisplay(name),
34308
- args,
34309
- },
34310
- groupId,
34311
- },
34312
- });
34313
- after((result) => {
34314
- activeAction = undefined;
34315
- api.addTimelineEvent({
34316
- layerId: MUTATIONS_LAYER_ID,
34317
- event: {
34318
- time: now(),
34319
- title: '🛬 ' + name,
34320
- subtitle: 'end',
34321
- data: {
34322
- store: formatDisplay(store.$id),
34323
- action: formatDisplay(name),
34324
- args,
34325
- result,
34326
- },
34327
- groupId,
34328
- },
34329
- });
34330
- });
34331
- onError((error) => {
34332
- activeAction = undefined;
34333
- api.addTimelineEvent({
34334
- layerId: MUTATIONS_LAYER_ID,
34335
- event: {
34336
- time: now(),
34337
- logType: 'error',
34338
- title: '💥 ' + name,
34339
- subtitle: 'end',
34340
- data: {
34341
- store: formatDisplay(store.$id),
34342
- action: formatDisplay(name),
34343
- args,
34344
- error,
34345
- },
34346
- groupId,
34347
- },
34348
- });
34349
- });
34350
- }, true);
34351
- store._customProperties.forEach((name) => {
34352
- watch(() => unref(store[name]), (newValue, oldValue) => {
34353
- api.notifyComponentUpdate();
34354
- api.sendInspectorState(INSPECTOR_ID);
34355
- if (isTimelineActive) {
34356
- api.addTimelineEvent({
34357
- layerId: MUTATIONS_LAYER_ID,
34358
- event: {
34359
- time: now(),
34360
- title: 'Change',
34361
- subtitle: name,
34362
- data: {
34363
- newValue,
34364
- oldValue,
34365
- },
34366
- groupId: activeAction,
34367
- },
34368
- });
34369
- }
34370
- }, { deep: true });
34371
- });
34372
- store.$subscribe(({ events, type }, state) => {
34373
- api.notifyComponentUpdate();
34374
- api.sendInspectorState(INSPECTOR_ID);
34375
- if (!isTimelineActive)
34376
- return;
34377
- // rootStore.state[store.id] = state
34378
- const eventData = {
34379
- time: now(),
34380
- title: formatMutationType(type),
34381
- data: assign$1({ store: formatDisplay(store.$id) }, formatEventData(events)),
34382
- groupId: activeAction,
34383
- };
34384
- if (type === MutationType.patchFunction) {
34385
- eventData.subtitle = '⤵️';
34386
- }
34387
- else if (type === MutationType.patchObject) {
34388
- eventData.subtitle = '🧩';
34389
- }
34390
- else if (events && !Array.isArray(events)) {
34391
- eventData.subtitle = events.type;
34392
- }
34393
- if (events) {
34394
- eventData.data['rawEvent(s)'] = {
34395
- _custom: {
34396
- display: 'DebuggerEvent',
34397
- type: 'object',
34398
- tooltip: 'raw DebuggerEvent[]',
34399
- value: events,
34400
- },
34401
- };
34402
- }
34403
- api.addTimelineEvent({
34404
- layerId: MUTATIONS_LAYER_ID,
34405
- event: eventData,
34406
- });
34407
- }, { detached: true, flush: 'sync' });
34408
- const hotUpdate = store._hotUpdate;
34409
- store._hotUpdate = markRaw((newStore) => {
34410
- hotUpdate(newStore);
34411
- api.addTimelineEvent({
34412
- layerId: MUTATIONS_LAYER_ID,
34413
- event: {
34414
- time: now(),
34415
- title: '🔥 ' + store.$id,
34416
- subtitle: 'HMR update',
34417
- data: {
34418
- store: formatDisplay(store.$id),
34419
- info: formatDisplay(`HMR update`),
34420
- },
34421
- },
34422
- });
34423
- // update the devtools too
34424
- api.notifyComponentUpdate();
34425
- api.sendInspectorTree(INSPECTOR_ID);
34426
- api.sendInspectorState(INSPECTOR_ID);
34427
- });
34428
- const { $dispose } = store;
34429
- store.$dispose = () => {
34430
- $dispose();
34431
- api.notifyComponentUpdate();
34432
- api.sendInspectorTree(INSPECTOR_ID);
34433
- api.sendInspectorState(INSPECTOR_ID);
34434
- api.getSettings().logStoreChanges &&
34435
- toastMessage(`Disposed "${store.$id}" store 🗑`);
34436
- };
34437
- // trigger an update so it can display new registered stores
34438
- api.notifyComponentUpdate();
34439
- api.sendInspectorTree(INSPECTOR_ID);
34440
- api.sendInspectorState(INSPECTOR_ID);
34441
- api.getSettings().logStoreChanges &&
34442
- toastMessage(`"${store.$id}" store installed 🆕`);
34443
- });
34444
- }
34445
- let runningActionId = 0;
34446
- let activeAction;
34447
- /**
34448
- * Patches a store to enable action grouping in devtools by wrapping the store with a Proxy that is passed as the
34449
- * context of all actions, allowing us to set `runningAction` on each access and effectively associating any state
34450
- * mutation to the action.
34451
- *
34452
- * @param store - store to patch
34453
- * @param actionNames - list of actionst to patch
34454
- */
34455
- function patchActionForGrouping(store, actionNames, wrapWithProxy) {
34456
- // original actions of the store as they are given by pinia. We are going to override them
34457
- const actions = actionNames.reduce((storeActions, actionName) => {
34458
- // use toRaw to avoid tracking #541
34459
- storeActions[actionName] = toRaw(store)[actionName];
34460
- return storeActions;
34461
- }, {});
34462
- for (const actionName in actions) {
34463
- store[actionName] = function () {
34464
- // the running action id is incremented in a before action hook
34465
- const _actionId = runningActionId;
34466
- const trackedStore = wrapWithProxy
34467
- ? new Proxy(store, {
34468
- get(...args) {
34469
- activeAction = _actionId;
34470
- return Reflect.get(...args);
34471
- },
34472
- set(...args) {
34473
- activeAction = _actionId;
34474
- return Reflect.set(...args);
34475
- },
34476
- })
34477
- : store;
34478
- // For Setup Stores we need https://github.com/tc39/proposal-async-context
34479
- activeAction = _actionId;
34480
- const retValue = actions[actionName].apply(trackedStore, arguments);
34481
- // this is safer as async actions in Setup Stores would associate mutations done outside of the action
34482
- activeAction = undefined;
34483
- return retValue;
34484
- };
34485
- }
34486
- }
34487
- /**
34488
- * pinia.use(devtoolsPlugin)
34489
- */
34490
- function devtoolsPlugin({ app, store, options }) {
34491
- // HMR module
34492
- if (store.$id.startsWith('__hot:')) {
34493
- return;
34494
- }
34495
- // detect option api vs setup api
34496
- store._isOptionsAPI = !!options.state;
34497
- patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI);
34498
- // Upgrade the HMR to also update the new actions
34499
- const originalHotUpdate = store._hotUpdate;
34500
- toRaw(store)._hotUpdate = function (newStore) {
34501
- originalHotUpdate.apply(this, arguments);
34502
- patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI);
34503
- };
34504
- addStoreToDevtools(app,
34505
- // FIXME: is there a way to allow the assignment from Store<Id, S, G, A> to StoreGeneric?
34506
- store);
34507
- }
34508
-
34509
- /**
34510
- * Creates a Pinia instance to be used by the application
34511
- */
34512
- function createPinia() {
34513
- const scope = effectScope(true);
34514
- // NOTE: here we could check the window object for a state and directly set it
34515
- // if there is anything like it with Vue 3 SSR
34516
- const state = scope.run(() => ref({}));
34517
- let _p = [];
34518
- // plugins added before calling app.use(pinia)
34519
- let toBeInstalled = [];
34520
- const pinia = markRaw({
34521
- install(app) {
34522
- // this allows calling useStore() outside of a component setup after
34523
- // installing pinia's plugin
34524
- setActivePinia(pinia);
34525
- if (!isVue2) {
34526
- pinia._a = app;
34527
- app.provide(piniaSymbol, pinia);
34528
- app.config.globalProperties.$pinia = pinia;
34529
- /* istanbul ignore else */
34530
- if (USE_DEVTOOLS) {
34531
- registerPiniaDevtools(app, pinia);
34532
- }
34533
- toBeInstalled.forEach((plugin) => _p.push(plugin));
34534
- toBeInstalled = [];
34535
- }
34536
- },
34537
- use(plugin) {
34538
- if (!this._a && !isVue2) {
34539
- toBeInstalled.push(plugin);
34540
- }
34541
- else {
34542
- _p.push(plugin);
34543
- }
34544
- return this;
34545
- },
34546
- _p,
34547
- // it's actually undefined here
34548
- // @ts-expect-error
34549
- _a: null,
34550
- _e: scope,
34551
- _s: new Map(),
34552
- state,
34553
- });
34554
- // pinia devtools rely on dev only features so they cannot be forced unless
34555
- // the dev build of Vue is used. Avoid old browsers like IE11.
34556
- if (USE_DEVTOOLS && typeof Proxy !== 'undefined') {
34557
- pinia.use(devtoolsPlugin);
34558
- }
34559
- return pinia;
34560
- }
34561
-
34562
- /**
34563
- * Checks if a function is a `StoreDefinition`.
34564
- *
34565
- * @param fn - object to test
34566
- * @returns true if `fn` is a StoreDefinition
34567
- */
34568
- const isUseStore = (fn) => {
34569
- return typeof fn === 'function' && typeof fn.$id === 'string';
34570
- };
34571
- /**
34572
- * Mutates in place `newState` with `oldState` to _hot update_ it. It will
34573
- * remove any key not existing in `newState` and recursively merge plain
34574
- * objects.
34575
- *
34576
- * @param newState - new state object to be patched
34577
- * @param oldState - old state that should be used to patch newState
34578
- * @returns - newState
34579
- */
34580
- function patchObject(newState, oldState) {
34581
- // no need to go through symbols because they cannot be serialized anyway
34582
- for (const key in oldState) {
34583
- const subPatch = oldState[key];
34584
- // skip the whole sub tree
34585
- if (!(key in newState)) {
34586
- continue;
34587
- }
34588
- const targetValue = newState[key];
34589
- if (isPlainObject(targetValue) &&
34590
- isPlainObject(subPatch) &&
34591
- !isRef(subPatch) &&
34592
- !isReactive(subPatch)) {
34593
- newState[key] = patchObject(targetValue, subPatch);
34594
- }
34595
- else {
34596
- // objects are either a bit more complex (e.g. refs) or primitives, so we
34597
- // just set the whole thing
34598
- if (isVue2) {
34599
- set(newState, key, subPatch);
34600
- }
34601
- else {
34602
- newState[key] = subPatch;
34603
- }
34604
- }
34605
- }
34606
- return newState;
34607
- }
34608
- /**
34609
- * Creates an _accept_ function to pass to `import.meta.hot` in Vite applications.
34610
- *
34611
- * @example
34612
- * ```js
34613
- * const useUser = defineStore(...)
34614
- * if (import.meta.hot) {
34615
- * import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot))
34616
- * }
34617
- * ```
34618
- *
34619
- * @param initialUseStore - return of the defineStore to hot update
34620
- * @param hot - `import.meta.hot`
34621
- */
34622
- function acceptHMRUpdate(initialUseStore, hot) {
34623
- // strip as much as possible from iife.prod
34624
- if (true) {
34625
- return () => { };
34626
- }
34627
- return (newModule) => {
34628
- const pinia = hot.data.pinia || initialUseStore._pinia;
34629
- if (!pinia) {
34630
- // this store is still not used
34631
- return;
34632
- }
34633
- // preserve the pinia instance across loads
34634
- hot.data.pinia = pinia;
34635
- // console.log('got data', newStore)
34636
- for (const exportName in newModule) {
34637
- const useStore = newModule[exportName];
34638
- // console.log('checking for', exportName)
34639
- if (isUseStore(useStore) && pinia._s.has(useStore.$id)) {
34640
- // console.log('Accepting update for', useStore.$id)
34641
- const id = useStore.$id;
34642
- if (id !== initialUseStore.$id) {
34643
- console.warn(`The id of the store changed from "${initialUseStore.$id}" to "${id}". Reloading.`);
34644
- // return import.meta.hot.invalidate()
34645
- return hot.invalidate();
34646
- }
34647
- const existingStore = pinia._s.get(id);
34648
- if (!existingStore) {
34649
- console.log(`[Pinia]: skipping hmr because store doesn't exist yet`);
34650
- return;
34651
- }
34652
- useStore(pinia, existingStore);
34653
- }
34654
- }
34655
- };
34656
- }
34657
-
34658
- const pinia_noop = () => { };
34659
- function addSubscription(subscriptions, callback, detached, onCleanup = pinia_noop) {
34660
- subscriptions.push(callback);
34661
- const removeSubscription = () => {
34662
- const idx = subscriptions.indexOf(callback);
34663
- if (idx > -1) {
34664
- subscriptions.splice(idx, 1);
34665
- onCleanup();
34666
- }
34667
- };
34668
- if (!detached && getCurrentScope()) {
34669
- onScopeDispose(removeSubscription);
34670
- }
34671
- return removeSubscription;
34672
- }
34673
- function triggerSubscriptions(subscriptions, ...args) {
34674
- subscriptions.slice().forEach((callback) => {
34675
- callback(...args);
34676
- });
34677
- }
34678
-
34679
- const fallbackRunWithContext = (fn) => fn();
34680
- function mergeReactiveObjects(target, patchToApply) {
34681
- // Handle Map instances
34682
- if (target instanceof Map && patchToApply instanceof Map) {
34683
- patchToApply.forEach((value, key) => target.set(key, value));
34684
- }
34685
- // Handle Set instances
34686
- if (target instanceof Set && patchToApply instanceof Set) {
34687
- patchToApply.forEach(target.add, target);
34688
- }
34689
- // no need to go through symbols because they cannot be serialized anyway
34690
- for (const key in patchToApply) {
34691
- if (!patchToApply.hasOwnProperty(key))
34692
- continue;
34693
- const subPatch = patchToApply[key];
34694
- const targetValue = target[key];
34695
- if (isPlainObject(targetValue) &&
34696
- isPlainObject(subPatch) &&
34697
- target.hasOwnProperty(key) &&
34698
- !isRef(subPatch) &&
34699
- !isReactive(subPatch)) {
34700
- // NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might
34701
- // start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that
34702
- // to `undefined`. When trying to hydrate, we want to override the Map with `undefined`.
34703
- target[key] = mergeReactiveObjects(targetValue, subPatch);
34704
- }
34705
- else {
34706
- // @ts-expect-error: subPatch is a valid value
34707
- target[key] = subPatch;
34708
- }
34709
- }
34710
- return target;
34711
- }
34712
- const skipHydrateSymbol = ( false)
34713
- ? 0
34714
- : /* istanbul ignore next */ Symbol();
34715
- const skipHydrateMap = /*#__PURE__*/ new WeakMap();
34716
- /**
34717
- * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a
34718
- * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store.
34719
- *
34720
- * @param obj - target object
34721
- * @returns obj
34722
- */
34723
- function skipHydrate(obj) {
34724
- return isVue2
34725
- ? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work...
34726
- /* istanbul ignore next */ skipHydrateMap.set(obj, 1) && obj
34727
- : Object.defineProperty(obj, skipHydrateSymbol, {});
34728
- }
34729
- /**
34730
- * Returns whether a value should be hydrated
34731
- *
34732
- * @param obj - target variable
34733
- * @returns true if `obj` should be hydrated
34734
- */
34735
- function shouldHydrate(obj) {
34736
- return isVue2
34737
- ? /* istanbul ignore next */ !skipHydrateMap.has(obj)
34738
- : !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol);
34739
- }
34740
- const { assign: pinia_assign } = Object;
34741
- function isComputed(o) {
34742
- return !!(isRef(o) && o.effect);
34743
- }
34744
- function createOptionsStore(id, options, pinia, hot) {
34745
- const { state, actions, getters } = options;
34746
- const initialState = pinia.state.value[id];
34747
- let store;
34748
- function setup() {
34749
- if (!initialState && ( true || 0)) {
34750
- /* istanbul ignore if */
34751
- if (isVue2) {
34752
- set(pinia.state.value, id, state ? state() : {});
34753
- }
34754
- else {
34755
- pinia.state.value[id] = state ? state() : {};
34756
- }
34757
- }
34758
- // avoid creating a state in pinia.state.value
34759
- const localState = false
34760
- ? // use ref() to unwrap refs inside state TODO: check if this is still necessary
34761
- 0
34762
- : toRefs(pinia.state.value[id]);
34763
- return pinia_assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
34764
- if (false) {}
34765
- computedGetters[name] = markRaw(computed(() => {
34766
- setActivePinia(pinia);
34767
- // it was created just before
34768
- const store = pinia._s.get(id);
34769
- // allow cross using stores
34770
- /* istanbul ignore next */
34771
- if (isVue2 && !store._r)
34772
- return;
34773
- // @ts-expect-error
34774
- // return getters![name].call(context, context)
34775
- // TODO: avoid reading the getter while assigning with a global variable
34776
- return getters[name].call(store, store);
34777
- }));
34778
- return computedGetters;
34779
- }, {}));
34780
- }
34781
- store = createSetupStore(id, setup, options, pinia, hot, true);
34782
- return store;
34783
- }
34784
- function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
34785
- let scope;
34786
- const optionsForPlugin = pinia_assign({ actions: {} }, options);
34787
- /* istanbul ignore if */
34788
- if (false) {}
34789
- // watcher options for $subscribe
34790
- const $subscribeOptions = {
34791
- deep: true,
34792
- // flush: 'post',
34793
- };
34794
- /* istanbul ignore else */
34795
- if (false) {}
34796
- // internal state
34797
- let isListening; // set to true at the end
34798
- let isSyncListening; // set to true at the end
34799
- let subscriptions = [];
34800
- let actionSubscriptions = [];
34801
- let debuggerEvents;
34802
- const initialState = pinia.state.value[$id];
34803
- // avoid setting the state for option stores if it is set
34804
- // by the setup
34805
- if (!isOptionsStore && !initialState && ( true || 0)) {
34806
- /* istanbul ignore if */
34807
- if (isVue2) {
34808
- set(pinia.state.value, $id, {});
34809
- }
34810
- else {
34811
- pinia.state.value[$id] = {};
34812
- }
34813
- }
34814
- const hotState = ref({});
34815
- // avoid triggering too many listeners
34816
- // https://github.com/vuejs/pinia/issues/1129
34817
- let activeListener;
34818
- function $patch(partialStateOrMutator) {
34819
- let subscriptionMutation;
34820
- isListening = isSyncListening = false;
34821
- // reset the debugger events since patches are sync
34822
- /* istanbul ignore else */
34823
- if ((false)) {}
34824
- if (typeof partialStateOrMutator === 'function') {
34825
- partialStateOrMutator(pinia.state.value[$id]);
34826
- subscriptionMutation = {
34827
- type: MutationType.patchFunction,
34828
- storeId: $id,
34829
- events: debuggerEvents,
34830
- };
34831
- }
34832
- else {
34833
- mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
34834
- subscriptionMutation = {
34835
- type: MutationType.patchObject,
34836
- payload: partialStateOrMutator,
34837
- storeId: $id,
34838
- events: debuggerEvents,
34839
- };
34840
- }
34841
- const myListenerId = (activeListener = Symbol());
34842
- nextTick().then(() => {
34843
- if (activeListener === myListenerId) {
34844
- isListening = true;
34845
- }
34846
- });
34847
- isSyncListening = true;
34848
- // because we paused the watcher, we need to manually call the subscriptions
34849
- triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
34850
- }
34851
- const $reset = isOptionsStore
34852
- ? function $reset() {
34853
- const { state } = options;
34854
- const newState = state ? state() : {};
34855
- // we use a patch to group all changes into one single subscription
34856
- this.$patch(($state) => {
34857
- pinia_assign($state, newState);
34858
- });
34859
- }
34860
- : /* istanbul ignore next */
34861
- ( false)
34862
- ? 0
34863
- : pinia_noop;
34864
- function $dispose() {
34865
- scope.stop();
34866
- subscriptions = [];
34867
- actionSubscriptions = [];
34868
- pinia._s.delete($id);
34869
- }
34870
- /**
34871
- * Wraps an action to handle subscriptions.
34872
- *
34873
- * @param name - name of the action
34874
- * @param action - action to wrap
34875
- * @returns a wrapped action to handle subscriptions
34876
- */
34877
- function wrapAction(name, action) {
34878
- return function () {
34879
- setActivePinia(pinia);
34880
- const args = Array.from(arguments);
34881
- const afterCallbackList = [];
34882
- const onErrorCallbackList = [];
34883
- function after(callback) {
34884
- afterCallbackList.push(callback);
34885
- }
34886
- function onError(callback) {
34887
- onErrorCallbackList.push(callback);
34888
- }
34889
- // @ts-expect-error
34890
- triggerSubscriptions(actionSubscriptions, {
34891
- args,
34892
- name,
34893
- store,
34894
- after,
34895
- onError,
34896
- });
34897
- let ret;
34898
- try {
34899
- ret = action.apply(this && this.$id === $id ? this : store, args);
34900
- // handle sync errors
34901
- }
34902
- catch (error) {
34903
- triggerSubscriptions(onErrorCallbackList, error);
34904
- throw error;
34905
- }
34906
- if (ret instanceof Promise) {
34907
- return ret
34908
- .then((value) => {
34909
- triggerSubscriptions(afterCallbackList, value);
34910
- return value;
34911
- })
34912
- .catch((error) => {
34913
- triggerSubscriptions(onErrorCallbackList, error);
34914
- return Promise.reject(error);
34915
- });
34916
- }
34917
- // trigger after callbacks
34918
- triggerSubscriptions(afterCallbackList, ret);
34919
- return ret;
34920
- };
34921
- }
34922
- const _hmrPayload = /*#__PURE__*/ markRaw({
34923
- actions: {},
34924
- getters: {},
34925
- state: [],
34926
- hotState,
34927
- });
34928
- const partialStore = {
34929
- _p: pinia,
34930
- // _s: scope,
34931
- $id,
34932
- $onAction: addSubscription.bind(null, actionSubscriptions),
34933
- $patch,
34934
- $reset,
34935
- $subscribe(callback, options = {}) {
34936
- const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher());
34937
- const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => {
34938
- if (options.flush === 'sync' ? isSyncListening : isListening) {
34939
- callback({
34940
- storeId: $id,
34941
- type: MutationType.direct,
34942
- events: debuggerEvents,
34943
- }, state);
34944
- }
34945
- }, pinia_assign({}, $subscribeOptions, options)));
34946
- return removeSubscription;
34947
- },
34948
- $dispose,
34949
- };
34950
- /* istanbul ignore if */
34951
- if (isVue2) {
34952
- // start as non ready
34953
- partialStore._r = false;
34954
- }
34955
- const store = reactive(( false) || USE_DEVTOOLS
34956
- ? pinia_assign({
34957
- _hmrPayload,
34958
- _customProperties: markRaw(new Set()), // devtools custom properties
34959
- }, partialStore
34960
- // must be added later
34961
- // setupStore
34962
- )
34963
- : partialStore);
34964
- // store the partial store now so the setup of stores can instantiate each other before they are finished without
34965
- // creating infinite loops.
34966
- pinia._s.set($id, store);
34967
- const runWithContext = (pinia._a && pinia._a.runWithContext) || fallbackRunWithContext;
34968
- // TODO: idea create skipSerialize that marks properties as non serializable and they are skipped
34969
- const setupStore = runWithContext(() => pinia._e.run(() => (scope = effectScope()).run(setup)));
34970
- // overwrite existing actions to support $onAction
34971
- for (const key in setupStore) {
34972
- const prop = setupStore[key];
34973
- if ((isRef(prop) && !isComputed(prop)) || isReactive(prop)) {
34974
- // mark it as a piece of state to be serialized
34975
- if (false) {}
34976
- else if (!isOptionsStore) {
34977
- // in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created
34978
- if (initialState && shouldHydrate(prop)) {
34979
- if (isRef(prop)) {
34980
- prop.value = initialState[key];
34981
- }
34982
- else {
34983
- // probably a reactive object, lets recursively assign
34984
- // @ts-expect-error: prop is unknown
34985
- mergeReactiveObjects(prop, initialState[key]);
34986
- }
34987
- }
34988
- // transfer the ref to the pinia state to keep everything in sync
34989
- /* istanbul ignore if */
34990
- if (isVue2) {
34991
- set(pinia.state.value[$id], key, prop);
34992
- }
34993
- else {
34994
- pinia.state.value[$id][key] = prop;
34995
- }
34996
- }
34997
- /* istanbul ignore else */
34998
- if ((false)) {}
34999
- // action
35000
- }
35001
- else if (typeof prop === 'function') {
35002
- // @ts-expect-error: we are overriding the function we avoid wrapping if
35003
- const actionValue = false ? 0 : wrapAction(key, prop);
35004
- // this a hot module replacement store because the hotUpdate method needs
35005
- // to do it with the right context
35006
- /* istanbul ignore if */
35007
- if (isVue2) {
35008
- set(setupStore, key, actionValue);
35009
- }
35010
- else {
35011
- // @ts-expect-error
35012
- setupStore[key] = actionValue;
35013
- }
35014
- /* istanbul ignore else */
35015
- if ((false)) {}
35016
- // list actions so they can be used in plugins
35017
- // @ts-expect-error
35018
- optionsForPlugin.actions[key] = prop;
35019
- }
35020
- else if ((false)) {}
35021
- }
35022
- // add the state, getters, and action properties
35023
- /* istanbul ignore if */
35024
- if (isVue2) {
35025
- Object.keys(setupStore).forEach((key) => {
35026
- set(store, key, setupStore[key]);
35027
- });
35028
- }
35029
- else {
35030
- pinia_assign(store, setupStore);
35031
- // allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object.
35032
- // Make `storeToRefs()` work with `reactive()` #799
35033
- pinia_assign(toRaw(store), setupStore);
35034
- }
35035
- // use this instead of a computed with setter to be able to create it anywhere
35036
- // without linking the computed lifespan to wherever the store is first
35037
- // created.
35038
- Object.defineProperty(store, '$state', {
35039
- get: () => ( false ? 0 : pinia.state.value[$id]),
35040
- set: (state) => {
35041
- /* istanbul ignore if */
35042
- if (false) {}
35043
- $patch(($state) => {
35044
- pinia_assign($state, state);
35045
- });
35046
- },
35047
- });
35048
- // add the hotUpdate before plugins to allow them to override it
35049
- /* istanbul ignore else */
35050
- if ((false)) {}
35051
- if (USE_DEVTOOLS) {
35052
- const nonEnumerable = {
35053
- writable: true,
35054
- configurable: true,
35055
- // avoid warning on devtools trying to display this property
35056
- enumerable: false,
35057
- };
35058
- ['_p', '_hmrPayload', '_getters', '_customProperties'].forEach((p) => {
35059
- Object.defineProperty(store, p, pinia_assign({ value: store[p] }, nonEnumerable));
35060
- });
35061
- }
35062
- /* istanbul ignore if */
35063
- if (isVue2) {
35064
- // mark the store as ready before plugins
35065
- store._r = true;
35066
- }
35067
- // apply all plugins
35068
- pinia._p.forEach((extender) => {
35069
- /* istanbul ignore else */
35070
- if (USE_DEVTOOLS) {
35071
- const extensions = scope.run(() => extender({
35072
- store,
35073
- app: pinia._a,
35074
- pinia,
35075
- options: optionsForPlugin,
35076
- }));
35077
- Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key));
35078
- pinia_assign(store, extensions);
35079
- }
35080
- else {
35081
- pinia_assign(store, scope.run(() => extender({
35082
- store,
35083
- app: pinia._a,
35084
- pinia,
35085
- options: optionsForPlugin,
35086
- })));
35087
- }
35088
- });
35089
- if (false) {}
35090
- // only apply hydrate to option stores with an initial state in pinia
35091
- if (initialState &&
35092
- isOptionsStore &&
35093
- options.hydrate) {
35094
- options.hydrate(store.$state, initialState);
35095
- }
35096
- isListening = true;
35097
- isSyncListening = true;
35098
- return store;
35099
- }
35100
- function defineStore(
35101
- // TODO: add proper types from above
35102
- idOrOptions, setup, setupOptions) {
35103
- let id;
35104
- let options;
35105
- const isSetupStore = typeof setup === 'function';
35106
- if (typeof idOrOptions === 'string') {
35107
- id = idOrOptions;
35108
- // the option store setup will contain the actual options in this case
35109
- options = isSetupStore ? setupOptions : setup;
35110
- }
35111
- else {
35112
- options = idOrOptions;
35113
- id = idOrOptions.id;
35114
- if (false) {}
35115
- }
35116
- function useStore(pinia, hot) {
35117
- const hasContext = hasInjectionContext();
35118
- pinia =
35119
- // in test mode, ignore the argument provided as we can always retrieve a
35120
- // pinia instance with getActivePinia()
35121
- ( false ? 0 : pinia) ||
35122
- (hasContext ? inject(piniaSymbol, null) : null);
35123
- if (pinia)
35124
- setActivePinia(pinia);
35125
- if (false) {}
35126
- pinia = activePinia;
35127
- if (!pinia._s.has(id)) {
35128
- // creating the store registers it in `pinia._s`
35129
- if (isSetupStore) {
35130
- createSetupStore(id, setup, options, pinia);
35131
- }
35132
- else {
35133
- createOptionsStore(id, options, pinia);
35134
- }
35135
- /* istanbul ignore else */
35136
- if ((false)) {}
35137
- }
35138
- const store = pinia._s.get(id);
35139
- if (false) {}
35140
- if (false) {}
35141
- // StoreGeneric cannot be casted towards Store
35142
- return store;
35143
- }
35144
- useStore.$id = id;
35145
- return useStore;
35146
- }
35147
-
35148
- let mapStoreSuffix = 'Store';
35149
- /**
35150
- * Changes the suffix added by `mapStores()`. Can be set to an empty string.
35151
- * Defaults to `"Store"`. Make sure to extend the MapStoresCustomization
35152
- * interface if you are using TypeScript.
35153
- *
35154
- * @param suffix - new suffix
35155
- */
35156
- function setMapStoreSuffix(suffix // could be 'Store' but that would be annoying for JS
35157
- ) {
35158
- mapStoreSuffix = suffix;
35159
- }
35160
- /**
35161
- * Allows using stores without the composition API (`setup()`) by generating an
35162
- * object to be spread in the `computed` field of a component. It accepts a list
35163
- * of store definitions.
35164
- *
35165
- * @example
35166
- * ```js
35167
- * export default {
35168
- * computed: {
35169
- * // other computed properties
35170
- * ...mapStores(useUserStore, useCartStore)
35171
- * },
35172
- *
35173
- * created() {
35174
- * this.userStore // store with id "user"
35175
- * this.cartStore // store with id "cart"
35176
- * }
35177
- * }
35178
- * ```
35179
- *
35180
- * @param stores - list of stores to map to an object
35181
- */
35182
- function mapStores(...stores) {
35183
- if (false) {}
35184
- return stores.reduce((reduced, useStore) => {
35185
- // @ts-expect-error: $id is added by defineStore
35186
- reduced[useStore.$id + mapStoreSuffix] = function () {
35187
- return useStore(this.$pinia);
35188
- };
35189
- return reduced;
35190
- }, {});
35191
- }
35192
- /**
35193
- * Allows using state and getters from one store without using the composition
35194
- * API (`setup()`) by generating an object to be spread in the `computed` field
35195
- * of a component.
35196
- *
35197
- * @param useStore - store to map from
35198
- * @param keysOrMapper - array or object
35199
- */
35200
- function mapState(useStore, keysOrMapper) {
35201
- return Array.isArray(keysOrMapper)
35202
- ? keysOrMapper.reduce((reduced, key) => {
35203
- reduced[key] = function () {
35204
- return useStore(this.$pinia)[key];
35205
- };
35206
- return reduced;
35207
- }, {})
35208
- : Object.keys(keysOrMapper).reduce((reduced, key) => {
35209
- // @ts-expect-error
35210
- reduced[key] = function () {
35211
- const store = useStore(this.$pinia);
35212
- const storeKey = keysOrMapper[key];
35213
- // for some reason TS is unable to infer the type of storeKey to be a
35214
- // function
35215
- return typeof storeKey === 'function'
35216
- ? storeKey.call(this, store)
35217
- : store[storeKey];
35218
- };
35219
- return reduced;
35220
- }, {});
35221
- }
35222
- /**
35223
- * Alias for `mapState()`. You should use `mapState()` instead.
35224
- * @deprecated use `mapState()` instead.
35225
- */
35226
- const mapGetters = (/* unused pure expression or super */ null && (mapState));
35227
- /**
35228
- * Allows directly using actions from your store without using the composition
35229
- * API (`setup()`) by generating an object to be spread in the `methods` field
35230
- * of a component.
35231
- *
35232
- * @param useStore - store to map from
35233
- * @param keysOrMapper - array or object
35234
- */
35235
- function mapActions(useStore, keysOrMapper) {
35236
- return Array.isArray(keysOrMapper)
35237
- ? keysOrMapper.reduce((reduced, key) => {
35238
- // @ts-expect-error
35239
- reduced[key] = function (...args) {
35240
- return useStore(this.$pinia)[key](...args);
35241
- };
35242
- return reduced;
35243
- }, {})
35244
- : Object.keys(keysOrMapper).reduce((reduced, key) => {
35245
- // @ts-expect-error
35246
- reduced[key] = function (...args) {
35247
- return useStore(this.$pinia)[keysOrMapper[key]](...args);
35248
- };
35249
- return reduced;
35250
- }, {});
35251
- }
35252
- /**
35253
- * Allows using state and getters from one store without using the composition
35254
- * API (`setup()`) by generating an object to be spread in the `computed` field
35255
- * of a component.
35256
- *
35257
- * @param useStore - store to map from
35258
- * @param keysOrMapper - array or object
35259
- */
35260
- function mapWritableState(useStore, keysOrMapper) {
35261
- return Array.isArray(keysOrMapper)
35262
- ? keysOrMapper.reduce((reduced, key) => {
35263
- // @ts-ignore
35264
- reduced[key] = {
35265
- get() {
35266
- return useStore(this.$pinia)[key];
35267
- },
35268
- set(value) {
35269
- // it's easier to type it here as any
35270
- return (useStore(this.$pinia)[key] = value);
35271
- },
35272
- };
35273
- return reduced;
35274
- }, {})
35275
- : Object.keys(keysOrMapper).reduce((reduced, key) => {
35276
- // @ts-ignore
35277
- reduced[key] = {
35278
- get() {
35279
- return useStore(this.$pinia)[keysOrMapper[key]];
35280
- },
35281
- set(value) {
35282
- // it's easier to type it here as any
35283
- return (useStore(this.$pinia)[keysOrMapper[key]] = value);
35284
- },
35285
- };
35286
- return reduced;
35287
- }, {});
35288
- }
35289
-
35290
- /**
35291
- * Creates an object of references with all the state, getters, and plugin-added
35292
- * state properties of the store. Similar to `toRefs()` but specifically
35293
- * designed for Pinia stores so methods and non reactive properties are
35294
- * completely ignored.
35295
- *
35296
- * @param store - store to extract the refs from
35297
- */
35298
- function storeToRefs(store) {
35299
- // See https://github.com/vuejs/pinia/issues/852
35300
- // It's easier to just use toRefs() even if it includes more stuff
35301
- if (isVue2) {
35302
- // @ts-expect-error: toRefs include methods and others
35303
- return toRefs(store);
35304
- }
35305
- else {
35306
- store = toRaw(store);
35307
- const refs = {};
35308
- for (const key in store) {
35309
- const value = store[key];
35310
- if (isRef(value) || isReactive(value)) {
35311
- // @ts-expect-error: the key is state or getter
35312
- refs[key] =
35313
- // ---
35314
- toRef(store, key);
35315
- }
35316
- }
35317
- return refs;
35318
- }
35319
- }
35320
-
35321
- /**
35322
- * Vue 2 Plugin that must be installed for pinia to work. Note **you don't need
35323
- * this plugin if you are using Nuxt.js**. Use the `buildModule` instead:
35324
- * https://pinia.vuejs.org/ssr/nuxt.html.
35325
- *
35326
- * @example
35327
- * ```js
35328
- * import Vue from 'vue'
35329
- * import { PiniaVuePlugin, createPinia } from 'pinia'
35330
- *
35331
- * Vue.use(PiniaVuePlugin)
35332
- * const pinia = createPinia()
35333
- *
35334
- * new Vue({
35335
- * el: '#app',
35336
- * // ...
35337
- * pinia,
35338
- * })
35339
- * ```
35340
- *
35341
- * @param _Vue - `Vue` imported from 'vue'.
35342
- */
35343
- const PiniaVuePlugin = function (_Vue) {
35344
- // Equivalent of
35345
- // app.config.globalProperties.$pinia = pinia
35346
- _Vue.mixin({
35347
- beforeCreate() {
35348
- const options = this.$options;
35349
- if (options.pinia) {
35350
- const pinia = options.pinia;
35351
- // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/main/src/apis/inject.ts#L31
35352
- /* istanbul ignore else */
35353
- if (!this._provided) {
35354
- const provideCache = {};
35355
- Object.defineProperty(this, '_provided', {
35356
- get: () => provideCache,
35357
- set: (v) => Object.assign(provideCache, v),
35358
- });
35359
- }
35360
- this._provided[piniaSymbol] = pinia;
35361
- // propagate the pinia instance in an SSR friendly way
35362
- // avoid adding it to nuxt twice
35363
- /* istanbul ignore else */
35364
- if (!this.$pinia) {
35365
- this.$pinia = pinia;
35366
- }
35367
- pinia._a = this;
35368
- if (IS_CLIENT) {
35369
- // this allows calling useStore() outside of a component setup after
35370
- // installing pinia's plugin
35371
- setActivePinia(pinia);
35372
- }
35373
- if (USE_DEVTOOLS) {
35374
- registerPiniaDevtools(pinia._a, pinia);
35375
- }
35376
- }
35377
- else if (!this.$pinia && options.parent && options.parent.$pinia) {
35378
- this.$pinia = options.parent.$pinia;
35379
- }
35380
- },
35381
- destroyed() {
35382
- delete this._pStores;
35383
- },
35384
- });
35385
- };
35386
-
35387
-
35388
33449
 
35389
33450
  ;// CONCATENATED MODULE: ./node_modules/@fortawesome/free-solid-svg-icons/index.mjs
35390
33451
  var prefix = "fas";
@@ -44859,6 +42920,2242 @@ var icons = {
44859
42920
 
44860
42921
 
44861
42922
 
42923
+ ;// CONCATENATED MODULE: ./node_modules/ts-loader/index.js??clonedRuleSet-83.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/UserExperience.vue?vue&type=script&lang=ts
42924
+
42925
+
42926
+
42927
+
42928
+
42929
+
42930
+ library$1.add(faFaceGrinStars);
42931
+ library$1.add(faFaceSmile);
42932
+ library$1.add(faFaceMeh);
42933
+ library$1.add(faFaceFrownOpen);
42934
+ library$1.add(faFaceFrown);
42935
+ /* harmony default export */ const UserExperiencevue_type_script_lang_ts = ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.defineComponent)({
42936
+ extends: MiniDSBase,
42937
+ // eslint-disable-next-line @typescript-eslint/naming-convention
42938
+ components: { FontAwesomeIcon: FontAwesomeIcon },
42939
+ props: {
42940
+ ratingColors: {
42941
+ type: Array,
42942
+ default: function () { return DEFAULT_RATING_COLORS; },
42943
+ },
42944
+ question: {
42945
+ type: String,
42946
+ default: "How would you rate your experience?",
42947
+ },
42948
+ commentPlaceholder: {
42949
+ type: String,
42950
+ default: "Please tell us more if you like",
42951
+ },
42952
+ askForComments: {
42953
+ type: Boolean,
42954
+ default: true,
42955
+ },
42956
+ iconSize: {
42957
+ type: String,
42958
+ default: "5x",
42959
+ },
42960
+ color: {
42961
+ type: String,
42962
+ default: "surface",
42963
+ },
42964
+ baseColor: {
42965
+ type: String,
42966
+ required: true,
42967
+ }
42968
+ },
42969
+ data: function () {
42970
+ var ratingIcons = {
42971
+ // eslint-disable-next-line @typescript-eslint/naming-convention
42972
+ "very_bad": ["fa-face-frown", "red"],
42973
+ "poor": ["fa-face-frown-open", "orange"],
42974
+ "good": ["fa-face-smile", "lightgreen"],
42975
+ "excellent": ["fa-face-grin-stars", "green"],
42976
+ };
42977
+ return {
42978
+ currentRating: null,
42979
+ comments: null,
42980
+ showComments: false,
42981
+ ratings: Object.keys(ratingIcons),
42982
+ ratingIcons: ratingIcons,
42983
+ };
42984
+ },
42985
+ computed: {
42986
+ showFooter: function () {
42987
+ return !!this.$slots.footer;
42988
+ },
42989
+ css: function () {
42990
+ return {
42991
+ "--footer-visible": this.showFooter ? "visible" : "none",
42992
+ };
42993
+ }
42994
+ },
42995
+ watch: {
42996
+ currentRating: function (rating) {
42997
+ if (rating) {
42998
+ if (this.askForComments) {
42999
+ this.showComments = true;
43000
+ }
43001
+ this.$emit("rating", rating);
43002
+ }
43003
+ }
43004
+ }
43005
+ }));
43006
+
43007
+ ;// CONCATENATED MODULE: ./src/components/UserExperience.vue?vue&type=script&lang=ts
43008
+
43009
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-75.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-75.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-75.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-75.use[3]!./node_modules/less-loader/dist/cjs.js??clonedRuleSet-75.use[4]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/UserExperience.vue?vue&type=style&index=0&id=7b3028df&lang=less
43010
+ var UserExperiencevue_type_style_index_0_id_7b3028df_lang_less = __webpack_require__(426);
43011
+ ;// CONCATENATED MODULE: ./src/components/UserExperience.vue?vue&type=style&index=0&id=7b3028df&lang=less
43012
+
43013
+ ;// CONCATENATED MODULE: ./src/components/UserExperience.vue
43014
+
43015
+
43016
+
43017
+
43018
+ ;
43019
+
43020
+
43021
+ const UserExperience_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(UserExperiencevue_type_script_lang_ts, [['render',UserExperiencevue_type_template_id_7b3028df_ts_true_render]])
43022
+
43023
+ /* harmony default export */ const UserExperience = (UserExperience_exports_);
43024
+ ;// CONCATENATED MODULE: ./node_modules/ts-loader/index.js??clonedRuleSet-83.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/wwtHUD.vue?vue&type=template&id=5867328d&ts=true
43025
+
43026
+ var wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_1 = { id: "wwt-hud" };
43027
+ var wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_2 = /*#__PURE__*/ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("h3", null, " Camera settings ", -1);
43028
+ var wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_3 = /*#__PURE__*/ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("h3", null, " Imagesets ", -1);
43029
+ var _hoisted_4 = /*#__PURE__*/ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("h3", null, " Clock ", -1);
43030
+ var _hoisted_5 = { key: 0 };
43031
+ function wwtHUDvue_type_template_id_5867328d_ts_true_render(_ctx, _cache, $props, $setup, $data, $options) {
43032
+ return ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
43033
+ style: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeStyle)(_ctx.cssVars)
43034
+ }, [
43035
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_1, [
43036
+ wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_2,
43037
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " RA: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtRARad) + " (" + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtRADeg) + ") ", 1),
43038
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Dec: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtDecRad) + " (" + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtDecDeg) + ") ", 1),
43039
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Roll: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtRollRad), 1),
43040
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Zoom: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtZoomDeg), 1),
43041
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Mode: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.mode), 1),
43042
+ wwtHUDvue_type_template_id_5867328d_ts_true_hoisted_3,
43043
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Bkg: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.bkgImage), 1),
43044
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Fg: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.fgImg) + " (op: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtForegroundOpacity) + " ) ", 1),
43045
+ _hoisted_4,
43046
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Time: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtCurrentTime), 1),
43047
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Rate: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtClockRate), 1),
43048
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", null, " Location: " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.wwtLocation), 1),
43049
+ (Object.keys(_ctx.otherVariables).length > 0)
43050
+ ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("h3", _hoisted_5, " User defined vars "))
43051
+ : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true),
43052
+ ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(true), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)(external_commonjs_vue_commonjs2_vue_root_Vue_.Fragment, null, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderList)(_ctx.otherVariables, function (value, key) {
43053
+ return ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("p", { key: key }, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(key) + ": " + (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(value), 1));
43054
+ }), 128)),
43055
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderSlot)(_ctx.$slots, "default")
43056
+ ])
43057
+ ], 4));
43058
+ }
43059
+
43060
+ ;// CONCATENATED MODULE: ./src/components/wwtHUD.vue?vue&type=template&id=5867328d&ts=true
43061
+
43062
+ // EXTERNAL MODULE: external {"amd":"@wwtelescope/engine","commonjs2":"@wwtelescope/engine","commonjs":"@wwtelescope/engine","root":"wwtlib"}
43063
+ var engine_root_wwtlib_ = __webpack_require__(380);
43064
+ ;// CONCATENATED MODULE: ./node_modules/ts-loader/index.js??clonedRuleSet-83.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/wwtHUD.vue?vue&type=script&lang=ts
43065
+
43066
+
43067
+
43068
+ var wwtHUDvue_type_script_lang_ts_R2D = 180 / Math.PI;
43069
+ /* harmony default export */ const wwtHUDvue_type_script_lang_ts = ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.defineComponent)({
43070
+ name: 'wwtHUD',
43071
+ extends: index_umd.WWTAwareComponent,
43072
+ props: {
43073
+ // location: center {x, y} in percent
43074
+ location: {
43075
+ type: Object,
43076
+ default: function () { return ({ top: '50%', left: '50%' }); }
43077
+ },
43078
+ offsetCenter: {
43079
+ // example: {x: 0.5, y: 0.5} for transform: translate(-50%, -50%)
43080
+ type: Object,
43081
+ default: function () { return ({ x: .5, y: .5 }); }
43082
+ },
43083
+ otherVariables: {
43084
+ type: Object,
43085
+ default: function () { return ({}); }
43086
+ },
43087
+ // styling props
43088
+ fontSize: {
43089
+ type: String,
43090
+ default: '1em'
43091
+ },
43092
+ backgroundColor: {
43093
+ type: String || null,
43094
+ default: 'rgba(0, 0, 0, 0.5)'
43095
+ },
43096
+ textShadow: {
43097
+ type: String || null,
43098
+ default: '0 0 5px black'
43099
+ },
43100
+ },
43101
+ computed: {
43102
+ wwtSettings: function () {
43103
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
43104
+ // @ts-ignore
43105
+ return engine_root_wwtlib_.Settings.get_active();
43106
+ },
43107
+ wwtControl: function () {
43108
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
43109
+ // @ts-ignore
43110
+ return engine_root_wwtlib_.WWTControl.singleton;
43111
+ },
43112
+ wwtScriptInterface: function () {
43113
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
43114
+ // @ts-ignore
43115
+ return engine_root_wwtlib_.ScriptInterface.singleton;
43116
+ },
43117
+ cssVars: function () {
43118
+ var _a, _b, _c, _d;
43119
+ return {
43120
+ '--hud-top': (_a = this.location.top) !== null && _a !== void 0 ? _a : 'auto',
43121
+ '--hud-left': (_b = this.location.left) !== null && _b !== void 0 ? _b : 'auto',
43122
+ '--hud-bottom': (_c = this.location.bottom) !== null && _c !== void 0 ? _c : 'auto',
43123
+ '--hud-right': (_d = this.location.right) !== null && _d !== void 0 ? _d : 'auto',
43124
+ '--font-size': this.fontSize,
43125
+ '--background-color': this.backgroundColor || 'transparent',
43126
+ '--text-shadow': this.textShadow || 'none',
43127
+ '--offset-center-x': "-".concat(this.offsetCenter.x * 100, "%"),
43128
+ '--offset-center-y': "-".concat(this.offsetCenter.y * 100, "%"),
43129
+ };
43130
+ },
43131
+ wwtRADeg: function () {
43132
+ return this.wwtRARad * wwtHUDvue_type_script_lang_ts_R2D;
43133
+ },
43134
+ wwtDecDeg: function () {
43135
+ return this.wwtDecRad * wwtHUDvue_type_script_lang_ts_R2D;
43136
+ },
43137
+ bkgImage: function () {
43138
+ var _a;
43139
+ return (_a = this.wwtBackgroundImageset) === null || _a === void 0 ? void 0 : _a.get_name();
43140
+ },
43141
+ fgImg: function () {
43142
+ var _a;
43143
+ return (_a = this.wwtForegroundImageset) === null || _a === void 0 ? void 0 : _a.get_name();
43144
+ },
43145
+ mode: function () {
43146
+ if (this.bkgImage == "3D Solar System View") {
43147
+ return '3D';
43148
+ }
43149
+ if (this.wwtSettings.get_galacticMode()) {
43150
+ return 'Sky (galactic)';
43151
+ }
43152
+ if (this.wwtSettings.get_localHorizonMode()) {
43153
+ return 'Sky (local horizon)';
43154
+ }
43155
+ return 'Sky (equatorial)';
43156
+ },
43157
+ wwtLocation: function () {
43158
+ return {
43159
+ lat: this.wwtSettings.get_locationLat(),
43160
+ lon: this.wwtSettings.get_locationLng(),
43161
+ alt: this.wwtSettings.get_locationAltitude(),
43162
+ };
43163
+ },
43164
+ },
43165
+ }));
43166
+
43167
+ ;// CONCATENATED MODULE: ./src/components/wwtHUD.vue?vue&type=script&lang=ts
43168
+
43169
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-75.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-75.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-75.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-75.use[3]!./node_modules/less-loader/dist/cjs.js??clonedRuleSet-75.use[4]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/wwtHUD.vue?vue&type=style&index=0&id=5867328d&lang=less
43170
+ var wwtHUDvue_type_style_index_0_id_5867328d_lang_less = __webpack_require__(293);
43171
+ ;// CONCATENATED MODULE: ./src/components/wwtHUD.vue?vue&type=style&index=0&id=5867328d&lang=less
43172
+
43173
+ ;// CONCATENATED MODULE: ./src/components/wwtHUD.vue
43174
+
43175
+
43176
+
43177
+
43178
+ ;
43179
+
43180
+
43181
+ const wwtHUD_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(wwtHUDvue_type_script_lang_ts, [['render',wwtHUDvue_type_template_id_5867328d_ts_true_render]])
43182
+
43183
+ /* harmony default export */ const wwtHUD = (wwtHUD_exports_);
43184
+ ;// CONCATENATED MODULE: ./src/background.ts
43185
+ var BackgroundImageset = /** @class */ (function () {
43186
+ function BackgroundImageset(displayName, imagesetName) {
43187
+ this.displayName = displayName;
43188
+ this.imagesetName = imagesetName;
43189
+ }
43190
+ return BackgroundImageset;
43191
+ }());
43192
+
43193
+ var skyBackgroundImagesets = [
43194
+ new BackgroundImageset("Optical (Terapixel DSS)", "Digitized Sky Survey (Color)"),
43195
+ new BackgroundImageset("Low-frequency radio (VLSS)", "VLSS: VLA Low-frequency Sky Survey (Radio)"),
43196
+ new BackgroundImageset("Infrared (2MASS)", "2Mass: Imagery (Infrared)"),
43197
+ new BackgroundImageset("Infrared (SFD dust map)", "SFD Dust Map (Infrared)"),
43198
+ new BackgroundImageset("Ultraviolet (GALEX)", "GALEX (Ultraviolet)"),
43199
+ new BackgroundImageset("X-Ray (ROSAT RASS)", "RASS: ROSAT All Sky Survey (X-ray)"),
43200
+ new BackgroundImageset("Gamma Rays (FERMI LAT 8-year)", "Fermi LAT 8-year (gamma)"),
43201
+ ];
43202
+
43203
+ ;// CONCATENATED MODULE: ./node_modules/ts-loader/index.js??clonedRuleSet-83.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Gallery.vue?vue&type=template&id=4cc30028&ts=true
43204
+
43205
+
43206
+ var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_1 = { class: "default-activator-title noselect" };
43207
+ var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_2 = ["src"];
43208
+ var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_3 = { class: "gallery-header" };
43209
+ var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_4 = { class: "gallery-title" };
43210
+ var Galleryvue_type_template_id_4cc30028_ts_true_hoisted_5 = { class: "gallery-content" };
43211
+ var _hoisted_6 = ["onClick"];
43212
+ var _hoisted_7 = ["src"];
43213
+ var _hoisted_8 = { class: "place-name noselect" };
43214
+ function Galleryvue_type_template_id_4cc30028_ts_true_render(_ctx, _cache, $props, $setup, $data, $options) {
43215
+ var _component_font_awesome_icon = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.resolveComponent)("font-awesome-icon");
43216
+ return ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
43217
+ class: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeClass)(['gallery-root', { 'open': _ctx.open }])
43218
+ }, [
43219
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", {
43220
+ class: "just-holding-events",
43221
+ onClick: _cache[2] || (_cache[2] = function ($event) { return (_ctx.open = true); }),
43222
+ onKeyup: _cache[3] || (_cache[3] = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withKeys)(function ($event) { return (_ctx.open = true); }, ["enter"])),
43223
+ tabindex: "0"
43224
+ }, [
43225
+ (!_ctx.open)
43226
+ ? (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderSlot)(_ctx.$slots, "closed", { key: 0 }, function () {
43227
+ var _a, _b;
43228
+ return [
43229
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", {
43230
+ class: "default-activator blurred",
43231
+ onClick: _cache[0] || (_cache[0] = function ($event) { return (_ctx.open = true); }),
43232
+ onKeyup: _cache[1] || (_cache[1] = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withKeys)(function ($event) { return (_ctx.open = true); }, ["enter"]))
43233
+ }, [
43234
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("span", Galleryvue_type_template_id_4cc30028_ts_true_hoisted_1, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.closedText), 1),
43235
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("img", {
43236
+ class: "noselect",
43237
+ src: _ctx.places[_ctx.previewIndex] ? ((_b = (_a = _ctx.getImageset(_ctx.places[_ctx.previewIndex])) === null || _a === void 0 ? void 0 : _a.get_thumbnailUrl()) !== null && _b !== void 0 ? _b : '') : ''
43238
+ }, null, 8, Galleryvue_type_template_id_4cc30028_ts_true_hoisted_2)
43239
+ ], 32)
43240
+ ];
43241
+ })
43242
+ : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)
43243
+ ], 32),
43244
+ (_ctx.open)
43245
+ ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
43246
+ key: 0,
43247
+ style: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeStyle)(_ctx.cssVars),
43248
+ class: "gallery blurred"
43249
+ }, [
43250
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", Galleryvue_type_template_id_4cc30028_ts_true_hoisted_3, [
43251
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("span", Galleryvue_type_template_id_4cc30028_ts_true_hoisted_4, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(_ctx.title), 1),
43252
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createVNode)(_component_font_awesome_icon, {
43253
+ class: "gallery-close",
43254
+ icon: "times",
43255
+ size: "lg",
43256
+ onClick: _cache[4] || (_cache[4] = function ($event) { return (_ctx.open = false); }),
43257
+ onKeyup: _cache[5] || (_cache[5] = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.withKeys)(function ($event) { return (_ctx.open = false); }, ["enter"])),
43258
+ tabindex: "0"
43259
+ })
43260
+ ]),
43261
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", Galleryvue_type_template_id_4cc30028_ts_true_hoisted_5, [
43262
+ ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(true), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)(external_commonjs_vue_commonjs2_vue_root_Vue_.Fragment, null, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.renderList)(_ctx.places.entries(), function (_a) {
43263
+ var _b, _c;
43264
+ var _d = __read(_a, 2), index = _d[0], place = _d[1];
43265
+ return ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
43266
+ key: index,
43267
+ class: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeClass)(['gallery-item', { 'selected': _ctx.highlightLastOnly ? _ctx.selectedPlace === place : _ctx.selectedPlaces.includes(place) }]),
43268
+ onClick: function ($event) { return (_ctx.selectPlace(place)); }
43269
+ }, [
43270
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("img", {
43271
+ class: "noselect",
43272
+ src: (_c = (_b = _ctx.getImageset(place)) === null || _b === void 0 ? void 0 : _b.get_thumbnailUrl()) !== null && _c !== void 0 ? _c : ''
43273
+ }, null, 8, _hoisted_7),
43274
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("span", _hoisted_8, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)(place.get_name()), 1)
43275
+ ], 10, _hoisted_6));
43276
+ }), 128))
43277
+ ])
43278
+ ], 4))
43279
+ : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)
43280
+ ], 2));
43281
+ }
43282
+
43283
+ ;// CONCATENATED MODULE: ./src/components/Gallery.vue?vue&type=template&id=4cc30028&ts=true
43284
+
43285
+ ;// CONCATENATED MODULE: ./node_modules/vue-demi/lib/index.mjs
43286
+
43287
+
43288
+ var lib_isVue2 = false
43289
+ var isVue3 = true
43290
+ var Vue2 = (/* unused pure expression or super */ null && (undefined))
43291
+
43292
+ function install() {}
43293
+
43294
+ function lib_set(target, key, val) {
43295
+ if (Array.isArray(target)) {
43296
+ target.length = Math.max(target.length, key)
43297
+ target.splice(key, 1, val)
43298
+ return val
43299
+ }
43300
+ target[key] = val
43301
+ return val
43302
+ }
43303
+
43304
+ function del(target, key) {
43305
+ if (Array.isArray(target)) {
43306
+ target.splice(key, 1)
43307
+ return
43308
+ }
43309
+ delete target[key]
43310
+ }
43311
+
43312
+
43313
+
43314
+
43315
+ ;// CONCATENATED MODULE: ./node_modules/pinia/dist/pinia.mjs
43316
+ /*!
43317
+ * pinia v2.1.7
43318
+ * (c) 2023 Eduardo San Martin Morote
43319
+ * @license MIT
43320
+ */
43321
+
43322
+
43323
+
43324
+ /**
43325
+ * setActivePinia must be called to handle SSR at the top of functions like
43326
+ * `fetch`, `setup`, `serverPrefetch` and others
43327
+ */
43328
+ let activePinia;
43329
+ /**
43330
+ * Sets or unsets the active pinia. Used in SSR and internally when calling
43331
+ * actions and getters
43332
+ *
43333
+ * @param pinia - Pinia instance
43334
+ */
43335
+ // @ts-expect-error: cannot constrain the type of the return
43336
+ const setActivePinia = (pinia) => (activePinia = pinia);
43337
+ /**
43338
+ * Get the currently active pinia if there is any.
43339
+ */
43340
+ const getActivePinia = () => (hasInjectionContext() && inject(piniaSymbol)) || activePinia;
43341
+ const piniaSymbol = (( false) ? 0 : /* istanbul ignore next */ Symbol());
43342
+
43343
+ function isPlainObject(
43344
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43345
+ o) {
43346
+ return (o &&
43347
+ typeof o === 'object' &&
43348
+ Object.prototype.toString.call(o) === '[object Object]' &&
43349
+ typeof o.toJSON !== 'function');
43350
+ }
43351
+ // type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]> }
43352
+ // TODO: can we change these to numbers?
43353
+ /**
43354
+ * Possible types for SubscriptionCallback
43355
+ */
43356
+ var MutationType;
43357
+ (function (MutationType) {
43358
+ /**
43359
+ * Direct mutation of the state:
43360
+ *
43361
+ * - `store.name = 'new name'`
43362
+ * - `store.$state.name = 'new name'`
43363
+ * - `store.list.push('new item')`
43364
+ */
43365
+ MutationType["direct"] = "direct";
43366
+ /**
43367
+ * Mutated the state with `$patch` and an object
43368
+ *
43369
+ * - `store.$patch({ name: 'newName' })`
43370
+ */
43371
+ MutationType["patchObject"] = "patch object";
43372
+ /**
43373
+ * Mutated the state with `$patch` and a function
43374
+ *
43375
+ * - `store.$patch(state => state.name = 'newName')`
43376
+ */
43377
+ MutationType["patchFunction"] = "patch function";
43378
+ // maybe reset? for $state = {} and $reset
43379
+ })(MutationType || (MutationType = {}));
43380
+
43381
+ const IS_CLIENT = typeof window !== 'undefined';
43382
+ /**
43383
+ * Should we add the devtools plugins.
43384
+ * - only if dev mode or forced through the prod devtools flag
43385
+ * - not in test
43386
+ * - only if window exists (could change in the future)
43387
+ */
43388
+ const USE_DEVTOOLS = (/* unused pure expression or super */ null && ( false && 0));
43389
+
43390
+ /*
43391
+ * FileSaver.js A saveAs() FileSaver implementation.
43392
+ *
43393
+ * Originally by Eli Grey, adapted as an ESM module by Eduardo San Martin
43394
+ * Morote.
43395
+ *
43396
+ * License : MIT
43397
+ */
43398
+ // The one and only way of getting global scope in all environments
43399
+ // https://stackoverflow.com/q/3277182/1008999
43400
+ const _global = /*#__PURE__*/ (() => typeof window === 'object' && window.window === window
43401
+ ? window
43402
+ : typeof self === 'object' && self.self === self
43403
+ ? self
43404
+ : typeof global === 'object' && global.global === global
43405
+ ? global
43406
+ : typeof globalThis === 'object'
43407
+ ? globalThis
43408
+ : { HTMLElement: null })();
43409
+ function bom(blob, { autoBom = false } = {}) {
43410
+ // prepend BOM for UTF-8 XML and text/* types (including HTML)
43411
+ // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
43412
+ if (autoBom &&
43413
+ /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
43414
+ return new Blob([String.fromCharCode(0xfeff), blob], { type: blob.type });
43415
+ }
43416
+ return blob;
43417
+ }
43418
+ function download(url, name, opts) {
43419
+ const xhr = new XMLHttpRequest();
43420
+ xhr.open('GET', url);
43421
+ xhr.responseType = 'blob';
43422
+ xhr.onload = function () {
43423
+ saveAs(xhr.response, name, opts);
43424
+ };
43425
+ xhr.onerror = function () {
43426
+ console.error('could not download file');
43427
+ };
43428
+ xhr.send();
43429
+ }
43430
+ function corsEnabled(url) {
43431
+ const xhr = new XMLHttpRequest();
43432
+ // use sync to avoid popup blocker
43433
+ xhr.open('HEAD', url, false);
43434
+ try {
43435
+ xhr.send();
43436
+ }
43437
+ catch (e) { }
43438
+ return xhr.status >= 200 && xhr.status <= 299;
43439
+ }
43440
+ // `a.click()` doesn't work for all browsers (#465)
43441
+ function click(node) {
43442
+ try {
43443
+ node.dispatchEvent(new MouseEvent('click'));
43444
+ }
43445
+ catch (e) {
43446
+ const evt = document.createEvent('MouseEvents');
43447
+ evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
43448
+ node.dispatchEvent(evt);
43449
+ }
43450
+ }
43451
+ const _navigator =
43452
+ typeof navigator === 'object' ? navigator : { userAgent: '' };
43453
+ // Detect WebView inside a native macOS app by ruling out all browsers
43454
+ // We just need to check for 'Safari' because all other browsers (besides Firefox) include that too
43455
+ // https://www.whatismybrowser.com/guides/the-latest-user-agent/macos
43456
+ const isMacOSWebView = /*#__PURE__*/ (() => /Macintosh/.test(_navigator.userAgent) &&
43457
+ /AppleWebKit/.test(_navigator.userAgent) &&
43458
+ !/Safari/.test(_navigator.userAgent))();
43459
+ const saveAs = !IS_CLIENT
43460
+ ? () => { } // noop
43461
+ : // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program
43462
+ typeof HTMLAnchorElement !== 'undefined' &&
43463
+ 'download' in HTMLAnchorElement.prototype &&
43464
+ !isMacOSWebView
43465
+ ? downloadSaveAs
43466
+ : // Use msSaveOrOpenBlob as a second approach
43467
+ 'msSaveOrOpenBlob' in _navigator
43468
+ ? msSaveAs
43469
+ : // Fallback to using FileReader and a popup
43470
+ fileSaverSaveAs;
43471
+ function downloadSaveAs(blob, name = 'download', opts) {
43472
+ const a = document.createElement('a');
43473
+ a.download = name;
43474
+ a.rel = 'noopener'; // tabnabbing
43475
+ // TODO: detect chrome extensions & packaged apps
43476
+ // a.target = '_blank'
43477
+ if (typeof blob === 'string') {
43478
+ // Support regular links
43479
+ a.href = blob;
43480
+ if (a.origin !== location.origin) {
43481
+ if (corsEnabled(a.href)) {
43482
+ download(blob, name, opts);
43483
+ }
43484
+ else {
43485
+ a.target = '_blank';
43486
+ click(a);
43487
+ }
43488
+ }
43489
+ else {
43490
+ click(a);
43491
+ }
43492
+ }
43493
+ else {
43494
+ // Support blobs
43495
+ a.href = URL.createObjectURL(blob);
43496
+ setTimeout(function () {
43497
+ URL.revokeObjectURL(a.href);
43498
+ }, 4e4); // 40s
43499
+ setTimeout(function () {
43500
+ click(a);
43501
+ }, 0);
43502
+ }
43503
+ }
43504
+ function msSaveAs(blob, name = 'download', opts) {
43505
+ if (typeof blob === 'string') {
43506
+ if (corsEnabled(blob)) {
43507
+ download(blob, name, opts);
43508
+ }
43509
+ else {
43510
+ const a = document.createElement('a');
43511
+ a.href = blob;
43512
+ a.target = '_blank';
43513
+ setTimeout(function () {
43514
+ click(a);
43515
+ });
43516
+ }
43517
+ }
43518
+ else {
43519
+ // @ts-ignore: works on windows
43520
+ navigator.msSaveOrOpenBlob(bom(blob, opts), name);
43521
+ }
43522
+ }
43523
+ function fileSaverSaveAs(blob, name, opts, popup) {
43524
+ // Open a popup immediately do go around popup blocker
43525
+ // Mostly only available on user interaction and the fileReader is async so...
43526
+ popup = popup || open('', '_blank');
43527
+ if (popup) {
43528
+ popup.document.title = popup.document.body.innerText = 'downloading...';
43529
+ }
43530
+ if (typeof blob === 'string')
43531
+ return download(blob, name, opts);
43532
+ const force = blob.type === 'application/octet-stream';
43533
+ const isSafari = /constructor/i.test(String(_global.HTMLElement)) || 'safari' in _global;
43534
+ const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
43535
+ if ((isChromeIOS || (force && isSafari) || isMacOSWebView) &&
43536
+ typeof FileReader !== 'undefined') {
43537
+ // Safari doesn't allow downloading of blob URLs
43538
+ const reader = new FileReader();
43539
+ reader.onloadend = function () {
43540
+ let url = reader.result;
43541
+ if (typeof url !== 'string') {
43542
+ popup = null;
43543
+ throw new Error('Wrong reader.result type');
43544
+ }
43545
+ url = isChromeIOS
43546
+ ? url
43547
+ : url.replace(/^data:[^;]*;/, 'data:attachment/file;');
43548
+ if (popup) {
43549
+ popup.location.href = url;
43550
+ }
43551
+ else {
43552
+ location.assign(url);
43553
+ }
43554
+ popup = null; // reverse-tabnabbing #460
43555
+ };
43556
+ reader.readAsDataURL(blob);
43557
+ }
43558
+ else {
43559
+ const url = URL.createObjectURL(blob);
43560
+ if (popup)
43561
+ popup.location.assign(url);
43562
+ else
43563
+ location.href = url;
43564
+ popup = null; // reverse-tabnabbing #460
43565
+ setTimeout(function () {
43566
+ URL.revokeObjectURL(url);
43567
+ }, 4e4); // 40s
43568
+ }
43569
+ }
43570
+
43571
+ /**
43572
+ * Shows a toast or console.log
43573
+ *
43574
+ * @param message - message to log
43575
+ * @param type - different color of the tooltip
43576
+ */
43577
+ function toastMessage(message, type) {
43578
+ const piniaMessage = '🍍 ' + message;
43579
+ if (typeof __VUE_DEVTOOLS_TOAST__ === 'function') {
43580
+ // No longer available :(
43581
+ __VUE_DEVTOOLS_TOAST__(piniaMessage, type);
43582
+ }
43583
+ else if (type === 'error') {
43584
+ console.error(piniaMessage);
43585
+ }
43586
+ else if (type === 'warn') {
43587
+ console.warn(piniaMessage);
43588
+ }
43589
+ else {
43590
+ console.log(piniaMessage);
43591
+ }
43592
+ }
43593
+ function isPinia(o) {
43594
+ return '_a' in o && 'install' in o;
43595
+ }
43596
+
43597
+ /**
43598
+ * This file contain devtools actions, they are not Pinia actions.
43599
+ */
43600
+ // ---
43601
+ function checkClipboardAccess() {
43602
+ if (!('clipboard' in navigator)) {
43603
+ toastMessage(`Your browser doesn't support the Clipboard API`, 'error');
43604
+ return true;
43605
+ }
43606
+ }
43607
+ function checkNotFocusedError(error) {
43608
+ if (error instanceof Error &&
43609
+ error.message.toLowerCase().includes('document is not focused')) {
43610
+ toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', 'warn');
43611
+ return true;
43612
+ }
43613
+ return false;
43614
+ }
43615
+ async function actionGlobalCopyState(pinia) {
43616
+ if (checkClipboardAccess())
43617
+ return;
43618
+ try {
43619
+ await navigator.clipboard.writeText(JSON.stringify(pinia.state.value));
43620
+ toastMessage('Global state copied to clipboard.');
43621
+ }
43622
+ catch (error) {
43623
+ if (checkNotFocusedError(error))
43624
+ return;
43625
+ toastMessage(`Failed to serialize the state. Check the console for more details.`, 'error');
43626
+ console.error(error);
43627
+ }
43628
+ }
43629
+ async function actionGlobalPasteState(pinia) {
43630
+ if (checkClipboardAccess())
43631
+ return;
43632
+ try {
43633
+ loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText()));
43634
+ toastMessage('Global state pasted from clipboard.');
43635
+ }
43636
+ catch (error) {
43637
+ if (checkNotFocusedError(error))
43638
+ return;
43639
+ toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, 'error');
43640
+ console.error(error);
43641
+ }
43642
+ }
43643
+ async function actionGlobalSaveState(pinia) {
43644
+ try {
43645
+ saveAs(new Blob([JSON.stringify(pinia.state.value)], {
43646
+ type: 'text/plain;charset=utf-8',
43647
+ }), 'pinia-state.json');
43648
+ }
43649
+ catch (error) {
43650
+ toastMessage(`Failed to export the state as JSON. Check the console for more details.`, 'error');
43651
+ console.error(error);
43652
+ }
43653
+ }
43654
+ let fileInput;
43655
+ function getFileOpener() {
43656
+ if (!fileInput) {
43657
+ fileInput = document.createElement('input');
43658
+ fileInput.type = 'file';
43659
+ fileInput.accept = '.json';
43660
+ }
43661
+ function openFile() {
43662
+ return new Promise((resolve, reject) => {
43663
+ fileInput.onchange = async () => {
43664
+ const files = fileInput.files;
43665
+ if (!files)
43666
+ return resolve(null);
43667
+ const file = files.item(0);
43668
+ if (!file)
43669
+ return resolve(null);
43670
+ return resolve({ text: await file.text(), file });
43671
+ };
43672
+ // @ts-ignore: TODO: changed from 4.3 to 4.4
43673
+ fileInput.oncancel = () => resolve(null);
43674
+ fileInput.onerror = reject;
43675
+ fileInput.click();
43676
+ });
43677
+ }
43678
+ return openFile;
43679
+ }
43680
+ async function actionGlobalOpenStateFile(pinia) {
43681
+ try {
43682
+ const open = getFileOpener();
43683
+ const result = await open();
43684
+ if (!result)
43685
+ return;
43686
+ const { text, file } = result;
43687
+ loadStoresState(pinia, JSON.parse(text));
43688
+ toastMessage(`Global state imported from "${file.name}".`);
43689
+ }
43690
+ catch (error) {
43691
+ toastMessage(`Failed to import the state from JSON. Check the console for more details.`, 'error');
43692
+ console.error(error);
43693
+ }
43694
+ }
43695
+ function loadStoresState(pinia, state) {
43696
+ for (const key in state) {
43697
+ const storeState = pinia.state.value[key];
43698
+ // store is already instantiated, patch it
43699
+ if (storeState) {
43700
+ Object.assign(storeState, state[key]);
43701
+ }
43702
+ else {
43703
+ // store is not instantiated, set the initial state
43704
+ pinia.state.value[key] = state[key];
43705
+ }
43706
+ }
43707
+ }
43708
+
43709
+ function formatDisplay(display) {
43710
+ return {
43711
+ _custom: {
43712
+ display,
43713
+ },
43714
+ };
43715
+ }
43716
+ const PINIA_ROOT_LABEL = '🍍 Pinia (root)';
43717
+ const PINIA_ROOT_ID = '_root';
43718
+ function formatStoreForInspectorTree(store) {
43719
+ return isPinia(store)
43720
+ ? {
43721
+ id: PINIA_ROOT_ID,
43722
+ label: PINIA_ROOT_LABEL,
43723
+ }
43724
+ : {
43725
+ id: store.$id,
43726
+ label: store.$id,
43727
+ };
43728
+ }
43729
+ function formatStoreForInspectorState(store) {
43730
+ if (isPinia(store)) {
43731
+ const storeNames = Array.from(store._s.keys());
43732
+ const storeMap = store._s;
43733
+ const state = {
43734
+ state: storeNames.map((storeId) => ({
43735
+ editable: true,
43736
+ key: storeId,
43737
+ value: store.state.value[storeId],
43738
+ })),
43739
+ getters: storeNames
43740
+ .filter((id) => storeMap.get(id)._getters)
43741
+ .map((id) => {
43742
+ const store = storeMap.get(id);
43743
+ return {
43744
+ editable: false,
43745
+ key: id,
43746
+ value: store._getters.reduce((getters, key) => {
43747
+ getters[key] = store[key];
43748
+ return getters;
43749
+ }, {}),
43750
+ };
43751
+ }),
43752
+ };
43753
+ return state;
43754
+ }
43755
+ const state = {
43756
+ state: Object.keys(store.$state).map((key) => ({
43757
+ editable: true,
43758
+ key,
43759
+ value: store.$state[key],
43760
+ })),
43761
+ };
43762
+ // avoid adding empty getters
43763
+ if (store._getters && store._getters.length) {
43764
+ state.getters = store._getters.map((getterName) => ({
43765
+ editable: false,
43766
+ key: getterName,
43767
+ value: store[getterName],
43768
+ }));
43769
+ }
43770
+ if (store._customProperties.size) {
43771
+ state.customProperties = Array.from(store._customProperties).map((key) => ({
43772
+ editable: true,
43773
+ key,
43774
+ value: store[key],
43775
+ }));
43776
+ }
43777
+ return state;
43778
+ }
43779
+ function formatEventData(events) {
43780
+ if (!events)
43781
+ return {};
43782
+ if (Array.isArray(events)) {
43783
+ // TODO: handle add and delete for arrays and objects
43784
+ return events.reduce((data, event) => {
43785
+ data.keys.push(event.key);
43786
+ data.operations.push(event.type);
43787
+ data.oldValue[event.key] = event.oldValue;
43788
+ data.newValue[event.key] = event.newValue;
43789
+ return data;
43790
+ }, {
43791
+ oldValue: {},
43792
+ keys: [],
43793
+ operations: [],
43794
+ newValue: {},
43795
+ });
43796
+ }
43797
+ else {
43798
+ return {
43799
+ operation: formatDisplay(events.type),
43800
+ key: formatDisplay(events.key),
43801
+ oldValue: events.oldValue,
43802
+ newValue: events.newValue,
43803
+ };
43804
+ }
43805
+ }
43806
+ function formatMutationType(type) {
43807
+ switch (type) {
43808
+ case MutationType.direct:
43809
+ return 'mutation';
43810
+ case MutationType.patchFunction:
43811
+ return '$patch';
43812
+ case MutationType.patchObject:
43813
+ return '$patch';
43814
+ default:
43815
+ return 'unknown';
43816
+ }
43817
+ }
43818
+
43819
+ // timeline can be paused when directly changing the state
43820
+ let isTimelineActive = true;
43821
+ const componentStateTypes = (/* unused pure expression or super */ null && ([]));
43822
+ const MUTATIONS_LAYER_ID = 'pinia:mutations';
43823
+ const INSPECTOR_ID = 'pinia';
43824
+ const { assign: assign$1 } = Object;
43825
+ /**
43826
+ * Gets the displayed name of a store in devtools
43827
+ *
43828
+ * @param id - id of the store
43829
+ * @returns a formatted string
43830
+ */
43831
+ const getStoreType = (id) => '🍍 ' + id;
43832
+ /**
43833
+ * Add the pinia plugin without any store. Allows displaying a Pinia plugin tab
43834
+ * as soon as it is added to the application.
43835
+ *
43836
+ * @param app - Vue application
43837
+ * @param pinia - pinia instance
43838
+ */
43839
+ function registerPiniaDevtools(app, pinia) {
43840
+ setupDevtoolsPlugin({
43841
+ id: 'dev.esm.pinia',
43842
+ label: 'Pinia 🍍',
43843
+ logo: 'https://pinia.vuejs.org/logo.svg',
43844
+ packageName: 'pinia',
43845
+ homepage: 'https://pinia.vuejs.org',
43846
+ componentStateTypes,
43847
+ app,
43848
+ }, (api) => {
43849
+ if (typeof api.now !== 'function') {
43850
+ toastMessage('You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.');
43851
+ }
43852
+ api.addTimelineLayer({
43853
+ id: MUTATIONS_LAYER_ID,
43854
+ label: `Pinia 🍍`,
43855
+ color: 0xe5df88,
43856
+ });
43857
+ api.addInspector({
43858
+ id: INSPECTOR_ID,
43859
+ label: 'Pinia 🍍',
43860
+ icon: 'storage',
43861
+ treeFilterPlaceholder: 'Search stores',
43862
+ actions: [
43863
+ {
43864
+ icon: 'content_copy',
43865
+ action: () => {
43866
+ actionGlobalCopyState(pinia);
43867
+ },
43868
+ tooltip: 'Serialize and copy the state',
43869
+ },
43870
+ {
43871
+ icon: 'content_paste',
43872
+ action: async () => {
43873
+ await actionGlobalPasteState(pinia);
43874
+ api.sendInspectorTree(INSPECTOR_ID);
43875
+ api.sendInspectorState(INSPECTOR_ID);
43876
+ },
43877
+ tooltip: 'Replace the state with the content of your clipboard',
43878
+ },
43879
+ {
43880
+ icon: 'save',
43881
+ action: () => {
43882
+ actionGlobalSaveState(pinia);
43883
+ },
43884
+ tooltip: 'Save the state as a JSON file',
43885
+ },
43886
+ {
43887
+ icon: 'folder_open',
43888
+ action: async () => {
43889
+ await actionGlobalOpenStateFile(pinia);
43890
+ api.sendInspectorTree(INSPECTOR_ID);
43891
+ api.sendInspectorState(INSPECTOR_ID);
43892
+ },
43893
+ tooltip: 'Import the state from a JSON file',
43894
+ },
43895
+ ],
43896
+ nodeActions: [
43897
+ {
43898
+ icon: 'restore',
43899
+ tooltip: 'Reset the state (with "$reset")',
43900
+ action: (nodeId) => {
43901
+ const store = pinia._s.get(nodeId);
43902
+ if (!store) {
43903
+ toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, 'warn');
43904
+ }
43905
+ else if (typeof store.$reset !== 'function') {
43906
+ toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, 'warn');
43907
+ }
43908
+ else {
43909
+ store.$reset();
43910
+ toastMessage(`Store "${nodeId}" reset.`);
43911
+ }
43912
+ },
43913
+ },
43914
+ ],
43915
+ });
43916
+ api.on.inspectComponent((payload, ctx) => {
43917
+ const proxy = (payload.componentInstance &&
43918
+ payload.componentInstance.proxy);
43919
+ if (proxy && proxy._pStores) {
43920
+ const piniaStores = payload.componentInstance.proxy._pStores;
43921
+ Object.values(piniaStores).forEach((store) => {
43922
+ payload.instanceData.state.push({
43923
+ type: getStoreType(store.$id),
43924
+ key: 'state',
43925
+ editable: true,
43926
+ value: store._isOptionsAPI
43927
+ ? {
43928
+ _custom: {
43929
+ value: toRaw(store.$state),
43930
+ actions: [
43931
+ {
43932
+ icon: 'restore',
43933
+ tooltip: 'Reset the state of this store',
43934
+ action: () => store.$reset(),
43935
+ },
43936
+ ],
43937
+ },
43938
+ }
43939
+ : // NOTE: workaround to unwrap transferred refs
43940
+ Object.keys(store.$state).reduce((state, key) => {
43941
+ state[key] = store.$state[key];
43942
+ return state;
43943
+ }, {}),
43944
+ });
43945
+ if (store._getters && store._getters.length) {
43946
+ payload.instanceData.state.push({
43947
+ type: getStoreType(store.$id),
43948
+ key: 'getters',
43949
+ editable: false,
43950
+ value: store._getters.reduce((getters, key) => {
43951
+ try {
43952
+ getters[key] = store[key];
43953
+ }
43954
+ catch (error) {
43955
+ // @ts-expect-error: we just want to show it in devtools
43956
+ getters[key] = error;
43957
+ }
43958
+ return getters;
43959
+ }, {}),
43960
+ });
43961
+ }
43962
+ });
43963
+ }
43964
+ });
43965
+ api.on.getInspectorTree((payload) => {
43966
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
43967
+ let stores = [pinia];
43968
+ stores = stores.concat(Array.from(pinia._s.values()));
43969
+ payload.rootNodes = (payload.filter
43970
+ ? stores.filter((store) => '$id' in store
43971
+ ? store.$id
43972
+ .toLowerCase()
43973
+ .includes(payload.filter.toLowerCase())
43974
+ : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase()))
43975
+ : stores).map(formatStoreForInspectorTree);
43976
+ }
43977
+ });
43978
+ api.on.getInspectorState((payload) => {
43979
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
43980
+ const inspectedStore = payload.nodeId === PINIA_ROOT_ID
43981
+ ? pinia
43982
+ : pinia._s.get(payload.nodeId);
43983
+ if (!inspectedStore) {
43984
+ // this could be the selected store restored for a different project
43985
+ // so it's better not to say anything here
43986
+ return;
43987
+ }
43988
+ if (inspectedStore) {
43989
+ payload.state = formatStoreForInspectorState(inspectedStore);
43990
+ }
43991
+ }
43992
+ });
43993
+ api.on.editInspectorState((payload, ctx) => {
43994
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
43995
+ const inspectedStore = payload.nodeId === PINIA_ROOT_ID
43996
+ ? pinia
43997
+ : pinia._s.get(payload.nodeId);
43998
+ if (!inspectedStore) {
43999
+ return toastMessage(`store "${payload.nodeId}" not found`, 'error');
44000
+ }
44001
+ const { path } = payload;
44002
+ if (!isPinia(inspectedStore)) {
44003
+ // access only the state
44004
+ if (path.length !== 1 ||
44005
+ !inspectedStore._customProperties.has(path[0]) ||
44006
+ path[0] in inspectedStore.$state) {
44007
+ path.unshift('$state');
44008
+ }
44009
+ }
44010
+ else {
44011
+ // Root access, we can omit the `.value` because the devtools API does it for us
44012
+ path.unshift('state');
44013
+ }
44014
+ isTimelineActive = false;
44015
+ payload.set(inspectedStore, path, payload.state.value);
44016
+ isTimelineActive = true;
44017
+ }
44018
+ });
44019
+ api.on.editComponentState((payload) => {
44020
+ if (payload.type.startsWith('🍍')) {
44021
+ const storeId = payload.type.replace(/^🍍\s*/, '');
44022
+ const store = pinia._s.get(storeId);
44023
+ if (!store) {
44024
+ return toastMessage(`store "${storeId}" not found`, 'error');
44025
+ }
44026
+ const { path } = payload;
44027
+ if (path[0] !== 'state') {
44028
+ return toastMessage(`Invalid path for store "${storeId}":\n${path}\nOnly state can be modified.`);
44029
+ }
44030
+ // rewrite the first entry to be able to directly set the state as
44031
+ // well as any other path
44032
+ path[0] = '$state';
44033
+ isTimelineActive = false;
44034
+ payload.set(store, path, payload.state.value);
44035
+ isTimelineActive = true;
44036
+ }
44037
+ });
44038
+ });
44039
+ }
44040
+ function addStoreToDevtools(app, store) {
44041
+ if (!componentStateTypes.includes(getStoreType(store.$id))) {
44042
+ componentStateTypes.push(getStoreType(store.$id));
44043
+ }
44044
+ setupDevtoolsPlugin({
44045
+ id: 'dev.esm.pinia',
44046
+ label: 'Pinia 🍍',
44047
+ logo: 'https://pinia.vuejs.org/logo.svg',
44048
+ packageName: 'pinia',
44049
+ homepage: 'https://pinia.vuejs.org',
44050
+ componentStateTypes,
44051
+ app,
44052
+ settings: {
44053
+ logStoreChanges: {
44054
+ label: 'Notify about new/deleted stores',
44055
+ type: 'boolean',
44056
+ defaultValue: true,
44057
+ },
44058
+ // useEmojis: {
44059
+ // label: 'Use emojis in messages ⚡️',
44060
+ // type: 'boolean',
44061
+ // defaultValue: true,
44062
+ // },
44063
+ },
44064
+ }, (api) => {
44065
+ // gracefully handle errors
44066
+ const now = typeof api.now === 'function' ? api.now.bind(api) : Date.now;
44067
+ store.$onAction(({ after, onError, name, args }) => {
44068
+ const groupId = runningActionId++;
44069
+ api.addTimelineEvent({
44070
+ layerId: MUTATIONS_LAYER_ID,
44071
+ event: {
44072
+ time: now(),
44073
+ title: '🛫 ' + name,
44074
+ subtitle: 'start',
44075
+ data: {
44076
+ store: formatDisplay(store.$id),
44077
+ action: formatDisplay(name),
44078
+ args,
44079
+ },
44080
+ groupId,
44081
+ },
44082
+ });
44083
+ after((result) => {
44084
+ activeAction = undefined;
44085
+ api.addTimelineEvent({
44086
+ layerId: MUTATIONS_LAYER_ID,
44087
+ event: {
44088
+ time: now(),
44089
+ title: '🛬 ' + name,
44090
+ subtitle: 'end',
44091
+ data: {
44092
+ store: formatDisplay(store.$id),
44093
+ action: formatDisplay(name),
44094
+ args,
44095
+ result,
44096
+ },
44097
+ groupId,
44098
+ },
44099
+ });
44100
+ });
44101
+ onError((error) => {
44102
+ activeAction = undefined;
44103
+ api.addTimelineEvent({
44104
+ layerId: MUTATIONS_LAYER_ID,
44105
+ event: {
44106
+ time: now(),
44107
+ logType: 'error',
44108
+ title: '💥 ' + name,
44109
+ subtitle: 'end',
44110
+ data: {
44111
+ store: formatDisplay(store.$id),
44112
+ action: formatDisplay(name),
44113
+ args,
44114
+ error,
44115
+ },
44116
+ groupId,
44117
+ },
44118
+ });
44119
+ });
44120
+ }, true);
44121
+ store._customProperties.forEach((name) => {
44122
+ watch(() => unref(store[name]), (newValue, oldValue) => {
44123
+ api.notifyComponentUpdate();
44124
+ api.sendInspectorState(INSPECTOR_ID);
44125
+ if (isTimelineActive) {
44126
+ api.addTimelineEvent({
44127
+ layerId: MUTATIONS_LAYER_ID,
44128
+ event: {
44129
+ time: now(),
44130
+ title: 'Change',
44131
+ subtitle: name,
44132
+ data: {
44133
+ newValue,
44134
+ oldValue,
44135
+ },
44136
+ groupId: activeAction,
44137
+ },
44138
+ });
44139
+ }
44140
+ }, { deep: true });
44141
+ });
44142
+ store.$subscribe(({ events, type }, state) => {
44143
+ api.notifyComponentUpdate();
44144
+ api.sendInspectorState(INSPECTOR_ID);
44145
+ if (!isTimelineActive)
44146
+ return;
44147
+ // rootStore.state[store.id] = state
44148
+ const eventData = {
44149
+ time: now(),
44150
+ title: formatMutationType(type),
44151
+ data: assign$1({ store: formatDisplay(store.$id) }, formatEventData(events)),
44152
+ groupId: activeAction,
44153
+ };
44154
+ if (type === MutationType.patchFunction) {
44155
+ eventData.subtitle = '⤵️';
44156
+ }
44157
+ else if (type === MutationType.patchObject) {
44158
+ eventData.subtitle = '🧩';
44159
+ }
44160
+ else if (events && !Array.isArray(events)) {
44161
+ eventData.subtitle = events.type;
44162
+ }
44163
+ if (events) {
44164
+ eventData.data['rawEvent(s)'] = {
44165
+ _custom: {
44166
+ display: 'DebuggerEvent',
44167
+ type: 'object',
44168
+ tooltip: 'raw DebuggerEvent[]',
44169
+ value: events,
44170
+ },
44171
+ };
44172
+ }
44173
+ api.addTimelineEvent({
44174
+ layerId: MUTATIONS_LAYER_ID,
44175
+ event: eventData,
44176
+ });
44177
+ }, { detached: true, flush: 'sync' });
44178
+ const hotUpdate = store._hotUpdate;
44179
+ store._hotUpdate = markRaw((newStore) => {
44180
+ hotUpdate(newStore);
44181
+ api.addTimelineEvent({
44182
+ layerId: MUTATIONS_LAYER_ID,
44183
+ event: {
44184
+ time: now(),
44185
+ title: '🔥 ' + store.$id,
44186
+ subtitle: 'HMR update',
44187
+ data: {
44188
+ store: formatDisplay(store.$id),
44189
+ info: formatDisplay(`HMR update`),
44190
+ },
44191
+ },
44192
+ });
44193
+ // update the devtools too
44194
+ api.notifyComponentUpdate();
44195
+ api.sendInspectorTree(INSPECTOR_ID);
44196
+ api.sendInspectorState(INSPECTOR_ID);
44197
+ });
44198
+ const { $dispose } = store;
44199
+ store.$dispose = () => {
44200
+ $dispose();
44201
+ api.notifyComponentUpdate();
44202
+ api.sendInspectorTree(INSPECTOR_ID);
44203
+ api.sendInspectorState(INSPECTOR_ID);
44204
+ api.getSettings().logStoreChanges &&
44205
+ toastMessage(`Disposed "${store.$id}" store 🗑`);
44206
+ };
44207
+ // trigger an update so it can display new registered stores
44208
+ api.notifyComponentUpdate();
44209
+ api.sendInspectorTree(INSPECTOR_ID);
44210
+ api.sendInspectorState(INSPECTOR_ID);
44211
+ api.getSettings().logStoreChanges &&
44212
+ toastMessage(`"${store.$id}" store installed 🆕`);
44213
+ });
44214
+ }
44215
+ let runningActionId = 0;
44216
+ let activeAction;
44217
+ /**
44218
+ * Patches a store to enable action grouping in devtools by wrapping the store with a Proxy that is passed as the
44219
+ * context of all actions, allowing us to set `runningAction` on each access and effectively associating any state
44220
+ * mutation to the action.
44221
+ *
44222
+ * @param store - store to patch
44223
+ * @param actionNames - list of actionst to patch
44224
+ */
44225
+ function patchActionForGrouping(store, actionNames, wrapWithProxy) {
44226
+ // original actions of the store as they are given by pinia. We are going to override them
44227
+ const actions = actionNames.reduce((storeActions, actionName) => {
44228
+ // use toRaw to avoid tracking #541
44229
+ storeActions[actionName] = toRaw(store)[actionName];
44230
+ return storeActions;
44231
+ }, {});
44232
+ for (const actionName in actions) {
44233
+ store[actionName] = function () {
44234
+ // the running action id is incremented in a before action hook
44235
+ const _actionId = runningActionId;
44236
+ const trackedStore = wrapWithProxy
44237
+ ? new Proxy(store, {
44238
+ get(...args) {
44239
+ activeAction = _actionId;
44240
+ return Reflect.get(...args);
44241
+ },
44242
+ set(...args) {
44243
+ activeAction = _actionId;
44244
+ return Reflect.set(...args);
44245
+ },
44246
+ })
44247
+ : store;
44248
+ // For Setup Stores we need https://github.com/tc39/proposal-async-context
44249
+ activeAction = _actionId;
44250
+ const retValue = actions[actionName].apply(trackedStore, arguments);
44251
+ // this is safer as async actions in Setup Stores would associate mutations done outside of the action
44252
+ activeAction = undefined;
44253
+ return retValue;
44254
+ };
44255
+ }
44256
+ }
44257
+ /**
44258
+ * pinia.use(devtoolsPlugin)
44259
+ */
44260
+ function devtoolsPlugin({ app, store, options }) {
44261
+ // HMR module
44262
+ if (store.$id.startsWith('__hot:')) {
44263
+ return;
44264
+ }
44265
+ // detect option api vs setup api
44266
+ store._isOptionsAPI = !!options.state;
44267
+ patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI);
44268
+ // Upgrade the HMR to also update the new actions
44269
+ const originalHotUpdate = store._hotUpdate;
44270
+ toRaw(store)._hotUpdate = function (newStore) {
44271
+ originalHotUpdate.apply(this, arguments);
44272
+ patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI);
44273
+ };
44274
+ addStoreToDevtools(app,
44275
+ // FIXME: is there a way to allow the assignment from Store<Id, S, G, A> to StoreGeneric?
44276
+ store);
44277
+ }
44278
+
44279
+ /**
44280
+ * Creates a Pinia instance to be used by the application
44281
+ */
44282
+ function createPinia() {
44283
+ const scope = effectScope(true);
44284
+ // NOTE: here we could check the window object for a state and directly set it
44285
+ // if there is anything like it with Vue 3 SSR
44286
+ const state = scope.run(() => ref({}));
44287
+ let _p = [];
44288
+ // plugins added before calling app.use(pinia)
44289
+ let toBeInstalled = [];
44290
+ const pinia = markRaw({
44291
+ install(app) {
44292
+ // this allows calling useStore() outside of a component setup after
44293
+ // installing pinia's plugin
44294
+ setActivePinia(pinia);
44295
+ if (!isVue2) {
44296
+ pinia._a = app;
44297
+ app.provide(piniaSymbol, pinia);
44298
+ app.config.globalProperties.$pinia = pinia;
44299
+ /* istanbul ignore else */
44300
+ if (USE_DEVTOOLS) {
44301
+ registerPiniaDevtools(app, pinia);
44302
+ }
44303
+ toBeInstalled.forEach((plugin) => _p.push(plugin));
44304
+ toBeInstalled = [];
44305
+ }
44306
+ },
44307
+ use(plugin) {
44308
+ if (!this._a && !isVue2) {
44309
+ toBeInstalled.push(plugin);
44310
+ }
44311
+ else {
44312
+ _p.push(plugin);
44313
+ }
44314
+ return this;
44315
+ },
44316
+ _p,
44317
+ // it's actually undefined here
44318
+ // @ts-expect-error
44319
+ _a: null,
44320
+ _e: scope,
44321
+ _s: new Map(),
44322
+ state,
44323
+ });
44324
+ // pinia devtools rely on dev only features so they cannot be forced unless
44325
+ // the dev build of Vue is used. Avoid old browsers like IE11.
44326
+ if (USE_DEVTOOLS && typeof Proxy !== 'undefined') {
44327
+ pinia.use(devtoolsPlugin);
44328
+ }
44329
+ return pinia;
44330
+ }
44331
+
44332
+ /**
44333
+ * Checks if a function is a `StoreDefinition`.
44334
+ *
44335
+ * @param fn - object to test
44336
+ * @returns true if `fn` is a StoreDefinition
44337
+ */
44338
+ const isUseStore = (fn) => {
44339
+ return typeof fn === 'function' && typeof fn.$id === 'string';
44340
+ };
44341
+ /**
44342
+ * Mutates in place `newState` with `oldState` to _hot update_ it. It will
44343
+ * remove any key not existing in `newState` and recursively merge plain
44344
+ * objects.
44345
+ *
44346
+ * @param newState - new state object to be patched
44347
+ * @param oldState - old state that should be used to patch newState
44348
+ * @returns - newState
44349
+ */
44350
+ function patchObject(newState, oldState) {
44351
+ // no need to go through symbols because they cannot be serialized anyway
44352
+ for (const key in oldState) {
44353
+ const subPatch = oldState[key];
44354
+ // skip the whole sub tree
44355
+ if (!(key in newState)) {
44356
+ continue;
44357
+ }
44358
+ const targetValue = newState[key];
44359
+ if (isPlainObject(targetValue) &&
44360
+ isPlainObject(subPatch) &&
44361
+ !isRef(subPatch) &&
44362
+ !isReactive(subPatch)) {
44363
+ newState[key] = patchObject(targetValue, subPatch);
44364
+ }
44365
+ else {
44366
+ // objects are either a bit more complex (e.g. refs) or primitives, so we
44367
+ // just set the whole thing
44368
+ if (isVue2) {
44369
+ set(newState, key, subPatch);
44370
+ }
44371
+ else {
44372
+ newState[key] = subPatch;
44373
+ }
44374
+ }
44375
+ }
44376
+ return newState;
44377
+ }
44378
+ /**
44379
+ * Creates an _accept_ function to pass to `import.meta.hot` in Vite applications.
44380
+ *
44381
+ * @example
44382
+ * ```js
44383
+ * const useUser = defineStore(...)
44384
+ * if (import.meta.hot) {
44385
+ * import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot))
44386
+ * }
44387
+ * ```
44388
+ *
44389
+ * @param initialUseStore - return of the defineStore to hot update
44390
+ * @param hot - `import.meta.hot`
44391
+ */
44392
+ function acceptHMRUpdate(initialUseStore, hot) {
44393
+ // strip as much as possible from iife.prod
44394
+ if (true) {
44395
+ return () => { };
44396
+ }
44397
+ return (newModule) => {
44398
+ const pinia = hot.data.pinia || initialUseStore._pinia;
44399
+ if (!pinia) {
44400
+ // this store is still not used
44401
+ return;
44402
+ }
44403
+ // preserve the pinia instance across loads
44404
+ hot.data.pinia = pinia;
44405
+ // console.log('got data', newStore)
44406
+ for (const exportName in newModule) {
44407
+ const useStore = newModule[exportName];
44408
+ // console.log('checking for', exportName)
44409
+ if (isUseStore(useStore) && pinia._s.has(useStore.$id)) {
44410
+ // console.log('Accepting update for', useStore.$id)
44411
+ const id = useStore.$id;
44412
+ if (id !== initialUseStore.$id) {
44413
+ console.warn(`The id of the store changed from "${initialUseStore.$id}" to "${id}". Reloading.`);
44414
+ // return import.meta.hot.invalidate()
44415
+ return hot.invalidate();
44416
+ }
44417
+ const existingStore = pinia._s.get(id);
44418
+ if (!existingStore) {
44419
+ console.log(`[Pinia]: skipping hmr because store doesn't exist yet`);
44420
+ return;
44421
+ }
44422
+ useStore(pinia, existingStore);
44423
+ }
44424
+ }
44425
+ };
44426
+ }
44427
+
44428
+ const pinia_noop = () => { };
44429
+ function addSubscription(subscriptions, callback, detached, onCleanup = pinia_noop) {
44430
+ subscriptions.push(callback);
44431
+ const removeSubscription = () => {
44432
+ const idx = subscriptions.indexOf(callback);
44433
+ if (idx > -1) {
44434
+ subscriptions.splice(idx, 1);
44435
+ onCleanup();
44436
+ }
44437
+ };
44438
+ if (!detached && getCurrentScope()) {
44439
+ onScopeDispose(removeSubscription);
44440
+ }
44441
+ return removeSubscription;
44442
+ }
44443
+ function triggerSubscriptions(subscriptions, ...args) {
44444
+ subscriptions.slice().forEach((callback) => {
44445
+ callback(...args);
44446
+ });
44447
+ }
44448
+
44449
+ const fallbackRunWithContext = (fn) => fn();
44450
+ function mergeReactiveObjects(target, patchToApply) {
44451
+ // Handle Map instances
44452
+ if (target instanceof Map && patchToApply instanceof Map) {
44453
+ patchToApply.forEach((value, key) => target.set(key, value));
44454
+ }
44455
+ // Handle Set instances
44456
+ if (target instanceof Set && patchToApply instanceof Set) {
44457
+ patchToApply.forEach(target.add, target);
44458
+ }
44459
+ // no need to go through symbols because they cannot be serialized anyway
44460
+ for (const key in patchToApply) {
44461
+ if (!patchToApply.hasOwnProperty(key))
44462
+ continue;
44463
+ const subPatch = patchToApply[key];
44464
+ const targetValue = target[key];
44465
+ if (isPlainObject(targetValue) &&
44466
+ isPlainObject(subPatch) &&
44467
+ target.hasOwnProperty(key) &&
44468
+ !isRef(subPatch) &&
44469
+ !isReactive(subPatch)) {
44470
+ // NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might
44471
+ // start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that
44472
+ // to `undefined`. When trying to hydrate, we want to override the Map with `undefined`.
44473
+ target[key] = mergeReactiveObjects(targetValue, subPatch);
44474
+ }
44475
+ else {
44476
+ // @ts-expect-error: subPatch is a valid value
44477
+ target[key] = subPatch;
44478
+ }
44479
+ }
44480
+ return target;
44481
+ }
44482
+ const skipHydrateSymbol = ( false)
44483
+ ? 0
44484
+ : /* istanbul ignore next */ Symbol();
44485
+ const skipHydrateMap = /*#__PURE__*/ new WeakMap();
44486
+ /**
44487
+ * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a
44488
+ * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store.
44489
+ *
44490
+ * @param obj - target object
44491
+ * @returns obj
44492
+ */
44493
+ function skipHydrate(obj) {
44494
+ return isVue2
44495
+ ? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work...
44496
+ /* istanbul ignore next */ skipHydrateMap.set(obj, 1) && obj
44497
+ : Object.defineProperty(obj, skipHydrateSymbol, {});
44498
+ }
44499
+ /**
44500
+ * Returns whether a value should be hydrated
44501
+ *
44502
+ * @param obj - target variable
44503
+ * @returns true if `obj` should be hydrated
44504
+ */
44505
+ function shouldHydrate(obj) {
44506
+ return isVue2
44507
+ ? /* istanbul ignore next */ !skipHydrateMap.has(obj)
44508
+ : !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol);
44509
+ }
44510
+ const { assign: pinia_assign } = Object;
44511
+ function isComputed(o) {
44512
+ return !!(isRef(o) && o.effect);
44513
+ }
44514
+ function createOptionsStore(id, options, pinia, hot) {
44515
+ const { state, actions, getters } = options;
44516
+ const initialState = pinia.state.value[id];
44517
+ let store;
44518
+ function setup() {
44519
+ if (!initialState && ( true || 0)) {
44520
+ /* istanbul ignore if */
44521
+ if (isVue2) {
44522
+ set(pinia.state.value, id, state ? state() : {});
44523
+ }
44524
+ else {
44525
+ pinia.state.value[id] = state ? state() : {};
44526
+ }
44527
+ }
44528
+ // avoid creating a state in pinia.state.value
44529
+ const localState = false
44530
+ ? // use ref() to unwrap refs inside state TODO: check if this is still necessary
44531
+ 0
44532
+ : toRefs(pinia.state.value[id]);
44533
+ return pinia_assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
44534
+ if (false) {}
44535
+ computedGetters[name] = markRaw(computed(() => {
44536
+ setActivePinia(pinia);
44537
+ // it was created just before
44538
+ const store = pinia._s.get(id);
44539
+ // allow cross using stores
44540
+ /* istanbul ignore next */
44541
+ if (isVue2 && !store._r)
44542
+ return;
44543
+ // @ts-expect-error
44544
+ // return getters![name].call(context, context)
44545
+ // TODO: avoid reading the getter while assigning with a global variable
44546
+ return getters[name].call(store, store);
44547
+ }));
44548
+ return computedGetters;
44549
+ }, {}));
44550
+ }
44551
+ store = createSetupStore(id, setup, options, pinia, hot, true);
44552
+ return store;
44553
+ }
44554
+ function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
44555
+ let scope;
44556
+ const optionsForPlugin = pinia_assign({ actions: {} }, options);
44557
+ /* istanbul ignore if */
44558
+ if (false) {}
44559
+ // watcher options for $subscribe
44560
+ const $subscribeOptions = {
44561
+ deep: true,
44562
+ // flush: 'post',
44563
+ };
44564
+ /* istanbul ignore else */
44565
+ if (false) {}
44566
+ // internal state
44567
+ let isListening; // set to true at the end
44568
+ let isSyncListening; // set to true at the end
44569
+ let subscriptions = [];
44570
+ let actionSubscriptions = [];
44571
+ let debuggerEvents;
44572
+ const initialState = pinia.state.value[$id];
44573
+ // avoid setting the state for option stores if it is set
44574
+ // by the setup
44575
+ if (!isOptionsStore && !initialState && ( true || 0)) {
44576
+ /* istanbul ignore if */
44577
+ if (isVue2) {
44578
+ set(pinia.state.value, $id, {});
44579
+ }
44580
+ else {
44581
+ pinia.state.value[$id] = {};
44582
+ }
44583
+ }
44584
+ const hotState = ref({});
44585
+ // avoid triggering too many listeners
44586
+ // https://github.com/vuejs/pinia/issues/1129
44587
+ let activeListener;
44588
+ function $patch(partialStateOrMutator) {
44589
+ let subscriptionMutation;
44590
+ isListening = isSyncListening = false;
44591
+ // reset the debugger events since patches are sync
44592
+ /* istanbul ignore else */
44593
+ if ((false)) {}
44594
+ if (typeof partialStateOrMutator === 'function') {
44595
+ partialStateOrMutator(pinia.state.value[$id]);
44596
+ subscriptionMutation = {
44597
+ type: MutationType.patchFunction,
44598
+ storeId: $id,
44599
+ events: debuggerEvents,
44600
+ };
44601
+ }
44602
+ else {
44603
+ mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
44604
+ subscriptionMutation = {
44605
+ type: MutationType.patchObject,
44606
+ payload: partialStateOrMutator,
44607
+ storeId: $id,
44608
+ events: debuggerEvents,
44609
+ };
44610
+ }
44611
+ const myListenerId = (activeListener = Symbol());
44612
+ nextTick().then(() => {
44613
+ if (activeListener === myListenerId) {
44614
+ isListening = true;
44615
+ }
44616
+ });
44617
+ isSyncListening = true;
44618
+ // because we paused the watcher, we need to manually call the subscriptions
44619
+ triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
44620
+ }
44621
+ const $reset = isOptionsStore
44622
+ ? function $reset() {
44623
+ const { state } = options;
44624
+ const newState = state ? state() : {};
44625
+ // we use a patch to group all changes into one single subscription
44626
+ this.$patch(($state) => {
44627
+ pinia_assign($state, newState);
44628
+ });
44629
+ }
44630
+ : /* istanbul ignore next */
44631
+ ( false)
44632
+ ? 0
44633
+ : pinia_noop;
44634
+ function $dispose() {
44635
+ scope.stop();
44636
+ subscriptions = [];
44637
+ actionSubscriptions = [];
44638
+ pinia._s.delete($id);
44639
+ }
44640
+ /**
44641
+ * Wraps an action to handle subscriptions.
44642
+ *
44643
+ * @param name - name of the action
44644
+ * @param action - action to wrap
44645
+ * @returns a wrapped action to handle subscriptions
44646
+ */
44647
+ function wrapAction(name, action) {
44648
+ return function () {
44649
+ setActivePinia(pinia);
44650
+ const args = Array.from(arguments);
44651
+ const afterCallbackList = [];
44652
+ const onErrorCallbackList = [];
44653
+ function after(callback) {
44654
+ afterCallbackList.push(callback);
44655
+ }
44656
+ function onError(callback) {
44657
+ onErrorCallbackList.push(callback);
44658
+ }
44659
+ // @ts-expect-error
44660
+ triggerSubscriptions(actionSubscriptions, {
44661
+ args,
44662
+ name,
44663
+ store,
44664
+ after,
44665
+ onError,
44666
+ });
44667
+ let ret;
44668
+ try {
44669
+ ret = action.apply(this && this.$id === $id ? this : store, args);
44670
+ // handle sync errors
44671
+ }
44672
+ catch (error) {
44673
+ triggerSubscriptions(onErrorCallbackList, error);
44674
+ throw error;
44675
+ }
44676
+ if (ret instanceof Promise) {
44677
+ return ret
44678
+ .then((value) => {
44679
+ triggerSubscriptions(afterCallbackList, value);
44680
+ return value;
44681
+ })
44682
+ .catch((error) => {
44683
+ triggerSubscriptions(onErrorCallbackList, error);
44684
+ return Promise.reject(error);
44685
+ });
44686
+ }
44687
+ // trigger after callbacks
44688
+ triggerSubscriptions(afterCallbackList, ret);
44689
+ return ret;
44690
+ };
44691
+ }
44692
+ const _hmrPayload = /*#__PURE__*/ markRaw({
44693
+ actions: {},
44694
+ getters: {},
44695
+ state: [],
44696
+ hotState,
44697
+ });
44698
+ const partialStore = {
44699
+ _p: pinia,
44700
+ // _s: scope,
44701
+ $id,
44702
+ $onAction: addSubscription.bind(null, actionSubscriptions),
44703
+ $patch,
44704
+ $reset,
44705
+ $subscribe(callback, options = {}) {
44706
+ const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher());
44707
+ const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => {
44708
+ if (options.flush === 'sync' ? isSyncListening : isListening) {
44709
+ callback({
44710
+ storeId: $id,
44711
+ type: MutationType.direct,
44712
+ events: debuggerEvents,
44713
+ }, state);
44714
+ }
44715
+ }, pinia_assign({}, $subscribeOptions, options)));
44716
+ return removeSubscription;
44717
+ },
44718
+ $dispose,
44719
+ };
44720
+ /* istanbul ignore if */
44721
+ if (isVue2) {
44722
+ // start as non ready
44723
+ partialStore._r = false;
44724
+ }
44725
+ const store = reactive(( false) || USE_DEVTOOLS
44726
+ ? pinia_assign({
44727
+ _hmrPayload,
44728
+ _customProperties: markRaw(new Set()), // devtools custom properties
44729
+ }, partialStore
44730
+ // must be added later
44731
+ // setupStore
44732
+ )
44733
+ : partialStore);
44734
+ // store the partial store now so the setup of stores can instantiate each other before they are finished without
44735
+ // creating infinite loops.
44736
+ pinia._s.set($id, store);
44737
+ const runWithContext = (pinia._a && pinia._a.runWithContext) || fallbackRunWithContext;
44738
+ // TODO: idea create skipSerialize that marks properties as non serializable and they are skipped
44739
+ const setupStore = runWithContext(() => pinia._e.run(() => (scope = effectScope()).run(setup)));
44740
+ // overwrite existing actions to support $onAction
44741
+ for (const key in setupStore) {
44742
+ const prop = setupStore[key];
44743
+ if ((isRef(prop) && !isComputed(prop)) || isReactive(prop)) {
44744
+ // mark it as a piece of state to be serialized
44745
+ if (false) {}
44746
+ else if (!isOptionsStore) {
44747
+ // in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created
44748
+ if (initialState && shouldHydrate(prop)) {
44749
+ if (isRef(prop)) {
44750
+ prop.value = initialState[key];
44751
+ }
44752
+ else {
44753
+ // probably a reactive object, lets recursively assign
44754
+ // @ts-expect-error: prop is unknown
44755
+ mergeReactiveObjects(prop, initialState[key]);
44756
+ }
44757
+ }
44758
+ // transfer the ref to the pinia state to keep everything in sync
44759
+ /* istanbul ignore if */
44760
+ if (isVue2) {
44761
+ set(pinia.state.value[$id], key, prop);
44762
+ }
44763
+ else {
44764
+ pinia.state.value[$id][key] = prop;
44765
+ }
44766
+ }
44767
+ /* istanbul ignore else */
44768
+ if ((false)) {}
44769
+ // action
44770
+ }
44771
+ else if (typeof prop === 'function') {
44772
+ // @ts-expect-error: we are overriding the function we avoid wrapping if
44773
+ const actionValue = false ? 0 : wrapAction(key, prop);
44774
+ // this a hot module replacement store because the hotUpdate method needs
44775
+ // to do it with the right context
44776
+ /* istanbul ignore if */
44777
+ if (isVue2) {
44778
+ set(setupStore, key, actionValue);
44779
+ }
44780
+ else {
44781
+ // @ts-expect-error
44782
+ setupStore[key] = actionValue;
44783
+ }
44784
+ /* istanbul ignore else */
44785
+ if ((false)) {}
44786
+ // list actions so they can be used in plugins
44787
+ // @ts-expect-error
44788
+ optionsForPlugin.actions[key] = prop;
44789
+ }
44790
+ else if ((false)) {}
44791
+ }
44792
+ // add the state, getters, and action properties
44793
+ /* istanbul ignore if */
44794
+ if (isVue2) {
44795
+ Object.keys(setupStore).forEach((key) => {
44796
+ set(store, key, setupStore[key]);
44797
+ });
44798
+ }
44799
+ else {
44800
+ pinia_assign(store, setupStore);
44801
+ // allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object.
44802
+ // Make `storeToRefs()` work with `reactive()` #799
44803
+ pinia_assign(toRaw(store), setupStore);
44804
+ }
44805
+ // use this instead of a computed with setter to be able to create it anywhere
44806
+ // without linking the computed lifespan to wherever the store is first
44807
+ // created.
44808
+ Object.defineProperty(store, '$state', {
44809
+ get: () => ( false ? 0 : pinia.state.value[$id]),
44810
+ set: (state) => {
44811
+ /* istanbul ignore if */
44812
+ if (false) {}
44813
+ $patch(($state) => {
44814
+ pinia_assign($state, state);
44815
+ });
44816
+ },
44817
+ });
44818
+ // add the hotUpdate before plugins to allow them to override it
44819
+ /* istanbul ignore else */
44820
+ if ((false)) {}
44821
+ if (USE_DEVTOOLS) {
44822
+ const nonEnumerable = {
44823
+ writable: true,
44824
+ configurable: true,
44825
+ // avoid warning on devtools trying to display this property
44826
+ enumerable: false,
44827
+ };
44828
+ ['_p', '_hmrPayload', '_getters', '_customProperties'].forEach((p) => {
44829
+ Object.defineProperty(store, p, pinia_assign({ value: store[p] }, nonEnumerable));
44830
+ });
44831
+ }
44832
+ /* istanbul ignore if */
44833
+ if (isVue2) {
44834
+ // mark the store as ready before plugins
44835
+ store._r = true;
44836
+ }
44837
+ // apply all plugins
44838
+ pinia._p.forEach((extender) => {
44839
+ /* istanbul ignore else */
44840
+ if (USE_DEVTOOLS) {
44841
+ const extensions = scope.run(() => extender({
44842
+ store,
44843
+ app: pinia._a,
44844
+ pinia,
44845
+ options: optionsForPlugin,
44846
+ }));
44847
+ Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key));
44848
+ pinia_assign(store, extensions);
44849
+ }
44850
+ else {
44851
+ pinia_assign(store, scope.run(() => extender({
44852
+ store,
44853
+ app: pinia._a,
44854
+ pinia,
44855
+ options: optionsForPlugin,
44856
+ })));
44857
+ }
44858
+ });
44859
+ if (false) {}
44860
+ // only apply hydrate to option stores with an initial state in pinia
44861
+ if (initialState &&
44862
+ isOptionsStore &&
44863
+ options.hydrate) {
44864
+ options.hydrate(store.$state, initialState);
44865
+ }
44866
+ isListening = true;
44867
+ isSyncListening = true;
44868
+ return store;
44869
+ }
44870
+ function defineStore(
44871
+ // TODO: add proper types from above
44872
+ idOrOptions, setup, setupOptions) {
44873
+ let id;
44874
+ let options;
44875
+ const isSetupStore = typeof setup === 'function';
44876
+ if (typeof idOrOptions === 'string') {
44877
+ id = idOrOptions;
44878
+ // the option store setup will contain the actual options in this case
44879
+ options = isSetupStore ? setupOptions : setup;
44880
+ }
44881
+ else {
44882
+ options = idOrOptions;
44883
+ id = idOrOptions.id;
44884
+ if (false) {}
44885
+ }
44886
+ function useStore(pinia, hot) {
44887
+ const hasContext = hasInjectionContext();
44888
+ pinia =
44889
+ // in test mode, ignore the argument provided as we can always retrieve a
44890
+ // pinia instance with getActivePinia()
44891
+ ( false ? 0 : pinia) ||
44892
+ (hasContext ? inject(piniaSymbol, null) : null);
44893
+ if (pinia)
44894
+ setActivePinia(pinia);
44895
+ if (false) {}
44896
+ pinia = activePinia;
44897
+ if (!pinia._s.has(id)) {
44898
+ // creating the store registers it in `pinia._s`
44899
+ if (isSetupStore) {
44900
+ createSetupStore(id, setup, options, pinia);
44901
+ }
44902
+ else {
44903
+ createOptionsStore(id, options, pinia);
44904
+ }
44905
+ /* istanbul ignore else */
44906
+ if ((false)) {}
44907
+ }
44908
+ const store = pinia._s.get(id);
44909
+ if (false) {}
44910
+ if (false) {}
44911
+ // StoreGeneric cannot be casted towards Store
44912
+ return store;
44913
+ }
44914
+ useStore.$id = id;
44915
+ return useStore;
44916
+ }
44917
+
44918
+ let mapStoreSuffix = 'Store';
44919
+ /**
44920
+ * Changes the suffix added by `mapStores()`. Can be set to an empty string.
44921
+ * Defaults to `"Store"`. Make sure to extend the MapStoresCustomization
44922
+ * interface if you are using TypeScript.
44923
+ *
44924
+ * @param suffix - new suffix
44925
+ */
44926
+ function setMapStoreSuffix(suffix // could be 'Store' but that would be annoying for JS
44927
+ ) {
44928
+ mapStoreSuffix = suffix;
44929
+ }
44930
+ /**
44931
+ * Allows using stores without the composition API (`setup()`) by generating an
44932
+ * object to be spread in the `computed` field of a component. It accepts a list
44933
+ * of store definitions.
44934
+ *
44935
+ * @example
44936
+ * ```js
44937
+ * export default {
44938
+ * computed: {
44939
+ * // other computed properties
44940
+ * ...mapStores(useUserStore, useCartStore)
44941
+ * },
44942
+ *
44943
+ * created() {
44944
+ * this.userStore // store with id "user"
44945
+ * this.cartStore // store with id "cart"
44946
+ * }
44947
+ * }
44948
+ * ```
44949
+ *
44950
+ * @param stores - list of stores to map to an object
44951
+ */
44952
+ function mapStores(...stores) {
44953
+ if (false) {}
44954
+ return stores.reduce((reduced, useStore) => {
44955
+ // @ts-expect-error: $id is added by defineStore
44956
+ reduced[useStore.$id + mapStoreSuffix] = function () {
44957
+ return useStore(this.$pinia);
44958
+ };
44959
+ return reduced;
44960
+ }, {});
44961
+ }
44962
+ /**
44963
+ * Allows using state and getters from one store without using the composition
44964
+ * API (`setup()`) by generating an object to be spread in the `computed` field
44965
+ * of a component.
44966
+ *
44967
+ * @param useStore - store to map from
44968
+ * @param keysOrMapper - array or object
44969
+ */
44970
+ function mapState(useStore, keysOrMapper) {
44971
+ return Array.isArray(keysOrMapper)
44972
+ ? keysOrMapper.reduce((reduced, key) => {
44973
+ reduced[key] = function () {
44974
+ return useStore(this.$pinia)[key];
44975
+ };
44976
+ return reduced;
44977
+ }, {})
44978
+ : Object.keys(keysOrMapper).reduce((reduced, key) => {
44979
+ // @ts-expect-error
44980
+ reduced[key] = function () {
44981
+ const store = useStore(this.$pinia);
44982
+ const storeKey = keysOrMapper[key];
44983
+ // for some reason TS is unable to infer the type of storeKey to be a
44984
+ // function
44985
+ return typeof storeKey === 'function'
44986
+ ? storeKey.call(this, store)
44987
+ : store[storeKey];
44988
+ };
44989
+ return reduced;
44990
+ }, {});
44991
+ }
44992
+ /**
44993
+ * Alias for `mapState()`. You should use `mapState()` instead.
44994
+ * @deprecated use `mapState()` instead.
44995
+ */
44996
+ const mapGetters = (/* unused pure expression or super */ null && (mapState));
44997
+ /**
44998
+ * Allows directly using actions from your store without using the composition
44999
+ * API (`setup()`) by generating an object to be spread in the `methods` field
45000
+ * of a component.
45001
+ *
45002
+ * @param useStore - store to map from
45003
+ * @param keysOrMapper - array or object
45004
+ */
45005
+ function mapActions(useStore, keysOrMapper) {
45006
+ return Array.isArray(keysOrMapper)
45007
+ ? keysOrMapper.reduce((reduced, key) => {
45008
+ // @ts-expect-error
45009
+ reduced[key] = function (...args) {
45010
+ return useStore(this.$pinia)[key](...args);
45011
+ };
45012
+ return reduced;
45013
+ }, {})
45014
+ : Object.keys(keysOrMapper).reduce((reduced, key) => {
45015
+ // @ts-expect-error
45016
+ reduced[key] = function (...args) {
45017
+ return useStore(this.$pinia)[keysOrMapper[key]](...args);
45018
+ };
45019
+ return reduced;
45020
+ }, {});
45021
+ }
45022
+ /**
45023
+ * Allows using state and getters from one store without using the composition
45024
+ * API (`setup()`) by generating an object to be spread in the `computed` field
45025
+ * of a component.
45026
+ *
45027
+ * @param useStore - store to map from
45028
+ * @param keysOrMapper - array or object
45029
+ */
45030
+ function mapWritableState(useStore, keysOrMapper) {
45031
+ return Array.isArray(keysOrMapper)
45032
+ ? keysOrMapper.reduce((reduced, key) => {
45033
+ // @ts-ignore
45034
+ reduced[key] = {
45035
+ get() {
45036
+ return useStore(this.$pinia)[key];
45037
+ },
45038
+ set(value) {
45039
+ // it's easier to type it here as any
45040
+ return (useStore(this.$pinia)[key] = value);
45041
+ },
45042
+ };
45043
+ return reduced;
45044
+ }, {})
45045
+ : Object.keys(keysOrMapper).reduce((reduced, key) => {
45046
+ // @ts-ignore
45047
+ reduced[key] = {
45048
+ get() {
45049
+ return useStore(this.$pinia)[keysOrMapper[key]];
45050
+ },
45051
+ set(value) {
45052
+ // it's easier to type it here as any
45053
+ return (useStore(this.$pinia)[keysOrMapper[key]] = value);
45054
+ },
45055
+ };
45056
+ return reduced;
45057
+ }, {});
45058
+ }
45059
+
45060
+ /**
45061
+ * Creates an object of references with all the state, getters, and plugin-added
45062
+ * state properties of the store. Similar to `toRefs()` but specifically
45063
+ * designed for Pinia stores so methods and non reactive properties are
45064
+ * completely ignored.
45065
+ *
45066
+ * @param store - store to extract the refs from
45067
+ */
45068
+ function storeToRefs(store) {
45069
+ // See https://github.com/vuejs/pinia/issues/852
45070
+ // It's easier to just use toRefs() even if it includes more stuff
45071
+ if (isVue2) {
45072
+ // @ts-expect-error: toRefs include methods and others
45073
+ return toRefs(store);
45074
+ }
45075
+ else {
45076
+ store = toRaw(store);
45077
+ const refs = {};
45078
+ for (const key in store) {
45079
+ const value = store[key];
45080
+ if (isRef(value) || isReactive(value)) {
45081
+ // @ts-expect-error: the key is state or getter
45082
+ refs[key] =
45083
+ // ---
45084
+ toRef(store, key);
45085
+ }
45086
+ }
45087
+ return refs;
45088
+ }
45089
+ }
45090
+
45091
+ /**
45092
+ * Vue 2 Plugin that must be installed for pinia to work. Note **you don't need
45093
+ * this plugin if you are using Nuxt.js**. Use the `buildModule` instead:
45094
+ * https://pinia.vuejs.org/ssr/nuxt.html.
45095
+ *
45096
+ * @example
45097
+ * ```js
45098
+ * import Vue from 'vue'
45099
+ * import { PiniaVuePlugin, createPinia } from 'pinia'
45100
+ *
45101
+ * Vue.use(PiniaVuePlugin)
45102
+ * const pinia = createPinia()
45103
+ *
45104
+ * new Vue({
45105
+ * el: '#app',
45106
+ * // ...
45107
+ * pinia,
45108
+ * })
45109
+ * ```
45110
+ *
45111
+ * @param _Vue - `Vue` imported from 'vue'.
45112
+ */
45113
+ const PiniaVuePlugin = function (_Vue) {
45114
+ // Equivalent of
45115
+ // app.config.globalProperties.$pinia = pinia
45116
+ _Vue.mixin({
45117
+ beforeCreate() {
45118
+ const options = this.$options;
45119
+ if (options.pinia) {
45120
+ const pinia = options.pinia;
45121
+ // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/main/src/apis/inject.ts#L31
45122
+ /* istanbul ignore else */
45123
+ if (!this._provided) {
45124
+ const provideCache = {};
45125
+ Object.defineProperty(this, '_provided', {
45126
+ get: () => provideCache,
45127
+ set: (v) => Object.assign(provideCache, v),
45128
+ });
45129
+ }
45130
+ this._provided[piniaSymbol] = pinia;
45131
+ // propagate the pinia instance in an SSR friendly way
45132
+ // avoid adding it to nuxt twice
45133
+ /* istanbul ignore else */
45134
+ if (!this.$pinia) {
45135
+ this.$pinia = pinia;
45136
+ }
45137
+ pinia._a = this;
45138
+ if (IS_CLIENT) {
45139
+ // this allows calling useStore() outside of a component setup after
45140
+ // installing pinia's plugin
45141
+ setActivePinia(pinia);
45142
+ }
45143
+ if (USE_DEVTOOLS) {
45144
+ registerPiniaDevtools(pinia._a, pinia);
45145
+ }
45146
+ }
45147
+ else if (!this.$pinia && options.parent && options.parent.$pinia) {
45148
+ this.$pinia = options.parent.$pinia;
45149
+ }
45150
+ },
45151
+ destroyed() {
45152
+ delete this._pStores;
45153
+ },
45154
+ });
45155
+ };
45156
+
45157
+
45158
+
44862
45159
  ;// CONCATENATED MODULE: ./node_modules/ts-loader/index.js??clonedRuleSet-83.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Gallery.vue?vue&type=script&lang=ts
44863
45160
 
44864
45161
 
@@ -45023,12 +45320,6 @@ var Galleryvue_type_style_index_0_id_4cc30028_lang_less = __webpack_require__(17
45023
45320
  const Gallery_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(Galleryvue_type_script_lang_ts, [['render',Galleryvue_type_template_id_4cc30028_ts_true_render]])
45024
45321
 
45025
45322
  /* harmony default export */ const Gallery = (Gallery_exports_);
45026
- ;// CONCATENATED MODULE: ./src/utils.ts
45027
- var D2R = Math.PI / 180;
45028
- var utils_R2D = 180 / Math.PI;
45029
- var API_BASE_URL = "https://api.cosmicds.cfa.harvard.edu";
45030
- var MINIDS_BASE_URL = "".concat(API_BASE_URL, "/minids");
45031
-
45032
45323
  ;// CONCATENATED MODULE: ./src/index.ts
45033
45324
 
45034
45325
 
@@ -45043,6 +45334,7 @@ var MINIDS_BASE_URL = "".concat(API_BASE_URL, "/minids");
45043
45334
 
45044
45335
 
45045
45336
 
45337
+
45046
45338
  ;// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib-no-default.js
45047
45339
 
45048
45340