@danielx/civet 0.6.50 → 0.6.51
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/browser.js +35 -6
- package/dist/esbuild.js +42 -9
- package/dist/main.js +35 -6
- package/dist/main.mjs +35 -6
- package/dist/rollup.js +42 -9
- package/dist/unplugin-shared.mjs +43 -9
- package/dist/unplugin.d.mts +2 -1
- package/dist/unplugin.d.ts +2 -1
- package/dist/unplugin.js +48 -10
- package/dist/unplugin.mjs +3 -1
- package/dist/vite.js +42 -9
- package/dist/webpack.js +42 -9
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -5328,8 +5328,11 @@ ${input.slice(result.pos)}
|
|
|
5328
5328
|
function TrailingDeclaration(ctx, state) {
|
|
5329
5329
|
return $EVENT(ctx, state, "TrailingDeclaration", TrailingDeclaration$0);
|
|
5330
5330
|
}
|
|
5331
|
-
var FatArrowBody$0 = $
|
|
5332
|
-
var exp =
|
|
5331
|
+
var FatArrowBody$0 = $TS($S($N(EOS), NonPipelinePostfixedExpression, $N(TrailingDeclaration), $N(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
5332
|
+
var exp = $2;
|
|
5333
|
+
if (exp.type === "ObjectExpression") {
|
|
5334
|
+
return makeLeftHandSideExpression(exp);
|
|
5335
|
+
}
|
|
5333
5336
|
return exp;
|
|
5334
5337
|
});
|
|
5335
5338
|
var FatArrowBody$1 = NoCommaBracedOrEmptyBlock;
|
|
@@ -12998,19 +13001,45 @@ ${input.slice(result.pos)}
|
|
|
12998
13001
|
};
|
|
12999
13002
|
module.prelude.push(["", [preludeVar, moduloRef, typeSuffix, " = (a, b) => (a % b + b) % b;", "\n"]]);
|
|
13000
13003
|
},
|
|
13004
|
+
Falsy(FalsyRef) {
|
|
13005
|
+
module.prelude.push(["", [{
|
|
13006
|
+
ts: true,
|
|
13007
|
+
children: ["type ", FalsyRef, " = false | 0 | '' | 0n | null | undefined;", "\n"]
|
|
13008
|
+
}]]);
|
|
13009
|
+
},
|
|
13001
13010
|
xor(xorRef) {
|
|
13011
|
+
const Falsy = module.getRef("Falsy");
|
|
13002
13012
|
const typeSuffix = {
|
|
13003
13013
|
ts: true,
|
|
13004
|
-
children: [
|
|
13014
|
+
children: [
|
|
13015
|
+
": <A, B>(a: A, b: B) => A extends ",
|
|
13016
|
+
Falsy,
|
|
13017
|
+
" ? B : B extends ",
|
|
13018
|
+
Falsy,
|
|
13019
|
+
" ? A : (false | (A & ",
|
|
13020
|
+
Falsy,
|
|
13021
|
+
" extends never ? never : B) | (B & ",
|
|
13022
|
+
Falsy,
|
|
13023
|
+
" extends never ? never : A))"
|
|
13024
|
+
]
|
|
13005
13025
|
};
|
|
13006
|
-
module.prelude.push(["", [preludeVar, xorRef, typeSuffix, " = (a, b) => a ? !b && a : b;", "\n"]]);
|
|
13026
|
+
module.prelude.push(["", [preludeVar, xorRef, typeSuffix, " = (a, b) => (a ? !b && a : b)", asAny, ";", "\n"]]);
|
|
13007
13027
|
},
|
|
13008
13028
|
xnor(xnorRef) {
|
|
13029
|
+
const Falsy = module.getRef("Falsy");
|
|
13009
13030
|
const typeSuffix = {
|
|
13010
13031
|
ts: true,
|
|
13011
|
-
children: [
|
|
13032
|
+
children: [
|
|
13033
|
+
": <A, B>(a: A, b: B) => A & ",
|
|
13034
|
+
Falsy,
|
|
13035
|
+
" extends never ? B : (true | (B extends ",
|
|
13036
|
+
Falsy,
|
|
13037
|
+
" ? never : A) | (A extends ",
|
|
13038
|
+
Falsy,
|
|
13039
|
+
" ? never : B))"
|
|
13040
|
+
]
|
|
13012
13041
|
};
|
|
13013
|
-
module.prelude.push(["", [preludeVar, xnorRef, typeSuffix, " = (a, b) => a ? b : !b || a;", "\n"]]);
|
|
13042
|
+
module.prelude.push(["", [preludeVar, xnorRef, typeSuffix, " = (a, b) => (a ? b : !b || a)", asAny, ";", "\n"]]);
|
|
13014
13043
|
},
|
|
13015
13044
|
returnSymbol(ref) {
|
|
13016
13045
|
module.prelude.push({
|
package/dist/esbuild.js
CHANGED
|
@@ -42,14 +42,46 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var import_typescript = __toESM(require("typescript"));
|
|
44
44
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
45
|
+
var import_os = __toESM(require("os"));
|
|
45
46
|
var formatHost = {
|
|
46
47
|
getCurrentDirectory: () => import_typescript.default.sys.getCurrentDirectory(),
|
|
47
48
|
getNewLine: () => import_typescript.default.sys.newLine,
|
|
48
49
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
49
50
|
};
|
|
50
51
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
51
|
-
var isCivetTranspiled = (id) => /\.civet\.(
|
|
52
|
-
var isCivetTranspiledTS = (id) => /\.civet\.
|
|
52
|
+
var isCivetTranspiled = (id) => /\.civet\.[jt]sx(\?transform)?$/.test(id);
|
|
53
|
+
var isCivetTranspiledTS = (id) => /\.civet\.tsx$/.test(id);
|
|
54
|
+
var postfixRE = /(\.[jt]sx)?[?#].*$/s;
|
|
55
|
+
var isWindows = import_os.default.platform() === "win32";
|
|
56
|
+
var windowsSlashRE = /\\/g;
|
|
57
|
+
function cleanCivetId(id) {
|
|
58
|
+
return id.replace(postfixRE, "");
|
|
59
|
+
}
|
|
60
|
+
function tryStatSync(file) {
|
|
61
|
+
try {
|
|
62
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
63
|
+
} catch {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function slash(p) {
|
|
68
|
+
return p.replace(windowsSlashRE, "/");
|
|
69
|
+
}
|
|
70
|
+
function normalizePath(id) {
|
|
71
|
+
return import_path.default.posix.normalize(isWindows ? slash(id) : id);
|
|
72
|
+
}
|
|
73
|
+
function tryFsResolve(file) {
|
|
74
|
+
const fileStat = tryStatSync(file);
|
|
75
|
+
if (fileStat?.isFile())
|
|
76
|
+
return normalizePath(file);
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
function resolveAbsolutePath(rootDir, id) {
|
|
80
|
+
const resolved = tryFsResolve(import_path.default.join(rootDir, id));
|
|
81
|
+
if (!resolved)
|
|
82
|
+
return tryFsResolve(id);
|
|
83
|
+
return resolved;
|
|
84
|
+
}
|
|
53
85
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
54
86
|
if (options.dts && options.js) {
|
|
55
87
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -62,7 +94,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
62
94
|
let fsMap = /* @__PURE__ */ new Map();
|
|
63
95
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
64
96
|
let compilerOptions;
|
|
65
|
-
let rootDir;
|
|
97
|
+
let rootDir = process.cwd();
|
|
66
98
|
return {
|
|
67
99
|
name: "unplugin-civet",
|
|
68
100
|
enforce: "pre",
|
|
@@ -162,10 +194,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
162
194
|
return null;
|
|
163
195
|
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
164
196
|
return null;
|
|
165
|
-
|
|
197
|
+
id = cleanCivetId(id);
|
|
198
|
+
const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
199
|
+
if (!absolutePath)
|
|
200
|
+
return null;
|
|
166
201
|
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
167
|
-
if (isCivetTranspiled(id))
|
|
168
|
-
return relativeId.replace(/\?transform$/, "");
|
|
169
202
|
const relativePath = relativeId + outExt;
|
|
170
203
|
return relativePath;
|
|
171
204
|
},
|
|
@@ -206,9 +239,9 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
206
239
|
if (options.dts || options.typecheck) {
|
|
207
240
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
208
241
|
fsMap.set(resolved, code);
|
|
209
|
-
const
|
|
210
|
-
if (resolved !==
|
|
211
|
-
fsMap.set(
|
|
242
|
+
const slashed = slash(resolved);
|
|
243
|
+
if (resolved !== slashed)
|
|
244
|
+
fsMap.set(slashed, code);
|
|
212
245
|
}
|
|
213
246
|
return null;
|
|
214
247
|
},
|
package/dist/main.js
CHANGED
|
@@ -5320,8 +5320,11 @@ var require_parser = __commonJS({
|
|
|
5320
5320
|
function TrailingDeclaration(ctx, state) {
|
|
5321
5321
|
return $EVENT(ctx, state, "TrailingDeclaration", TrailingDeclaration$0);
|
|
5322
5322
|
}
|
|
5323
|
-
var FatArrowBody$0 = $
|
|
5324
|
-
var exp =
|
|
5323
|
+
var FatArrowBody$0 = $TS($S($N(EOS), NonPipelinePostfixedExpression, $N(TrailingDeclaration), $N(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
5324
|
+
var exp = $2;
|
|
5325
|
+
if (exp.type === "ObjectExpression") {
|
|
5326
|
+
return makeLeftHandSideExpression(exp);
|
|
5327
|
+
}
|
|
5325
5328
|
return exp;
|
|
5326
5329
|
});
|
|
5327
5330
|
var FatArrowBody$1 = NoCommaBracedOrEmptyBlock;
|
|
@@ -12990,19 +12993,45 @@ var require_parser = __commonJS({
|
|
|
12990
12993
|
};
|
|
12991
12994
|
module2.prelude.push(["", [preludeVar, moduloRef, typeSuffix, " = (a, b) => (a % b + b) % b;", "\n"]]);
|
|
12992
12995
|
},
|
|
12996
|
+
Falsy(FalsyRef) {
|
|
12997
|
+
module2.prelude.push(["", [{
|
|
12998
|
+
ts: true,
|
|
12999
|
+
children: ["type ", FalsyRef, " = false | 0 | '' | 0n | null | undefined;", "\n"]
|
|
13000
|
+
}]]);
|
|
13001
|
+
},
|
|
12993
13002
|
xor(xorRef) {
|
|
13003
|
+
const Falsy = module2.getRef("Falsy");
|
|
12994
13004
|
const typeSuffix = {
|
|
12995
13005
|
ts: true,
|
|
12996
|
-
children: [
|
|
13006
|
+
children: [
|
|
13007
|
+
": <A, B>(a: A, b: B) => A extends ",
|
|
13008
|
+
Falsy,
|
|
13009
|
+
" ? B : B extends ",
|
|
13010
|
+
Falsy,
|
|
13011
|
+
" ? A : (false | (A & ",
|
|
13012
|
+
Falsy,
|
|
13013
|
+
" extends never ? never : B) | (B & ",
|
|
13014
|
+
Falsy,
|
|
13015
|
+
" extends never ? never : A))"
|
|
13016
|
+
]
|
|
12997
13017
|
};
|
|
12998
|
-
module2.prelude.push(["", [preludeVar, xorRef, typeSuffix, " = (a, b) => a ? !b && a : b;", "\n"]]);
|
|
13018
|
+
module2.prelude.push(["", [preludeVar, xorRef, typeSuffix, " = (a, b) => (a ? !b && a : b)", asAny, ";", "\n"]]);
|
|
12999
13019
|
},
|
|
13000
13020
|
xnor(xnorRef) {
|
|
13021
|
+
const Falsy = module2.getRef("Falsy");
|
|
13001
13022
|
const typeSuffix = {
|
|
13002
13023
|
ts: true,
|
|
13003
|
-
children: [
|
|
13024
|
+
children: [
|
|
13025
|
+
": <A, B>(a: A, b: B) => A & ",
|
|
13026
|
+
Falsy,
|
|
13027
|
+
" extends never ? B : (true | (B extends ",
|
|
13028
|
+
Falsy,
|
|
13029
|
+
" ? never : A) | (A extends ",
|
|
13030
|
+
Falsy,
|
|
13031
|
+
" ? never : B))"
|
|
13032
|
+
]
|
|
13004
13033
|
};
|
|
13005
|
-
module2.prelude.push(["", [preludeVar, xnorRef, typeSuffix, " = (a, b) => a ? b : !b || a;", "\n"]]);
|
|
13034
|
+
module2.prelude.push(["", [preludeVar, xnorRef, typeSuffix, " = (a, b) => (a ? b : !b || a)", asAny, ";", "\n"]]);
|
|
13006
13035
|
},
|
|
13007
13036
|
returnSymbol(ref) {
|
|
13008
13037
|
module2.prelude.push({
|
package/dist/main.mjs
CHANGED
|
@@ -5318,8 +5318,11 @@ var require_parser = __commonJS({
|
|
|
5318
5318
|
function TrailingDeclaration(ctx, state) {
|
|
5319
5319
|
return $EVENT(ctx, state, "TrailingDeclaration", TrailingDeclaration$0);
|
|
5320
5320
|
}
|
|
5321
|
-
var FatArrowBody$0 = $
|
|
5322
|
-
var exp =
|
|
5321
|
+
var FatArrowBody$0 = $TS($S($N(EOS), NonPipelinePostfixedExpression, $N(TrailingDeclaration), $N(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
5322
|
+
var exp = $2;
|
|
5323
|
+
if (exp.type === "ObjectExpression") {
|
|
5324
|
+
return makeLeftHandSideExpression(exp);
|
|
5325
|
+
}
|
|
5323
5326
|
return exp;
|
|
5324
5327
|
});
|
|
5325
5328
|
var FatArrowBody$1 = NoCommaBracedOrEmptyBlock;
|
|
@@ -12988,19 +12991,45 @@ var require_parser = __commonJS({
|
|
|
12988
12991
|
};
|
|
12989
12992
|
module.prelude.push(["", [preludeVar, moduloRef, typeSuffix, " = (a, b) => (a % b + b) % b;", "\n"]]);
|
|
12990
12993
|
},
|
|
12994
|
+
Falsy(FalsyRef) {
|
|
12995
|
+
module.prelude.push(["", [{
|
|
12996
|
+
ts: true,
|
|
12997
|
+
children: ["type ", FalsyRef, " = false | 0 | '' | 0n | null | undefined;", "\n"]
|
|
12998
|
+
}]]);
|
|
12999
|
+
},
|
|
12991
13000
|
xor(xorRef) {
|
|
13001
|
+
const Falsy = module.getRef("Falsy");
|
|
12992
13002
|
const typeSuffix = {
|
|
12993
13003
|
ts: true,
|
|
12994
|
-
children: [
|
|
13004
|
+
children: [
|
|
13005
|
+
": <A, B>(a: A, b: B) => A extends ",
|
|
13006
|
+
Falsy,
|
|
13007
|
+
" ? B : B extends ",
|
|
13008
|
+
Falsy,
|
|
13009
|
+
" ? A : (false | (A & ",
|
|
13010
|
+
Falsy,
|
|
13011
|
+
" extends never ? never : B) | (B & ",
|
|
13012
|
+
Falsy,
|
|
13013
|
+
" extends never ? never : A))"
|
|
13014
|
+
]
|
|
12995
13015
|
};
|
|
12996
|
-
module.prelude.push(["", [preludeVar, xorRef, typeSuffix, " = (a, b) => a ? !b && a : b;", "\n"]]);
|
|
13016
|
+
module.prelude.push(["", [preludeVar, xorRef, typeSuffix, " = (a, b) => (a ? !b && a : b)", asAny, ";", "\n"]]);
|
|
12997
13017
|
},
|
|
12998
13018
|
xnor(xnorRef) {
|
|
13019
|
+
const Falsy = module.getRef("Falsy");
|
|
12999
13020
|
const typeSuffix = {
|
|
13000
13021
|
ts: true,
|
|
13001
|
-
children: [
|
|
13022
|
+
children: [
|
|
13023
|
+
": <A, B>(a: A, b: B) => A & ",
|
|
13024
|
+
Falsy,
|
|
13025
|
+
" extends never ? B : (true | (B extends ",
|
|
13026
|
+
Falsy,
|
|
13027
|
+
" ? never : A) | (A extends ",
|
|
13028
|
+
Falsy,
|
|
13029
|
+
" ? never : B))"
|
|
13030
|
+
]
|
|
13002
13031
|
};
|
|
13003
|
-
module.prelude.push(["", [preludeVar, xnorRef, typeSuffix, " = (a, b) => a ? b : !b || a;", "\n"]]);
|
|
13032
|
+
module.prelude.push(["", [preludeVar, xnorRef, typeSuffix, " = (a, b) => (a ? b : !b || a)", asAny, ";", "\n"]]);
|
|
13004
13033
|
},
|
|
13005
13034
|
returnSymbol(ref) {
|
|
13006
13035
|
module.prelude.push({
|
package/dist/rollup.js
CHANGED
|
@@ -42,14 +42,46 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var import_typescript = __toESM(require("typescript"));
|
|
44
44
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
45
|
+
var import_os = __toESM(require("os"));
|
|
45
46
|
var formatHost = {
|
|
46
47
|
getCurrentDirectory: () => import_typescript.default.sys.getCurrentDirectory(),
|
|
47
48
|
getNewLine: () => import_typescript.default.sys.newLine,
|
|
48
49
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
49
50
|
};
|
|
50
51
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
51
|
-
var isCivetTranspiled = (id) => /\.civet\.(
|
|
52
|
-
var isCivetTranspiledTS = (id) => /\.civet\.
|
|
52
|
+
var isCivetTranspiled = (id) => /\.civet\.[jt]sx(\?transform)?$/.test(id);
|
|
53
|
+
var isCivetTranspiledTS = (id) => /\.civet\.tsx$/.test(id);
|
|
54
|
+
var postfixRE = /(\.[jt]sx)?[?#].*$/s;
|
|
55
|
+
var isWindows = import_os.default.platform() === "win32";
|
|
56
|
+
var windowsSlashRE = /\\/g;
|
|
57
|
+
function cleanCivetId(id) {
|
|
58
|
+
return id.replace(postfixRE, "");
|
|
59
|
+
}
|
|
60
|
+
function tryStatSync(file) {
|
|
61
|
+
try {
|
|
62
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
63
|
+
} catch {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function slash(p) {
|
|
68
|
+
return p.replace(windowsSlashRE, "/");
|
|
69
|
+
}
|
|
70
|
+
function normalizePath(id) {
|
|
71
|
+
return import_path.default.posix.normalize(isWindows ? slash(id) : id);
|
|
72
|
+
}
|
|
73
|
+
function tryFsResolve(file) {
|
|
74
|
+
const fileStat = tryStatSync(file);
|
|
75
|
+
if (fileStat?.isFile())
|
|
76
|
+
return normalizePath(file);
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
function resolveAbsolutePath(rootDir, id) {
|
|
80
|
+
const resolved = tryFsResolve(import_path.default.join(rootDir, id));
|
|
81
|
+
if (!resolved)
|
|
82
|
+
return tryFsResolve(id);
|
|
83
|
+
return resolved;
|
|
84
|
+
}
|
|
53
85
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
54
86
|
if (options.dts && options.js) {
|
|
55
87
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -62,7 +94,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
62
94
|
let fsMap = /* @__PURE__ */ new Map();
|
|
63
95
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
64
96
|
let compilerOptions;
|
|
65
|
-
let rootDir;
|
|
97
|
+
let rootDir = process.cwd();
|
|
66
98
|
return {
|
|
67
99
|
name: "unplugin-civet",
|
|
68
100
|
enforce: "pre",
|
|
@@ -162,10 +194,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
162
194
|
return null;
|
|
163
195
|
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
164
196
|
return null;
|
|
165
|
-
|
|
197
|
+
id = cleanCivetId(id);
|
|
198
|
+
const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
199
|
+
if (!absolutePath)
|
|
200
|
+
return null;
|
|
166
201
|
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
167
|
-
if (isCivetTranspiled(id))
|
|
168
|
-
return relativeId.replace(/\?transform$/, "");
|
|
169
202
|
const relativePath = relativeId + outExt;
|
|
170
203
|
return relativePath;
|
|
171
204
|
},
|
|
@@ -206,9 +239,9 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
206
239
|
if (options.dts || options.typecheck) {
|
|
207
240
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
208
241
|
fsMap.set(resolved, code);
|
|
209
|
-
const
|
|
210
|
-
if (resolved !==
|
|
211
|
-
fsMap.set(
|
|
242
|
+
const slashed = slash(resolved);
|
|
243
|
+
if (resolved !== slashed)
|
|
244
|
+
fsMap.set(slashed, code);
|
|
212
245
|
}
|
|
213
246
|
return null;
|
|
214
247
|
},
|
package/dist/unplugin-shared.mjs
CHANGED
|
@@ -11,14 +11,46 @@ import * as fs from "fs";
|
|
|
11
11
|
import path from "path";
|
|
12
12
|
import ts from "typescript";
|
|
13
13
|
import * as tsvfs from "@typescript/vfs";
|
|
14
|
+
import os from "os";
|
|
14
15
|
var formatHost = {
|
|
15
16
|
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
|
|
16
17
|
getNewLine: () => ts.sys.newLine,
|
|
17
18
|
getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
18
19
|
};
|
|
19
20
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
20
|
-
var isCivetTranspiled = (id) => /\.civet\.(
|
|
21
|
-
var isCivetTranspiledTS = (id) => /\.civet\.
|
|
21
|
+
var isCivetTranspiled = (id) => /\.civet\.[jt]sx(\?transform)?$/.test(id);
|
|
22
|
+
var isCivetTranspiledTS = (id) => /\.civet\.tsx$/.test(id);
|
|
23
|
+
var postfixRE = /(\.[jt]sx)?[?#].*$/s;
|
|
24
|
+
var isWindows = os.platform() === "win32";
|
|
25
|
+
var windowsSlashRE = /\\/g;
|
|
26
|
+
function cleanCivetId(id) {
|
|
27
|
+
return id.replace(postfixRE, "");
|
|
28
|
+
}
|
|
29
|
+
function tryStatSync(file) {
|
|
30
|
+
try {
|
|
31
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
32
|
+
} catch {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function slash(p) {
|
|
37
|
+
return p.replace(windowsSlashRE, "/");
|
|
38
|
+
}
|
|
39
|
+
function normalizePath(id) {
|
|
40
|
+
return path.posix.normalize(isWindows ? slash(id) : id);
|
|
41
|
+
}
|
|
42
|
+
function tryFsResolve(file) {
|
|
43
|
+
const fileStat = tryStatSync(file);
|
|
44
|
+
if (fileStat?.isFile())
|
|
45
|
+
return normalizePath(file);
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
function resolveAbsolutePath(rootDir, id) {
|
|
49
|
+
const resolved = tryFsResolve(path.join(rootDir, id));
|
|
50
|
+
if (!resolved)
|
|
51
|
+
return tryFsResolve(id);
|
|
52
|
+
return resolved;
|
|
53
|
+
}
|
|
22
54
|
var civetUnplugin = createUnplugin((options = {}) => {
|
|
23
55
|
if (options.dts && options.js) {
|
|
24
56
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -31,7 +63,7 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
31
63
|
let fsMap = /* @__PURE__ */ new Map();
|
|
32
64
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
33
65
|
let compilerOptions;
|
|
34
|
-
let rootDir;
|
|
66
|
+
let rootDir = process.cwd();
|
|
35
67
|
return {
|
|
36
68
|
name: "unplugin-civet",
|
|
37
69
|
enforce: "pre",
|
|
@@ -131,10 +163,11 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
131
163
|
return null;
|
|
132
164
|
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
133
165
|
return null;
|
|
134
|
-
|
|
166
|
+
id = cleanCivetId(id);
|
|
167
|
+
const absolutePath = path.isAbsolute(id) ? resolveAbsolutePath(rootDir, id) : path.resolve(path.dirname(importer ?? ""), id);
|
|
168
|
+
if (!absolutePath)
|
|
169
|
+
return null;
|
|
135
170
|
const relativeId = path.relative(process.cwd(), absolutePath);
|
|
136
|
-
if (isCivetTranspiled(id))
|
|
137
|
-
return relativeId.replace(/\?transform$/, "");
|
|
138
171
|
const relativePath = relativeId + outExt;
|
|
139
172
|
return relativePath;
|
|
140
173
|
},
|
|
@@ -175,9 +208,9 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
175
208
|
if (options.dts || options.typecheck) {
|
|
176
209
|
const resolved = path.resolve(process.cwd(), id);
|
|
177
210
|
fsMap.set(resolved, code);
|
|
178
|
-
const
|
|
179
|
-
if (resolved !==
|
|
180
|
-
fsMap.set(
|
|
211
|
+
const slashed = slash(resolved);
|
|
212
|
+
if (resolved !== slashed)
|
|
213
|
+
fsMap.set(slashed, code);
|
|
181
214
|
}
|
|
182
215
|
return null;
|
|
183
216
|
},
|
|
@@ -218,5 +251,6 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
218
251
|
var src_default = civetUnplugin;
|
|
219
252
|
|
|
220
253
|
export {
|
|
254
|
+
slash,
|
|
221
255
|
src_default
|
|
222
256
|
};
|
package/dist/unplugin.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ type PluginOptions = {
|
|
|
13
13
|
typecheck?: true;
|
|
14
14
|
js?: false;
|
|
15
15
|
});
|
|
16
|
+
declare function slash(p: string): string;
|
|
16
17
|
declare const civetUnplugin: unplugin.UnpluginInstance<PluginOptions, boolean>;
|
|
17
18
|
|
|
18
|
-
export { PluginOptions, civetUnplugin as default };
|
|
19
|
+
export { PluginOptions, civetUnplugin as default, slash };
|
package/dist/unplugin.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ type PluginOptions = {
|
|
|
13
13
|
typecheck?: true;
|
|
14
14
|
js?: false;
|
|
15
15
|
});
|
|
16
|
+
declare function slash(p: string): string;
|
|
16
17
|
declare const civetUnplugin: unplugin.UnpluginInstance<PluginOptions, boolean>;
|
|
17
18
|
|
|
18
|
-
export { PluginOptions, civetUnplugin as default };
|
|
19
|
+
export { PluginOptions, civetUnplugin as default, slash };
|
package/dist/unplugin.js
CHANGED
|
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
default: () => src_default
|
|
33
|
+
default: () => src_default,
|
|
34
|
+
slash: () => slash
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(src_exports);
|
|
36
37
|
var import_unplugin = require("unplugin");
|
|
@@ -40,14 +41,46 @@ var fs = __toESM(require("fs"));
|
|
|
40
41
|
var import_path = __toESM(require("path"));
|
|
41
42
|
var import_typescript = __toESM(require("typescript"));
|
|
42
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
|
+
var import_os = __toESM(require("os"));
|
|
43
45
|
var formatHost = {
|
|
44
46
|
getCurrentDirectory: () => import_typescript.default.sys.getCurrentDirectory(),
|
|
45
47
|
getNewLine: () => import_typescript.default.sys.newLine,
|
|
46
48
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
47
49
|
};
|
|
48
50
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
49
|
-
var isCivetTranspiled = (id) => /\.civet\.(
|
|
50
|
-
var isCivetTranspiledTS = (id) => /\.civet\.
|
|
51
|
+
var isCivetTranspiled = (id) => /\.civet\.[jt]sx(\?transform)?$/.test(id);
|
|
52
|
+
var isCivetTranspiledTS = (id) => /\.civet\.tsx$/.test(id);
|
|
53
|
+
var postfixRE = /(\.[jt]sx)?[?#].*$/s;
|
|
54
|
+
var isWindows = import_os.default.platform() === "win32";
|
|
55
|
+
var windowsSlashRE = /\\/g;
|
|
56
|
+
function cleanCivetId(id) {
|
|
57
|
+
return id.replace(postfixRE, "");
|
|
58
|
+
}
|
|
59
|
+
function tryStatSync(file) {
|
|
60
|
+
try {
|
|
61
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
62
|
+
} catch {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function slash(p) {
|
|
67
|
+
return p.replace(windowsSlashRE, "/");
|
|
68
|
+
}
|
|
69
|
+
function normalizePath(id) {
|
|
70
|
+
return import_path.default.posix.normalize(isWindows ? slash(id) : id);
|
|
71
|
+
}
|
|
72
|
+
function tryFsResolve(file) {
|
|
73
|
+
const fileStat = tryStatSync(file);
|
|
74
|
+
if (fileStat?.isFile())
|
|
75
|
+
return normalizePath(file);
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
function resolveAbsolutePath(rootDir, id) {
|
|
79
|
+
const resolved = tryFsResolve(import_path.default.join(rootDir, id));
|
|
80
|
+
if (!resolved)
|
|
81
|
+
return tryFsResolve(id);
|
|
82
|
+
return resolved;
|
|
83
|
+
}
|
|
51
84
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
52
85
|
if (options.dts && options.js) {
|
|
53
86
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -60,7 +93,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
60
93
|
let fsMap = /* @__PURE__ */ new Map();
|
|
61
94
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
62
95
|
let compilerOptions;
|
|
63
|
-
let rootDir;
|
|
96
|
+
let rootDir = process.cwd();
|
|
64
97
|
return {
|
|
65
98
|
name: "unplugin-civet",
|
|
66
99
|
enforce: "pre",
|
|
@@ -160,10 +193,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
160
193
|
return null;
|
|
161
194
|
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
162
195
|
return null;
|
|
163
|
-
|
|
196
|
+
id = cleanCivetId(id);
|
|
197
|
+
const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
198
|
+
if (!absolutePath)
|
|
199
|
+
return null;
|
|
164
200
|
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
165
|
-
if (isCivetTranspiled(id))
|
|
166
|
-
return relativeId.replace(/\?transform$/, "");
|
|
167
201
|
const relativePath = relativeId + outExt;
|
|
168
202
|
return relativePath;
|
|
169
203
|
},
|
|
@@ -204,9 +238,9 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
204
238
|
if (options.dts || options.typecheck) {
|
|
205
239
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
206
240
|
fsMap.set(resolved, code);
|
|
207
|
-
const
|
|
208
|
-
if (resolved !==
|
|
209
|
-
fsMap.set(
|
|
241
|
+
const slashed = slash(resolved);
|
|
242
|
+
if (resolved !== slashed)
|
|
243
|
+
fsMap.set(slashed, code);
|
|
210
244
|
}
|
|
211
245
|
return null;
|
|
212
246
|
},
|
|
@@ -245,3 +279,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
245
279
|
};
|
|
246
280
|
});
|
|
247
281
|
var src_default = civetUnplugin;
|
|
282
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
283
|
+
0 && (module.exports = {
|
|
284
|
+
slash
|
|
285
|
+
});
|
package/dist/unplugin.mjs
CHANGED
package/dist/vite.js
CHANGED
|
@@ -42,14 +42,46 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var import_typescript = __toESM(require("typescript"));
|
|
44
44
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
45
|
+
var import_os = __toESM(require("os"));
|
|
45
46
|
var formatHost = {
|
|
46
47
|
getCurrentDirectory: () => import_typescript.default.sys.getCurrentDirectory(),
|
|
47
48
|
getNewLine: () => import_typescript.default.sys.newLine,
|
|
48
49
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
49
50
|
};
|
|
50
51
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
51
|
-
var isCivetTranspiled = (id) => /\.civet\.(
|
|
52
|
-
var isCivetTranspiledTS = (id) => /\.civet\.
|
|
52
|
+
var isCivetTranspiled = (id) => /\.civet\.[jt]sx(\?transform)?$/.test(id);
|
|
53
|
+
var isCivetTranspiledTS = (id) => /\.civet\.tsx$/.test(id);
|
|
54
|
+
var postfixRE = /(\.[jt]sx)?[?#].*$/s;
|
|
55
|
+
var isWindows = import_os.default.platform() === "win32";
|
|
56
|
+
var windowsSlashRE = /\\/g;
|
|
57
|
+
function cleanCivetId(id) {
|
|
58
|
+
return id.replace(postfixRE, "");
|
|
59
|
+
}
|
|
60
|
+
function tryStatSync(file) {
|
|
61
|
+
try {
|
|
62
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
63
|
+
} catch {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function slash(p) {
|
|
68
|
+
return p.replace(windowsSlashRE, "/");
|
|
69
|
+
}
|
|
70
|
+
function normalizePath(id) {
|
|
71
|
+
return import_path.default.posix.normalize(isWindows ? slash(id) : id);
|
|
72
|
+
}
|
|
73
|
+
function tryFsResolve(file) {
|
|
74
|
+
const fileStat = tryStatSync(file);
|
|
75
|
+
if (fileStat?.isFile())
|
|
76
|
+
return normalizePath(file);
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
function resolveAbsolutePath(rootDir, id) {
|
|
80
|
+
const resolved = tryFsResolve(import_path.default.join(rootDir, id));
|
|
81
|
+
if (!resolved)
|
|
82
|
+
return tryFsResolve(id);
|
|
83
|
+
return resolved;
|
|
84
|
+
}
|
|
53
85
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
54
86
|
if (options.dts && options.js) {
|
|
55
87
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -62,7 +94,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
62
94
|
let fsMap = /* @__PURE__ */ new Map();
|
|
63
95
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
64
96
|
let compilerOptions;
|
|
65
|
-
let rootDir;
|
|
97
|
+
let rootDir = process.cwd();
|
|
66
98
|
return {
|
|
67
99
|
name: "unplugin-civet",
|
|
68
100
|
enforce: "pre",
|
|
@@ -162,10 +194,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
162
194
|
return null;
|
|
163
195
|
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
164
196
|
return null;
|
|
165
|
-
|
|
197
|
+
id = cleanCivetId(id);
|
|
198
|
+
const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
199
|
+
if (!absolutePath)
|
|
200
|
+
return null;
|
|
166
201
|
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
167
|
-
if (isCivetTranspiled(id))
|
|
168
|
-
return relativeId.replace(/\?transform$/, "");
|
|
169
202
|
const relativePath = relativeId + outExt;
|
|
170
203
|
return relativePath;
|
|
171
204
|
},
|
|
@@ -206,9 +239,9 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
206
239
|
if (options.dts || options.typecheck) {
|
|
207
240
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
208
241
|
fsMap.set(resolved, code);
|
|
209
|
-
const
|
|
210
|
-
if (resolved !==
|
|
211
|
-
fsMap.set(
|
|
242
|
+
const slashed = slash(resolved);
|
|
243
|
+
if (resolved !== slashed)
|
|
244
|
+
fsMap.set(slashed, code);
|
|
212
245
|
}
|
|
213
246
|
return null;
|
|
214
247
|
},
|
package/dist/webpack.js
CHANGED
|
@@ -42,14 +42,46 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var import_typescript = __toESM(require("typescript"));
|
|
44
44
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
45
|
+
var import_os = __toESM(require("os"));
|
|
45
46
|
var formatHost = {
|
|
46
47
|
getCurrentDirectory: () => import_typescript.default.sys.getCurrentDirectory(),
|
|
47
48
|
getNewLine: () => import_typescript.default.sys.newLine,
|
|
48
49
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
49
50
|
};
|
|
50
51
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
51
|
-
var isCivetTranspiled = (id) => /\.civet\.(
|
|
52
|
-
var isCivetTranspiledTS = (id) => /\.civet\.
|
|
52
|
+
var isCivetTranspiled = (id) => /\.civet\.[jt]sx(\?transform)?$/.test(id);
|
|
53
|
+
var isCivetTranspiledTS = (id) => /\.civet\.tsx$/.test(id);
|
|
54
|
+
var postfixRE = /(\.[jt]sx)?[?#].*$/s;
|
|
55
|
+
var isWindows = import_os.default.platform() === "win32";
|
|
56
|
+
var windowsSlashRE = /\\/g;
|
|
57
|
+
function cleanCivetId(id) {
|
|
58
|
+
return id.replace(postfixRE, "");
|
|
59
|
+
}
|
|
60
|
+
function tryStatSync(file) {
|
|
61
|
+
try {
|
|
62
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
63
|
+
} catch {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function slash(p) {
|
|
68
|
+
return p.replace(windowsSlashRE, "/");
|
|
69
|
+
}
|
|
70
|
+
function normalizePath(id) {
|
|
71
|
+
return import_path.default.posix.normalize(isWindows ? slash(id) : id);
|
|
72
|
+
}
|
|
73
|
+
function tryFsResolve(file) {
|
|
74
|
+
const fileStat = tryStatSync(file);
|
|
75
|
+
if (fileStat?.isFile())
|
|
76
|
+
return normalizePath(file);
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
function resolveAbsolutePath(rootDir, id) {
|
|
80
|
+
const resolved = tryFsResolve(import_path.default.join(rootDir, id));
|
|
81
|
+
if (!resolved)
|
|
82
|
+
return tryFsResolve(id);
|
|
83
|
+
return resolved;
|
|
84
|
+
}
|
|
53
85
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
54
86
|
if (options.dts && options.js) {
|
|
55
87
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -62,7 +94,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
62
94
|
let fsMap = /* @__PURE__ */ new Map();
|
|
63
95
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
64
96
|
let compilerOptions;
|
|
65
|
-
let rootDir;
|
|
97
|
+
let rootDir = process.cwd();
|
|
66
98
|
return {
|
|
67
99
|
name: "unplugin-civet",
|
|
68
100
|
enforce: "pre",
|
|
@@ -162,10 +194,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
162
194
|
return null;
|
|
163
195
|
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
164
196
|
return null;
|
|
165
|
-
|
|
197
|
+
id = cleanCivetId(id);
|
|
198
|
+
const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
199
|
+
if (!absolutePath)
|
|
200
|
+
return null;
|
|
166
201
|
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
167
|
-
if (isCivetTranspiled(id))
|
|
168
|
-
return relativeId.replace(/\?transform$/, "");
|
|
169
202
|
const relativePath = relativeId + outExt;
|
|
170
203
|
return relativePath;
|
|
171
204
|
},
|
|
@@ -206,9 +239,9 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
206
239
|
if (options.dts || options.typecheck) {
|
|
207
240
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
208
241
|
fsMap.set(resolved, code);
|
|
209
|
-
const
|
|
210
|
-
if (resolved !==
|
|
211
|
-
fsMap.set(
|
|
242
|
+
const slashed = slash(resolved);
|
|
243
|
+
if (resolved !== slashed)
|
|
244
|
+
fsMap.set(slashed, code);
|
|
212
245
|
}
|
|
213
246
|
return null;
|
|
214
247
|
},
|