cbst 2.0.0 → 2.0.1

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/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2022-2024 Morris Brodersen <mb@morrisbrodersen.de>
1
+ Copyright 2022-2025 Morris Brodersen <mb@morrisbrodersen.de>
2
2
 
3
3
  Permission to use, copy, modify, and/or distribute this software for any purpose
4
4
  with or without fee is hereby granted, provided that the above copyright notice
package/README.md CHANGED
@@ -81,7 +81,7 @@ The configuration file (JSON) supports the following properties:
81
81
  - `dynamic`
82
82
  - List of file patterns to treat as dynamic.
83
83
  - Matching files will not be versioned.
84
- - References found in matching source files will be still be rewritten.
84
+ - References found in matching source files will still be rewritten.
85
85
  - Defaults to `["*.html"]`.
86
86
  - `metadata`
87
87
  - Metadata filename (JSON).
@@ -122,12 +122,12 @@ Cache-Control: public, max-age=31536000, immutable
122
122
  ```
123
123
 
124
124
  Version tags generated by `cbst` are prefixed with `v-`. You may configure your
125
- web server to deliver files containing `.v-` in their name with the above
125
+ web server to deliver files containing `.v-` in their names with the above
126
126
  immutable cache control header.
127
127
 
128
128
  **Dynamic files** (those listed in `dynamic`) will not be versioned, but any
129
129
  references detected inside these files will be rewritten if necessary. For
130
- example, `*.html` files are usually be marked dynamic because they are directly
130
+ example, `*.html` files are usually marked dynamic because they are directly
131
131
  visited, not indirectly requested like other files.
132
132
 
133
133
  Dynamic files should be delivered with a `Cache-Control` header that requires
@@ -153,7 +153,7 @@ See also
153
153
  Chicken and egg problem here. The industry got used to bundlers and started
154
154
  building libraries for the web assuming that everyone used a bundler.
155
155
 
156
- Ask library authors to ship standard ES modules. That will make all our lives
156
+ Ask library authors to ship native ES modules. That will make all our lives
157
157
  easier.
158
158
 
159
159
  > Isn't bundling still more performant for larger websites?
@@ -1,4 +1,4 @@
1
- import EventEmitter from 'events';
1
+ import EventEmitter from 'node:events';
2
2
  import { Cache } from './util/Cache.js';
3
3
  import { Glob } from './util/Glob.js';
4
4
  export interface CacheBusterConfig {
@@ -56,7 +56,7 @@ export declare class CacheBuster extends EventEmitter {
56
56
  protected hashFileCache: Cache<string | undefined>;
57
57
  protected getReferencesCache: Cache<string[]>;
58
58
  protected hashRawFileCache: Cache<string>;
59
- protected readFileCache: Cache<Buffer>;
59
+ protected readFileCache: Cache<Buffer<ArrayBufferLike>>;
60
60
  protected map: Map<string, string>;
61
61
  protected unresolved: Map<string, Set<string>>;
62
62
  protected referenceRx: RegExp;
@@ -68,7 +68,7 @@ export declare class CacheBuster extends EventEmitter {
68
68
  writeMetadata(file: string): Promise<void>;
69
69
  handleDir(dir: string): Promise<void>;
70
70
  handleFile(file: string): Promise<void>;
71
- transformFile(file: string): Promise<string | Buffer>;
71
+ transformFile(file: string): Promise<string | Buffer<ArrayBufferLike>>;
72
72
  hashFile(file: string): Promise<string | undefined>;
73
73
  hashFileReferences(file: string, exclude: string[]): Promise<string[]>;
74
74
  hashRawFile(file: string): Promise<string>;
@@ -80,8 +80,8 @@ export declare class CacheBuster extends EventEmitter {
80
80
  getBase(file: string): Promise<string>;
81
81
  formatVersion(hash: string): string;
82
82
  hash(inputs: (string | Buffer)[]): string;
83
- readFile(file: string): Promise<Buffer>;
84
- readDir(dir: string): Promise<import("fs").Dirent[]>;
83
+ readFile(file: string): Promise<Buffer<ArrayBufferLike>>;
84
+ readDir(dir: string): Promise<import("fs").Dirent<string>[]>;
85
85
  writeFile(file: string, data: string | Buffer): Promise<void>;
86
86
  safePath(rootDir: string, candidate: string): string;
87
87
  }
@@ -1,7 +1,7 @@
1
- import { createHash } from 'crypto';
2
- import EventEmitter from 'events';
3
- import { promises as fs } from 'fs';
4
- import { posix as path } from 'path';
1
+ import { createHash } from 'node:crypto';
2
+ import EventEmitter from 'node:events';
3
+ import { promises as fs } from 'node:fs';
4
+ import { posix as path } from 'node:path';
5
5
  import { ReferenceError } from './ReferenceError.js';
6
6
  import { Cache } from './util/Cache.js';
7
7
  import { Glob } from './util/Glob.js';
@@ -1,4 +1,4 @@
1
- import { promises as fs } from 'fs';
1
+ import { promises as fs } from 'node:fs';
2
2
  import { CacheBuster } from './CacheBuster.js';
3
3
  import { isRecord } from './util/isRecord.js';
4
4
  import { isStringArray } from './util/isStringArray.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cbst",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A cache buster that versions a website's files for immutable cache control",
5
5
  "keywords": [
6
6
  "versioning",
@@ -17,10 +17,10 @@
17
17
  "bugs": {
18
18
  "url": "https://github.com/morris/cbst/issues"
19
19
  },
20
+ "type": "module",
20
21
  "engines": {
21
22
  "node": ">=20"
22
23
  },
23
- "type": "module",
24
24
  "files": [
25
25
  "dist"
26
26
  ],