@ryanatkn/gro 0.136.0 → 0.137.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/filer.d.ts.map +1 -1
- package/dist/filer.js +29 -29
- package/dist/gro_plugin_gen.d.ts +2 -1
- package/dist/gro_plugin_gen.d.ts.map +1 -1
- package/dist/gro_plugin_gen.js +2 -6
- package/dist/package.js +2 -2
- package/package.json +1 -1
- package/src/lib/filer.ts +34 -33
- package/src/lib/gro_plugin_gen.ts +3 -5
- package/src/lib/package.ts +2 -2
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;AAUxB,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACtC,YAAY,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,KAAK,IAAI,CAAC;AAEzF,MAAM,WAAW,OAAO;IACvB,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,iBAAiB,EAAE,WAA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WAAW,GAAG,SAAS,CAEhD;IAEF,aAAa,OAAQ,OAAO,KAAG,WAAW,CAWxC;IA6HI,KAAK,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAKxD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
package/dist/filer.js
CHANGED
|
@@ -40,44 +40,44 @@ export class Filer {
|
|
|
40
40
|
#update(id) {
|
|
41
41
|
const file = this.get_or_create(id);
|
|
42
42
|
const new_contents = existsSync(id) ? readFileSync(id, 'utf8') : null;
|
|
43
|
-
|
|
43
|
+
if (file.contents === new_contents) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
44
46
|
file.contents = new_contents;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
d.dependents.set(file.id, file);
|
|
61
|
-
}
|
|
47
|
+
const dir = dirname(file.id);
|
|
48
|
+
const dependencies_before = new Set(file.dependencies.keys());
|
|
49
|
+
const dependencies_removed = new Set(dependencies_before);
|
|
50
|
+
const imported = file.contents ? parse_imports(file.id, file.contents) : [];
|
|
51
|
+
for (const specifier of imported) {
|
|
52
|
+
// TODO logic is duplicated from loader
|
|
53
|
+
const path = map_sveltekit_aliases(specifier, aliases);
|
|
54
|
+
// The specifier `path` has now been mapped to its final form, so we can inspect it.
|
|
55
|
+
if (path[0] === '.' || path[0] === '/') {
|
|
56
|
+
const { path_id } = resolve_specifier(path, dir);
|
|
57
|
+
dependencies_removed.delete(path_id);
|
|
58
|
+
if (!dependencies_before.has(path_id)) {
|
|
59
|
+
const d = this.get_or_create(path_id);
|
|
60
|
+
file.dependencies.set(d.id, d);
|
|
61
|
+
d.dependents.set(file.id, file);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
}
|
|
65
|
+
// update any removed dependencies
|
|
66
|
+
for (const dependency_removed of dependencies_removed) {
|
|
67
|
+
const deleted1 = file.dependencies.delete(dependency_removed);
|
|
68
|
+
if (!deleted1)
|
|
69
|
+
throw Error('expected to delete1 ' + file.id); // TODO @many delete if correct
|
|
70
|
+
const dependency_removed_file = this.get_or_create(dependency_removed);
|
|
71
|
+
const deleted2 = dependency_removed_file.dependents.delete(file.id);
|
|
72
|
+
if (!deleted2)
|
|
73
|
+
throw Error('expected to delete2 ' + file.id); // TODO @many delete if correct
|
|
74
74
|
}
|
|
75
75
|
return file;
|
|
76
76
|
}
|
|
77
77
|
#remove(id) {
|
|
78
78
|
const file = this.get_by_id(id);
|
|
79
79
|
if (!file)
|
|
80
|
-
return; // this is safe because the object would exist if any other file referenced it as a dependency or dependent
|
|
80
|
+
return null; // this is safe because the object would exist if any other file referenced it as a dependency or dependent
|
|
81
81
|
file.contents = null; // clear contents in case it gets re-added later, we want the change to be detected
|
|
82
82
|
let found = false;
|
|
83
83
|
for (const d of this.files.values()) {
|
package/dist/gro_plugin_gen.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ export interface Task_Args extends Args {
|
|
|
6
6
|
watch?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export interface Options {
|
|
9
|
+
input_paths?: string[];
|
|
9
10
|
root_dirs?: string[];
|
|
10
11
|
flush_debounce_delay?: number;
|
|
11
12
|
}
|
|
12
|
-
export declare const gro_plugin_gen: ({ root_dirs, flush_debounce_delay, }?: Options) => Plugin;
|
|
13
|
+
export declare const gro_plugin_gen: ({ input_paths, root_dirs, flush_debounce_delay, }?: Options) => Plugin;
|
|
13
14
|
export declare const filter_dependents: (source_file: Source_File, get_by_id: (id: Path_Id) => Source_File | undefined, filter?: File_Filter, results?: Set<string>, searched?: Set<string>) => Set<string>;
|
|
14
15
|
//# sourceMappingURL=gro_plugin_gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gro_plugin_gen.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAKpC,OAAO,KAAK,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAgB,WAAW,EAAC,MAAM,YAAY,CAAC;AAK3D,MAAM,WAAW,SAAU,SAAQ,IAAI;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,OAAO;IACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"gro_plugin_gen.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAKpC,OAAO,KAAK,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAgB,WAAW,EAAC,MAAM,YAAY,CAAC;AAK3D,MAAM,WAAW,SAAU,SAAQ,IAAI;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,OAAO;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,uDAIxB,OAAO,KAAkB,MA2F3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,gBAChB,WAAW,aACb,CAAC,EAAE,EAAE,OAAO,KAAK,WAAW,GAAG,SAAS,WAC1C,WAAW,YACX,GAAG,CAAC,MAAM,CAAC,aACV,GAAG,CAAC,MAAM,CAAC,KACnB,GAAG,CAAC,MAAM,CAYZ,CAAC"}
|
package/dist/gro_plugin_gen.js
CHANGED
|
@@ -5,8 +5,7 @@ import { throttle } from './throttle.js';
|
|
|
5
5
|
import { spawn_cli } from './cli.js';
|
|
6
6
|
import { Unreachable_Error } from '@ryanatkn/belt/error.js';
|
|
7
7
|
const FLUSH_DEBOUNCE_DELAY = 500;
|
|
8
|
-
export const gro_plugin_gen = ({ root_dirs = [paths.source], flush_debounce_delay = FLUSH_DEBOUNCE_DELAY, } = EMPTY_OBJECT) => {
|
|
9
|
-
const input_path = paths.source; // TODO option?
|
|
8
|
+
export const gro_plugin_gen = ({ input_paths = [paths.source], root_dirs = [paths.source], flush_debounce_delay = FLUSH_DEBOUNCE_DELAY, } = EMPTY_OBJECT) => {
|
|
10
9
|
let generating = false;
|
|
11
10
|
let regen = false;
|
|
12
11
|
let flushing_timeout;
|
|
@@ -46,14 +45,13 @@ export const gro_plugin_gen = ({ root_dirs = [paths.source], flush_debounce_dela
|
|
|
46
45
|
if (!dev)
|
|
47
46
|
return;
|
|
48
47
|
// Do we need to just generate everything once and exit?
|
|
49
|
-
// TODO could we have an esbuild context here? problem is watching the right files, maybe a plugin that tracks deps
|
|
50
48
|
if (!watch) {
|
|
51
49
|
log.info('generating and exiting early');
|
|
52
50
|
// Run `gen`, first checking if there are any modules to avoid a console error.
|
|
53
51
|
// Some parts of the build may have already happened,
|
|
54
52
|
// making us miss `build` events for gen dependencies,
|
|
55
53
|
// so we run `gen` here even if it's usually wasteful.
|
|
56
|
-
const found = find_genfiles(
|
|
54
|
+
const found = find_genfiles(input_paths, root_dirs, config);
|
|
57
55
|
if (found.ok && found.value.resolved_input_files.length > 0) {
|
|
58
56
|
await gen();
|
|
59
57
|
}
|
|
@@ -65,8 +63,6 @@ export const gro_plugin_gen = ({ root_dirs = [paths.source], flush_debounce_dela
|
|
|
65
63
|
switch (change.type) {
|
|
66
64
|
case 'add':
|
|
67
65
|
case 'update': {
|
|
68
|
-
// TODO how to handle this now? the loader traces deps for us with `parentPath`,
|
|
69
|
-
// but we probably want to make this an esbuild plugin instead
|
|
70
66
|
if (is_gen_path(source_file.id)) {
|
|
71
67
|
queue_gen(source_file.id);
|
|
72
68
|
}
|
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.
|
|
4
|
+
version: '0.137.0',
|
|
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.
|
|
267
|
+
version: '0.137.0',
|
|
268
268
|
modules: {
|
|
269
269
|
'.': {
|
|
270
270
|
path: 'index.ts',
|
package/package.json
CHANGED
package/src/lib/filer.ts
CHANGED
|
@@ -74,51 +74,52 @@ export class Filer {
|
|
|
74
74
|
return file;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
#update(id: Path_Id): Source_File {
|
|
77
|
+
#update(id: Path_Id): Source_File | null {
|
|
78
78
|
const file = this.get_or_create(id);
|
|
79
79
|
const new_contents = existsSync(id) ? readFileSync(id, 'utf8') : null;
|
|
80
|
-
|
|
80
|
+
if (file.contents === new_contents) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
81
84
|
file.contents = new_contents;
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
d.dependents.set(file.id, file);
|
|
102
|
-
}
|
|
86
|
+
const dir = dirname(file.id);
|
|
87
|
+
|
|
88
|
+
const dependencies_before = new Set(file.dependencies.keys());
|
|
89
|
+
const dependencies_removed = new Set(dependencies_before);
|
|
90
|
+
|
|
91
|
+
const imported = file.contents ? parse_imports(file.id, file.contents) : [];
|
|
92
|
+
for (const specifier of imported) {
|
|
93
|
+
// TODO logic is duplicated from loader
|
|
94
|
+
const path = map_sveltekit_aliases(specifier, aliases);
|
|
95
|
+
|
|
96
|
+
// The specifier `path` has now been mapped to its final form, so we can inspect it.
|
|
97
|
+
if (path[0] === '.' || path[0] === '/') {
|
|
98
|
+
const {path_id} = resolve_specifier(path, dir);
|
|
99
|
+
dependencies_removed.delete(path_id);
|
|
100
|
+
if (!dependencies_before.has(path_id)) {
|
|
101
|
+
const d = this.get_or_create(path_id);
|
|
102
|
+
file.dependencies.set(d.id, d);
|
|
103
|
+
d.dependents.set(file.id, file);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
106
|
+
}
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
108
|
+
// update any removed dependencies
|
|
109
|
+
for (const dependency_removed of dependencies_removed) {
|
|
110
|
+
const deleted1 = file.dependencies.delete(dependency_removed);
|
|
111
|
+
if (!deleted1) throw Error('expected to delete1 ' + file.id); // TODO @many delete if correct
|
|
112
|
+
const dependency_removed_file = this.get_or_create(dependency_removed);
|
|
113
|
+
const deleted2 = dependency_removed_file.dependents.delete(file.id);
|
|
114
|
+
if (!deleted2) throw Error('expected to delete2 ' + file.id); // TODO @many delete if correct
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
return file;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
#remove(id: Path_Id): Source_File |
|
|
120
|
+
#remove(id: Path_Id): Source_File | null {
|
|
120
121
|
const file = this.get_by_id(id);
|
|
121
|
-
if (!file) return; // this is safe because the object would exist if any other file referenced it as a dependency or dependent
|
|
122
|
+
if (!file) return null; // this is safe because the object would exist if any other file referenced it as a dependency or dependent
|
|
122
123
|
|
|
123
124
|
file.contents = null; // clear contents in case it gets re-added later, we want the change to be detected
|
|
124
125
|
|
|
@@ -177,7 +178,7 @@ export class Filer {
|
|
|
177
178
|
|
|
178
179
|
#on_change: Watcher_Change_Callback = (change) => {
|
|
179
180
|
if (change.is_directory) return;
|
|
180
|
-
let source_file: Source_File |
|
|
181
|
+
let source_file: Source_File | null;
|
|
181
182
|
switch (change.type) {
|
|
182
183
|
case 'add':
|
|
183
184
|
case 'update': {
|
|
@@ -17,15 +17,16 @@ export interface Task_Args extends Args {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface Options {
|
|
20
|
+
input_paths?: string[];
|
|
20
21
|
root_dirs?: string[];
|
|
21
22
|
flush_debounce_delay?: number;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export const gro_plugin_gen = ({
|
|
26
|
+
input_paths = [paths.source],
|
|
25
27
|
root_dirs = [paths.source],
|
|
26
28
|
flush_debounce_delay = FLUSH_DEBOUNCE_DELAY,
|
|
27
29
|
}: Options = EMPTY_OBJECT): Plugin => {
|
|
28
|
-
const input_path = paths.source; // TODO option?
|
|
29
30
|
let generating = false;
|
|
30
31
|
let regen = false;
|
|
31
32
|
let flushing_timeout: NodeJS.Timeout | undefined;
|
|
@@ -67,7 +68,6 @@ export const gro_plugin_gen = ({
|
|
|
67
68
|
if (!dev) return;
|
|
68
69
|
|
|
69
70
|
// Do we need to just generate everything once and exit?
|
|
70
|
-
// TODO could we have an esbuild context here? problem is watching the right files, maybe a plugin that tracks deps
|
|
71
71
|
if (!watch) {
|
|
72
72
|
log.info('generating and exiting early');
|
|
73
73
|
|
|
@@ -75,7 +75,7 @@ export const gro_plugin_gen = ({
|
|
|
75
75
|
// Some parts of the build may have already happened,
|
|
76
76
|
// making us miss `build` events for gen dependencies,
|
|
77
77
|
// so we run `gen` here even if it's usually wasteful.
|
|
78
|
-
const found = find_genfiles(
|
|
78
|
+
const found = find_genfiles(input_paths, root_dirs, config);
|
|
79
79
|
if (found.ok && found.value.resolved_input_files.length > 0) {
|
|
80
80
|
await gen();
|
|
81
81
|
}
|
|
@@ -88,8 +88,6 @@ export const gro_plugin_gen = ({
|
|
|
88
88
|
switch (change.type) {
|
|
89
89
|
case 'add':
|
|
90
90
|
case 'update': {
|
|
91
|
-
// TODO how to handle this now? the loader traces deps for us with `parentPath`,
|
|
92
|
-
// but we probably want to make this an esbuild plugin instead
|
|
93
91
|
if (is_gen_path(source_file.id)) {
|
|
94
92
|
queue_gen(source_file.id);
|
|
95
93
|
}
|
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.
|
|
8
|
+
version: '0.137.0',
|
|
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.
|
|
273
|
+
version: '0.137.0',
|
|
274
274
|
modules: {
|
|
275
275
|
'.': {
|
|
276
276
|
path: 'index.ts',
|