@ryanatkn/gro 0.140.5 → 0.140.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/filer.d.ts +3 -1
- package/dist/filer.d.ts.map +1 -1
- package/dist/filer.js +10 -3
- package/dist/package.js +2 -2
- package/package.json +1 -1
- package/src/lib/filer.ts +17 -4
- package/src/lib/package.ts +2 -2
package/dist/filer.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface Source_File {
|
|
|
8
8
|
* We create the file in memory to track its dependents regardless of its existence on disk.
|
|
9
9
|
*/
|
|
10
10
|
contents: string | null;
|
|
11
|
+
mtime: number | null;
|
|
11
12
|
dependents: Map<Path_Id, Source_File>;
|
|
12
13
|
dependencies: Map<Path_Id, Source_File>;
|
|
13
14
|
}
|
|
@@ -19,7 +20,8 @@ export interface Options {
|
|
|
19
20
|
}
|
|
20
21
|
export declare class Filer {
|
|
21
22
|
#private;
|
|
22
|
-
|
|
23
|
+
readonly root_dir: Path_Id;
|
|
24
|
+
readonly files: Map<Path_Id, Source_File>;
|
|
23
25
|
constructor(options?: Options);
|
|
24
26
|
get_by_id: (id: Path_Id) => Source_File | undefined;
|
|
25
27
|
get_or_create: (id: Path_Id) => Source_File;
|
package/dist/filer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filer.d.ts","sourceRoot":"../src/lib/","sources":["filer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAGzD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EACN,SAAS,EAET,KAAK,cAAc,EACnB,KAAK,OAAO,IAAI,iBAAiB,EAEjC,MAAM,gBAAgB,CAAC;AAYxB,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"filer.d.ts","sourceRoot":"../src/lib/","sources":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}
|
package/dist/filer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EMPTY_OBJECT } from '@ryanatkn/belt/object.js';
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
3
3
|
import { dirname, resolve } from 'node:path';
|
|
4
4
|
import { wait } from '@ryanatkn/belt/async.js';
|
|
5
5
|
import { watch_dir, } from './watch_dir.js';
|
|
@@ -13,12 +13,14 @@ import { Unreachable_Error } from '@ryanatkn/belt/error.js';
|
|
|
13
13
|
// import {resolve_node_specifier} from './resolve_node_specifier.js';
|
|
14
14
|
const aliases = Object.entries(default_sveltekit_config.alias);
|
|
15
15
|
export class Filer {
|
|
16
|
+
root_dir;
|
|
16
17
|
files = new Map();
|
|
17
18
|
#watch_dir;
|
|
18
19
|
#watch_dir_options;
|
|
19
20
|
constructor(options = EMPTY_OBJECT) {
|
|
20
21
|
this.#watch_dir = options.watch_dir ?? watch_dir;
|
|
21
22
|
this.#watch_dir_options = options.watch_dir_options ?? EMPTY_OBJECT;
|
|
23
|
+
this.root_dir = resolve(options.watch_dir_options?.dir ?? paths.source);
|
|
22
24
|
}
|
|
23
25
|
#watching;
|
|
24
26
|
#listeners = new Set();
|
|
@@ -33,6 +35,7 @@ export class Filer {
|
|
|
33
35
|
const file = {
|
|
34
36
|
id,
|
|
35
37
|
contents: null,
|
|
38
|
+
mtime: null,
|
|
36
39
|
dependents: new Map(),
|
|
37
40
|
dependencies: new Map(),
|
|
38
41
|
};
|
|
@@ -41,7 +44,11 @@ export class Filer {
|
|
|
41
44
|
};
|
|
42
45
|
#update(id) {
|
|
43
46
|
const file = this.get_or_create(id);
|
|
44
|
-
const
|
|
47
|
+
const stats = existsSync(id) ? statSync(id) : null;
|
|
48
|
+
// const mtime_prev = file.mtime;
|
|
49
|
+
// const mtime_changed = mtime_prev !== (stats?.mtimeMs ?? null);
|
|
50
|
+
file.mtime = stats?.mtimeMs ?? null;
|
|
51
|
+
const new_contents = stats ? readFileSync(id, 'utf8') : null;
|
|
45
52
|
if (file.contents === new_contents) {
|
|
46
53
|
return null;
|
|
47
54
|
}
|
|
@@ -130,7 +137,7 @@ export class Filer {
|
|
|
130
137
|
this.#watching = this.#watch_dir({
|
|
131
138
|
filter: (path, is_directory) => (is_directory ? true : default_file_filter(path)),
|
|
132
139
|
...this.#watch_dir_options,
|
|
133
|
-
dir:
|
|
140
|
+
dir: this.root_dir,
|
|
134
141
|
on_change: this.#on_change,
|
|
135
142
|
});
|
|
136
143
|
await this.#watching.init();
|
package/dist/package.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// generated by src/lib/package.gen.ts
|
|
2
2
|
export const package_json = {
|
|
3
3
|
name: '@ryanatkn/gro',
|
|
4
|
-
version: '0.140.
|
|
4
|
+
version: '0.140.7',
|
|
5
5
|
description: 'task runner and toolkit extending SvelteKit',
|
|
6
6
|
motto: 'generate, run, optimize',
|
|
7
7
|
glyph: '🌰',
|
|
@@ -264,7 +264,7 @@ export const package_json = {
|
|
|
264
264
|
};
|
|
265
265
|
export const src_json = {
|
|
266
266
|
name: '@ryanatkn/gro',
|
|
267
|
-
version: '0.140.
|
|
267
|
+
version: '0.140.7',
|
|
268
268
|
modules: {
|
|
269
269
|
'.': {
|
|
270
270
|
path: 'index.ts',
|
package/package.json
CHANGED
package/src/lib/filer.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {EMPTY_OBJECT} from '@ryanatkn/belt/object.js';
|
|
2
|
-
import {existsSync, readFileSync} from 'node:fs';
|
|
2
|
+
import {existsSync, readFileSync, statSync} from 'node:fs';
|
|
3
3
|
import {dirname, resolve} from 'node:path';
|
|
4
4
|
import type {Omit_Strict} from '@ryanatkn/belt/types.js';
|
|
5
5
|
import {wait} from '@ryanatkn/belt/async.js';
|
|
@@ -25,11 +25,13 @@ const aliases = Object.entries(default_sveltekit_config.alias);
|
|
|
25
25
|
|
|
26
26
|
export interface Source_File {
|
|
27
27
|
id: Path_Id;
|
|
28
|
+
// TODO add // mtime: number;
|
|
28
29
|
/**
|
|
29
30
|
* `null` contents means it doesn't exist.
|
|
30
31
|
* We create the file in memory to track its dependents regardless of its existence on disk.
|
|
31
32
|
*/
|
|
32
33
|
contents: string | null;
|
|
34
|
+
mtime: number | null;
|
|
33
35
|
dependents: Map<Path_Id, Source_File>;
|
|
34
36
|
dependencies: Map<Path_Id, Source_File>;
|
|
35
37
|
}
|
|
@@ -44,7 +46,9 @@ export interface Options {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export class Filer {
|
|
47
|
-
|
|
49
|
+
readonly root_dir: Path_Id;
|
|
50
|
+
|
|
51
|
+
readonly files: Map<Path_Id, Source_File> = new Map();
|
|
48
52
|
|
|
49
53
|
#watch_dir: typeof watch_dir;
|
|
50
54
|
#watch_dir_options: Partial<Watch_Dir_Options>;
|
|
@@ -52,6 +56,7 @@ export class Filer {
|
|
|
52
56
|
constructor(options: Options = EMPTY_OBJECT) {
|
|
53
57
|
this.#watch_dir = options.watch_dir ?? watch_dir;
|
|
54
58
|
this.#watch_dir_options = options.watch_dir_options ?? EMPTY_OBJECT;
|
|
59
|
+
this.root_dir = resolve(options.watch_dir_options?.dir ?? paths.source);
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
#watching: Watch_Node_Fs | undefined;
|
|
@@ -69,6 +74,7 @@ export class Filer {
|
|
|
69
74
|
const file: Source_File = {
|
|
70
75
|
id,
|
|
71
76
|
contents: null,
|
|
77
|
+
mtime: null,
|
|
72
78
|
dependents: new Map(),
|
|
73
79
|
dependencies: new Map(),
|
|
74
80
|
};
|
|
@@ -78,7 +84,14 @@ export class Filer {
|
|
|
78
84
|
|
|
79
85
|
#update(id: Path_Id): Source_File | null {
|
|
80
86
|
const file = this.get_or_create(id);
|
|
81
|
-
|
|
87
|
+
|
|
88
|
+
const stats = existsSync(id) ? statSync(id) : null;
|
|
89
|
+
// const mtime_prev = file.mtime;
|
|
90
|
+
// const mtime_changed = mtime_prev !== (stats?.mtimeMs ?? null);
|
|
91
|
+
file.mtime = stats?.mtimeMs ?? null;
|
|
92
|
+
|
|
93
|
+
const new_contents = stats ? readFileSync(id, 'utf8') : null;
|
|
94
|
+
|
|
82
95
|
if (file.contents === new_contents) {
|
|
83
96
|
return null;
|
|
84
97
|
}
|
|
@@ -175,7 +188,7 @@ export class Filer {
|
|
|
175
188
|
this.#watching = this.#watch_dir({
|
|
176
189
|
filter: (path, is_directory) => (is_directory ? true : default_file_filter(path)),
|
|
177
190
|
...this.#watch_dir_options,
|
|
178
|
-
dir:
|
|
191
|
+
dir: this.root_dir,
|
|
179
192
|
on_change: this.#on_change,
|
|
180
193
|
});
|
|
181
194
|
await this.#watching.init();
|
package/src/lib/package.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {Src_Json} from './src_json.js';
|
|
|
5
5
|
|
|
6
6
|
export const package_json = {
|
|
7
7
|
name: '@ryanatkn/gro',
|
|
8
|
-
version: '0.140.
|
|
8
|
+
version: '0.140.7',
|
|
9
9
|
description: 'task runner and toolkit extending SvelteKit',
|
|
10
10
|
motto: 'generate, run, optimize',
|
|
11
11
|
glyph: '🌰',
|
|
@@ -270,7 +270,7 @@ export const package_json = {
|
|
|
270
270
|
|
|
271
271
|
export const src_json = {
|
|
272
272
|
name: '@ryanatkn/gro',
|
|
273
|
-
version: '0.140.
|
|
273
|
+
version: '0.140.7',
|
|
274
274
|
modules: {
|
|
275
275
|
'.': {
|
|
276
276
|
path: 'index.ts',
|