@featurevisor/vue 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/coverage/clover.xml +12 -0
- package/coverage/coverage-final.json +2 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +116 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/setupApp.ts.html +109 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +14 -0
- package/dist/index.js +2 -0
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -0
- package/jest.config.js +7 -0
- package/jest.setup.js +4 -0
- package/lib/activateFeature.d.ts +2 -0
- package/lib/activateFeature.js +7 -0
- package/lib/activateFeature.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/index.spec.d.ts +1 -0
- package/lib/index.spec.js +112 -0
- package/lib/index.spec.js.map +1 -0
- package/lib/setupApp.d.ts +4 -0
- package/lib/setupApp.js +5 -0
- package/lib/setupApp.js.map +1 -0
- package/lib/useSdk.d.ts +2 -0
- package/lib/useSdk.js +7 -0
- package/lib/useSdk.js.map +1 -0
- package/lib/useStatus.d.ts +5 -0
- package/lib/useStatus.js +17 -0
- package/lib/useStatus.js.map +1 -0
- package/lib/useVariable.d.ts +2 -0
- package/lib/useVariable.js +7 -0
- package/lib/useVariable.js.map +1 -0
- package/lib/useVariation.d.ts +2 -0
- package/lib/useVariation.js +7 -0
- package/lib/useVariation.js.map +1 -0
- package/package.json +55 -0
- package/src/activateFeature.ts +12 -0
- package/src/index.spec.ts +75 -0
- package/src/index.ts +7 -0
- package/src/setupApp.ts +8 -0
- package/src/useSdk.ts +10 -0
- package/src/useStatus.ts +26 -0
- package/src/useVariable.ts +13 -0
- package/src/useVariation.ts +12 -0
- package/stub/types__react/index.d.ts +1 -0
- package/tsconfig.cjs.json +12 -0
- package/tsconfig.esm.json +14 -0
- package/tsconfig.json +13 -0
- package/webpack.config.js +21 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
<title>Code coverage report for setupApp.ts</title>
|
|
7
|
+
<meta charset="utf-8" />
|
|
8
|
+
<link rel="stylesheet" href="prettify.css" />
|
|
9
|
+
<link rel="stylesheet" href="base.css" />
|
|
10
|
+
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
+
<style type='text/css'>
|
|
13
|
+
.coverage-summary .sorter {
|
|
14
|
+
background-image: url(sort-arrow-sprite.png);
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<div class='wrapper'>
|
|
21
|
+
<div class='pad1'>
|
|
22
|
+
<h1><a href="index.html">All files</a> setupApp.ts</h1>
|
|
23
|
+
<div class='clearfix'>
|
|
24
|
+
|
|
25
|
+
<div class='fl pad1y space-right2'>
|
|
26
|
+
<span class="strong">100% </span>
|
|
27
|
+
<span class="quiet">Statements</span>
|
|
28
|
+
<span class='fraction'>3/3</span>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<div class='fl pad1y space-right2'>
|
|
33
|
+
<span class="strong">100% </span>
|
|
34
|
+
<span class="quiet">Branches</span>
|
|
35
|
+
<span class='fraction'>0/0</span>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<div class='fl pad1y space-right2'>
|
|
40
|
+
<span class="strong">100% </span>
|
|
41
|
+
<span class="quiet">Functions</span>
|
|
42
|
+
<span class='fraction'>1/1</span>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<div class='fl pad1y space-right2'>
|
|
47
|
+
<span class="strong">100% </span>
|
|
48
|
+
<span class="quiet">Lines</span>
|
|
49
|
+
<span class='fraction'>3/3</span>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
<p class="quiet">
|
|
55
|
+
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
+
</p>
|
|
57
|
+
<template id="filterTemplate">
|
|
58
|
+
<div class="quiet">
|
|
59
|
+
Filter:
|
|
60
|
+
<input oninput="onInput()" type="search" id="fileSearch">
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
</div>
|
|
64
|
+
<div class='status-line high'></div>
|
|
65
|
+
<pre><table class="coverage">
|
|
66
|
+
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
|
+
<a name='L2'></a><a href='#L2'>2</a>
|
|
68
|
+
<a name='L3'></a><a href='#L3'>3</a>
|
|
69
|
+
<a name='L4'></a><a href='#L4'>4</a>
|
|
70
|
+
<a name='L5'></a><a href='#L5'>5</a>
|
|
71
|
+
<a name='L6'></a><a href='#L6'>6</a>
|
|
72
|
+
<a name='L7'></a><a href='#L7'>7</a>
|
|
73
|
+
<a name='L8'></a><a href='#L8'>8</a>
|
|
74
|
+
<a name='L9'></a><a href='#L9'>9</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
75
|
+
<span class="cline-any cline-neutral"> </span>
|
|
76
|
+
<span class="cline-any cline-neutral"> </span>
|
|
77
|
+
<span class="cline-any cline-yes">1x</span>
|
|
78
|
+
<span class="cline-any cline-neutral"> </span>
|
|
79
|
+
<span class="cline-any cline-yes">1x</span>
|
|
80
|
+
<span class="cline-any cline-yes">1x</span>
|
|
81
|
+
<span class="cline-any cline-neutral"> </span>
|
|
82
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { App } from "vue";
|
|
83
|
+
import { FeaturevisorInstance } from "@featurevisor/sdk";
|
|
84
|
+
|
|
85
|
+
export const PROVIDER_NAME = "featurevisor";
|
|
86
|
+
|
|
87
|
+
export function setupApp(app: App, sdk: FeaturevisorInstance) {
|
|
88
|
+
app.provide(PROVIDER_NAME, sdk);
|
|
89
|
+
}
|
|
90
|
+
</pre></td></tr></table></pre>
|
|
91
|
+
|
|
92
|
+
<div class='push'></div><!-- for sticky footer -->
|
|
93
|
+
</div><!-- /wrapper -->
|
|
94
|
+
<div class='footer quiet pad2 space-top1 center small'>
|
|
95
|
+
Code coverage generated by
|
|
96
|
+
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
97
|
+
at 2023-07-06T19:35:36.780Z
|
|
98
|
+
</div>
|
|
99
|
+
<script src="prettify.js"></script>
|
|
100
|
+
<script>
|
|
101
|
+
window.onload = function () {
|
|
102
|
+
prettyPrint();
|
|
103
|
+
};
|
|
104
|
+
</script>
|
|
105
|
+
<script src="sorter.js"></script>
|
|
106
|
+
<script src="block-navigation.js"></script>
|
|
107
|
+
</body>
|
|
108
|
+
</html>
|
|
109
|
+
|
|
Binary file
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
var addSorting = (function() {
|
|
3
|
+
'use strict';
|
|
4
|
+
var cols,
|
|
5
|
+
currentSort = {
|
|
6
|
+
index: 0,
|
|
7
|
+
desc: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// returns the summary table element
|
|
11
|
+
function getTable() {
|
|
12
|
+
return document.querySelector('.coverage-summary');
|
|
13
|
+
}
|
|
14
|
+
// returns the thead element of the summary table
|
|
15
|
+
function getTableHeader() {
|
|
16
|
+
return getTable().querySelector('thead tr');
|
|
17
|
+
}
|
|
18
|
+
// returns the tbody element of the summary table
|
|
19
|
+
function getTableBody() {
|
|
20
|
+
return getTable().querySelector('tbody');
|
|
21
|
+
}
|
|
22
|
+
// returns the th element for nth column
|
|
23
|
+
function getNthColumn(n) {
|
|
24
|
+
return getTableHeader().querySelectorAll('th')[n];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function onFilterInput() {
|
|
28
|
+
const searchValue = document.getElementById('fileSearch').value;
|
|
29
|
+
const rows = document.getElementsByTagName('tbody')[0].children;
|
|
30
|
+
for (let i = 0; i < rows.length; i++) {
|
|
31
|
+
const row = rows[i];
|
|
32
|
+
if (
|
|
33
|
+
row.textContent
|
|
34
|
+
.toLowerCase()
|
|
35
|
+
.includes(searchValue.toLowerCase())
|
|
36
|
+
) {
|
|
37
|
+
row.style.display = '';
|
|
38
|
+
} else {
|
|
39
|
+
row.style.display = 'none';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// loads the search box
|
|
45
|
+
function addSearchBox() {
|
|
46
|
+
var template = document.getElementById('filterTemplate');
|
|
47
|
+
var templateClone = template.content.cloneNode(true);
|
|
48
|
+
templateClone.getElementById('fileSearch').oninput = onFilterInput;
|
|
49
|
+
template.parentElement.appendChild(templateClone);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// loads all columns
|
|
53
|
+
function loadColumns() {
|
|
54
|
+
var colNodes = getTableHeader().querySelectorAll('th'),
|
|
55
|
+
colNode,
|
|
56
|
+
cols = [],
|
|
57
|
+
col,
|
|
58
|
+
i;
|
|
59
|
+
|
|
60
|
+
for (i = 0; i < colNodes.length; i += 1) {
|
|
61
|
+
colNode = colNodes[i];
|
|
62
|
+
col = {
|
|
63
|
+
key: colNode.getAttribute('data-col'),
|
|
64
|
+
sortable: !colNode.getAttribute('data-nosort'),
|
|
65
|
+
type: colNode.getAttribute('data-type') || 'string'
|
|
66
|
+
};
|
|
67
|
+
cols.push(col);
|
|
68
|
+
if (col.sortable) {
|
|
69
|
+
col.defaultDescSort = col.type === 'number';
|
|
70
|
+
colNode.innerHTML =
|
|
71
|
+
colNode.innerHTML + '<span class="sorter"></span>';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return cols;
|
|
75
|
+
}
|
|
76
|
+
// attaches a data attribute to every tr element with an object
|
|
77
|
+
// of data values keyed by column name
|
|
78
|
+
function loadRowData(tableRow) {
|
|
79
|
+
var tableCols = tableRow.querySelectorAll('td'),
|
|
80
|
+
colNode,
|
|
81
|
+
col,
|
|
82
|
+
data = {},
|
|
83
|
+
i,
|
|
84
|
+
val;
|
|
85
|
+
for (i = 0; i < tableCols.length; i += 1) {
|
|
86
|
+
colNode = tableCols[i];
|
|
87
|
+
col = cols[i];
|
|
88
|
+
val = colNode.getAttribute('data-value');
|
|
89
|
+
if (col.type === 'number') {
|
|
90
|
+
val = Number(val);
|
|
91
|
+
}
|
|
92
|
+
data[col.key] = val;
|
|
93
|
+
}
|
|
94
|
+
return data;
|
|
95
|
+
}
|
|
96
|
+
// loads all row data
|
|
97
|
+
function loadData() {
|
|
98
|
+
var rows = getTableBody().querySelectorAll('tr'),
|
|
99
|
+
i;
|
|
100
|
+
|
|
101
|
+
for (i = 0; i < rows.length; i += 1) {
|
|
102
|
+
rows[i].data = loadRowData(rows[i]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// sorts the table using the data for the ith column
|
|
106
|
+
function sortByIndex(index, desc) {
|
|
107
|
+
var key = cols[index].key,
|
|
108
|
+
sorter = function(a, b) {
|
|
109
|
+
a = a.data[key];
|
|
110
|
+
b = b.data[key];
|
|
111
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
112
|
+
},
|
|
113
|
+
finalSorter = sorter,
|
|
114
|
+
tableBody = document.querySelector('.coverage-summary tbody'),
|
|
115
|
+
rowNodes = tableBody.querySelectorAll('tr'),
|
|
116
|
+
rows = [],
|
|
117
|
+
i;
|
|
118
|
+
|
|
119
|
+
if (desc) {
|
|
120
|
+
finalSorter = function(a, b) {
|
|
121
|
+
return -1 * sorter(a, b);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (i = 0; i < rowNodes.length; i += 1) {
|
|
126
|
+
rows.push(rowNodes[i]);
|
|
127
|
+
tableBody.removeChild(rowNodes[i]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
rows.sort(finalSorter);
|
|
131
|
+
|
|
132
|
+
for (i = 0; i < rows.length; i += 1) {
|
|
133
|
+
tableBody.appendChild(rows[i]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// removes sort indicators for current column being sorted
|
|
137
|
+
function removeSortIndicators() {
|
|
138
|
+
var col = getNthColumn(currentSort.index),
|
|
139
|
+
cls = col.className;
|
|
140
|
+
|
|
141
|
+
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
|
142
|
+
col.className = cls;
|
|
143
|
+
}
|
|
144
|
+
// adds sort indicators for current column being sorted
|
|
145
|
+
function addSortIndicators() {
|
|
146
|
+
getNthColumn(currentSort.index).className += currentSort.desc
|
|
147
|
+
? ' sorted-desc'
|
|
148
|
+
: ' sorted';
|
|
149
|
+
}
|
|
150
|
+
// adds event listeners for all sorter widgets
|
|
151
|
+
function enableUI() {
|
|
152
|
+
var i,
|
|
153
|
+
el,
|
|
154
|
+
ithSorter = function ithSorter(i) {
|
|
155
|
+
var col = cols[i];
|
|
156
|
+
|
|
157
|
+
return function() {
|
|
158
|
+
var desc = col.defaultDescSort;
|
|
159
|
+
|
|
160
|
+
if (currentSort.index === i) {
|
|
161
|
+
desc = !currentSort.desc;
|
|
162
|
+
}
|
|
163
|
+
sortByIndex(i, desc);
|
|
164
|
+
removeSortIndicators();
|
|
165
|
+
currentSort.index = i;
|
|
166
|
+
currentSort.desc = desc;
|
|
167
|
+
addSortIndicators();
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
for (i = 0; i < cols.length; i += 1) {
|
|
171
|
+
if (cols[i].sortable) {
|
|
172
|
+
// add the click event handler on the th so users
|
|
173
|
+
// dont have to click on those tiny arrows
|
|
174
|
+
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
|
175
|
+
if (el.addEventListener) {
|
|
176
|
+
el.addEventListener('click', ithSorter(i));
|
|
177
|
+
} else {
|
|
178
|
+
el.attachEvent('onclick', ithSorter(i));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// adds sorting functionality to the UI
|
|
184
|
+
return function() {
|
|
185
|
+
if (!getTable()) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
cols = loadColumns();
|
|
189
|
+
loadData();
|
|
190
|
+
addSearchBox();
|
|
191
|
+
addSortIndicators();
|
|
192
|
+
enableUI();
|
|
193
|
+
};
|
|
194
|
+
})();
|
|
195
|
+
|
|
196
|
+
window.addEventListener('load', addSorting);
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):"object"==typeof exports?exports.FeaturevisorVue=t(require("vue")):e.FeaturevisorVue=t(e.Vue)}(this,(e=>(()=>{"use strict";var t={289:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.activateFeature=void 0;var o=r(901);t.activateFeature=function(e,t){return void 0===t&&(t={}),(0,o.useSdk)().activate(e,t)}},97:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var u=Object.getOwnPropertyDescriptor(t,r);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,u)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),u=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),u(r(121),t),u(r(289),t),u(r(901),t),u(r(9),t),u(r(26),t),u(r(613),t)},121:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupApp=t.PROVIDER_NAME=void 0,t.PROVIDER_NAME="featurevisor",t.setupApp=function(e,r){e.provide(t.PROVIDER_NAME,r)}},901:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useSdk=void 0;var o=r(976),u=r(121);t.useSdk=function(){return(0,o.inject)(u.PROVIDER_NAME)}},9:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useStatus=void 0;var o=r(976),u=r(901);t.useStatus=function(){var e=(0,u.useSdk)(),t=e.isReady(),r=(0,o.ref)({isReady:t});return t?r:(e.on("ready",(function(){r.value.isReady=!0})),(0,o.readonly)(r))}},26:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useVariable=void 0;var o=r(901);t.useVariable=function(e,t,r){return void 0===r&&(r={}),(0,o.useSdk)().getVariable(e,t,r)}},613:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useVariation=void 0;var o=r(901);t.useVariation=function(e,t){return void 0===t&&(t={}),(0,o.useSdk)().getVariation(e,t)}},976:t=>{t.exports=e}},r={};return function e(o){var u=r[o];if(void 0!==u)return u.exports;var i=r[o]={exports:{}};return t[o].call(i.exports,i,i.exports,e),i.exports}(97)})()));
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.gz
ADDED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,QACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,OAAQJ,GACU,iBAAZC,QACdA,QAAyB,gBAAID,EAAQG,QAAQ,QAE7CJ,EAAsB,gBAAIC,EAAQD,EAAU,IAC7C,CATD,CASGO,MAAOC,G,kHCPV,aAEA,2BACEC,EACAC,GAIA,YAJA,IAAAA,IAAAA,EAAA,KAEY,IAAAC,UAEDC,SAASH,EAAYC,EAClC,C,0fCXA,YAEA,YACA,YACA,UACA,WACA,W,iGCHa,EAAAG,cAAgB,eAE7B,oBAAyBC,EAAUC,GACjCD,EAAIE,QAAQ,EAAAH,cAAeE,EAC7B,C,iFCPA,aAGA,SAEA,oBAGE,OAFY,IAAAE,QAAO,EAAAJ,cAGrB,C,kFCTA,aAEA,SAMA,uBACE,IAAME,GAAM,IAAAJ,UACNO,EAAgBH,EAAII,UAEpBC,GAAS,IAAAC,KAAI,CACjBF,QAASD,IAGX,OAAIA,EACKE,GAGTL,EAAIO,GAAG,SAAS,WACdF,EAAOG,MAAMJ,SAAU,CACzB,KAEO,IAAAK,UAASJ,GAClB,C,qFCvBA,aAEA,uBACEX,EACAgB,EACAf,GAIA,YAJA,IAAAA,IAAAA,EAAA,KAEY,IAAAC,UAEDe,YAAYjB,EAAYgB,EAAaf,EAClD,C,uFCVA,aAEA,wBACED,EACAC,GAIA,YAJA,IAAAA,IAAAA,EAAA,KAEY,IAAAC,UAEDgB,aAAalB,EAAYC,EACtC,C,UCXAP,EAAOD,QAAUM,C,GCCboB,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa7B,QAGrB,IAAIC,EAASyB,EAAyBE,GAAY,CAGjD5B,QAAS,CAAC,GAOX,OAHA+B,EAAoBH,GAAUI,KAAK/B,EAAOD,QAASC,EAAQA,EAAOD,QAAS2B,GAGpE1B,EAAOD,OACf,CCnB0B2B,CAAoB,G","sources":["webpack://FeaturevisorVue/webpack/universalModuleDefinition","webpack://FeaturevisorVue/./src/activateFeature.ts","webpack://FeaturevisorVue/./src/index.ts","webpack://FeaturevisorVue/./src/setupApp.ts","webpack://FeaturevisorVue/./src/useSdk.ts","webpack://FeaturevisorVue/./src/useStatus.ts","webpack://FeaturevisorVue/./src/useVariable.ts","webpack://FeaturevisorVue/./src/useVariation.ts","webpack://FeaturevisorVue/external umd {\"commonjs\":\"vue\",\"commonjs2\":\"vue\",\"amd\":\"vue\",\"root\":\"Vue\"}","webpack://FeaturevisorVue/webpack/bootstrap","webpack://FeaturevisorVue/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"vue\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"vue\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FeaturevisorVue\"] = factory(require(\"vue\"));\n\telse\n\t\troot[\"FeaturevisorVue\"] = factory(root[\"Vue\"]);\n})(this, (__WEBPACK_EXTERNAL_MODULE__976__) => {\nreturn ","import { Attributes, FeatureKey, VariationValue } from \"@featurevisor/types\";\n\nimport { useSdk } from \"./useSdk\";\n\nexport function activateFeature(\n featureKey: FeatureKey,\n attributes: Attributes = {},\n): VariationValue | undefined {\n const sdk = useSdk();\n\n return sdk.activate(featureKey, attributes);\n}\n","export * from \"./setupApp\";\n\nexport * from \"./activateFeature\";\nexport * from \"./useSdk\";\nexport * from \"./useStatus\";\nexport * from \"./useVariable\";\nexport * from \"./useVariation\";\n","import { App } from \"vue\";\nimport { FeaturevisorInstance } from \"@featurevisor/sdk\";\n\nexport const PROVIDER_NAME = \"featurevisor\";\n\nexport function setupApp(app: App, sdk: FeaturevisorInstance) {\n app.provide(PROVIDER_NAME, sdk);\n}\n","import { inject } from \"vue\";\nimport { FeaturevisorInstance } from \"@featurevisor/sdk\";\n\nimport { PROVIDER_NAME } from \"./setupApp\";\n\nexport function useSdk(): FeaturevisorInstance {\n const sdk = inject(PROVIDER_NAME) as FeaturevisorInstance;\n\n return sdk;\n}\n","import { Ref, readonly, ref } from \"vue\";\n\nimport { useSdk } from \"./useSdk\";\n\nexport interface Status {\n isReady: boolean;\n}\n\nexport function useStatus(): Ref<Status> {\n const sdk = useSdk();\n const initialStatus = sdk.isReady();\n\n const result = ref({\n isReady: initialStatus,\n });\n\n if (initialStatus) {\n return result;\n }\n\n sdk.on(\"ready\", () => {\n result.value.isReady = true;\n });\n\n return readonly(result);\n}\n","import { Attributes, FeatureKey, VariableKey, VariableValue } from \"@featurevisor/types\";\n\nimport { useSdk } from \"./useSdk\";\n\nexport function useVariable(\n featureKey: FeatureKey,\n variableKey: VariableKey,\n attributes: Attributes = {},\n): VariableValue | undefined {\n const sdk = useSdk();\n\n return sdk.getVariable(featureKey, variableKey, attributes);\n}\n","import { Attributes, FeatureKey, VariationValue } from \"@featurevisor/types\";\n\nimport { useSdk } from \"./useSdk\";\n\nexport function useVariation(\n featureKey: FeatureKey,\n attributes: Attributes = {},\n): VariationValue | undefined {\n const sdk = useSdk();\n\n return sdk.getVariation(featureKey, attributes);\n}\n","module.exports = __WEBPACK_EXTERNAL_MODULE__976__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(97);\n"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE__976__","featureKey","attributes","useSdk","activate","PROVIDER_NAME","app","sdk","provide","inject","initialStatus","isReady","result","ref","on","value","readonly","variableKey","getVariable","getVariation","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call"],"sourceRoot":""}
|
package/jest.config.js
ADDED
package/jest.setup.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activateFeature.js","sourceRoot":"","sources":["../src/activateFeature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,eAAe,CAC7B,UAAsB,EACtB,UAA2B;IAA3B,2BAAA,EAAA,eAA2B;IAE3B,IAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IAErB,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAC9C,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { createApp } from "vue";
|
|
38
|
+
import { createInstance } from "@featurevisor/sdk";
|
|
39
|
+
import { mount } from "@vue/test-utils";
|
|
40
|
+
import { setupApp, PROVIDER_NAME } from "./setupApp";
|
|
41
|
+
describe("vue: index", function () {
|
|
42
|
+
it("can set up sdk in app and then inject the sdk instance", function () {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var sdk, TestComponent, App, app, wrapper, pText, revisionText;
|
|
45
|
+
var _a;
|
|
46
|
+
return __generator(this, function (_b) {
|
|
47
|
+
switch (_b.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
sdk = createInstance({
|
|
50
|
+
datafile: {
|
|
51
|
+
schemaVersion: "1",
|
|
52
|
+
revision: "1.0",
|
|
53
|
+
features: [
|
|
54
|
+
{
|
|
55
|
+
key: "test",
|
|
56
|
+
defaultVariation: false,
|
|
57
|
+
bucketBy: "userId",
|
|
58
|
+
variations: [{ value: true }, { value: false }],
|
|
59
|
+
traffic: [
|
|
60
|
+
{
|
|
61
|
+
key: "1",
|
|
62
|
+
segments: "*",
|
|
63
|
+
percentage: 100000,
|
|
64
|
+
allocation: [
|
|
65
|
+
{ variation: true, range: [0, 100000] },
|
|
66
|
+
{ variation: false, range: [0, 0] },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
attributes: [],
|
|
73
|
+
segments: [],
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
TestComponent = {
|
|
77
|
+
inject: [PROVIDER_NAME],
|
|
78
|
+
data: function () {
|
|
79
|
+
var revision = this[PROVIDER_NAME].getRevision();
|
|
80
|
+
return {
|
|
81
|
+
revision: revision,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
template: "<div>\n <p data-test=\"p\">TestComponent here</p>\n <p data-test=\"revision\">{{ revision }}</p>\n </div>",
|
|
85
|
+
};
|
|
86
|
+
App = {
|
|
87
|
+
components: { TestComponent: TestComponent },
|
|
88
|
+
template: "<div><TestComponent /></div>",
|
|
89
|
+
provide: (_a = {},
|
|
90
|
+
_a[PROVIDER_NAME] = sdk,
|
|
91
|
+
_a),
|
|
92
|
+
};
|
|
93
|
+
app = createApp(App);
|
|
94
|
+
setupApp(app, sdk);
|
|
95
|
+
wrapper = mount(App);
|
|
96
|
+
expect(wrapper.exists()).toEqual(true);
|
|
97
|
+
return [4 /*yield*/, wrapper.get("[data-test=\"p\"]").text()];
|
|
98
|
+
case 1:
|
|
99
|
+
pText = _b.sent();
|
|
100
|
+
expect(pText).toEqual("TestComponent here");
|
|
101
|
+
return [4 /*yield*/, wrapper.get("[data-test=\"revision\"]").text()];
|
|
102
|
+
case 2:
|
|
103
|
+
revisionText = _b.sent();
|
|
104
|
+
expect(revisionText).toEqual("1.0");
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
// @TODO: add more tests that utilizes Composition API
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=index.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGrD,QAAQ,CAAC,YAAY,EAAE;IACrB,EAAE,CAAC,wDAAwD,EAAE;;;;;;;wBACrD,GAAG,GAAG,cAAc,CAAC;4BACzB,QAAQ,EAAE;gCACR,aAAa,EAAE,GAAG;gCAClB,QAAQ,EAAE,KAAK;gCACf,QAAQ,EAAE;oCACR;wCACE,GAAG,EAAE,MAAM;wCACX,gBAAgB,EAAE,KAAK;wCACvB,QAAQ,EAAE,QAAQ;wCAClB,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;wCAC/C,OAAO,EAAE;4CACP;gDACE,GAAG,EAAE,GAAG;gDACR,QAAQ,EAAE,GAAG;gDACb,UAAU,EAAE,MAAM;gDAClB,UAAU,EAAE;oDACV,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE;oDACvC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;iDACpC;6CACF;yCACF;qCACF;iCACF;gCACD,UAAU,EAAE,EAAE;gCACd,QAAQ,EAAE,EAAE;6BACb;yBACF,CAAC,CAAC;wBAEG,aAAa,GAAG;4BACpB,MAAM,EAAE,CAAC,aAAa,CAAC;4BACvB,IAAI,EAAE;gCACJ,IAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;gCAEnD,OAAO;oCACL,QAAQ,UAAA;iCACT,CAAC;4BACJ,CAAC;4BACD,QAAQ,EAAE,8HAGH;yBACR,CAAC;wBAEI,GAAG,GAAG;4BACV,UAAU,EAAE,EAAE,aAAa,eAAA,EAAE;4BAC7B,QAAQ,EAAE,8BAA8B;4BACxC,OAAO;gCACL,GAAC,aAAa,IAAG,GAAG;mCACrB;yBACF,CAAC;wBAEI,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;wBAC3B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;wBAEb,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;wBAC3B,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;wBAEzB,qBAAM,OAAO,CAAC,GAAG,CAAC,mBAAiB,CAAC,CAAC,IAAI,EAAE,EAAA;;wBAAnD,KAAK,GAAG,SAA2C;wBACzD,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;wBAEvB,qBAAM,OAAO,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC,IAAI,EAAE,EAAA;;wBAAjE,YAAY,GAAG,SAAkD;wBACvE,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;;;;;KACrC,CAAC,CAAC;IAEH,sDAAsD;AACxD,CAAC,CAAC,CAAC"}
|
package/lib/setupApp.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupApp.js","sourceRoot":"","sources":["../src/setupApp.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,IAAM,aAAa,GAAG,cAAc,CAAC;AAE5C,MAAM,UAAU,QAAQ,CAAC,GAAQ,EAAE,GAAyB;IAC1D,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC"}
|
package/lib/useSdk.d.ts
ADDED
package/lib/useSdk.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSdk.js","sourceRoot":"","sources":["../src/useSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,UAAU,MAAM;IACpB,IAAM,GAAG,GAAG,MAAM,CAAC,aAAa,CAAyB,CAAC;IAE1D,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/lib/useStatus.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { readonly, ref } from "vue";
|
|
2
|
+
import { useSdk } from "./useSdk";
|
|
3
|
+
export function useStatus() {
|
|
4
|
+
var sdk = useSdk();
|
|
5
|
+
var initialStatus = sdk.isReady();
|
|
6
|
+
var result = ref({
|
|
7
|
+
isReady: initialStatus,
|
|
8
|
+
});
|
|
9
|
+
if (initialStatus) {
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
sdk.on("ready", function () {
|
|
13
|
+
result.value.isReady = true;
|
|
14
|
+
});
|
|
15
|
+
return readonly(result);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=useStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStatus.js","sourceRoot":"","sources":["../src/useStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAMlC,MAAM,UAAU,SAAS;IACvB,IAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,IAAM,aAAa,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAEpC,IAAM,MAAM,GAAG,GAAG,CAAC;QACjB,OAAO,EAAE,aAAa;KACvB,CAAC,CAAC;IAEH,IAAI,aAAa,EAAE;QACjB,OAAO,MAAM,CAAC;KACf;IAED,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE;QACd,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useSdk } from "./useSdk";
|
|
2
|
+
export function useVariable(featureKey, variableKey, attributes) {
|
|
3
|
+
if (attributes === void 0) { attributes = {}; }
|
|
4
|
+
var sdk = useSdk();
|
|
5
|
+
return sdk.getVariable(featureKey, variableKey, attributes);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=useVariable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVariable.js","sourceRoot":"","sources":["../src/useVariable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,WAAW,CACzB,UAAsB,EACtB,WAAwB,EACxB,UAA2B;IAA3B,2BAAA,EAAA,eAA2B;IAE3B,IAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IAErB,OAAO,GAAG,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVariation.js","sourceRoot":"","sources":["../src/useVariation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,YAAY,CAC1B,UAAsB,EACtB,UAA2B;IAA3B,2BAAA,EAAA,eAA2B;IAE3B,IAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IAErB,OAAO,GAAG,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAClD,CAAC"}
|