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