@plumeria/utils 12.0.5 → 12.0.7

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 (2) hide show
  1. package/dist/parser.js +126 -99
  2. package/package.json +3 -3
package/dist/parser.js CHANGED
@@ -220,13 +220,23 @@ function objectExpressionToObject(node, staticTable, keyframesHashTable, viewTra
220
220
  function collectLocalConsts(ast) {
221
221
  const localConsts = {};
222
222
  const decls = new Map();
223
- traverse(ast, {
224
- VariableDeclarator({ node }) {
225
- if (exports.t.isIdentifier(node.id) && node.init) {
226
- decls.set(node.id.value, node.init);
223
+ for (const node of ast.body) {
224
+ let declarations = [];
225
+ if (exports.t.isVariableDeclaration(node)) {
226
+ declarations = node.declarations;
227
+ }
228
+ else if (exports.t.isExportDeclaration(node) &&
229
+ exports.t.isVariableDeclaration(node.declaration)) {
230
+ declarations = node.declaration.declarations;
231
+ }
232
+ for (const decl of declarations) {
233
+ if (exports.t.isVariableDeclarator(decl) &&
234
+ exports.t.isIdentifier(decl.id) &&
235
+ decl.init) {
236
+ decls.set(decl.id.value, decl.init);
227
237
  }
228
- },
229
- });
238
+ }
239
+ }
230
240
  const visiting = new Set();
231
241
  function resolveValue(name) {
232
242
  if (localConsts[name] !== undefined)
@@ -555,100 +565,118 @@ function scanAll() {
555
565
  createStaticObjectTable: {},
556
566
  };
557
567
  const files = rs.globSync(PATTERN_PATH, GLOB_OPTIONS);
568
+ const uncachedFiles = [];
569
+ for (const filePath of files) {
570
+ try {
571
+ const stats = fs.statSync(filePath);
572
+ const cached = fileCache[filePath];
573
+ if (cached && cached.mtimeMs === stats.mtimeMs) {
574
+ if (cached.hasCssUsage) {
575
+ for (const key of Object.keys(cached.staticTable)) {
576
+ localTables.staticTable[`${filePath}-${key}`] =
577
+ cached.staticTable[key];
578
+ }
579
+ for (const key of Object.keys(cached.keyframesHashTable)) {
580
+ localTables.keyframesHashTable[`${filePath}-${key}`] =
581
+ cached.keyframesHashTable[key];
582
+ }
583
+ for (const key of Object.keys(cached.keyframesObjectTable)) {
584
+ localTables.keyframesObjectTable[key] =
585
+ cached.keyframesObjectTable[key];
586
+ }
587
+ for (const key of Object.keys(cached.viewTransitionHashTable)) {
588
+ localTables.viewTransitionHashTable[`${filePath}-${key}`] =
589
+ cached.viewTransitionHashTable[key];
590
+ }
591
+ for (const key of Object.keys(cached.viewTransitionObjectTable)) {
592
+ localTables.viewTransitionObjectTable[key] =
593
+ cached.viewTransitionObjectTable[key];
594
+ }
595
+ for (const key of Object.keys(cached.createThemeHashTable)) {
596
+ localTables.createThemeHashTable[`${filePath}-${key}`] =
597
+ cached.createThemeHashTable[key];
598
+ }
599
+ for (const key of Object.keys(cached.createThemeObjectTable)) {
600
+ localTables.createThemeObjectTable[key] =
601
+ cached.createThemeObjectTable[key];
602
+ }
603
+ for (const key of Object.keys(cached.createStaticHashTable)) {
604
+ localTables.createStaticHashTable[`${filePath}-${key}`] =
605
+ cached.createStaticHashTable[key];
606
+ }
607
+ for (const key of Object.keys(cached.createStaticObjectTable)) {
608
+ localTables.createStaticObjectTable[key] =
609
+ cached.createStaticObjectTable[key];
610
+ }
611
+ for (const key of Object.keys(cached.createHashTable)) {
612
+ localTables.createHashTable[`${filePath}-${key}`] =
613
+ cached.createHashTable[key];
614
+ }
615
+ for (const key of Object.keys(cached.createObjectTable)) {
616
+ localTables.createObjectTable[key] = cached.createObjectTable[key];
617
+ }
618
+ for (const key of Object.keys(cached.createAtomicMapTable)) {
619
+ localTables.createAtomicMapTable[key] =
620
+ cached.createAtomicMapTable[key];
621
+ }
622
+ for (const key of Object.keys(cached.variantsHashTable)) {
623
+ localTables.variantsHashTable[`${filePath}-${key}`] =
624
+ cached.variantsHashTable[key];
625
+ }
626
+ for (const key of Object.keys(cached.variantsObjectTable)) {
627
+ localTables.variantsObjectTable[key] =
628
+ cached.variantsObjectTable[key];
629
+ }
630
+ }
631
+ }
632
+ else {
633
+ uncachedFiles.push(filePath);
634
+ }
635
+ }
636
+ catch (e) {
637
+ uncachedFiles.push(filePath);
638
+ }
639
+ }
640
+ const parsedFiles = [];
641
+ for (const filePath of uncachedFiles) {
642
+ try {
643
+ const stats = fs.statSync(filePath);
644
+ const source = fs.readFileSync(filePath, 'utf8');
645
+ if (!source.includes('@plumeria/core')) {
646
+ fileCache[filePath] = {
647
+ mtimeMs: stats.mtimeMs,
648
+ staticTable: {},
649
+ keyframesHashTable: {},
650
+ keyframesObjectTable: {},
651
+ viewTransitionHashTable: {},
652
+ viewTransitionObjectTable: {},
653
+ createThemeHashTable: {},
654
+ createThemeObjectTable: {},
655
+ createHashTable: {},
656
+ createObjectTable: {},
657
+ createAtomicMapTable: {},
658
+ variantsHashTable: {},
659
+ variantsObjectTable: {},
660
+ createStaticHashTable: {},
661
+ createStaticObjectTable: {},
662
+ hasCssUsage: false,
663
+ };
664
+ continue;
665
+ }
666
+ const ast = (0, core_1.parseSync)(source, {
667
+ syntax: 'typescript',
668
+ tsx: true,
669
+ target: 'es2022',
670
+ });
671
+ parsedFiles.push({ filePath, ast, mtimeMs: stats.mtimeMs });
672
+ }
673
+ catch (e) {
674
+ }
675
+ }
558
676
  for (let passNumber = 1; passNumber <= 2; passNumber++) {
559
677
  const isFirstPass = passNumber === 1;
560
- for (const filePath of files) {
678
+ for (const { filePath, ast, mtimeMs } of parsedFiles) {
561
679
  try {
562
- const stats = fs.statSync(filePath);
563
- const cached = fileCache[filePath];
564
- if (cached && cached.mtimeMs === stats.mtimeMs) {
565
- if (cached.hasCssUsage) {
566
- for (const key of Object.keys(cached.staticTable)) {
567
- localTables.staticTable[`${filePath}-${key}`] =
568
- cached.staticTable[key];
569
- }
570
- for (const key of Object.keys(cached.keyframesHashTable)) {
571
- localTables.keyframesHashTable[`${filePath}-${key}`] =
572
- cached.keyframesHashTable[key];
573
- }
574
- for (const key of Object.keys(cached.keyframesObjectTable)) {
575
- localTables.keyframesObjectTable[key] =
576
- cached.keyframesObjectTable[key];
577
- }
578
- for (const key of Object.keys(cached.viewTransitionHashTable)) {
579
- localTables.viewTransitionHashTable[`${filePath}-${key}`] =
580
- cached.viewTransitionHashTable[key];
581
- }
582
- for (const key of Object.keys(cached.viewTransitionObjectTable)) {
583
- localTables.viewTransitionObjectTable[key] =
584
- cached.viewTransitionObjectTable[key];
585
- }
586
- for (const key of Object.keys(cached.createThemeHashTable)) {
587
- localTables.createThemeHashTable[`${filePath}-${key}`] =
588
- cached.createThemeHashTable[key];
589
- }
590
- for (const key of Object.keys(cached.createThemeObjectTable)) {
591
- localTables.createThemeObjectTable[key] =
592
- cached.createThemeObjectTable[key];
593
- }
594
- for (const key of Object.keys(cached.createStaticHashTable)) {
595
- localTables.createStaticHashTable[`${filePath}-${key}`] =
596
- cached.createStaticHashTable[key];
597
- }
598
- for (const key of Object.keys(cached.createStaticObjectTable)) {
599
- localTables.createStaticObjectTable[key] =
600
- cached.createStaticObjectTable[key];
601
- }
602
- for (const key of Object.keys(cached.createHashTable)) {
603
- localTables.createHashTable[`${filePath}-${key}`] =
604
- cached.createHashTable[key];
605
- }
606
- for (const key of Object.keys(cached.createObjectTable)) {
607
- localTables.createObjectTable[key] =
608
- cached.createObjectTable[key];
609
- }
610
- for (const key of Object.keys(cached.createAtomicMapTable)) {
611
- localTables.createAtomicMapTable[key] =
612
- cached.createAtomicMapTable[key];
613
- }
614
- for (const key of Object.keys(cached.variantsHashTable)) {
615
- localTables.variantsHashTable[`${filePath}-${key}`] =
616
- cached.variantsHashTable[key];
617
- }
618
- for (const key of Object.keys(cached.variantsObjectTable)) {
619
- localTables.variantsObjectTable[key] =
620
- cached.variantsObjectTable[key];
621
- }
622
- }
623
- continue;
624
- }
625
- const source = fs.readFileSync(filePath, 'utf8');
626
- if (!source.includes('@plumeria/core')) {
627
- fileCache[filePath] = {
628
- mtimeMs: stats.mtimeMs,
629
- staticTable: {},
630
- keyframesHashTable: {},
631
- keyframesObjectTable: {},
632
- viewTransitionHashTable: {},
633
- viewTransitionObjectTable: {},
634
- createThemeHashTable: {},
635
- createThemeObjectTable: {},
636
- createHashTable: {},
637
- createObjectTable: {},
638
- createAtomicMapTable: {},
639
- variantsHashTable: {},
640
- variantsObjectTable: {},
641
- createStaticHashTable: {},
642
- createStaticObjectTable: {},
643
- hasCssUsage: false,
644
- };
645
- continue;
646
- }
647
- const ast = (0, core_1.parseSync)(source, {
648
- syntax: 'typescript',
649
- tsx: true,
650
- target: 'es2022',
651
- });
652
680
  const localStaticTable = {};
653
681
  const localKeyframesHashTable = {};
654
682
  const localKeyframesObjectTable = {};
@@ -749,7 +777,6 @@ function scanAll() {
749
777
  if (exports.t.isVariableDeclarator(decl) &&
750
778
  exports.t.isIdentifier(decl.id) &&
751
779
  decl.init &&
752
- exports.t.isCallExpression(decl.init) &&
753
780
  exports.t.isCallExpression(decl.init)) {
754
781
  const callee = decl.init.callee;
755
782
  let method;
@@ -859,7 +886,7 @@ function scanAll() {
859
886
  }
860
887
  if (!isFirstPass) {
861
888
  fileCache[filePath] = {
862
- mtimeMs: stats.mtimeMs,
889
+ mtimeMs: mtimeMs,
863
890
  staticTable: localStaticTable,
864
891
  keyframesHashTable: localKeyframesHashTable,
865
892
  keyframesObjectTable: localKeyframesObjectTable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/utils",
3
- "version": "12.0.5",
3
+ "version": "12.0.7",
4
4
  "description": "Plumeria Utils",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -22,9 +22,9 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@rust-gear/glob": "1.0.0",
25
- "@swc/core": "1.15.33",
25
+ "@swc/core": "1.15.40",
26
26
  "lightningcss": "^1.32.0",
27
- "postcss": "8.5.14",
27
+ "postcss": "8.5.15",
28
28
  "postcss-combine-media-query": "^2.1.0",
29
29
  "zss-engine": "2.2.8"
30
30
  },