Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

warnings-1000a372.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. 'use strict';
  2. var PlainValue = require('./PlainValue-ec8e588e.js');
  3. var resolveSeq = require('./resolveSeq-d03cb037.js');
  4. /* global atob, btoa, Buffer */
  5. const binary = {
  6. identify: value => value instanceof Uint8Array,
  7. // Buffer inherits from Uint8Array
  8. default: false,
  9. tag: 'tag:yaml.org,2002:binary',
  10. /**
  11. * Returns a Buffer in node and an Uint8Array in browsers
  12. *
  13. * To use the resulting buffer as an image, you'll want to do something like:
  14. *
  15. * const blob = new Blob([buffer], { type: 'image/jpeg' })
  16. * document.querySelector('#photo').src = URL.createObjectURL(blob)
  17. */
  18. resolve: (doc, node) => {
  19. const src = resolveSeq.resolveString(doc, node);
  20. if (typeof Buffer === 'function') {
  21. return Buffer.from(src, 'base64');
  22. } else if (typeof atob === 'function') {
  23. // On IE 11, atob() can't handle newlines
  24. const str = atob(src.replace(/[\n\r]/g, ''));
  25. const buffer = new Uint8Array(str.length);
  26. for (let i = 0; i < str.length; ++i) buffer[i] = str.charCodeAt(i);
  27. return buffer;
  28. } else {
  29. const msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
  30. doc.errors.push(new PlainValue.YAMLReferenceError(node, msg));
  31. return null;
  32. }
  33. },
  34. options: resolveSeq.binaryOptions,
  35. stringify: ({
  36. comment,
  37. type,
  38. value
  39. }, ctx, onComment, onChompKeep) => {
  40. let src;
  41. if (typeof Buffer === 'function') {
  42. src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
  43. } else if (typeof btoa === 'function') {
  44. let s = '';
  45. for (let i = 0; i < value.length; ++i) s += String.fromCharCode(value[i]);
  46. src = btoa(s);
  47. } else {
  48. throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
  49. }
  50. if (!type) type = resolveSeq.binaryOptions.defaultType;
  51. if (type === PlainValue.Type.QUOTE_DOUBLE) {
  52. value = src;
  53. } else {
  54. const {
  55. lineWidth
  56. } = resolveSeq.binaryOptions;
  57. const n = Math.ceil(src.length / lineWidth);
  58. const lines = new Array(n);
  59. for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
  60. lines[i] = src.substr(o, lineWidth);
  61. }
  62. value = lines.join(type === PlainValue.Type.BLOCK_LITERAL ? '\n' : ' ');
  63. }
  64. return resolveSeq.stringifyString({
  65. comment,
  66. type,
  67. value
  68. }, ctx, onComment, onChompKeep);
  69. }
  70. };
  71. function parsePairs(doc, cst) {
  72. const seq = resolveSeq.resolveSeq(doc, cst);
  73. for (let i = 0; i < seq.items.length; ++i) {
  74. let item = seq.items[i];
  75. if (item instanceof resolveSeq.Pair) continue;else if (item instanceof resolveSeq.YAMLMap) {
  76. if (item.items.length > 1) {
  77. const msg = 'Each pair must have its own sequence indicator';
  78. throw new PlainValue.YAMLSemanticError(cst, msg);
  79. }
  80. const pair = item.items[0] || new resolveSeq.Pair();
  81. if (item.commentBefore) pair.commentBefore = pair.commentBefore ? `${item.commentBefore}\n${pair.commentBefore}` : item.commentBefore;
  82. if (item.comment) pair.comment = pair.comment ? `${item.comment}\n${pair.comment}` : item.comment;
  83. item = pair;
  84. }
  85. seq.items[i] = item instanceof resolveSeq.Pair ? item : new resolveSeq.Pair(item);
  86. }
  87. return seq;
  88. }
  89. function createPairs(schema, iterable, ctx) {
  90. const pairs = new resolveSeq.YAMLSeq(schema);
  91. pairs.tag = 'tag:yaml.org,2002:pairs';
  92. for (const it of iterable) {
  93. let key, value;
  94. if (Array.isArray(it)) {
  95. if (it.length === 2) {
  96. key = it[0];
  97. value = it[1];
  98. } else throw new TypeError(`Expected [key, value] tuple: ${it}`);
  99. } else if (it && it instanceof Object) {
  100. const keys = Object.keys(it);
  101. if (keys.length === 1) {
  102. key = keys[0];
  103. value = it[key];
  104. } else throw new TypeError(`Expected { key: value } tuple: ${it}`);
  105. } else {
  106. key = it;
  107. }
  108. const pair = schema.createPair(key, value, ctx);
  109. pairs.items.push(pair);
  110. }
  111. return pairs;
  112. }
  113. const pairs = {
  114. default: false,
  115. tag: 'tag:yaml.org,2002:pairs',
  116. resolve: parsePairs,
  117. createNode: createPairs
  118. };
  119. class YAMLOMap extends resolveSeq.YAMLSeq {
  120. constructor() {
  121. super();
  122. PlainValue._defineProperty(this, "add", resolveSeq.YAMLMap.prototype.add.bind(this));
  123. PlainValue._defineProperty(this, "delete", resolveSeq.YAMLMap.prototype.delete.bind(this));
  124. PlainValue._defineProperty(this, "get", resolveSeq.YAMLMap.prototype.get.bind(this));
  125. PlainValue._defineProperty(this, "has", resolveSeq.YAMLMap.prototype.has.bind(this));
  126. PlainValue._defineProperty(this, "set", resolveSeq.YAMLMap.prototype.set.bind(this));
  127. this.tag = YAMLOMap.tag;
  128. }
  129. toJSON(_, ctx) {
  130. const map = new Map();
  131. if (ctx && ctx.onCreate) ctx.onCreate(map);
  132. for (const pair of this.items) {
  133. let key, value;
  134. if (pair instanceof resolveSeq.Pair) {
  135. key = resolveSeq.toJSON(pair.key, '', ctx);
  136. value = resolveSeq.toJSON(pair.value, key, ctx);
  137. } else {
  138. key = resolveSeq.toJSON(pair, '', ctx);
  139. }
  140. if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
  141. map.set(key, value);
  142. }
  143. return map;
  144. }
  145. }
  146. PlainValue._defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
  147. function parseOMap(doc, cst) {
  148. const pairs = parsePairs(doc, cst);
  149. const seenKeys = [];
  150. for (const {
  151. key
  152. } of pairs.items) {
  153. if (key instanceof resolveSeq.Scalar) {
  154. if (seenKeys.includes(key.value)) {
  155. const msg = 'Ordered maps must not include duplicate keys';
  156. throw new PlainValue.YAMLSemanticError(cst, msg);
  157. } else {
  158. seenKeys.push(key.value);
  159. }
  160. }
  161. }
  162. return Object.assign(new YAMLOMap(), pairs);
  163. }
  164. function createOMap(schema, iterable, ctx) {
  165. const pairs = createPairs(schema, iterable, ctx);
  166. const omap = new YAMLOMap();
  167. omap.items = pairs.items;
  168. return omap;
  169. }
  170. const omap = {
  171. identify: value => value instanceof Map,
  172. nodeClass: YAMLOMap,
  173. default: false,
  174. tag: 'tag:yaml.org,2002:omap',
  175. resolve: parseOMap,
  176. createNode: createOMap
  177. };
  178. class YAMLSet extends resolveSeq.YAMLMap {
  179. constructor() {
  180. super();
  181. this.tag = YAMLSet.tag;
  182. }
  183. add(key) {
  184. const pair = key instanceof resolveSeq.Pair ? key : new resolveSeq.Pair(key);
  185. const prev = resolveSeq.findPair(this.items, pair.key);
  186. if (!prev) this.items.push(pair);
  187. }
  188. get(key, keepPair) {
  189. const pair = resolveSeq.findPair(this.items, key);
  190. return !keepPair && pair instanceof resolveSeq.Pair ? pair.key instanceof resolveSeq.Scalar ? pair.key.value : pair.key : pair;
  191. }
  192. set(key, value) {
  193. if (typeof value !== 'boolean') throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`);
  194. const prev = resolveSeq.findPair(this.items, key);
  195. if (prev && !value) {
  196. this.items.splice(this.items.indexOf(prev), 1);
  197. } else if (!prev && value) {
  198. this.items.push(new resolveSeq.Pair(key));
  199. }
  200. }
  201. toJSON(_, ctx) {
  202. return super.toJSON(_, ctx, Set);
  203. }
  204. toString(ctx, onComment, onChompKeep) {
  205. if (!ctx) return JSON.stringify(this);
  206. if (this.hasAllNullValues()) return super.toString(ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values');
  207. }
  208. }
  209. PlainValue._defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set');
  210. function parseSet(doc, cst) {
  211. const map = resolveSeq.resolveMap(doc, cst);
  212. if (!map.hasAllNullValues()) throw new PlainValue.YAMLSemanticError(cst, 'Set items must all have null values');
  213. return Object.assign(new YAMLSet(), map);
  214. }
  215. function createSet(schema, iterable, ctx) {
  216. const set = new YAMLSet();
  217. for (const value of iterable) set.items.push(schema.createPair(value, null, ctx));
  218. return set;
  219. }
  220. const set = {
  221. identify: value => value instanceof Set,
  222. nodeClass: YAMLSet,
  223. default: false,
  224. tag: 'tag:yaml.org,2002:set',
  225. resolve: parseSet,
  226. createNode: createSet
  227. };
  228. const parseSexagesimal = (sign, parts) => {
  229. const n = parts.split(':').reduce((n, p) => n * 60 + Number(p), 0);
  230. return sign === '-' ? -n : n;
  231. }; // hhhh:mm:ss.sss
  232. const stringifySexagesimal = ({
  233. value
  234. }) => {
  235. if (isNaN(value) || !isFinite(value)) return resolveSeq.stringifyNumber(value);
  236. let sign = '';
  237. if (value < 0) {
  238. sign = '-';
  239. value = Math.abs(value);
  240. }
  241. const parts = [value % 60]; // seconds, including ms
  242. if (value < 60) {
  243. parts.unshift(0); // at least one : is required
  244. } else {
  245. value = Math.round((value - parts[0]) / 60);
  246. parts.unshift(value % 60); // minutes
  247. if (value >= 60) {
  248. value = Math.round((value - parts[0]) / 60);
  249. parts.unshift(value); // hours
  250. }
  251. }
  252. return sign + parts.map(n => n < 10 ? '0' + String(n) : String(n)).join(':').replace(/000000\d*$/, '') // % 60 may introduce error
  253. ;
  254. };
  255. const intTime = {
  256. identify: value => typeof value === 'number',
  257. default: true,
  258. tag: 'tag:yaml.org,2002:int',
  259. format: 'TIME',
  260. test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/,
  261. resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')),
  262. stringify: stringifySexagesimal
  263. };
  264. const floatTime = {
  265. identify: value => typeof value === 'number',
  266. default: true,
  267. tag: 'tag:yaml.org,2002:float',
  268. format: 'TIME',
  269. test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/,
  270. resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')),
  271. stringify: stringifySexagesimal
  272. };
  273. const timestamp = {
  274. identify: value => value instanceof Date,
  275. default: true,
  276. tag: 'tag:yaml.org,2002:timestamp',
  277. // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
  278. // may be omitted altogether, resulting in a date format. In such a case, the time part is
  279. // assumed to be 00:00:00Z (start of day, UTC).
  280. test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd
  281. '(?:(?:t|T|[ \\t]+)' + // t | T | whitespace
  282. '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)?
  283. '(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30
  284. ')?' + ')$'),
  285. resolve: (str, year, month, day, hour, minute, second, millisec, tz) => {
  286. if (millisec) millisec = (millisec + '00').substr(1, 3);
  287. let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0);
  288. if (tz && tz !== 'Z') {
  289. let d = parseSexagesimal(tz[0], tz.slice(1));
  290. if (Math.abs(d) < 30) d *= 60;
  291. date -= 60000 * d;
  292. }
  293. return new Date(date);
  294. },
  295. stringify: ({
  296. value
  297. }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
  298. };
  299. /* global console, process, YAML_SILENCE_DEPRECATION_WARNINGS, YAML_SILENCE_WARNINGS */
  300. function shouldWarn(deprecation) {
  301. const env = typeof process !== 'undefined' && process.env || {};
  302. if (deprecation) {
  303. if (typeof YAML_SILENCE_DEPRECATION_WARNINGS !== 'undefined') return !YAML_SILENCE_DEPRECATION_WARNINGS;
  304. return !env.YAML_SILENCE_DEPRECATION_WARNINGS;
  305. }
  306. if (typeof YAML_SILENCE_WARNINGS !== 'undefined') return !YAML_SILENCE_WARNINGS;
  307. return !env.YAML_SILENCE_WARNINGS;
  308. }
  309. function warn(warning, type) {
  310. if (shouldWarn(false)) {
  311. const emit = typeof process !== 'undefined' && process.emitWarning; // This will throw in Jest if `warning` is an Error instance due to
  312. // https://github.com/facebook/jest/issues/2549
  313. if (emit) emit(warning, type);else {
  314. // eslint-disable-next-line no-console
  315. console.warn(type ? `${type}: ${warning}` : warning);
  316. }
  317. }
  318. }
  319. function warnFileDeprecation(filename) {
  320. if (shouldWarn(true)) {
  321. const path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/');
  322. warn(`The endpoint 'yaml/${path}' will be removed in a future release.`, 'DeprecationWarning');
  323. }
  324. }
  325. const warned = {};
  326. function warnOptionDeprecation(name, alternative) {
  327. if (!warned[name] && shouldWarn(true)) {
  328. warned[name] = true;
  329. let msg = `The option '${name}' will be removed in a future release`;
  330. msg += alternative ? `, use '${alternative}' instead.` : '.';
  331. warn(msg, 'DeprecationWarning');
  332. }
  333. }
  334. exports.binary = binary;
  335. exports.floatTime = floatTime;
  336. exports.intTime = intTime;
  337. exports.omap = omap;
  338. exports.pairs = pairs;
  339. exports.set = set;
  340. exports.timestamp = timestamp;
  341. exports.warn = warn;
  342. exports.warnFileDeprecation = warnFileDeprecation;
  343. exports.warnOptionDeprecation = warnOptionDeprecation;