@kitschpatrol/unplugin-tldraw 1.1.0 → 1.1.2

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/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as Options, r as resolveOptions, t as ImportOverrides } from "./options-CZOXoH7Y.js";
1
+ import { n as Options, r as resolveOptions, t as ImportOverrides } from "./options-D2_OB7_C.js";
2
2
 
3
3
  //#region src/core/tldraw.d.ts
4
4
  declare class TldrawExport {
package/dist/api.js CHANGED
@@ -1,2 +1,2 @@
1
- import { r as resolveOptions, t as TldrawExport } from "./tldraw-D1GC-f9x.js";
1
+ import { r as resolveOptions, t as TldrawExport } from "./tldraw--EsjzXjm.js";
2
2
  export { TldrawExport, resolveOptions };
package/dist/bun.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$unplugin from "unplugin";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
 
4
3
  //#region src/bun.d.ts
5
4
  /**
@@ -7,6 +6,6 @@ import * as _$unplugin from "unplugin";
7
6
  *
8
7
  * @module
9
8
  */
10
- declare const _default: _$unplugin.UnpluginFactory<Options | undefined, boolean>;
9
+ declare const _default: import("unplugin").UnpluginFactory<Options | undefined, boolean>;
11
10
  //#endregion
12
11
  export { _default as default };
package/dist/esbuild.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$esbuild from "esbuild";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
 
4
3
  //#region src/esbuild.d.ts
5
4
  /**
@@ -16,6 +15,6 @@ import * as _$esbuild from "esbuild";
16
15
  *
17
16
  * build({ plugins: [tldraw()] })
18
17
  */
19
- declare const _default: (options?: Options | undefined) => _$esbuild.Plugin;
18
+ declare const _default: (options?: Options | undefined) => import("esbuild").Plugin;
20
19
  //#endregion
21
20
  export { _default as default };
package/dist/farm.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$_farmfe_core0 from "@farmfe/core";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
 
4
3
  //#region src/farm.d.ts
5
4
  /**
@@ -18,6 +17,6 @@ import * as _$_farmfe_core0 from "@farmfe/core";
18
17
  * plugins: [tldraw()],
19
18
  * }
20
19
  */
21
- declare const _default: (options?: Options | undefined) => _$_farmfe_core0.JsPlugin;
20
+ declare const _default: (options?: Options | undefined) => import("@farmfe/core").JsPlugin;
22
21
  //#endregion
23
22
  export { _default as default };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$unplugin from "unplugin";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
  import { UnpluginFactory } from "unplugin";
4
3
 
5
4
  //#region src/index.d.ts
6
5
  declare const unpluginFactory: UnpluginFactory<Options | undefined>;
7
- declare const unplugin: _$unplugin.UnpluginInstance<Options | undefined, boolean>;
6
+ declare const unplugin: import("unplugin").UnpluginInstance<Options | undefined, boolean>;
8
7
  //#endregion
9
8
  export { unplugin as default, unplugin, unpluginFactory };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as parseImportOverrides, t as TldrawExport } from "./tldraw-D1GC-f9x.js";
1
+ import { n as parseImportOverrides, t as TldrawExport } from "./tldraw--EsjzXjm.js";
2
2
  import path from "node:path";
3
3
  import { createUnplugin } from "unplugin";
4
4
  //#region src/index.ts
@@ -19,8 +19,8 @@ const unpluginFactory = (options) => {
19
19
  const queryIndex = id.indexOf("?");
20
20
  const cleanId = queryIndex === -1 ? id : id.slice(0, queryIndex);
21
21
  const queryString = queryIndex === -1 ? "" : id.slice(queryIndex + 1);
22
- const resolvedPath = importer && (cleanId.startsWith("./") || cleanId.startsWith("../")) ? path.resolve(path.dirname(importer), cleanId) : cleanId;
23
- const overrides = queryString ? parseImportOverrides(queryString) : void 0;
22
+ const resolvedPath = importer !== void 0 && importer !== "" && (cleanId.startsWith("./") || cleanId.startsWith("../")) ? path.resolve(path.dirname(importer), cleanId) : cleanId;
23
+ const overrides = queryString === "" ? void 0 : parseImportOverrides(queryString);
24
24
  return tldrawExport.convert(resolvedPath, overrides);
25
25
  }
26
26
  },
@@ -29,6 +29,6 @@ const unpluginFactory = (options) => {
29
29
  }
30
30
  };
31
31
  };
32
- const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
32
+ const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);
33
33
  //#endregion
