@iconoma/cli 0.0.1 → 0.0.3

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.
Files changed (45) hide show
  1. package/README.md +91 -91
  2. package/bin/run.js +0 -0
  3. package/dist/commands/studio.d.ts.map +1 -1
  4. package/dist/commands/studio.js +3 -3
  5. package/dist/tsconfig.tsbuildinfo +1 -1
  6. package/package.json +26 -13
  7. package/dist/get-studio.d.ts +0 -9
  8. package/dist/get-studio.d.ts.map +0 -1
  9. package/dist/get-studio.js +0 -4
  10. package/dist/studio/128.index.js +0 -55
  11. package/dist/studio/143.index.js +0 -2457
  12. package/dist/studio/148.index.js +0 -744
  13. package/dist/studio/211.index.js +0 -47186
  14. package/dist/studio/22.index.js +0 -5942
  15. package/dist/studio/259.index.js +0 -7397
  16. package/dist/studio/437.index.js +0 -20
  17. package/dist/studio/454.index.js +0 -295
  18. package/dist/studio/47.index.js +0 -1431
  19. package/dist/studio/509.index.js +0 -2240
  20. package/dist/studio/533.index.js +0 -883
  21. package/dist/studio/537.index.js +0 -62
  22. package/dist/studio/542.index.js +0 -22
  23. package/dist/studio/543.index.js +0 -6603
  24. package/dist/studio/777.index.js +0 -24
  25. package/dist/studio/786.index.js +0 -1065
  26. package/dist/studio/860.index.js +0 -13
  27. package/dist/studio/876.index.js +0 -38613
  28. package/dist/studio/922.index.js +0 -78317
  29. package/dist/studio/940.index.js +0 -6772
  30. package/dist/studio/942.index.js +0 -8218
  31. package/dist/studio/951.index.js +0 -98
  32. package/dist/studio/c4c9b2153fb0d143f75f.js +0 -1
  33. package/dist/studio/client/assets/base-80a1f760-DUOHyEl5.js +0 -1
  34. package/dist/studio/client/assets/consoleHook-59e792cb-jD7_jZ5v.js +0 -2
  35. package/dist/studio/client/assets/index-599aeaf7-B2yLv6MY.js +0 -16
  36. package/dist/studio/client/assets/index-RLDlFy_p.js +0 -810
  37. package/dist/studio/client/assets/index-iqn0_0ft.css +0 -1
  38. package/dist/studio/client/assets/node-BLCLUDWv.js +0 -4
  39. package/dist/studio/client/assets/runtime-BUwhFSj5.js +0 -1
  40. package/dist/studio/client/favicon.ico +0 -0
  41. package/dist/studio/client/icon.png +0 -0
  42. package/dist/studio/client/index.html +0 -21
  43. package/dist/studio/index.js +0 -277752
  44. package/dist/studio/package.json +0 -3
  45. package/oclif.manifest.json +0 -37
