@plumeria/utils 8.0.2 → 9.0.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/dist/create.js CHANGED
@@ -66,7 +66,11 @@ function getStyleRecords(styleRule) {
66
66
  Object.entries(style).forEach(([prop, value]) => {
67
67
  let hashSource = { [prop]: value };
68
68
  if (atRule) {
69
- hashSource = { [atRule]: { [selector]: hashSource } };
69
+ hashSource = {
70
+ [atRule]: {
71
+ [selector]: hashSource,
72
+ },
73
+ };
70
74
  }
71
75
  else {
72
76
  hashSource = { [selector]: hashSource };
package/dist/parser.js CHANGED
@@ -1,7 +1,37 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
36
  exports.t = void 0;
7
37
  exports.traverse = traverse;
@@ -12,8 +42,9 @@ exports.extractOndemandStyles = extractOndemandStyles;
12
42
  exports.deepMerge = deepMerge;
13
43
  const createTheme_1 = require("./createTheme");
14
44
  const core_1 = require("@swc/core");
15
- const path_1 = __importDefault(require("path"));
16
- const fs_1 = __importDefault(require("fs"));
45
+ const path = __importStar(require("path"));
46
+ const fs = __importStar(require("fs"));
47
+ const rs = __importStar(require("@rust-gear/glob"));
17
48
  const zss_engine_1 = require("zss-engine");
18
49
  const viewTransition_1 = require("./viewTransition");
19
50
  const create_1 = require("./create");
@@ -76,7 +107,7 @@ function traverse(node, visitor) {
76
107
  walk(node);
77
108
  }
78
109
  const PROJECT_ROOT = process.cwd().split('node_modules')[0];
79
- const PATTERN_PATH = path_1.default.join(PROJECT_ROOT, '**/*.{js,jsx,ts,tsx}');
110
+ const PATTERN_PATH = path.join(PROJECT_ROOT, '**/*.{js,jsx,ts,tsx}');
80
111
  const GLOB_OPTIONS = {
81
112
  exclude: ['**/node_modules/**', '**/dist/**', '**/build/**', '**/.next/**'],
82
113
  cwd: PROJECT_ROOT,
@@ -493,8 +524,13 @@ function resolveCreateStaticTableMemberExpression(node, createStaticHashTable, c
493
524
  }
494
525
  const fileCache = {};
495
526
  let globalAgregatedTables = null;
527
+ let lastScanTime = 0;
528
+ const CACHE_DURATION = 500;
496
529
  function scanAll() {
497
- if (process.env.NODE_ENV === 'production' && globalAgregatedTables) {
530
+ const now = Date.now();
531
+ if (globalAgregatedTables &&
532
+ (process.env.NODE_ENV === 'production' ||
533
+ now - lastScanTime < CACHE_DURATION)) {
498
534
  return globalAgregatedTables;
499
535
  }
500
536
  const localTables = {
@@ -513,12 +549,12 @@ function scanAll() {
513
549
  createStaticHashTable: {},
514
550
  createStaticObjectTable: {},
515
551
  };
516
- const files = fs_1.default.globSync(PATTERN_PATH, GLOB_OPTIONS);
552
+ const files = rs.globSync(PATTERN_PATH, GLOB_OPTIONS);
517
553
  for (let passNumber = 1; passNumber <= 2; passNumber++) {
518
554
  const isFirstPass = passNumber === 1;
519
555
  for (const filePath of files) {
520
556
  try {
521
- const stats = fs_1.default.statSync(filePath);
557
+ const stats = fs.statSync(filePath);
522
558
  const cached = fileCache[filePath];
523
559
  if (cached && cached.mtimeMs === stats.mtimeMs) {
524
560
  if (cached.hasCssUsage) {
@@ -581,7 +617,7 @@ function scanAll() {
581
617
  }
582
618
  continue;
583
619
  }
584
- const source = fs_1.default.readFileSync(filePath, 'utf8');
620
+ const source = fs.readFileSync(filePath, 'utf8');
585
621
  if (!source.includes('@plumeria/core')) {
586
622
  fileCache[filePath] = {
587
623
  mtimeMs: stats.mtimeMs,
@@ -714,7 +750,7 @@ function scanAll() {
714
750
  const objectName = callee.object.value;
715
751
  const propertyName = callee.property.value;
716
752
  const alias = plumeriaAliases[objectName];
717
- if (alias === 'NAMESPACE' || objectName === 'css') {
753
+ if (alias === 'NAMESPACE') {
718
754
  method = propertyName;
719
755
  }
720
756
  }
@@ -845,9 +881,8 @@ function scanAll() {
845
881
  }
846
882
  }
847
883
  }
848
- if (process.env.NODE_ENV === 'production') {
849
- globalAgregatedTables = localTables;
850
- }
884
+ globalAgregatedTables = localTables;
885
+ lastScanTime = now;
851
886
  return localTables;
852
887
  }
853
888
  function extractOndemandStyles(obj, extractedSheets, t) {
package/dist/resolver.js CHANGED
@@ -1,11 +1,41 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
36
  exports.resolveImportPath = resolveImportPath;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
9
39
  const tsConfigCache = new Map();
10
40
  const tsConfigPathCache = new Map();
11
41
  function getTsConfig(startDir) {
@@ -16,12 +46,12 @@ function getTsConfig(startDir) {
16
46
  return null;
17
47
  return {
18
48
  config: tsConfigCache.get(cachedPath) ?? null,
19
- basePath: path_1.default.dirname(cachedPath),
49
+ basePath: path.dirname(cachedPath),
20
50
  };
21
51
  }
22
- while (currentDir !== path_1.default.parse(currentDir).root) {
23
- const tsConfigPath = path_1.default.join(process.cwd(), 'tsconfig.json');
24
- if (fs_1.default.existsSync(tsConfigPath)) {
52
+ while (currentDir !== path.parse(currentDir).root) {
53
+ const tsConfigPath = path.join(process.cwd(), 'tsconfig.json');
54
+ if (fs.existsSync(tsConfigPath)) {
25
55
  if (!tsConfigCache.has(tsConfigPath)) {
26
56
  try {
27
57
  const config = require(tsConfigPath);
@@ -34,10 +64,10 @@ function getTsConfig(startDir) {
34
64
  tsConfigPathCache.set(startDir, tsConfigPath);
35
65
  return {
36
66
  config: tsConfigCache.get(tsConfigPath) ?? null,
37
- basePath: path_1.default.dirname(tsConfigPath),
67
+ basePath: path.dirname(tsConfigPath),
38
68
  };
39
69
  }
40
- currentDir = path_1.default.dirname(currentDir);
70
+ currentDir = path.dirname(currentDir);
41
71
  }
42
72
  tsConfigPathCache.set(startDir, null);
43
73
  return null;
@@ -53,20 +83,20 @@ const extensions = [
53
83
  '/index.jsx',
54
84
  ];
55
85
  function resolveWithExtension(basePath) {
56
- if (fs_1.default.existsSync(basePath) && fs_1.default.statSync(basePath).isFile())
86
+ if (fs.existsSync(basePath) && fs.statSync(basePath).isFile())
57
87
  return basePath;
58
88
  for (const ext of extensions) {
59
89
  const fullPath = basePath + ext;
60
- if (fs_1.default.existsSync(fullPath) && fs_1.default.statSync(fullPath).isFile())
90
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile())
61
91
  return fullPath;
62
92
  }
63
93
  return null;
64
94
  }
65
95
  function resolveImportPath(importPath, importerPath) {
66
96
  if (importPath.startsWith('.')) {
67
- return resolveWithExtension(path_1.default.resolve(path_1.default.dirname(importerPath), importPath));
97
+ return resolveWithExtension(path.resolve(path.dirname(importerPath), importPath));
68
98
  }
69
- const tsConfig = getTsConfig(path_1.default.dirname(importerPath));
99
+ const tsConfig = getTsConfig(path.dirname(importerPath));
70
100
  const config = tsConfig?.config;
71
101
  if (config?.paths) {
72
102
  const root = tsConfig.basePath;
@@ -75,7 +105,7 @@ function resolveImportPath(importPath, importerPath) {
75
105
  if (importPath.startsWith(prefix)) {
76
106
  for (const target of targets) {
77
107
  const resolvedTarget = target.replace(/\*$/, '');
78
- const candidate = path_1.default.resolve(root, resolvedTarget + importPath.slice(prefix.length));
108
+ const candidate = path.resolve(root, resolvedTarget + importPath.slice(prefix.length));
79
109
  const result = resolveWithExtension(candidate);
80
110
  if (result)
81
111
  return result;
@@ -83,12 +113,12 @@ function resolveImportPath(importPath, importerPath) {
83
113
  }
84
114
  }
85
115
  }
86
- let currentDir = path_1.default.dirname(importerPath);
87
- while (currentDir !== path_1.default.parse(currentDir).root) {
88
- if (fs_1.default.existsSync(path_1.default.join(currentDir, 'package.json'))) {
89
- return resolveWithExtension(path_1.default.resolve(currentDir, importPath));
116
+ let currentDir = path.dirname(importerPath);
117
+ while (currentDir !== path.parse(currentDir).root) {
118
+ if (fs.existsSync(path.join(currentDir, 'package.json'))) {
119
+ return resolveWithExtension(path.resolve(currentDir, importPath));
90
120
  }
91
- currentDir = path_1.default.dirname(currentDir);
121
+ currentDir = path.dirname(currentDir);
92
122
  }
93
123
  return null;
94
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/utils",
3
- "version": "8.0.2",
3
+ "version": "9.0.0",
4
4
  "description": "Plumeria Utils",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -21,11 +21,12 @@
21
21
  "dist/"
22
22
  ],
23
23
  "dependencies": {
24
- "@swc/core": "1.15.8",
25
- "zss-engine": "2.2.4",
24
+ "@rust-gear/glob": "0.2.8",
25
+ "@swc/core": "1.15.18",
26
+ "lightningcss": "^1.30.2",
26
27
  "postcss": "8.5.6",
27
28
  "postcss-combine-media-query": "^2.1.0",
28
- "lightningcss": "^1.30.2"
29
+ "zss-engine": "2.2.4"
29
30
  },
30
31
  "publishConfig": {
31
32
  "access": "public",