34
34
  export { unplugin as default, unplugin, unpluginFactory };
package/dist/nuxt.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$_nuxt_schema0 from "@nuxt/schema";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
 
4
3
  //#region src/nuxt.d.ts
5
4
  type ModuleOptions = Options;
@@ -12,6 +11,6 @@ type ModuleOptions = Options;
12
11
  * modules: ['@kitschpatrol/unplugin-tldraw/nuxt'],
13
12
  * })
14
13
  */
15
- declare const _default: _$_nuxt_schema0.NuxtModule<Options, Options, false>;
14
+ declare const _default: import("@nuxt/schema").NuxtModule<Options, Options, false>;
16
15
  //#endregion
17
16
  export { ModuleOptions, _default as default };
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$rolldown from "rolldown";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
 
4
3
  //#region src/rolldown.d.ts
5
4
  /**
@@ -18,6 +17,6 @@ import * as _$rolldown from "rolldown";
18
17
  * plugins: [tldraw()],
19
18
  * }
20
19
  */
21
- declare const _default: (options?: Options | undefined) => _$rolldown.Plugin<any> | _$rolldown.Plugin<any>[];
20
+ declare const _default: (options?: Options | undefined) => import("rolldown").Plugin<any> | import("rolldown").Plugin<any>[];
22
21
  //#endregion
23
22
  export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$rollup from "rollup";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
 
4
3
  //#region src/rollup.d.ts
5
4
  /**
@@ -18,6 +17,6 @@ import * as _$rollup from "rollup";
18
17
  * plugins: [tldraw()],
19
18
  * }
20
19
  */
21
- declare const _default: (options?: Options | undefined) => _$rollup.Plugin<any> | _$rollup.Plugin<any>[];
20
+ declare const _default: (options?: Options | undefined) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
22
21
  //#endregion
23
22
  export { _default as default };
package/dist/rspack.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$unplugin from "unplugin";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
 
4
3
  //#region src/rspack.d.ts
5
4
  /**
@@ -18,6 +17,6 @@ import * as _$unplugin from "unplugin";
18
17
  * plugins: [tldraw()],
19
18
  * }
20
19
  */
21
- declare const _default: (options?: Options | undefined) => _$unplugin.RspackPluginInstance;
20
+ declare const _default: (options?: Options | undefined) => import("unplugin").RspackPluginInstance;
22
21
  //#endregion
23
22
  export { _default as default };