@@ -1,1065 +0,0 @@
1
- import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module";
2
- export const id = 786;
3
- export const ids = [786];
4
- export const modules = {
5
-
6
- /***/ 748:
7
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8
-
9
- // Copyright 2017 Lovell Fuller and others.
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
-
13
-
14
- const childProcess = __webpack_require__(5317);
15
- const { isLinux, getReport } = __webpack_require__(3787);
16
- const { LDD_PATH, SELF_PATH, readFile, readFileSync } = __webpack_require__(3647);
17
- const { interpreterPath } = __webpack_require__(7535);
18
-
19
- let cachedFamilyInterpreter;
20
- let cachedFamilyFilesystem;
21
- let cachedVersionFilesystem;
22
-
23
- const command = 'getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true';
24
- let commandOut = '';
25
-
26
- const safeCommand = () => {
27
- if (!commandOut) {
28
- return new Promise((resolve) => {
29
- childProcess.exec(command, (err, out) => {
30
- commandOut = err ? ' ' : out;
31
- resolve(commandOut);
32
- });
33
- });
34
- }
35
- return commandOut;
36
- };
37
-
38
- const safeCommandSync = () => {
39
- if (!commandOut) {
40
- try {
41
- commandOut = childProcess.execSync(command, { encoding: 'utf8' });
42
- } catch (_err) {
43
- commandOut = ' ';
44
- }
45
- }
46
- return commandOut;
47
- };
48
-
49
- /**
50
- * A String constant containing the value `glibc`.
51
- * @type {string}
52
- * @public
53
- */
54
- const GLIBC = 'glibc';
55
-
56
- /**
57
- * A Regexp constant to get the GLIBC Version.
58
- * @type {string}
59
- */
60
- const RE_GLIBC_VERSION = /LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;
61
-
62
- /**
63
- * A String constant containing the value `musl`.
64
- * @type {string}
65
- * @public
66
- */
67
- const MUSL = 'musl';
68
-
69
- const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-');
70
-
71
- const familyFromReport = () => {
72
- const report = getReport();
73
- if (report.header && report.header.glibcVersionRuntime) {
74
- return GLIBC;
75
- }
76
- if (Array.isArray(report.sharedObjects)) {
77
- if (report.sharedObjects.some(isFileMusl)) {
78
- return MUSL;
79
- }
80
- }
81
- return null;
82
- };
83
-
84
- const familyFromCommand = (out) => {
85
- const [getconf, ldd1] = out.split(/[\r\n]+/);
86
- if (getconf && getconf.includes(GLIBC)) {
87
- return GLIBC;
88
- }
89
- if (ldd1 && ldd1.includes(MUSL)) {
90
- return MUSL;
91
- }
92
- return null;
93
- };
94
-
95
- const familyFromInterpreterPath = (path) => {
96
- if (path) {
97
- if (path.includes('/ld-musl-')) {
98
- return MUSL;
99
- } else if (path.includes('/ld-linux-')) {
100
- return GLIBC;
101
- }
102
- }
103
- return null;
104
- };
105
-
106
- const getFamilyFromLddContent = (content) => {
107
- content = content.toString();
108
- if (content.includes('musl')) {
109
- return MUSL;
110
- }
111
- if (content.includes('GNU C Library')) {
112
- return GLIBC;
113
- }
114
- return null;
115
- };
116
-
117
- const familyFromFilesystem = async () => {
118
- if (cachedFamilyFilesystem !== undefined) {
119
- return cachedFamilyFilesystem;
120
- }
121
- cachedFamilyFilesystem = null;
122
- try {
123
- const lddContent = await readFile(LDD_PATH);
124
- cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
125
- } catch (e) {}
126
- return cachedFamilyFilesystem;
127
- };
128
-
129
- const familyFromFilesystemSync = () => {
130
- if (cachedFamilyFilesystem !== undefined) {
131
- return cachedFamilyFilesystem;
132
- }
133
- cachedFamilyFilesystem = null;
134
- try {
135
- const lddContent = readFileSync(LDD_PATH);
136
- cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
137
- } catch (e) {}
138
- return cachedFamilyFilesystem;
139
- };
140
-
141
- const familyFromInterpreter = async () => {
142
- if (cachedFamilyInterpreter !== undefined) {
143
- return cachedFamilyInterpreter;
144
- }
145
- cachedFamilyInterpreter = null;
146
- try {
147
- const selfContent = await readFile(SELF_PATH);
148
- const path = interpreterPath(selfContent);
149
- cachedFamilyInterpreter = familyFromInterpreterPath(path);
150
- } catch (e) {}
151
- return cachedFamilyInterpreter;
152
- };
153
-
154
- const familyFromInterpreterSync = () => {
155
- if (cachedFamilyInterpreter !== undefined) {
156
- return cachedFamilyInterpreter;
157
- }
158
- cachedFamilyInterpreter = null;
159
- try {
160
- const selfContent = readFileSync(SELF_PATH);
161
- const path = interpreterPath(selfContent);
162
- cachedFamilyInterpreter = familyFromInterpreterPath(path);
163
- } catch (e) {}
164
- return cachedFamilyInterpreter;
165
- };
166
-
167
- /**
168
- * Resolves with the libc family when it can be determined, `null` otherwise.
169
- * @returns {Promise<?string>}
170
- */
171
- const family = async () => {
172
- let family = null;
173
- if (isLinux()) {
174
- family = await familyFromInterpreter();
175
- if (!family) {
176
- family = await familyFromFilesystem();
177
- if (!family) {
178
- family = familyFromReport();
179
- }
180
- if (!family) {
181
- const out = await safeCommand();
182
- family = familyFromCommand(out);
183
- }
184
- }
185
- }
186
- return family;
187
- };
188
-
189
- /**
190
- * Returns the libc family when it can be determined, `null` otherwise.
191
- * @returns {?string}
192
- */
193
- const familySync = () => {
194
- let family = null;
195
- if (isLinux()) {
196
- family = familyFromInterpreterSync();
197
- if (!family) {
198
- family = familyFromFilesystemSync();
199
- if (!family) {
200
- family = familyFromReport();
201
- }
202
- if (!family) {
203
- const out = safeCommandSync();
204
- family = familyFromCommand(out);
205
- }
206
- }
207
- }
208
- return family;
209
- };
210
-
211
- /**
212
- * Resolves `true` only when the platform is Linux and the libc family is not `glibc`.
213
- * @returns {Promise<boolean>}
214
- */
215
- const isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;
216
-
217
- /**
218
- * Returns `true` only when the platform is Linux and the libc family is not `glibc`.
219
- * @returns {boolean}
220
- */
221
- const isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;
222
-
223
- const versionFromFilesystem = async () => {
224
- if (cachedVersionFilesystem !== undefined) {
225
- return cachedVersionFilesystem;
226
- }
227
- cachedVersionFilesystem = null;
228
- try {
229
- const lddContent = await readFile(LDD_PATH);
230
- const versionMatch = lddContent.match(RE_GLIBC_VERSION);
231
- if (versionMatch) {
232
- cachedVersionFilesystem = versionMatch[1];
233
- }
234
- } catch (e) {}
235
- return cachedVersionFilesystem;
236
- };
237
-
238
- const versionFromFilesystemSync = () => {
239
- if (cachedVersionFilesystem !== undefined) {
240
- return cachedVersionFilesystem;
241
- }
242
- cachedVersionFilesystem = null;
243
- try {
244
- const lddContent = readFileSync(LDD_PATH);
245
- const versionMatch = lddContent.match(RE_GLIBC_VERSION);
246
- if (versionMatch) {
247
- cachedVersionFilesystem = versionMatch[1];
248
- }
249
- } catch (e) {}
250
- return cachedVersionFilesystem;
251
- };
252
-
253
- const versionFromReport = () => {
254
- const report = getReport();
255
- if (report.header && report.header.glibcVersionRuntime) {
256
- return report.header.glibcVersionRuntime;
257
- }
258
- return null;
259
- };
260
-
261
- const versionSuffix = (s) => s.trim().split(/\s+/)[1];
262
-
263
- const versionFromCommand = (out) => {
264
- const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
265
- if (getconf && getconf.includes(GLIBC)) {
266
- return versionSuffix(getconf);
267
- }
268
- if (ldd1 && ldd2 && ldd1.includes(MUSL)) {
269
- return versionSuffix(ldd2);
270
- }
271
- return null;
272
- };
273
-
274
- /**
275
- * Resolves with the libc version when it can be determined, `null` otherwise.
276
- * @returns {Promise<?string>}
277
- */
278
- const version = async () => {
279
- let version = null;
280
- if (isLinux()) {
281
- version = await versionFromFilesystem();
282
- if (!version) {
283
- version = versionFromReport();
284
- }
285
- if (!version) {
286
- const out = await safeCommand();
287
- version = versionFromCommand(out);
288
- }
289
- }
290
- return version;
291
- };
292
-
293
- /**
294
- * Returns the libc version when it can be determined, `null` otherwise.
295
- * @returns {?string}
296
- */
297
- const versionSync = () => {
298
- let version = null;
299
- if (isLinux()) {
300
- version = versionFromFilesystemSync();
301
- if (!version) {
302
- version = versionFromReport();
303
- }
304
- if (!version) {
305
- const out = safeCommandSync();
306
- version = versionFromCommand(out);
307
- }
308
- }
309
- return version;
310
- };
311
-
312
- module.exports = {
313
- GLIBC,
314
- MUSL,
315
- family,
316
- familySync,
317
- isNonGlibcLinux,
318
- isNonGlibcLinuxSync,
319
- version,
320
- versionSync
321
- };
322
-
323
-
324
- /***/ }),
325
-
326
- /***/ 7535:
327
- /***/ ((module) => {
328
-
329
- // Copyright 2017 Lovell Fuller and others.
330
- // SPDX-License-Identifier: Apache-2.0
331
-
332
-
333
-
334
- const interpreterPath = (elf) => {
335
- if (elf.length < 64) {
336
- return null;
337
- }
338
- if (elf.readUInt32BE(0) !== 0x7F454C46) {
339
- // Unexpected magic bytes
340
- return null;
341
- }
342
- if (elf.readUInt8(4) !== 2) {
343
- // Not a 64-bit ELF
344
- return null;
345
- }
346
- if (elf.readUInt8(5) !== 1) {
347
- // Not little-endian
348
- return null;
349
- }
350
- const offset = elf.readUInt32LE(32);
351
- const size = elf.readUInt16LE(54);
352
- const count = elf.readUInt16LE(56);
353
- for (let i = 0; i < count; i++) {
354
- const headerOffset = offset + (i * size);
355
- const type = elf.readUInt32LE(headerOffset);
356
- if (type === 3) {
357
- const fileOffset = elf.readUInt32LE(headerOffset + 8);
358
- const fileSize = elf.readUInt32LE(headerOffset + 32);
359
- return elf.subarray(fileOffset, fileOffset + fileSize).toString().replace(/\0.*$/g, '');
360
- }
361
- }
362
- return null;
363
- };
364
-
365
- module.exports = {
366
- interpreterPath
367
- };
368
-
369
-
370
- /***/ }),
371
-
372
- /***/ 3647:
373
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
374
-
375
- // Copyright 2017 Lovell Fuller and others.
376
- // SPDX-License-Identifier: Apache-2.0
377
-
378
-
379
-
380
- const fs = __webpack_require__(9896);
381
-
382
- const LDD_PATH = '/usr/bin/ldd';
383
- const SELF_PATH = '/proc/self/exe';
384
- const MAX_LENGTH = 2048;
385
-
386
- /**
387
- * Read the content of a file synchronous
388
- *
389
- * @param {string} path
390
- * @returns {Buffer}
391
- */
392
- const readFileSync = (path) => {
393
- const fd = fs.openSync(path, 'r');
394
- const buffer = Buffer.alloc(MAX_LENGTH);
395
- const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);
396
- fs.close(fd, () => {});
397
- return buffer.subarray(0, bytesRead);
398
- };
399
-
400
- /**
401
- * Read the content of a file
402
- *
403
- * @param {string} path
404
- * @returns {Promise<Buffer>}
405
- */
406
- const readFile = (path) => new Promise((resolve, reject) => {
407
- fs.open(path, 'r', (err, fd) => {
408
- if (err) {
409
- reject(err);
410
- } else {
411
- const buffer = Buffer.alloc(MAX_LENGTH);
412
- fs.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
413
- resolve(buffer.subarray(0, bytesRead));
414
- fs.close(fd, () => {});
415
- });
416
- }
417
- });
418
- });
419
-
420
- module.exports = {
421
- LDD_PATH,
422
- SELF_PATH,
423
- readFileSync,
424
- readFile
425
- };
426
-
427
-
428
- /***/ }),
429
-
430
- /***/ 3787:
431
- /***/ ((module) => {
432
-
433
- // Copyright 2017 Lovell Fuller and others.
434
- // SPDX-License-Identifier: Apache-2.0
435
-
436
-
437
-
438
- const isLinux = () => process.platform === 'linux';
439
-
440
- let report = null;
441
- const getReport = () => {
442
- if (!report) {
443
- /* istanbul ignore next */
444
- if (isLinux() && process.report) {
445
- const orig = process.report.excludeNetwork;
446
- process.report.excludeNetwork = true;
447
- report = process.report.getReport();
448
- process.report.excludeNetwork = orig;
449
- } else {
450
- report = {};
451
- }
452
- }
453
- return report;
454
- };
455
-
456
- module.exports = { isLinux, getReport };
457
-
458
-
459
- /***/ }),
460
-
461
- /***/ 9602:
462
- /***/ ((module) => {
463
-
464
- const BROWSER_MAPPING = {
465
- and_chr: 'chrome',
466
- and_ff: 'firefox',
467
- ie_mob: 'ie',
468
- op_mob: 'opera',
469
- and_qq: null,
470
- and_uc: null,
471
- baidu: null,
472
- bb: null,
473
- kaios: null,
474
- op_mini: null,
475
- };
476
-
477
- function browserslistToTargets(browserslist) {
478
- let targets = {};
479
- for (let browser of browserslist) {
480
- let [name, v] = browser.split(' ');
481
- if (BROWSER_MAPPING[name] === null) {
482
- continue;
483
- }
484
-
485
- let version = parseVersion(v);
486
- if (version == null) {
487
- continue;
488
- }
489
-
490
- if (targets[name] == null || version < targets[name]) {
491
- targets[name] = version;
492
- }
493
- }
494
-
495
- return targets;
496
- }
497
-
498
- function parseVersion(version) {
499
- let [major, minor = 0, patch = 0] = version
500
- .split('-')[0]
501
- .split('.')
502
- .map(v => parseInt(v, 10));
503
-
504
- if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
505
- return null;
506
- }
507
-
508
- return (major << 16) | (minor << 8) | patch;
509
- }
510
-
511
- module.exports = browserslistToTargets;
512
-
513
-
514
- /***/ }),
515
-
516
- /***/ 4007:
517
- /***/ ((module) => {
518
-
519
- // @ts-check
520
- /** @typedef {import('./index').Visitor} Visitor */
521
-
522
- /**
523
- * Composes multiple visitor objects into a single one.
524
- * @param {Visitor[]} visitors
525
- * @return {Visitor}
526
- */
527
- function composeVisitors(visitors) {
528
- if (visitors.length === 1) {
529
- return visitors[0];
530
- }
531
-
532
- /** @type Visitor */
533
- let res = {};
534
- composeSimpleVisitors(res, visitors, 'StyleSheet');
535
- composeSimpleVisitors(res, visitors, 'StyleSheetExit');
536
- composeObjectVisitors(res, visitors, 'Rule', ruleVisitor, wrapCustomAndUnknownAtRule);
537
- composeObjectVisitors(res, visitors, 'RuleExit', ruleVisitor, wrapCustomAndUnknownAtRule);
538
- composeObjectVisitors(res, visitors, 'Declaration', declarationVisitor, wrapCustomProperty);
539
- composeObjectVisitors(res, visitors, 'DeclarationExit', declarationVisitor, wrapCustomProperty);
540
- composeSimpleVisitors(res, visitors, 'Url');
541
- composeSimpleVisitors(res, visitors, 'Color');
542
- composeSimpleVisitors(res, visitors, 'Image');
543
- composeSimpleVisitors(res, visitors, 'ImageExit');
544
- composeSimpleVisitors(res, visitors, 'Length');
545
- composeSimpleVisitors(res, visitors, 'Angle');
546
- composeSimpleVisitors(res, visitors, 'Ratio');
547
- composeSimpleVisitors(res, visitors, 'Resolution');
548
- composeSimpleVisitors(res, visitors, 'Time');
549
- composeSimpleVisitors(res, visitors, 'CustomIdent');
550
- composeSimpleVisitors(res, visitors, 'DashedIdent');
551
- composeArrayFunctions(res, visitors, 'MediaQuery');
552
- composeArrayFunctions(res, visitors, 'MediaQueryExit');
553
- composeSimpleVisitors(res, visitors, 'SupportsCondition');
554
- composeSimpleVisitors(res, visitors, 'SupportsConditionExit');
555
- composeArrayFunctions(res, visitors, 'Selector');
556
- composeTokenVisitors(res, visitors, 'Token', 'token', false);
557
- composeTokenVisitors(res, visitors, 'Function', 'function', false);
558
- composeTokenVisitors(res, visitors, 'FunctionExit', 'function', true);
559
- composeTokenVisitors(res, visitors, 'Variable', 'var', false);
560
- composeTokenVisitors(res, visitors, 'VariableExit', 'var', true);
561
- composeTokenVisitors(res, visitors, 'EnvironmentVariable', 'env', false);
562
- composeTokenVisitors(res, visitors, 'EnvironmentVariableExit', 'env', true);
563
- return res;
564
- }
565
-
566
- module.exports = composeVisitors;
567
-
568
- function wrapCustomAndUnknownAtRule(k, f) {
569
- if (k === 'unknown') {
570
- return (value => f({ type: 'unknown', value }));
571
- }
572
- if (k === 'custom') {
573
- return (value => f({ type: 'custom', value }));
574
- }
575
- return f;
576
- }
577
-
578
- function wrapCustomProperty(k, f) {
579
- return k === 'custom' ? (value => f({ property: 'custom', value })) : f;
580
- }
581
-
582
- /**
583
- * @param {import('./index').Visitor['Rule']} f
584
- * @param {import('./ast').Rule} item
585
- */
586
- function ruleVisitor(f, item) {
587
- if (typeof f === 'object') {
588
- if (item.type === 'unknown') {
589
- let v = f.unknown;
590
- if (typeof v === 'object') {
591
- v = v[item.value.name];
592
- }
593
- return v?.(item.value);
594
- }
595
- if (item.type === 'custom') {
596
- let v = f.custom;
597
- if (typeof v === 'object') {
598
- v = v[item.value.name];
599
- }
600
- return v?.(item.value);
601
- }
602
- return f[item.type]?.(item);
603
- }
604
- return f?.(item);
605
- }
606
-
607
- /**
608
- * @param {import('./index').Visitor['Declaration']} f
609
- * @param {import('./ast').Declaration} item
610
- */
611
- function declarationVisitor(f, item) {
612
- if (typeof f === 'object') {
613
- /** @type {string} */
614
- let name = item.property;
615
- if (item.property === 'unparsed') {
616
- name = item.value.propertyId.property;
617
- } else if (item.property === 'custom') {
618
- let v = f.custom;
619
- if (typeof v === 'object') {
620
- v = v[item.value.name];
621
- }
622
- return v?.(item.value);
623
- }
624
- return f[name]?.(item);
625
- }
626
- return f?.(item);
627
- }
628
-
629
- /**
630
- *
631
- * @param {Visitor[]} visitors
632
- * @param {string} key
633
- * @returns {[any[], boolean, Set<string>]}
634
- */
635
- function extractObjectsOrFunctions(visitors, key) {
636
- let values = [];
637
- let hasFunction = false;
638
- let allKeys = new Set();
639
- for (let visitor of visitors) {
640
- let v = visitor[key];
641
- if (v) {
642
- if (typeof v === 'function') {
643
- hasFunction = true;
644
- } else {
645
- for (let key in v) {
646
- allKeys.add(key);
647
- }
648
- }
649
- values.push(v);
650
- }
651
- }
652
- return [values, hasFunction, allKeys];
653
- }
654
-
655
- /**
656
- * @template {keyof Visitor} K
657
- * @param {Visitor} res
658
- * @param {Visitor[]} visitors
659
- * @param {K} key
660
- * @param {(visitor: Visitor[K], item: any) => any | any[] | void} apply
661
- * @param {(k: string, f: any) => any} wrapKey
662
- */
663
- function composeObjectVisitors(res, visitors, key, apply, wrapKey) {
664
- let [values, hasFunction, allKeys] = extractObjectsOrFunctions(visitors, key);
665
- if (values.length === 0) {
666
- return;
667
- }
668
-
669
- if (values.length === 1) {
670
- res[key] = values[0];
671
- return;
672
- }
673
-
674
- let f = createArrayVisitor(visitors, (visitor, item) => apply(visitor[key], item));
675
- if (hasFunction) {
676
- res[key] = f;
677
- } else {
678
- /** @type {any} */
679
- let v = {};
680
- for (let k of allKeys) {
681
- v[k] = wrapKey(k, f);
682
- }
683
- res[key] = v;
684
- }
685
- }
686
-
687
- /**
688
- * @param {Visitor} res
689
- * @param {Visitor[]} visitors
690
- * @param {string} key
691
- * @param {import('./ast').TokenOrValue['type']} type
692
- * @param {boolean} isExit
693
- */
694
- function composeTokenVisitors(res, visitors, key, type, isExit) {
695
- let [values, hasFunction, allKeys] = extractObjectsOrFunctions(visitors, key);
696
- if (values.length === 0) {
697
- return;
698
- }
699
-
700
- if (values.length === 1) {
701
- res[key] = values[0];
702
- return;
703
- }
704
-
705
- let f = createTokenVisitor(visitors, type, isExit);
706
- if (hasFunction) {
707
- res[key] = f;
708
- } else {
709
- let v = {};
710
- for (let key of allKeys) {
711
- v[key] = f;
712
- }
713
- res[key] = v;
714
- }
715
- }
716
-
717
- /**
718
- * @param {Visitor[]} visitors
719
- * @param {import('./ast').TokenOrValue['type']} type
720
- */
721
- function createTokenVisitor(visitors, type, isExit) {
722
- let v = createArrayVisitor(visitors, (visitor, /** @type {import('./ast').TokenOrValue} */ item) => {
723
- let f;
724
- switch (item.type) {
725
- case 'token':
726
- f = visitor.Token;
727
- if (typeof f === 'object') {
728
- f = f[item.value.type];
729
- }
730
- break;
731
- case 'function':
732
- f = isExit ? visitor.FunctionExit : visitor.Function;
733
- if (typeof f === 'object') {
734
- f = f[item.value.name];
735
- }
736
- break;
737
- case 'var':
738
- f = isExit ? visitor.VariableExit : visitor.Variable;
739
- break;
740
- case 'env':
741
- f = isExit ? visitor.EnvironmentVariableExit : visitor.EnvironmentVariable;
742
- if (typeof f === 'object') {
743
- let name;
744
- switch (item.value.name.type) {
745
- case 'ua':
746
- case 'unknown':
747
- name = item.value.name.value;
748
- break;
749
- case 'custom':
750
- name = item.value.name.ident;
751
- break;
752
- }
753
- f = f[name];
754
- }
755
- break;
756
- case 'color':
757
- f = visitor.Color;
758
- break;
759
- case 'url':
760
- f = visitor.Url;
761
- break;
762
- case 'length':
763
- f = visitor.Length;
764
- break;
765
- case 'angle':
766
- f = visitor.Angle;
767
- break;
768
- case 'time':
769
- f = visitor.Time;
770
- break;
771
- case 'resolution':
772
- f = visitor.Resolution;
773
- break;
774
- case 'dashed-ident':
775
- f = visitor.DashedIdent;
776
- break;
777
- }
778
-
779
- if (!f) {
780
- return;
781
- }
782
-
783
- let res = f(item.value);
784
- switch (item.type) {
785
- case 'color':
786
- case 'url':
787
- case 'length':
788
- case 'angle':
789
- case 'time':
790
- case 'resolution':
791
- case 'dashed-ident':
792
- if (Array.isArray(res)) {
793
- res = res.map(value => ({ type: item.type, value }))
794
- } else if (res) {
795
- res = { type: item.type, value: res };
796
- }
797
- break;
798
- }
799
-
800
- return res;
801
- });
802
-
803
- return value => v({ type, value });
804
- }
805
-
806
- /**
807
- * @param {Visitor[]} visitors
808
- * @param {string} key
809
- */
810
- function extractFunctions(visitors, key) {
811
- let functions = [];
812
- for (let visitor of visitors) {
813
- let f = visitor[key];
814
- if (f) {
815
- functions.push(f);
816
- }
817
- }
818
- return functions;
819
- }
820
-
821
- /**
822
- * @param {Visitor} res
823
- * @param {Visitor[]} visitors
824
- * @param {string} key
825
- */
826
- function composeSimpleVisitors(res, visitors, key) {
827
- let functions = extractFunctions(visitors, key);
828
- if (functions.length === 0) {
829
- return;
830
- }
831
-
832
- if (functions.length === 1) {
833
- res[key] = functions[0];
834
- return;
835
- }
836
-
837
- res[key] = arg => {
838
- let mutated = false;
839
- for (let f of functions) {
840
- let res = f(arg);
841
- if (res) {
842
- arg = res;
843
- mutated = true;
844
- }
845
- }
846
-
847
- return mutated ? arg : undefined;
848
- };
849
- }
850
-
851
- /**
852
- * @param {Visitor} res
853
- * @param {Visitor[]} visitors
854
- * @param {string} key
855
- */
856
- function composeArrayFunctions(res, visitors, key) {
857
- let functions = extractFunctions(visitors, key);
858
- if (functions.length === 0) {
859
- return;
860
- }
861
-
862
- if (functions.length === 1) {
863
- res[key] = functions[0];
864
- return;
865
- }
866
-
867
- res[key] = createArrayVisitor(functions, (f, item) => f(item));
868
- }
869
-
870
- /**
871
- * @template T
872
- * @template V
873
- * @param {T[]} visitors
874
- * @param {(visitor: T, item: V) => V | V[] | void} apply
875
- * @returns {(item: V) => V | V[] | void}
876
- */
877
- function createArrayVisitor(visitors, apply) {
878
- let seen = new Bitset(visitors.length);
879
- return arg => {
880
- let arr = [arg];
881
- let mutated = false;
882
- seen.clear();
883
- for (let i = 0; i < arr.length; i++) {
884
- // For each value, call all visitors. If a visitor returns a new value,
885
- // we start over, but skip the visitor that generated the value or saw
886
- // it before (to avoid cycles). This way, visitors can be composed in any order.
887
- for (let v = 0; v < visitors.length;) {
888
- if (seen.get(v)) {
889
- v++;
890
- continue;
891
- }
892
-
893
- let item = arr[i];
894
- let visitor = visitors[v];
895
- let res = apply(visitor, item);
896
- if (Array.isArray(res)) {
897
- if (res.length === 0) {
898
- arr.splice(i, 1);
899
- } else if (res.length === 1) {
900
- arr[i] = res[0];
901
- } else {
902
- arr.splice(i, 1, ...res);
903
- }
904
- mutated = true;
905
- seen.set(v);
906
- v = 0;
907
- } else if (res) {
908
- arr[i] = res;
909
- mutated = true;
910
- seen.set(v);
911
- v = 0;
912
- } else {
913
- v++;
914
- }
915
- }
916
- }
917
-
918
- if (!mutated) {
919
- return;
920
- }
921
-
922
- return arr.length === 1 ? arr[0] : arr;
923
- };
924
- }
925
-
926
- class Bitset {
927
- constructor(maxBits = 32) {
928
- this.bits = 0;
929
- this.more = maxBits > 32 ? new Uint32Array(Math.ceil((maxBits - 32) / 32)) : null;
930
- }
931
-
932
- /** @param {number} bit */
933
- get(bit) {
934
- if (bit >= 32 && this.more) {
935
- let i = Math.floor((bit - 32) / 32);
936
- let b = bit % 32;
937
- return Boolean(this.more[i] & (1 << b));
938
- } else {
939
- return Boolean(this.bits & (1 << bit));
940
- }
941
- }
942
-
943
- /** @param {number} bit */
944
- set(bit) {
945
- if (bit >= 32 && this.more) {
946
- let i = Math.floor((bit - 32) / 32);
947
- let b = bit % 32;
948
- this.more[i] |= 1 << b;
949
- } else {
950
- this.bits |= 1 << bit;
951
- }
952
- }
953
-
954
- clear() {
955
- this.bits = 0;
956
- if (this.more) {
957
- this.more.fill(0);
958
- }
959
- }
960
- }
961
-
962
-
963
- /***/ }),
964
-
965
- /***/ 459:
966
- /***/ ((__unused_webpack_module, exports) => {
967
-
968
- // This file is autogenerated by build-prefixes.js. DO NOT EDIT!
969
-
970
- exports.Features = {
971
- Nesting: 1,
972
- NotSelectorList: 2,
973
- DirSelector: 4,
974
- LangSelectorList: 8,
975
- IsSelector: 16,
976
- TextDecorationThicknessPercent: 32,
977
- MediaIntervalSyntax: 64,
978
- MediaRangeSyntax: 128,
979
- CustomMediaQueries: 256,
980
- ClampFunction: 512,
981
- ColorFunction: 1024,
982
- OklabColors: 2048,
983
- LabColors: 4096,
984
- P3Colors: 8192,
985
- HexAlphaColors: 16384,
986
- SpaceSeparatedColorNotation: 32768,
987
- FontFamilySystemUi: 65536,
988
- DoublePositionGradients: 131072,
989
- VendorPrefixes: 262144,
990
- LogicalProperties: 524288,
991
- LightDark: 1048576,
992
- Selectors: 31,
993
- MediaQueries: 448,
994
- Colors: 1113088,
995
- };
996
-
997
-
998
- /***/ }),
999
-
1000
- /***/ 6504:
1001
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1002
-
1003
- let parts = [process.platform, process.arch];
1004
- if (process.platform === 'linux') {
1005
- const { MUSL, familySync } = __webpack_require__(748);
1006
- const family = familySync();
1007
- if (family === MUSL) {
1008
- parts.push('musl');
1009
- } else if (process.arch === 'arm') {
1010
- parts.push('gnueabihf');
1011
- } else {
1012
- parts.push('gnu');
1013
- }
1014
- } else if (process.platform === 'win32') {
1015
- parts.push('msvc');
1016
- }
1017
-
1018
- if (process.env.CSS_TRANSFORMER_WASM) {
1019
- module.exports = __webpack_require__(8746);
1020
- } else {
1021
- try {
1022
- module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(`lightningcss-${parts.join('-')}`);
1023
- } catch (err) {
1024
- module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(`../lightningcss.${parts.join('-')}.node`);
1025
- }
1026
- }
1027
-
1028
- module.exports.browserslistToTargets = __webpack_require__(9602);
1029
- module.exports.composeVisitors = __webpack_require__(4007);
1030
- module.exports.Features = __webpack_require__(459).Features;
1031
-
1032
-
1033
- /***/ }),
1034
-
1035
- /***/ 8746:
1036
- /***/ ((module) => {
1037
-
1038
- module.exports = eval("require")("../pkg");
1039
-
1040
-
1041
- /***/ }),
1042
-
1043
- /***/ 7786:
1044
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1045
-
1046
- __webpack_require__.r(__webpack_exports__);
1047
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1048
- /* harmony export */ Features: () => (/* binding */ Features),
1049
- /* harmony export */ browserslistToTargets: () => (/* binding */ browserslistToTargets),
1050
- /* harmony export */ bundle: () => (/* binding */ bundle),
1051
- /* harmony export */ bundleAsync: () => (/* binding */ bundleAsync),
1052
- /* harmony export */ composeVisitors: () => (/* binding */ composeVisitors),
1053
- /* harmony export */ transform: () => (/* binding */ transform),
1054
- /* harmony export */ transformStyleAttribute: () => (/* binding */ transformStyleAttribute)
1055
- /* harmony export */ });
1056
- /* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6504);
1057
-
1058
-
1059
- const { transform, transformStyleAttribute, bundle, bundleAsync, browserslistToTargets, composeVisitors, Features } = _index_js__WEBPACK_IMPORTED_MODULE_0__;
1060
-
1061
-
1062
-
1063
- /***/ })
1064
-
1065
- };