tang 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/tang/account/receipts_controller.rb +1 -1
- data/app/jobs/tang/import_subscriptions_job.rb +2 -5
- data/app/models/concerns/tang/customer.rb +2 -3
- data/app/models/tang/coupon.rb +1 -1
- data/app/models/tang/invoice.rb +45 -4
- data/app/models/tang/invoice_item.rb +2 -4
- data/app/models/tang/subscription.rb +20 -8
- data/app/services/tang/create_subscription.rb +3 -3
- data/app/services/tang/fail_invoice.rb +5 -0
- data/app/services/tang/pay_invoice.rb +16 -14
- data/app/views/tang/account/receipts/_receipt.html.erb +1 -1
- data/app/views/tang/admin/payments/index.html.erb +1 -1
- data/app/views/tang/admin/plans/show.html.erb +1 -1
- data/app/views/tang/admin/subscriptions/index.html.erb +1 -1
- data/config/cucumber.yml +1 -1
- data/lib/tang/version.rb +1 -1
- data/spec/fixtures/stripe_webhooks/invoice.created.json +6 -5
- data/spec/fixtures/stripe_webhooks/invoice.payment_succeeded.json +114 -0
- data/spec/requests/stripe_event_spec.rb +4 -2
- data/spec/services/tang/pay_invoice_spec.rb +7 -3
- data/spec/tang_app/app/views/layouts/application.html.erb +1 -1
- data/spec/tang_app/log/test.log +175832 -0
- data/spec/tang_app/public/packs-test/js/application-49b9b6a486f4575192e2.js +654 -0
- data/spec/tang_app/public/packs-test/js/application-49b9b6a486f4575192e2.js.map +1 -0
- data/spec/tang_app/public/packs-test/manifest.json +4 -4
- data/spec/tang_app/tmp/cache/webpacker/last-compilation-digest-test +1 -1
- metadata +14 -8
@@ -0,0 +1,654 @@
|
|
1
|
+
/******/ (function(modules) { // webpackBootstrap
|
2
|
+
/******/ // The module cache
|
3
|
+
/******/ var installedModules = {};
|
4
|
+
/******/
|
5
|
+
/******/ // The require function
|
6
|
+
/******/ function __webpack_require__(moduleId) {
|
7
|
+
/******/
|
8
|
+
/******/ // Check if module is in cache
|
9
|
+
/******/ if(installedModules[moduleId]) {
|
10
|
+
/******/ return installedModules[moduleId].exports;
|
11
|
+
/******/ }
|
12
|
+
/******/ // Create a new module (and put it into the cache)
|
13
|
+
/******/ var module = installedModules[moduleId] = {
|
14
|
+
/******/ i: moduleId,
|
15
|
+
/******/ l: false,
|
16
|
+
/******/ exports: {}
|
17
|
+
/******/ };
|
18
|
+
/******/
|
19
|
+
/******/ // Execute the module function
|
20
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21
|
+
/******/
|
22
|
+
/******/ // Flag the module as loaded
|
23
|
+
/******/ module.l = true;
|
24
|
+
/******/
|
25
|
+
/******/ // Return the exports of the module
|
26
|
+
/******/ return module.exports;
|
27
|
+
/******/ }
|
28
|
+
/******/
|
29
|
+
/******/
|
30
|
+
/******/ // expose the modules object (__webpack_modules__)
|
31
|
+
/******/ __webpack_require__.m = modules;
|
32
|
+
/******/
|
33
|
+
/******/ // expose the module cache
|
34
|
+
/******/ __webpack_require__.c = installedModules;
|
35
|
+
/******/
|
36
|
+
/******/ // define getter function for harmony exports
|
37
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
38
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
39
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
40
|
+
/******/ }
|
41
|
+
/******/ };
|
42
|
+
/******/
|
43
|
+
/******/ // define __esModule on exports
|
44
|
+
/******/ __webpack_require__.r = function(exports) {
|
45
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
46
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
47
|
+
/******/ }
|
48
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
49
|
+
/******/ };
|
50
|
+
/******/
|
51
|
+
/******/ // create a fake namespace object
|
52
|
+
/******/ // mode & 1: value is a module id, require it
|
53
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
54
|
+
/******/ // mode & 4: return value when already ns object
|
55
|
+
/******/ // mode & 8|1: behave like require
|
56
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
57
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
58
|
+
/******/ if(mode & 8) return value;
|
59
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
60
|
+
/******/ var ns = Object.create(null);
|
61
|
+
/******/ __webpack_require__.r(ns);
|
62
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
63
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
64
|
+
/******/ return ns;
|
65
|
+
/******/ };
|
66
|
+
/******/
|
67
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
68
|
+
/******/ __webpack_require__.n = function(module) {
|
69
|
+
/******/ var getter = module && module.__esModule ?
|
70
|
+
/******/ function getDefault() { return module['default']; } :
|
71
|
+
/******/ function getModuleExports() { return module; };
|
72
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
73
|
+
/******/ return getter;
|
74
|
+
/******/ };
|
75
|
+
/******/
|
76
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
77
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
78
|
+
/******/
|
79
|
+
/******/ // __webpack_public_path__
|
80
|
+
/******/ __webpack_require__.p = "/packs-test/";
|
81
|
+
/******/
|
82
|
+
/******/
|
83
|
+
/******/ // Load entry module and return exports
|
84
|
+
/******/ return __webpack_require__(__webpack_require__.s = "./app/javascript/packs/application.js");
|
85
|
+
/******/ })
|
86
|
+
/************************************************************************/
|
87
|
+
/******/ ({
|
88
|
+
|
89
|
+
/***/ "../../lib/css/main.css":
|
90
|
+
/*!*****************************************************!*\
|
91
|
+
!*** /Users/craigphares/Code/tang/lib/css/main.css ***!
|
92
|
+
\*****************************************************/
|
93
|
+
/*! no static exports found */
|
94
|
+
/***/ (function(module, exports, __webpack_require__) {
|
95
|
+
|
96
|
+
var api = __webpack_require__(/*! ../../spec/tang_app/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
|
97
|
+
var content = __webpack_require__(/*! !../../spec/tang_app/node_modules/css-loader/dist/cjs.js??ref--5-1!../../spec/tang_app/node_modules/postcss-loader/src??ref--5-2!./main.css */ "./node_modules/css-loader/dist/cjs.js?!./node_modules/postcss-loader/src/index.js?!../../lib/css/main.css");
|
98
|
+
|
99
|
+
content = content.__esModule ? content.default : content;
|
100
|
+
|
101
|
+
if (typeof content === 'string') {
|
102
|
+
content = [[module.i, content, '']];
|
103
|
+
}
|
104
|
+
|
105
|
+
var options = {};
|
106
|
+
|
107
|
+
options.insert = "head";
|
108
|
+
options.singleton = false;
|
109
|
+
|
110
|
+
var update = api(content, options);
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
module.exports = content.locals || {};
|
115
|
+
|
116
|
+
/***/ }),
|
117
|
+
|
118
|
+
/***/ "../../lib/js/index.js":
|
119
|
+
/*!****************************************************!*\
|
120
|
+
!*** /Users/craigphares/Code/tang/lib/js/index.js ***!
|
121
|
+
\****************************************************/
|
122
|
+
/*! exports provided: default */
|
123
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
124
|
+
|
125
|
+
"use strict";
|
126
|
+
__webpack_require__.r(__webpack_exports__);
|
127
|
+
// Create a Stripe client.
|
128
|
+
// var stripe = Stripe(process.env.STRIPE_PUBLISHABLE_KEY);
|
129
|
+
var stripe = Stripe(window.Tang.STRIPE_PUBLISHABLE_KEY)
|
130
|
+
|
131
|
+
const registerElements = () => {
|
132
|
+
|
133
|
+
if (!document.getElementById('card-element')) {
|
134
|
+
return
|
135
|
+
}
|
136
|
+
|
137
|
+
// Create an instance of Elements.
|
138
|
+
var elements = stripe.elements();
|
139
|
+
|
140
|
+
// Custom styling can be passed to options when creating an Element.
|
141
|
+
// (Note that this demo uses a wider set of styles than the guide below.)
|
142
|
+
var style = {
|
143
|
+
base: {
|
144
|
+
color: '#32325d',
|
145
|
+
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
|
146
|
+
fontSmoothing: 'antialiased',
|
147
|
+
fontSize: '16px',
|
148
|
+
'::placeholder': {
|
149
|
+
color: '#aab7c4'
|
150
|
+
}
|
151
|
+
},
|
152
|
+
invalid: {
|
153
|
+
color: '#fa755a',
|
154
|
+
iconColor: '#fa755a'
|
155
|
+
}
|
156
|
+
};
|
157
|
+
|
158
|
+
// Create an instance of the card Element.
|
159
|
+
var card = elements.create('card', {style: style});
|
160
|
+
|
161
|
+
// Add an instance of the card Element into the `card-element` <div>.
|
162
|
+
card.mount('#card-element');
|
163
|
+
// Handle real-time validation errors from the card Element.
|
164
|
+
card.on('change', function(event) {
|
165
|
+
var displayError = document.getElementById('card-errors');
|
166
|
+
if (event.error) {
|
167
|
+
displayError.textContent = event.error.message;
|
168
|
+
} else {
|
169
|
+
displayError.textContent = '';
|
170
|
+
}
|
171
|
+
});
|
172
|
+
|
173
|
+
// Handle form submission.
|
174
|
+
var form = document.getElementById('payment-form');
|
175
|
+
form.addEventListener('submit', function(event) {
|
176
|
+
event.preventDefault();
|
177
|
+
|
178
|
+
const name = form.querySelector('#name')
|
179
|
+
// const zip = form.querySelector('#zip')
|
180
|
+
const additionalData = {
|
181
|
+
name: name ? name.value : undefined,
|
182
|
+
// address_zip: zip ? zip.value : undefined
|
183
|
+
}
|
184
|
+
|
185
|
+
stripe.createToken(card, additionalData).then(function(result) {
|
186
|
+
if (result.error) {
|
187
|
+
// Inform the user if there was an error.
|
188
|
+
var errorElement = document.getElementById('card-errors');
|
189
|
+
errorElement.textContent = result.error.message;
|
190
|
+
} else {
|
191
|
+
// Send the token to your server.
|
192
|
+
stripeTokenHandler(result.token);
|
193
|
+
}
|
194
|
+
});
|
195
|
+
});
|
196
|
+
|
197
|
+
// Submit the form with the token ID.
|
198
|
+
function stripeTokenHandler(token) {
|
199
|
+
// Insert the token ID into the form so it gets submitted to the server
|
200
|
+
var form = document.getElementById('payment-form');
|
201
|
+
var hiddenInput = document.createElement('input');
|
202
|
+
hiddenInput.setAttribute('type', 'hidden');
|
203
|
+
hiddenInput.setAttribute('name', 'stripe_token');
|
204
|
+
hiddenInput.setAttribute('value', token.id);
|
205
|
+
form.appendChild(hiddenInput);
|
206
|
+
|
207
|
+
// Submit the form
|
208
|
+
form.submit();
|
209
|
+
}
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
/* harmony default export */ __webpack_exports__["default"] = (registerElements);
|
214
|
+
|
215
|
+
/***/ }),
|
216
|
+
|
217
|
+
/***/ "./app/javascript/packs/application.js":
|
218
|
+
/*!*********************************************!*\
|
219
|
+
!*** ./app/javascript/packs/application.js ***!
|
220
|
+
\*********************************************/
|
221
|
+
/*! no exports provided */
|
222
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
223
|
+
|
224
|
+
"use strict";
|
225
|
+
__webpack_require__.r(__webpack_exports__);
|
226
|
+
/* harmony import */ var _sixoverground_tang__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sixoverground/tang */ "../../lib/js/index.js");
|
227
|
+
/* harmony import */ var _sixoverground_tang_lib_css_main_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sixoverground/tang/lib/css/main.css */ "../../lib/css/main.css");
|
228
|
+
/* harmony import */ var _sixoverground_tang_lib_css_main_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_sixoverground_tang_lib_css_main_css__WEBPACK_IMPORTED_MODULE_1__);
|
229
|
+
/* eslint no-console:0 */
|
230
|
+
// This file is automatically compiled by Webpack, along with any other files
|
231
|
+
// present in this directory. You're encouraged to place your actual application logic in
|
232
|
+
// a relevant structure within app/javascript and only use these pack files to reference
|
233
|
+
// that code so it'll be compiled.
|
234
|
+
//
|
235
|
+
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
|
236
|
+
// layout file, like app/views/layouts/application.html.erb
|
237
|
+
// Uncomment to copy all static images under ../images to the output folder and reference
|
238
|
+
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
|
239
|
+
// or the `imagePath` JavaScript helper below.
|
240
|
+
//
|
241
|
+
// const images = require.context('../images', true)
|
242
|
+
// const imagePath = (name) => images(name, true)
|
243
|
+
|
244
|
+
|
245
|
+
console.log('Hello World from Webpacker 1');
|
246
|
+
Object(_sixoverground_tang__WEBPACK_IMPORTED_MODULE_0__["default"])();
|
247
|
+
|
248
|
+
/***/ }),
|
249
|
+
|
250
|
+
/***/ "./node_modules/css-loader/dist/cjs.js?!./node_modules/postcss-loader/src/index.js?!../../lib/css/main.css":
|
251
|
+
/*!*************************************************************************************************************************************************!*\
|
252
|
+
!*** ./node_modules/css-loader/dist/cjs.js??ref--5-1!./node_modules/postcss-loader/src??ref--5-2!/Users/craigphares/Code/tang/lib/css/main.css ***!
|
253
|
+
\*************************************************************************************************************************************************/
|
254
|
+
/*! no static exports found */
|
255
|
+
/***/ (function(module, exports, __webpack_require__) {
|
256
|
+
|
257
|
+
// Imports
|
258
|
+
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../spec/tang_app/node_modules/css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
|
259
|
+
exports = ___CSS_LOADER_API_IMPORT___(true);
|
260
|
+
// Module
|
261
|
+
exports.push([module.i, "/**\n * The CSS shown here will not be introduced in the Quickstart guide, but shows\n * how you can use CSS to style your Element's container.\n */\n .StripeElement {\n box-sizing: border-box;\n\n height: 40px;\n\n padding: 10px 12px;\n\n border: 1px solid transparent;\n border-radius: 4px;\n background-color: white;\n\n box-shadow: 0 1px 3px 0 #e6ebf1;\n transition: box-shadow 150ms ease;\n}\n .StripeElement--focus {\n box-shadow: 0 1px 3px 0 #cfd7df;\n }\n .StripeElement--invalid {\n border-color: #fa755a;\n }\n .StripeElement--webkit-autofill {\n background-color: #fefde5 !important;\n }", "",{"version":3,"sources":["main.css"],"names":[],"mappings":"AAAA;;;EAGE;CACD;EACC,sBAAsB;;EAEtB,YAAY;;EAEZ,kBAAkB;;EAElB,6BAA6B;EAC7B,kBAAkB;EAClB,uBAAuB;;EAEvB,+BAA+B;EAE/B,iCAAiC;AACnC;CAEE;IACE,+BAA+B;EACjC;CAEA;IACE,qBAAqB;EACvB;CAEA;IACE,oCAAoC;EACtC","file":"main.css","sourcesContent":["/**\n * The CSS shown here will not be introduced in the Quickstart guide, but shows\n * how you can use CSS to style your Element's container.\n */\n .StripeElement {\n box-sizing: border-box;\n\n height: 40px;\n\n padding: 10px 12px;\n\n border: 1px solid transparent;\n border-radius: 4px;\n background-color: white;\n\n box-shadow: 0 1px 3px 0 #e6ebf1;\n -webkit-transition: box-shadow 150ms ease;\n transition: box-shadow 150ms ease;\n}\n \n .StripeElement--focus {\n box-shadow: 0 1px 3px 0 #cfd7df;\n }\n \n .StripeElement--invalid {\n border-color: #fa755a;\n }\n \n .StripeElement--webkit-autofill {\n background-color: #fefde5 !important;\n }"]}]);
|
262
|
+
// Exports
|
263
|
+
module.exports = exports;
|
264
|
+
|
265
|
+
|
266
|
+
/***/ }),
|
267
|
+
|
268
|
+
/***/ "./node_modules/css-loader/dist/runtime/api.js":
|
269
|
+
/*!*****************************************************!*\
|
270
|
+
!*** ./node_modules/css-loader/dist/runtime/api.js ***!
|
271
|
+
\*****************************************************/
|
272
|
+
/*! no static exports found */
|
273
|
+
/***/ (function(module, exports, __webpack_require__) {
|
274
|
+
|
275
|
+
"use strict";
|
276
|
+
|
277
|
+
/*
|
278
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
279
|
+
Author Tobias Koppers @sokra
|
280
|
+
*/
|
281
|
+
// css base code, injected by the css-loader
|
282
|
+
// eslint-disable-next-line func-names
|
283
|
+
|
284
|
+
module.exports = function (useSourceMap) {
|
285
|
+
var list = []; // return the list of modules as css string
|
286
|
+
|
287
|
+
list.toString = function toString() {
|
288
|
+
return this.map(function (item) {
|
289
|
+
var content = cssWithMappingToString(item, useSourceMap);
|
290
|
+
|
291
|
+
if (item[2]) {
|
292
|
+
return "@media ".concat(item[2], " {").concat(content, "}");
|
293
|
+
}
|
294
|
+
|
295
|
+
return content;
|
296
|
+
}).join('');
|
297
|
+
}; // import a list of modules into the list
|
298
|
+
// eslint-disable-next-line func-names
|
299
|
+
|
300
|
+
|
301
|
+
list.i = function (modules, mediaQuery, dedupe) {
|
302
|
+
if (typeof modules === 'string') {
|
303
|
+
// eslint-disable-next-line no-param-reassign
|
304
|
+
modules = [[null, modules, '']];
|
305
|
+
}
|
306
|
+
|
307
|
+
var alreadyImportedModules = {};
|
308
|
+
|
309
|
+
if (dedupe) {
|
310
|
+
for (var i = 0; i < this.length; i++) {
|
311
|
+
// eslint-disable-next-line prefer-destructuring
|
312
|
+
var id = this[i][0];
|
313
|
+
|
314
|
+
if (id != null) {
|
315
|
+
alreadyImportedModules[id] = true;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
320
|
+
for (var _i = 0; _i < modules.length; _i++) {
|
321
|
+
var item = [].concat(modules[_i]);
|
322
|
+
|
323
|
+
if (dedupe && alreadyImportedModules[item[0]]) {
|
324
|
+
// eslint-disable-next-line no-continue
|
325
|
+
continue;
|
326
|
+
}
|
327
|
+
|
328
|
+
if (mediaQuery) {
|
329
|
+
if (!item[2]) {
|
330
|
+
item[2] = mediaQuery;
|
331
|
+
} else {
|
332
|
+
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
list.push(item);
|
337
|
+
}
|
338
|
+
};
|
339
|
+
|
340
|
+
return list;
|
341
|
+
};
|
342
|
+
|
343
|
+
function cssWithMappingToString(item, useSourceMap) {
|
344
|
+
var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring
|
345
|
+
|
346
|
+
var cssMapping = item[3];
|
347
|
+
|
348
|
+
if (!cssMapping) {
|
349
|
+
return content;
|
350
|
+
}
|
351
|
+
|
352
|
+
if (useSourceMap && typeof btoa === 'function') {
|
353
|
+
var sourceMapping = toComment(cssMapping);
|
354
|
+
var sourceURLs = cssMapping.sources.map(function (source) {
|
355
|
+
return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
|
356
|
+
});
|
357
|
+
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
|
358
|
+
}
|
359
|
+
|
360
|
+
return [content].join('\n');
|
361
|
+
} // Adapted from convert-source-map (MIT)
|
362
|
+
|
363
|
+
|
364
|
+
function toComment(sourceMap) {
|
365
|
+
// eslint-disable-next-line no-undef
|
366
|
+
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
367
|
+
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
|
368
|
+
return "/*# ".concat(data, " */");
|
369
|
+
}
|
370
|
+
|
371
|
+
/***/ }),
|
372
|
+
|
373
|
+
/***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":
|
374
|
+
/*!****************************************************************************!*\
|
375
|
+
!*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
|
376
|
+
\****************************************************************************/
|
377
|
+
/*! no static exports found */
|
378
|
+
/***/ (function(module, exports, __webpack_require__) {
|
379
|
+
|
380
|
+
"use strict";
|
381
|
+
|
382
|
+
|
383
|
+
var isOldIE = function isOldIE() {
|
384
|
+
var memo;
|
385
|
+
return function memorize() {
|
386
|
+
if (typeof memo === 'undefined') {
|
387
|
+
// Test for IE <= 9 as proposed by Browserhacks
|
388
|
+
// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
|
389
|
+
// Tests for existence of standard globals is to allow style-loader
|
390
|
+
// to operate correctly into non-standard environments
|
391
|
+
// @see https://github.com/webpack-contrib/style-loader/issues/177
|
392
|
+
memo = Boolean(window && document && document.all && !window.atob);
|
393
|
+
}
|
394
|
+
|
395
|
+
return memo;
|
396
|
+
};
|
397
|
+
}();
|
398
|
+
|
399
|
+
var getTarget = function getTarget() {
|
400
|
+
var memo = {};
|
401
|
+
return function memorize(target) {
|
402
|
+
if (typeof memo[target] === 'undefined') {
|
403
|
+
var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
|
404
|
+
|
405
|
+
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
|
406
|
+
try {
|
407
|
+
// This will throw an exception if access to iframe is blocked
|
408
|
+
// due to cross-origin restrictions
|
409
|
+
styleTarget = styleTarget.contentDocument.head;
|
410
|
+
} catch (e) {
|
411
|
+
// istanbul ignore next
|
412
|
+
styleTarget = null;
|
413
|
+
}
|
414
|
+
}
|
415
|
+
|
416
|
+
memo[target] = styleTarget;
|
417
|
+
}
|
418
|
+
|
419
|
+
return memo[target];
|
420
|
+
};
|
421
|
+
}();
|
422
|
+
|
423
|
+
var stylesInDom = [];
|
424
|
+
|
425
|
+
function getIndexByIdentifier(identifier) {
|
426
|
+
var result = -1;
|
427
|
+
|
428
|
+
for (var i = 0; i < stylesInDom.length; i++) {
|
429
|
+
if (stylesInDom[i].identifier === identifier) {
|
430
|
+
result = i;
|
431
|
+
break;
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
435
|
+
return result;
|
436
|
+
}
|
437
|
+
|
438
|
+
function modulesToDom(list, options) {
|
439
|
+
var idCountMap = {};
|
440
|
+
var identifiers = [];
|
441
|
+
|
442
|
+
for (var i = 0; i < list.length; i++) {
|
443
|
+
var item = list[i];
|
444
|
+
var id = options.base ? item[0] + options.base : item[0];
|
445
|
+
var count = idCountMap[id] || 0;
|
446
|
+
var identifier = "".concat(id, " ").concat(count);
|
447
|
+
idCountMap[id] = count + 1;
|
448
|
+
var index = getIndexByIdentifier(identifier);
|
449
|
+
var obj = {
|
450
|
+
css: item[1],
|
451
|
+
media: item[2],
|
452
|
+
sourceMap: item[3]
|
453
|
+
};
|
454
|
+
|
455
|
+
if (index !== -1) {
|
456
|
+
stylesInDom[index].references++;
|
457
|
+
stylesInDom[index].updater(obj);
|
458
|
+
} else {
|
459
|
+
stylesInDom.push({
|
460
|
+
identifier: identifier,
|
461
|
+
updater: addStyle(obj, options),
|
462
|
+
references: 1
|
463
|
+
});
|
464
|
+
}
|
465
|
+
|
466
|
+
identifiers.push(identifier);
|
467
|
+
}
|
468
|
+
|
469
|
+
return identifiers;
|
470
|
+
}
|
471
|
+
|
472
|
+
function insertStyleElement(options) {
|
473
|
+
var style = document.createElement('style');
|
474
|
+
var attributes = options.attributes || {};
|
475
|
+
|
476
|
+
if (typeof attributes.nonce === 'undefined') {
|
477
|
+
var nonce = true ? __webpack_require__.nc : undefined;
|
478
|
+
|
479
|
+
if (nonce) {
|
480
|
+
attributes.nonce = nonce;
|
481
|
+
}
|
482
|
+
}
|
483
|
+
|
484
|
+
Object.keys(attributes).forEach(function (key) {
|
485
|
+
style.setAttribute(key, attributes[key]);
|
486
|
+
});
|
487
|
+
|
488
|
+
if (typeof options.insert === 'function') {
|
489
|
+
options.insert(style);
|
490
|
+
} else {
|
491
|
+
var target = getTarget(options.insert || 'head');
|
492
|
+
|
493
|
+
if (!target) {
|
494
|
+
throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
|
495
|
+
}
|
496
|
+
|
497
|
+
target.appendChild(style);
|
498
|
+
}
|
499
|
+
|
500
|
+
return style;
|
501
|
+
}
|
502
|
+
|
503
|
+
function removeStyleElement(style) {
|
504
|
+
// istanbul ignore if
|
505
|
+
if (style.parentNode === null) {
|
506
|
+
return false;
|
507
|
+
}
|
508
|
+
|
509
|
+
style.parentNode.removeChild(style);
|
510
|
+
}
|
511
|
+
/* istanbul ignore next */
|
512
|
+
|
513
|
+
|
514
|
+
var replaceText = function replaceText() {
|
515
|
+
var textStore = [];
|
516
|
+
return function replace(index, replacement) {
|
517
|
+
textStore[index] = replacement;
|
518
|
+
return textStore.filter(Boolean).join('\n');
|
519
|
+
};
|
520
|
+
}();
|
521
|
+
|
522
|
+
function applyToSingletonTag(style, index, remove, obj) {
|
523
|
+
var css = remove ? '' : obj.media ? "@media ".concat(obj.media, " {").concat(obj.css, "}") : obj.css; // For old IE
|
524
|
+
|
525
|
+
/* istanbul ignore if */
|
526
|
+
|
527
|
+
if (style.styleSheet) {
|
528
|
+
style.styleSheet.cssText = replaceText(index, css);
|
529
|
+
} else {
|
530
|
+
var cssNode = document.createTextNode(css);
|
531
|
+
var childNodes = style.childNodes;
|
532
|
+
|
533
|
+
if (childNodes[index]) {
|
534
|
+
style.removeChild(childNodes[index]);
|
535
|
+
}
|
536
|
+
|
537
|
+
if (childNodes.length) {
|
538
|
+
style.insertBefore(cssNode, childNodes[index]);
|
539
|
+
} else {
|
540
|
+
style.appendChild(cssNode);
|
541
|
+
}
|
542
|
+
}
|
543
|
+
}
|
544
|
+
|
545
|
+
function applyToTag(style, options, obj) {
|
546
|
+
var css = obj.css;
|
547
|
+
var media = obj.media;
|
548
|
+
var sourceMap = obj.sourceMap;
|
549
|
+
|
550
|
+
if (media) {
|
551
|
+
style.setAttribute('media', media);
|
552
|
+
} else {
|
553
|
+
style.removeAttribute('media');
|
554
|
+
}
|
555
|
+
|
556
|
+
if (sourceMap && btoa) {
|
557
|
+
css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
|
558
|
+
} // For old IE
|
559
|
+
|
560
|
+
/* istanbul ignore if */
|
561
|
+
|
562
|
+
|
563
|
+
if (style.styleSheet) {
|
564
|
+
style.styleSheet.cssText = css;
|
565
|
+
} else {
|
566
|
+
while (style.firstChild) {
|
567
|
+
style.removeChild(style.firstChild);
|
568
|
+
}
|
569
|
+
|
570
|
+
style.appendChild(document.createTextNode(css));
|
571
|
+
}
|
572
|
+
}
|
573
|
+
|
574
|
+
var singleton = null;
|
575
|
+
var singletonCounter = 0;
|
576
|
+
|
577
|
+
function addStyle(obj, options) {
|
578
|
+
var style;
|
579
|
+
var update;
|
580
|
+
var remove;
|
581
|
+
|
582
|
+
if (options.singleton) {
|
583
|
+
var styleIndex = singletonCounter++;
|
584
|
+
style = singleton || (singleton = insertStyleElement(options));
|
585
|
+
update = applyToSingletonTag.bind(null, style, styleIndex, false);
|
586
|
+
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
|
587
|
+
} else {
|
588
|
+
style = insertStyleElement(options);
|
589
|
+
update = applyToTag.bind(null, style, options);
|
590
|
+
|
591
|
+
remove = function remove() {
|
592
|
+
removeStyleElement(style);
|
593
|
+
};
|
594
|
+
}
|
595
|
+
|
596
|
+
update(obj);
|
597
|
+
return function updateStyle(newObj) {
|
598
|
+
if (newObj) {
|
599
|
+
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
|
600
|
+
return;
|
601
|
+
}
|
602
|
+
|
603
|
+
update(obj = newObj);
|
604
|
+
} else {
|
605
|
+
remove();
|
606
|
+
}
|
607
|
+
};
|
608
|
+
}
|
609
|
+
|
610
|
+
module.exports = function (list, options) {
|
611
|
+
options = options || {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
|
612
|
+
// tags it will allow on a page
|
613
|
+
|
614
|
+
if (!options.singleton && typeof options.singleton !== 'boolean') {
|
615
|
+
options.singleton = isOldIE();
|
616
|
+
}
|
617
|
+
|
618
|
+
list = list || [];
|
619
|
+
var lastIdentifiers = modulesToDom(list, options);
|
620
|
+
return function update(newList) {
|
621
|
+
newList = newList || [];
|
622
|
+
|
623
|
+
if (Object.prototype.toString.call(newList) !== '[object Array]') {
|
624
|
+
return;
|
625
|
+
}
|
626
|
+
|
627
|
+
for (var i = 0; i < lastIdentifiers.length; i++) {
|
628
|
+
var identifier = lastIdentifiers[i];
|
629
|
+
var index = getIndexByIdentifier(identifier);
|
630
|
+
stylesInDom[index].references--;
|
631
|
+
}
|
632
|
+
|
633
|
+
var newLastIdentifiers = modulesToDom(newList, options);
|
634
|
+
|
635
|
+
for (var _i = 0; _i < lastIdentifiers.length; _i++) {
|
636
|
+
var _identifier = lastIdentifiers[_i];
|
637
|
+
|
638
|
+
var _index = getIndexByIdentifier(_identifier);
|
639
|
+
|
640
|
+
if (stylesInDom[_index].references === 0) {
|
641
|
+
stylesInDom[_index].updater();
|
642
|
+
|
643
|
+
stylesInDom.splice(_index, 1);
|
644
|
+
}
|
645
|
+
}
|
646
|
+
|
647
|
+
lastIdentifiers = newLastIdentifiers;
|
648
|
+
};
|
649
|
+
};
|
650
|
+
|
651
|
+
/***/ })
|
652
|
+
|
653
|
+
/******/ });
|
654
|
+
//# sourceMappingURL=application-49b9b6a486f4575192e2.js.map
|