@@ -38,39 +38,39 @@ function resolveOptions(options) {
38
38
  function parseImportOverrides(queryString) {
39
39
  const params = new URLSearchParams(queryString);
40
40
  const overrides = {};
41
- for (const [key, value] of params.entries()) {
42
- if (key === "tldr" || key === "tldraw") continue;
43
- switch (key) {
44
- case "dark":
45
- case "stripStyle":
46
- case "transparent":
47
- if (value === "true" || value === "") overrides[key] = true;
48
- else if (value === "false") overrides[key] = false;
49
- else log.warn(`Ignoring invalid value for "${key}": "${value}". Expected "true" or "false".`);
50
- break;
51
- case "format":
52
- overrides.format = value;
53
- break;
54
- case "frame":
55
- case "page":
56
- overrides[key] = value;
57
- break;
58
- case "padding":
59
- case "scale": {
60
- const numberValue = Number(value);
61
- if (!Number.isNaN(numberValue)) overrides[key] = numberValue;
62
- break;
63
- }
64
- default: break;
41
+ for (const [key, value] of params) applyOverride(overrides, key, value);
42
+ return overrides;
43
+ }
44
+ function applyOverride(overrides, key, value) {
45
+ switch (key) {
46
+ case "dark":
47
+ case "stripStyle":
48
+ case "transparent":
49
+ if (value === "true" || value === "") overrides[key] = true;
50
+ else if (value === "false") overrides[key] = false;
51
+ else log.warn(`Ignoring invalid value for "${key}": "${value}". Expected "true" or "false".`);
52
+ break;
53
+ case "format":
54
+ overrides.format = value;
55
+ break;
56
+ case "frame":
57
+ case "page":
58
+ overrides[key] = value;
59
+ break;
60
+ case "padding":
61
+ case "scale": {
62
+ const numberValue = Number(value);
63
+ if (!Number.isNaN(numberValue)) overrides[key] = numberValue;
64
+ break;
65
65
  }
66
+ default: break;
66
67
  }
67
- return overrides;
68
68
  }
69
69
  //#endregion
70
70
  //#region src/core/tldraw.ts
71
71
  const CACHE_FILE_NAME = ".tldraw-plugin-cache.json";
72
- const TLDR_EXTENSION_REGEX = /\.tldr(?:\?|$)/;
73
- const CACHE_HASH_REGEX = /-([a-f\d]{8})\.[^.]+$/;
72
+ const TLDR_EXTENSION_REGEX = /\.tldr(?:\?|$)/v;
73
+ const CACHE_HASH_REGEX = /-([a-f\d]{8})\.[^.]+$/v;
74
74
  var TldrawExport = class {
75
75
  /**
76
76
  * Pattern matching `.tldr` file imports. The `resolveId` hook filters on
@@ -165,7 +165,7 @@ var TldrawExport = class {
165
165
  async savePersistentCache() {
166
166
  if (!this.persistentCacheDirty) return;
167
167
  const cache = {};
168
- for (const [identifier, result] of this.resolvedCache.entries()) cache[this.toRelativeCacheKey(identifier)] = { result: toPosixPath(path.relative(this.options.cacheDirectory, result)) };
168
+ for (const [identifier, result] of this.resolvedCache) cache[this.toRelativeCacheKey(identifier)] = { result: toPosixPath(path.relative(this.options.cacheDirectory, result)) };
169
169
  await fs.writeFile(this.cacheFilePath, JSON.stringify(cache, void 0, 2));
170
170
  this.persistentCacheDirty = false;
171
171
  log.debug(`Saved ${this.resolvedCache.size} entries to persistent cache`);
@@ -206,8 +206,8 @@ var TldrawExport = class {
206
206
  if (frame !== void 0) tldrawCliOptions.frames = [frame];
207
207
  if (page !== void 0) tldrawCliOptions.pages = [page];
208
208
  try {
209
- const outputFile = (await tldrawToImage(absolutePath, tldrawCliOptions))[0];
210
- if (!outputFile) throw new Error(`tldraw-cli produced no output for "${absolutePath}"`);
209
+ const outputFile = (await tldrawToImage(absolutePath, tldrawCliOptions)).at(0);
210
+ if (outputFile === void 0) throw new Error(`tldraw-cli produced no output for "${absolutePath}"`);
211
211
  await fs.rename(outputFile, cachedFilePath);
212
212
  } finally {
213
213
  await fs.rm(tempOutputDirectory, {
@@ -233,13 +233,13 @@ var TldrawExport = class {
233
233
  async isFileHashCurrent(sourcePath, cachedResultPath, overrides) {
234
234
  if (!await fileExists(cachedResultPath)) return false;
235
235
  const cachedBasename = path.basename(cachedResultPath);
236
- const cachedHashMatch = CACHE_HASH_REGEX.exec(cachedBasename);
237
- if (!cachedHashMatch?.[1]) return false;
236
+ const cachedHash = CACHE_HASH_REGEX.exec(cachedBasename)?.[1];
237
+ if (cachedHash === void 0) return false;
238
238
  const { frame, page, ...imageOverrides } = overrides ?? {};
239
239
  const optionsForHash = { ...defu(imageOverrides, this.options.defaultImageOptions) };
240
240
  if (frame !== void 0) optionsForHash.frame = frame;
241
241
  if (page !== void 0) optionsForHash.page = page;
242
- return await computeCacheKey(sourcePath, optionsForHash) === cachedHashMatch[1];
242
+ return await computeCacheKey(sourcePath, optionsForHash) === cachedHash;
243
243
  }
244
244
  async loadPersistentCache() {
245
245
  try {
@@ -303,7 +303,7 @@ async function fileExists(filePath) {
303
303
  * replaces non-alphanumeric with hyphens, trims.
304
304
  */
305
305
  function slugify(text) {
306
- return text.toLowerCase().replaceAll(/[^\da-z]+/g, "-").replaceAll(/^-+|-+$/g, "");
306
+ return text.toLowerCase().replaceAll(/[^\da-z]+/gv, "-").replaceAll(/^-+|-+$/gv, "");
307
307
  }
308
308
  //#endregion
309
309
  export { parseImportOverrides as n, resolveOptions as r, TldrawExport as t };
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$vite from "vite";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
 
4
3
  //#region src/vite.d.ts
5
4
  /**
@@ -18,6 +17,6 @@ import * as _$vite from "vite";
18
17
  * plugins: [tldraw()],
19
18
  * })
20
19
  */
21
- declare const _default: (options?: Options | undefined) => _$vite.Plugin<any> | _$vite.Plugin<any>[];
20
+ declare const _default: (options?: Options | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
22
21
  //#endregion
23
22
  export { _default as default };
package/dist/webpack.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CZOXoH7Y.js";
2
- import * as _$webpack from "webpack";
1
+ import { n as Options } from "./options-D2_OB7_C.js";
3
2
 
4
3
  //#region src/webpack.d.ts
5
4
  /**
@@ -18,6 +17,6 @@ import * as _$webpack from "webpack";
18
17
  * plugins: [tldraw()],
19
18
  * }
20
19
  */
21
- declare const _default: (options?: Options | undefined) => _$webpack.WebpackPluginInstance;
20
+ declare const _default: (options?: Options | undefined) => import("webpack").WebpackPluginInstance;
22
21
  //#endregion
23
22
  export { _default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitschpatrol/unplugin-tldraw",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Unplugin for module-style import of local tldraw .tldr files with automatic conversion to SVG or PNG.",
5
5
  "keywords": [
6
6
  "tldraw",
@@ -68,35 +68,35 @@
68
68
  "dist"
69
69
  ],
70
70
  "dependencies": {
71
- "@kitschpatrol/tldraw-cli": "^5.0.16",
72
- "@types/node": "~22.18.13",
71
+ "@kitschpatrol/tldraw-cli": "^6.0.1",
72
+ "@types/node": "~22.19.19",
73
73
  "defu": "^6.1.7",
74
- "lognow": "^0.6.1",
74
+ "lognow": "^0.6.2",
75
75
  "p-limit": "^7.3.0",
76
76
  "pretty-bytes": "^7.1.0",
77
77
  "pretty-ms": "^9.3.0",
78
- "unplugin": "^3.0.0"
78
+ "unplugin": "^3.3.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@farmfe/core": ">=1.7.11",
82
- "@kitschpatrol/shared-config": "^7.5.2",
83
- "@nuxt/kit": "^4.4.2",
84
- "@nuxt/schema": "^4.4.2",
85
- "@rspack/core": "^2.0.1",
82
+ "@kitschpatrol/shared-config": "^8.0.0",
83
+ "@nuxt/kit": "^4.4.8",
84
+ "@nuxt/schema": "^4.4.8",
85
+ "@rspack/core": "^2.1.1",
86
86
  "@sxzz/test-utils": "^0.5.18",
87
- "@vitest/browser-playwright": "^4.1.5",
88
- "bumpp": "^11.0.1",
87
+ "@vitest/browser-playwright": "^4.1.9",
88
+ "bumpp": "^11.1.0",
89
89
  "esbuild": "*",
90
- "playwright": "^1.59.1",
91
- "poptab": "^1.1.0",
92
- "rolldown": "^1.0.0-rc.18",
93
- "rollup": "^4.60.2",
90
+ "playwright": "^1.61.1",
91
+ "poptab": "^1.1.1",
92
+ "rolldown": "^1.1.3",
93
+ "rollup": "^4.62.2",
94
94
  "shx": "^0.4.0",
95
- "tsdown": "^0.21.10",
96
- "typescript": "~5.9.3",
97
- "vite": "^7.3.2",
98
- "vitest": "^4.1.5",
99
- "webpack": "^5.106.2"
95
+ "tsdown": "^0.22.3",
96
+ "typescript": "~6.0.3",
97
+ "vite": "^8.1.3",
98
+ "vitest": "^4.1.9",
99
+ "webpack": "^5.108.3"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "@farmfe/core": ">=1",
@@ -139,7 +139,13 @@
139
139
  }
140
140
  },
141
141
  "engines": {
142
- "node": ">=22.18.0"
142
+ "node": ">=22.22.2"
143
+ },
144
+ "devEngines": {
145
+ "runtime": {
146
+ "name": "node",
147
+ "version": ">=24.16.0"
148
+ }
143
149
  },
144
150
  "publishConfig": {
145
151
  "access": "public"
@@ -151,7 +157,7 @@
151
157
  "fix": "ksc fix",
152
158
  "lint": "ksc lint",
153
159
  "play": "poptab && pnpm -C playground run dev",
154
- "release": "bumpp --commit 'Release: %s' && pnpm build && NPM_AUTH_TOKEN=$(op read 'op://Personal/npm/token') && pnpm publish",
160
+ "release": "bumpp --commit 'Release: %s' && pnpm build && NPM_AUTH_TOKEN=$(op read 'op://Personal/npm/token') pnpm publish",
155
161
  "test": "vitest run",
156
162
  "test:browser": "vitest run --config vitest.browser.config.ts"
157
163
  }