vite-plugin-qingkuai 1.0.5 → 1.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.
- package/dist/index.cjs +3 -14
- package/dist/index.js +3 -14
- package/dist/temp-type/sourcemap.d.ts +0 -2
- package/package.json +2 -3
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var node_path = require('node:path');
|
|
4
4
|
var node_fs = require('node:fs');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
|
-
var sourceMapJs = require('source-map-js');
|
|
7
6
|
var sourcemapCodec = require('@jridgewell/sourcemap-codec');
|
|
8
7
|
var compiler = require('qingkuai/compiler');
|
|
9
8
|
var postcss = require('postcss');
|
|
@@ -42,24 +41,13 @@ function offsetSourceMap(mappings, sourceIndex, preLine, preColumn) {
|
|
|
42
41
|
});
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
|
-
function getSourceFile(sourcemap, line, column) {
|
|
46
|
-
const consumer = new sourceMapJs.SourceMapConsumer({
|
|
47
|
-
...sourcemap,
|
|
48
|
-
version: sourcemap.version.toString()
|
|
49
|
-
});
|
|
50
|
-
return consumer.originalPositionFor({
|
|
51
|
-
line,
|
|
52
|
-
column
|
|
53
|
-
}).source;
|
|
54
|
-
}
|
|
55
44
|
|
|
56
45
|
async function attachScopeForStyleSelectors(code, hash, sourceFile, map) {
|
|
57
46
|
const processor = postcss([
|
|
58
47
|
{
|
|
59
48
|
postcssPlugin: "postcss-attach-scope-qingkuai",
|
|
60
49
|
Rule(rule) {
|
|
61
|
-
|
|
62
|
-
if (map && getSourceFile(map, line, column) !== sourceFile) {
|
|
50
|
+
if (rule.parent && "name" in rule?.parent && rule.parent.name === "keyframes") {
|
|
63
51
|
return;
|
|
64
52
|
}
|
|
65
53
|
rule.selector = selectorParser((selectors) => {
|
|
@@ -129,7 +117,7 @@ function qingkuaiPlugin() {
|
|
|
129
117
|
}
|
|
130
118
|
if (importer?.endsWith(".qk") && !node_path.extname(id)) {
|
|
131
119
|
const qingkuaiConfig = getQingkuaiConfiguration(id);
|
|
132
|
-
return id + (qingkuaiConfig.resolveImportExtension ? ".qk" : "");
|
|
120
|
+
return node_path.join(node_path.dirname(importer), id + (qingkuaiConfig.resolveImportExtension ? ".qk" : ""));
|
|
133
121
|
}
|
|
134
122
|
},
|
|
135
123
|
async load(id) {
|
|
@@ -175,6 +163,7 @@ function qingkuaiPlugin() {
|
|
|
175
163
|
style.loc.start.column - 1
|
|
176
164
|
)
|
|
177
165
|
);
|
|
166
|
+
console.log(attachScopeResult.code);
|
|
178
167
|
return {
|
|
179
168
|
code: attachScopeResult.code,
|
|
180
169
|
map: {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { join, basename, extname, dirname } from 'node:path';
|
|
2
2
|
import { readdirSync, existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { randomBytes } from 'node:crypto';
|
|
4
|
-
import { SourceMapConsumer } from 'source-map-js';
|
|
5
4
|
import { decode, encode } from '@jridgewell/sourcemap-codec';
|
|
6
5
|
import { compile, util } from 'qingkuai/compiler';
|
|
7
6
|
import postcss from 'postcss';
|
|
@@ -40,24 +39,13 @@ function offsetSourceMap(mappings, sourceIndex, preLine, preColumn) {
|
|
|
40
39
|
});
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
|
-
function getSourceFile(sourcemap, line, column) {
|
|
44
|
-
const consumer = new SourceMapConsumer({
|
|
45
|
-
...sourcemap,
|
|
46
|
-
version: sourcemap.version.toString()
|
|
47
|
-
});
|
|
48
|
-
return consumer.originalPositionFor({
|
|
49
|
-
line,
|
|
50
|
-
column
|
|
51
|
-
}).source;
|
|
52
|
-
}
|
|
53
42
|
|
|
54
43
|
async function attachScopeForStyleSelectors(code, hash, sourceFile, map) {
|
|
55
44
|
const processor = postcss([
|
|
56
45
|
{
|
|
57
46
|
postcssPlugin: "postcss-attach-scope-qingkuai",
|
|
58
47
|
Rule(rule) {
|
|
59
|
-
|
|
60
|
-
if (map && getSourceFile(map, line, column) !== sourceFile) {
|
|
48
|
+
if (rule.parent && "name" in rule?.parent && rule.parent.name === "keyframes") {
|
|
61
49
|
return;
|
|
62
50
|
}
|
|
63
51
|
rule.selector = selectorParser((selectors) => {
|
|
@@ -127,7 +115,7 @@ function qingkuaiPlugin() {
|
|
|
127
115
|
}
|
|
128
116
|
if (importer?.endsWith(".qk") && !extname(id)) {
|
|
129
117
|
const qingkuaiConfig = getQingkuaiConfiguration(id);
|
|
130
|
-
return id + (qingkuaiConfig.resolveImportExtension ? ".qk" : "");
|
|
118
|
+
return join(dirname(importer), id + (qingkuaiConfig.resolveImportExtension ? ".qk" : ""));
|
|
131
119
|
}
|
|
132
120
|
},
|
|
133
121
|
async load(id) {
|
|
@@ -173,6 +161,7 @@ function qingkuaiPlugin() {
|
|
|
173
161
|
style.loc.start.column - 1
|
|
174
162
|
)
|
|
175
163
|
);
|
|
164
|
+
console.log(attachScopeResult.code);
|
|
176
165
|
return {
|
|
177
166
|
code: attachScopeResult.code,
|
|
178
167
|
map: {
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import type { SourceMap } from "./types";
|
|
2
1
|
import type { SourceMapMappings } from "@jridgewell/sourcemap-codec";
|
|
3
2
|
export declare function offsetSourceMap(mappings: string, sourceIndex: number, preLine: number, preColumn: number): SourceMapMappings;
|
|
4
|
-
export declare function getSourceFile(sourcemap: SourceMap, line: number, column: number): string;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "vite-plugin-qingkuai",
|
|
3
3
|
"author": "mlgq",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.7",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"vite",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@jridgewell/sourcemap-codec": "^1.5.0",
|
|
41
41
|
"postcss": "^8.5.3",
|
|
42
|
-
"postcss-selector-parser": "^7.1.0"
|
|
43
|
-
"source-map-js": "^1.2.1"
|
|
42
|
+
"postcss-selector-parser": "^7.1.0"
|
|
44
43
|
}
|
|
45
44
|
}
|