@rohal12/twee-ts 1.15.4 → 1.16.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/bin/twee-ts.js +45 -8
- package/dist/bin/twee-ts.js.map +1 -1
- package/dist/{compiler-D3V_svy2.js → compiler-BiDNwR9q.js} +21 -5
- package/dist/compiler-BiDNwR9q.js.map +1 -0
- package/dist/index.cjs +60 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +38 -8
- package/dist/index.js.map +1 -1
- package/dist/plugins/rollup.d.ts +1 -1
- package/dist/plugins/rollup.js +1 -1
- package/dist/plugins/vite.d.ts +1 -1
- package/dist/plugins/vite.js +25 -17
- package/dist/plugins/vite.js.map +1 -1
- package/dist/{types-BFyb40Zq.d.ts → types-dR5vTVu2.d.ts} +5 -0
- package/package.json +1 -1
- package/schemas/twee-ts.config.schema.json +5 -0
- package/dist/compiler-D3V_svy2.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
2
24
|
let node_fs = require("node:fs");
|
|
3
|
-
let node_crypto = require("node:crypto");
|
|
4
25
|
let node_path = require("node:path");
|
|
26
|
+
node_path = __toESM(node_path, 1);
|
|
27
|
+
let node_crypto = require("node:crypto");
|
|
5
28
|
let node_os = require("node:os");
|
|
6
29
|
let node_url = require("node:url");
|
|
7
30
|
//#region src/ifid.ts
|
|
@@ -632,11 +655,25 @@ function fontFormatHint(ext) {
|
|
|
632
655
|
* Ported from filesystem.go.
|
|
633
656
|
*/
|
|
634
657
|
/**
|
|
658
|
+
* Whether `filename` matches one of the `exclude` globs. The globs are matched
|
|
659
|
+
* against the file's path relative to the working directory, the path
|
|
660
|
+
* getFilenames reports; an absolute `filename` is made relative first. A leading
|
|
661
|
+
* `./` in a glob is dropped. Matching is Node's `path.matchesGlob`.
|
|
662
|
+
*/
|
|
663
|
+
function isExcluded(filename, exclude) {
|
|
664
|
+
if (exclude.length === 0) return false;
|
|
665
|
+
const { matchesGlob } = node_path;
|
|
666
|
+
if (typeof matchesGlob !== "function") throw new Error(`The exclude option needs Node.js 22.5 or newer (found ${process.version}).`);
|
|
667
|
+
const rel = (0, node_path.relative)(process.cwd(), (0, node_path.resolve)(filename)) || filename;
|
|
668
|
+
return exclude.some((pattern) => matchesGlob(rel, pattern.replace(/^\.\//, "")));
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
635
671
|
* Recursively walk directories, collecting regular file paths.
|
|
636
|
-
* Filters out the output file to prevent circular compilation
|
|
672
|
+
* Filters out the output file to prevent circular compilation, and the files
|
|
673
|
+
* that match an `exclude` glob (see isExcluded).
|
|
637
674
|
* Like Tweego, a path that cannot be read is reported as a warning and skipped.
|
|
638
675
|
*/
|
|
639
|
-
function getFilenames(pathnames, outFilename) {
|
|
676
|
+
function getFilenames(pathnames, outFilename, exclude = []) {
|
|
640
677
|
const filenames = [];
|
|
641
678
|
const diagnostics = [];
|
|
642
679
|
const absOutFile = outFilename ? (0, node_path.resolve)(outFilename) : "";
|
|
@@ -658,6 +695,7 @@ function getFilenames(pathnames, outFilename) {
|
|
|
658
695
|
const abs = (0, node_path.resolve)(pathname);
|
|
659
696
|
if (abs === absOutFile) return;
|
|
660
697
|
const rel = (0, node_path.relative)(process.cwd(), abs);
|
|
698
|
+
if (isExcluded(rel || abs, exclude)) return;
|
|
661
699
|
filenames.push(rel || abs);
|
|
662
700
|
} else if (stat.isDirectory()) {
|
|
663
701
|
let entries;
|
|
@@ -678,9 +716,11 @@ function getFilenames(pathnames, outFilename) {
|
|
|
678
716
|
}
|
|
679
717
|
/**
|
|
680
718
|
* Watch paths for changes, calling the build callback on known file type changes.
|
|
719
|
+
* A change to a file `ignore` returns true for (given the path relative to the
|
|
720
|
+
* working directory) schedules no build.
|
|
681
721
|
* Uses debouncing to avoid rapid rebuilds.
|
|
682
722
|
*/
|
|
683
|
-
function watchFilesystem(pathnames, outFilename, callback) {
|
|
723
|
+
function watchFilesystem(pathnames, outFilename, callback, ignore = () => false) {
|
|
684
724
|
const absOutFile = (0, node_path.resolve)(outFilename);
|
|
685
725
|
const watchers = [];
|
|
686
726
|
let buildTimer = null;
|
|
@@ -701,7 +741,10 @@ function watchFilesystem(pathnames, outFilename, callback) {
|
|
|
701
741
|
if (!filename) return;
|
|
702
742
|
const abs = (0, node_path.resolve)(pathname, filename);
|
|
703
743
|
if (abs === absOutFile) return;
|
|
704
|
-
if (isKnownFileType(filename))
|
|
744
|
+
if (isKnownFileType(filename)) {
|
|
745
|
+
const rel = (0, node_path.relative)(process.cwd(), abs);
|
|
746
|
+
if (!ignore(rel || abs)) scheduleBuild(rel || abs);
|
|
747
|
+
}
|
|
705
748
|
});
|
|
706
749
|
watchers.push(watcher);
|
|
707
750
|
} catch {}
|
|
@@ -5172,14 +5215,22 @@ async function watch(options) {
|
|
|
5172
5215
|
const cache = /* @__PURE__ */ new Map();
|
|
5173
5216
|
const filePaths = options.sources.filter((s) => typeof s === "string");
|
|
5174
5217
|
const modulePaths = options.modules ?? [];
|
|
5175
|
-
const
|
|
5218
|
+
const allPaths = [...filePaths, ...modulePaths];
|
|
5219
|
+
const exclude = options.exclude ?? [];
|
|
5220
|
+
const moduleRoots = modulePaths.map((p) => (0, node_path.resolve)(p));
|
|
5221
|
+
const ignore = (filename) => {
|
|
5222
|
+
if (!isExcluded(filename, exclude)) return false;
|
|
5223
|
+
const abs = (0, node_path.resolve)(filename);
|
|
5224
|
+
return !moduleRoots.some((root) => abs === root || abs.startsWith(root + node_path.sep));
|
|
5225
|
+
};
|
|
5226
|
+
const handle = watchFilesystem(allPaths, options.outFile, (changedFiles) => {
|
|
5176
5227
|
buildOutput(options, cache, changedFiles).then((result) => {
|
|
5177
5228
|
(0, node_fs.writeFileSync)(options.outFile, result.output, "utf-8");
|
|
5178
5229
|
options.onBuild?.(result);
|
|
5179
5230
|
}).catch((e) => {
|
|
5180
5231
|
options.onError?.(e instanceof Error ? e : new Error(String(e)));
|
|
5181
5232
|
});
|
|
5182
|
-
});
|
|
5233
|
+
}, ignore);
|
|
5183
5234
|
controller.signal.addEventListener("abort", () => handle.close());
|
|
5184
5235
|
return controller;
|
|
5185
5236
|
}
|
|
@@ -5196,7 +5247,7 @@ async function buildOutput(options, cache, changedFiles) {
|
|
|
5196
5247
|
const inlineSources = [];
|
|
5197
5248
|
for (const source of options.sources) if (typeof source === "string") filePaths.push(source);
|
|
5198
5249
|
else inlineSources.push(source);
|
|
5199
|
-
const { filenames: sourceFilenames, diagnostics: sourcePathDiagnostics } = getFilenames(filePaths);
|
|
5250
|
+
const { filenames: sourceFilenames, diagnostics: sourcePathDiagnostics } = getFilenames(filePaths, void 0, options.exclude);
|
|
5200
5251
|
diagnostics.push(...sourcePathDiagnostics);
|
|
5201
5252
|
const story = createStory();
|
|
5202
5253
|
const processedFiles = /* @__PURE__ */ new Set();
|
|
@@ -6721,6 +6772,7 @@ function validateConfig(data) {
|
|
|
6721
6772
|
]) if (key in obj && typeof obj[key] !== "boolean") errors.push(`"${key}" must be a boolean.`);
|
|
6722
6773
|
for (const key of [
|
|
6723
6774
|
"sources",
|
|
6775
|
+
"exclude",
|
|
6724
6776
|
"formatPaths",
|
|
6725
6777
|
"formatIndices",
|
|
6726
6778
|
"formatUrls",
|