@plumeria/compiler 8.0.1 → 8.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 (2) hide show
  1. package/dist/index.js +44 -3
  2. package/package.json +4 -3
package/dist/index.js CHANGED
@@ -1,4 +1,37 @@
1
1
  "use strict";
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
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -7,14 +40,17 @@ exports.compileCSS = compileCSS;
7
40
  const core_1 = require("@swc/core");
8
41
  const zss_engine_1 = require("zss-engine");
9
42
  const fs_1 = __importDefault(require("fs"));
43
+ const rs = __importStar(require("@rust-gear/glob"));
10
44
  const utils_1 = require("@plumeria/utils");
45
+ const utils_2 = require("@plumeria/utils");
11
46
  function compileCSS(options) {
12
47
  const { include, exclude, cwd = process.cwd() } = options;
13
48
  const allSheets = new Set();
14
- const files = fs_1.default.globSync(include, {
49
+ const files = rs.globSync(include, {
15
50
  cwd,
16
51
  exclude: exclude,
17
52
  });
53
+ const scannedTables = (0, utils_1.scanAll)();
18
54
  const processFile = (filePath) => {
19
55
  const source = fs_1.default.readFileSync(filePath, 'utf-8');
20
56
  const extractedSheets = [];
@@ -23,7 +59,10 @@ function compileCSS(options) {
23
59
  tsx: true,
24
60
  target: 'es2022',
25
61
  });
26
- const scannedTables = (0, utils_1.scanAll)();
62
+ const leadingLen = (0, utils_2.getLeadingCommentLength)(source);
63
+ const sourceBuffer = Buffer.from(source, 'utf-8');
64
+ const leadingBytes = Buffer.byteLength(source.slice(0, leadingLen), 'utf-8');
65
+ const baseByteOffset = ast.span.start - leadingBytes;
27
66
  const localConsts = (0, utils_1.collectLocalConsts)(ast);
28
67
  const resourcePath = filePath;
29
68
  const importMap = {};
@@ -298,7 +337,9 @@ function compileCSS(options) {
298
337
  }
299
338
  if (handledAsObjectArg)
300
339
  continue;
301
- const getSource = (node) => source.substring(node.span.start - ast.span.start, node.span.end - ast.span.start);
340
+ const getSource = (node) => sourceBuffer
341
+ .subarray(node.span.start - baseByteOffset, node.span.end - baseByteOffset)
342
+ .toString('utf-8');
302
343
  const collectConditions = (node, testStrings = []) => {
303
344
  const staticStyle = resolveStyleObject(node);
304
345
  if (staticStyle) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/compiler",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "Plumeria swc based compiler for statically extracting css",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -21,10 +21,11 @@
21
21
  "dist/"
22
22
  ],
23
23
  "dependencies": {
24
- "@plumeria/utils": "^8.0.1"
24
+ "@plumeria/utils": "^8.0.3"
25
25
  },
26
26
  "devDependencies": {
27
- "@swc/core": "1.15.8",
27
+ "@rust-gear/glob": "0.2.8",
28
+ "@swc/core": "1.15.18",
28
29
  "zss-engine": "2.2.4"
29
30
  },
30
31
  "publishConfig": {