@ryanatkn/gro 0.138.2 → 0.139.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/dist/gro.config.default.d.ts.map +1 -1
- package/dist/gro.config.default.js +8 -1
- package/dist/gro_plugin_gen.d.ts.map +1 -1
- package/dist/gro_plugin_gen.js +3 -3
- package/dist/gro_plugin_server.d.ts.map +1 -1
- package/dist/gro_plugin_server.js +2 -2
- package/dist/moss_helpers.d.ts +9 -0
- package/dist/moss_helpers.d.ts.map +1 -0
- package/dist/moss_helpers.js +23 -0
- package/dist/package.d.ts +11 -11
- package/dist/package.d.ts.map +1 -1
- package/dist/package.js +15 -6
- package/dist/package_json.d.ts +6 -0
- package/dist/package_json.d.ts.map +1 -1
- package/dist/package_json.js +20 -0
- package/dist/sveltekit_helpers.d.ts +1 -1
- package/dist/sveltekit_helpers.d.ts.map +1 -1
- package/dist/sveltekit_helpers.js +4 -5
- package/dist/upgrade.task.js +10 -19
- package/package.json +7 -7
- package/src/lib/gro.config.default.ts +13 -2
- package/src/lib/gro_plugin_gen.ts +10 -7
- package/src/lib/gro_plugin_server.ts +18 -15
- package/src/lib/moss_helpers.ts +33 -0
- package/src/lib/package.ts +15 -6
- package/src/lib/package_json.ts +30 -0
- package/src/lib/sveltekit_helpers.ts +4 -6
- package/src/lib/upgrade.task.ts +11 -26
- package/dist/throttle.d.ts +0 -19
- package/dist/throttle.d.ts.map +0 -1
- package/dist/throttle.js +0 -58
- package/src/lib/throttle.ts +0 -64
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gro.config.default.d.ts","sourceRoot":"../src/lib/","sources":["gro.config.default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"gro.config.default.d.ts","sourceRoot":"../src/lib/","sources":["gro.config.default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAQvD;;;;;;;;GAQG;AACH,QAAA,MAAM,MAAM,EAAE,iBAyBb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { has_server, gro_plugin_server } from './gro_plugin_server.js';
|
|
|
3
3
|
import { gro_plugin_sveltekit_app } from './gro_plugin_sveltekit_app.js';
|
|
4
4
|
import { has_sveltekit_app, has_sveltekit_library } from './sveltekit_helpers.js';
|
|
5
5
|
import { gro_plugin_gen } from './gro_plugin_gen.js';
|
|
6
|
+
import { load_moss_plugin } from './moss_helpers.js';
|
|
6
7
|
/**
|
|
7
8
|
* This is the default config that's passed to `gro.config.ts`
|
|
8
9
|
* if it exists in the current project, and if not, this is the final config.
|
|
@@ -13,8 +14,14 @@ import { gro_plugin_gen } from './gro_plugin_gen.js';
|
|
|
13
14
|
* - if `src/lib/server/server.ts`, assumes a Node server
|
|
14
15
|
*/
|
|
15
16
|
const config = async (cfg) => {
|
|
16
|
-
const [has_sveltekit_library_result, has_server_result, has_sveltekit_app_result] = await Promise.all([
|
|
17
|
+
const [moss_plugin_result, has_sveltekit_library_result, has_server_result, has_sveltekit_app_result,] = await Promise.all([
|
|
18
|
+
load_moss_plugin(),
|
|
19
|
+
has_sveltekit_library(),
|
|
20
|
+
has_server(),
|
|
21
|
+
has_sveltekit_app(),
|
|
22
|
+
]);
|
|
17
23
|
cfg.plugins = () => [
|
|
24
|
+
moss_plugin_result.ok ? moss_plugin_result.gro_plugin_moss() : null, // must go before SvelteKit for corner case where the file is not yet built
|
|
18
25
|
has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
|
|
19
26
|
has_server_result.ok ? gro_plugin_server() : null,
|
|
20
27
|
has_sveltekit_app_result.ok
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gro_plugin_gen.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_gen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gro_plugin_gen.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_gen.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAIpC,OAAO,KAAK,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAgB,WAAW,EAAC,MAAM,YAAY,CAAC;AAI3D,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,MAiF3B,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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EMPTY_OBJECT } from '@ryanatkn/belt/object.js';
|
|
2
|
+
import { throttle } from '@ryanatkn/belt/throttle.js';
|
|
3
|
+
import { Unreachable_Error } from '@ryanatkn/belt/error.js';
|
|
2
4
|
import { paths } from './paths.js';
|
|
3
5
|
import { find_genfiles, is_gen_path } from './gen.js';
|
|
4
|
-
import { throttle } from './throttle.js';
|
|
5
6
|
import { spawn_cli } from './cli.js';
|
|
6
|
-
import { Unreachable_Error } from '@ryanatkn/belt/error.js';
|
|
7
7
|
const FLUSH_DEBOUNCE_DELAY = 500;
|
|
8
8
|
export const gro_plugin_gen = ({ input_paths = [paths.source], root_dirs = [paths.source], flush_debounce_delay = FLUSH_DEBOUNCE_DELAY, } = EMPTY_OBJECT) => {
|
|
9
9
|
let flushing_timeout;
|
|
@@ -21,7 +21,7 @@ export const gro_plugin_gen = ({ input_paths = [paths.source], root_dirs = [path
|
|
|
21
21
|
const files = Array.from(queued_files);
|
|
22
22
|
queued_files.clear();
|
|
23
23
|
await gen(files);
|
|
24
|
-
}, flush_debounce_delay);
|
|
24
|
+
}, { delay: flush_debounce_delay });
|
|
25
25
|
const gen = (files = []) => spawn_cli('gro', ['gen', ...files]);
|
|
26
26
|
let cleanup;
|
|
27
27
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gro_plugin_server.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAC,MAAM,IAAI,eAAe,EAAC,MAAM,eAAe,CAAC;AAI7D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"gro_plugin_server.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAC,MAAM,IAAI,eAAe,EAAC,MAAM,eAAe,CAAC;AAI7D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIrD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAgBxC,eAAO,MAAM,gBAAgB,6BAA0D,CAAC;AAExF,eAAO,MAAM,UAAU,0CAA8B,MAAM,CAAC,MAAM,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAKpF,CAAC;AAEF,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC;;OAEG;IACH,gBAAgB,CAAC,EAAE,eAAe,CAAC;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC;IACrF;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,CAAC;AAEzD,eAAO,MAAM,iBAAiB,yJAgB3B,OAAO,KAAQ,MAwJjB,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { join, resolve } from 'node:path';
|
|
|
4
4
|
import { identity } from '@ryanatkn/belt/function.js';
|
|
5
5
|
import { strip_before, strip_end } from '@ryanatkn/belt/string.js';
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
|
+
import { throttle } from '@ryanatkn/belt/throttle.js';
|
|
7
8
|
import { base_path_to_path_id, LIB_DIRNAME, paths } from './paths.js';
|
|
8
9
|
import { GRO_DEV_DIRNAME, SERVER_DIST_PATH } from './path_constants.js';
|
|
9
10
|
import { watch_dir } from './watch_dir.js';
|
|
@@ -15,7 +16,6 @@ import { esbuild_plugin_sveltekit_shim_alias } from './esbuild_plugin_sveltekit_
|
|
|
15
16
|
import { esbuild_plugin_external_worker } from './esbuild_plugin_external_worker.js';
|
|
16
17
|
import { esbuild_plugin_sveltekit_local_imports } from './esbuild_plugin_sveltekit_local_imports.js';
|
|
17
18
|
import { esbuild_plugin_svelte } from './esbuild_plugin_svelte.js';
|
|
18
|
-
import { throttle } from './throttle.js';
|
|
19
19
|
// TODO sourcemap as a hoisted option? disable for production by default - or like `outpaths`, passed a `dev` param
|
|
20
20
|
export const SERVER_SOURCE_ID = base_path_to_path_id(LIB_DIRNAME + '/server/server.ts');
|
|
21
21
|
export const has_server = (path = SERVER_SOURCE_ID) => {
|
|
@@ -112,7 +112,7 @@ export const gro_plugin_server = ({ entry_points = [SERVER_SOURCE_ID], dir = pro
|
|
|
112
112
|
print_build_result(log, build_result);
|
|
113
113
|
deps = parse_deps(metafile.inputs, dir);
|
|
114
114
|
server_process?.restart();
|
|
115
|
-
}, rebuild_throttle_delay);
|
|
115
|
+
}, { delay: rebuild_throttle_delay });
|
|
116
116
|
await rebuild();
|
|
117
117
|
// uses chokidar instead of esbuild's watcher for efficiency
|
|
118
118
|
if (watch) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Result } from '@ryanatkn/belt/result.js';
|
|
2
|
+
import { type Package_Json } from './package_json.js';
|
|
3
|
+
export declare const MOSS_PACKAGE_DEP_NAME = "@ryanatkn/moss";
|
|
4
|
+
export declare const load_moss_plugin: (package_json?: Package_Json, dep_name?: string, plugin_path?: string) => Promise<Result<{
|
|
5
|
+
gro_plugin_moss: any;
|
|
6
|
+
}, {
|
|
7
|
+
message: string;
|
|
8
|
+
}>>;
|
|
9
|
+
//# sourceMappingURL=moss_helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moss_helpers.d.ts","sourceRoot":"../src/lib/","sources":["moss_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIrD,OAAO,EAAU,KAAK,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE7D,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAGtD,eAAO,MAAM,gBAAgB,kBACb,YAAY,8CAGzB,OAAO,CAAC,MAAM,CAAC;IAAC,eAAe,EAAE,GAAG,CAAA;CAAC,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CAmB3D,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { has_dep } from './package_json.js';
|
|
4
|
+
export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
|
|
5
|
+
// TODO plugin type?
|
|
6
|
+
export const load_moss_plugin = async (package_json, dep_name = MOSS_PACKAGE_DEP_NAME, plugin_path = `node_modules/${dep_name}/dist/gro_plugin_moss.js`) => {
|
|
7
|
+
if (!has_dep(dep_name, package_json)) {
|
|
8
|
+
return {
|
|
9
|
+
ok: false,
|
|
10
|
+
message: `no dependency found in package.json for ${dep_name}, install it with \`npm i -D ${dep_name}\``,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const path = resolve(plugin_path);
|
|
14
|
+
if (!existsSync(path)) {
|
|
15
|
+
return {
|
|
16
|
+
ok: false,
|
|
17
|
+
// TODO warn?
|
|
18
|
+
message: `dependency on ${dep_name} detected but plugin not found at ${path}`,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const mod = await import(path);
|
|
22
|
+
return { ok: true, gro_plugin_moss: mod.gro_plugin_moss };
|
|
23
|
+
};
|
package/dist/package.d.ts
CHANGED
|
@@ -277,6 +277,10 @@ export declare const package_json: {
|
|
|
277
277
|
types: string;
|
|
278
278
|
default: string;
|
|
279
279
|
};
|
|
280
|
+
'./moss_helpers.js': {
|
|
281
|
+
types: string;
|
|
282
|
+
default: string;
|
|
283
|
+
};
|
|
280
284
|
'./package_json.js': {
|
|
281
285
|
types: string;
|
|
282
286
|
default: string;
|
|
@@ -417,10 +421,6 @@ export declare const package_json: {
|
|
|
417
421
|
types: string;
|
|
418
422
|
default: string;
|
|
419
423
|
};
|
|
420
|
-
'./throttle.js': {
|
|
421
|
-
types: string;
|
|
422
|
-
default: string;
|
|
423
|
-
};
|
|
424
424
|
'./typecheck.task.js': {
|
|
425
425
|
types: string;
|
|
426
426
|
default: string;
|
|
@@ -759,6 +759,13 @@ export declare const src_json: {
|
|
|
759
759
|
kind: string;
|
|
760
760
|
}[];
|
|
761
761
|
};
|
|
762
|
+
'./moss_helpers.js': {
|
|
763
|
+
path: string;
|
|
764
|
+
declarations: {
|
|
765
|
+
name: string;
|
|
766
|
+
kind: string;
|
|
767
|
+
}[];
|
|
768
|
+
};
|
|
762
769
|
'./package_json.js': {
|
|
763
770
|
path: string;
|
|
764
771
|
declarations: {
|
|
@@ -1001,13 +1008,6 @@ export declare const src_json: {
|
|
|
1001
1008
|
kind: string;
|
|
1002
1009
|
}[];
|
|
1003
1010
|
};
|
|
1004
|
-
'./throttle.js': {
|
|
1005
|
-
path: string;
|
|
1006
|
-
declarations: {
|
|
1007
|
-
name: string;
|
|
1008
|
-
kind: string;
|
|
1009
|
-
}[];
|
|
1010
|
-
};
|
|
1011
1011
|
'./typecheck.task.js': {
|
|
1012
1012
|
path: string;
|
|
1013
1013
|
declarations: {
|
package/dist/package.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"../src/lib/","sources":["package.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;CAuwBD,CAAC"}
|
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.139.1',
|
|
5
5
|
description: 'task runner and toolkit extending SvelteKit',
|
|
6
6
|
motto: 'generate, run, optimize',
|
|
7
7
|
glyph: '🌰',
|
|
@@ -39,7 +39,7 @@ export const package_json = {
|
|
|
39
39
|
'typescript',
|
|
40
40
|
],
|
|
41
41
|
dependencies: {
|
|
42
|
-
'@ryanatkn/belt': '^0.25.
|
|
42
|
+
'@ryanatkn/belt': '^0.25.3',
|
|
43
43
|
chokidar: '^4.0.1',
|
|
44
44
|
dotenv: '^16.4.5',
|
|
45
45
|
'es-module-lexer': '^1.5.4',
|
|
@@ -57,7 +57,7 @@ export const package_json = {
|
|
|
57
57
|
'@changesets/types': '^6.0.0',
|
|
58
58
|
'@ryanatkn/eslint-config': '^0.5.4',
|
|
59
59
|
'@ryanatkn/fuz': '^0.129.0',
|
|
60
|
-
'@ryanatkn/moss': '^0.
|
|
60
|
+
'@ryanatkn/moss': '^0.18.0',
|
|
61
61
|
'@sveltejs/adapter-static': '^3.0.5',
|
|
62
62
|
'@sveltejs/kit': '^2.6.1',
|
|
63
63
|
'@sveltejs/package': '^2.3.5',
|
|
@@ -176,6 +176,7 @@ export const package_json = {
|
|
|
176
176
|
'./loader.js': { types: './dist/loader.d.ts', default: './dist/loader.js' },
|
|
177
177
|
'./module.js': { types: './dist/module.d.ts', default: './dist/module.js' },
|
|
178
178
|
'./modules.js': { types: './dist/modules.d.ts', default: './dist/modules.js' },
|
|
179
|
+
'./moss_helpers.js': { types: './dist/moss_helpers.d.ts', default: './dist/moss_helpers.js' },
|
|
179
180
|
'./package_json.js': { types: './dist/package_json.d.ts', default: './dist/package_json.js' },
|
|
180
181
|
'./package_meta.js': { types: './dist/package_meta.d.ts', default: './dist/package_meta.js' },
|
|
181
182
|
'./package.gen.js': { types: './dist/package.gen.d.ts', default: './dist/package.gen.js' },
|
|
@@ -253,7 +254,6 @@ export const package_json = {
|
|
|
253
254
|
'./task_logging.js': { types: './dist/task_logging.d.ts', default: './dist/task_logging.js' },
|
|
254
255
|
'./task.js': { types: './dist/task.d.ts', default: './dist/task.js' },
|
|
255
256
|
'./test.task.js': { types: './dist/test.task.d.ts', default: './dist/test.task.js' },
|
|
256
|
-
'./throttle.js': { types: './dist/throttle.d.ts', default: './dist/throttle.js' },
|
|
257
257
|
'./typecheck.task.js': {
|
|
258
258
|
types: './dist/typecheck.task.d.ts',
|
|
259
259
|
default: './dist/typecheck.task.js',
|
|
@@ -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.139.1',
|
|
268
268
|
modules: {
|
|
269
269
|
'.': {
|
|
270
270
|
path: 'index.ts',
|
|
@@ -652,6 +652,13 @@ export const src_json = {
|
|
|
652
652
|
{ name: 'load_modules', kind: 'function' },
|
|
653
653
|
],
|
|
654
654
|
},
|
|
655
|
+
'./moss_helpers.js': {
|
|
656
|
+
path: 'moss_helpers.ts',
|
|
657
|
+
declarations: [
|
|
658
|
+
{ name: 'MOSS_PACKAGE_DEP_NAME', kind: 'variable' },
|
|
659
|
+
{ name: 'load_moss_plugin', kind: 'function' },
|
|
660
|
+
],
|
|
661
|
+
},
|
|
655
662
|
'./package_json.js': {
|
|
656
663
|
path: 'package_json.ts',
|
|
657
664
|
declarations: [
|
|
@@ -673,6 +680,9 @@ export const src_json = {
|
|
|
673
680
|
{ name: 'update_package_json', kind: 'function' },
|
|
674
681
|
{ name: 'to_package_exports', kind: 'function' },
|
|
675
682
|
{ name: 'parse_repo_url', kind: 'function' },
|
|
683
|
+
{ name: 'has_dep', kind: 'function' },
|
|
684
|
+
{ name: 'Package_Json_Dep', kind: 'type' },
|
|
685
|
+
{ name: 'extract_deps', kind: 'function' },
|
|
676
686
|
],
|
|
677
687
|
},
|
|
678
688
|
'./package_meta.js': {
|
|
@@ -1001,7 +1011,6 @@ export const src_json = {
|
|
|
1001
1011
|
{ name: 'task', kind: 'variable' },
|
|
1002
1012
|
],
|
|
1003
1013
|
},
|
|
1004
|
-
'./throttle.js': { path: 'throttle.ts', declarations: [{ name: 'throttle', kind: 'function' }] },
|
|
1005
1014
|
'./typecheck.task.js': {
|
|
1006
1015
|
path: 'typecheck.task.ts',
|
|
1007
1016
|
declarations: [
|
package/dist/package_json.d.ts
CHANGED
|
@@ -377,4 +377,10 @@ export declare const parse_repo_url: (package_json: Package_Json) => {
|
|
|
377
377
|
owner: string;
|
|
378
378
|
repo: string;
|
|
379
379
|
} | undefined;
|
|
380
|
+
export declare const has_dep: (dep_name: string, package_json?: Package_Json) => boolean;
|
|
381
|
+
export interface Package_Json_Dep {
|
|
382
|
+
name: string;
|
|
383
|
+
version: string;
|
|
384
|
+
}
|
|
385
|
+
export declare const extract_deps: (package_json: Package_Json) => Package_Json_Dep[];
|
|
380
386
|
//# sourceMappingURL=package_json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package_json.d.ts","sourceRoot":"../src/lib/","sources":["package_json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AAUtD,eAAO,MAAM,GAAG,aAAa,CAAC;AAC9B,MAAM,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;AAGvD,eAAO,MAAM,KAAK,aAAa,CAAC;AAChC,MAAM,MAAM,KAAK,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AAC;AAE7C,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,YAAY,iBAAkB,YAAY,KAAG,gBAAgB,EAezE,CAAC"}
|
package/dist/package_json.js
CHANGED
|
@@ -260,3 +260,23 @@ const parse_or_throw_formatted_error = (name, schema, value) => {
|
|
|
260
260
|
}
|
|
261
261
|
return parsed.data;
|
|
262
262
|
};
|
|
263
|
+
export const has_dep = (dep_name, package_json = load_package_json()) => !!package_json.devDependencies?.[dep_name] ||
|
|
264
|
+
!!package_json.dependencies?.[dep_name] ||
|
|
265
|
+
!!package_json.peerDependencies?.[dep_name];
|
|
266
|
+
export const extract_deps = (package_json) => {
|
|
267
|
+
const deps_by_name = new Map();
|
|
268
|
+
// Earlier versions override later ones, so peer deps goes last.
|
|
269
|
+
const add_deps = (deps) => {
|
|
270
|
+
if (!deps)
|
|
271
|
+
return;
|
|
272
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
273
|
+
if (!deps_by_name.has(name)) {
|
|
274
|
+
deps_by_name.set(name, { name, version });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
add_deps(package_json.dependencies);
|
|
279
|
+
add_deps(package_json.devDependencies);
|
|
280
|
+
add_deps(package_json.peerDependencies);
|
|
281
|
+
return Array.from(deps_by_name.values());
|
|
282
|
+
};
|
|
@@ -12,7 +12,7 @@ export declare const SVELTEKIT_ENV_MATCHER: RegExp;
|
|
|
12
12
|
export declare const has_sveltekit_app: () => Result<object, {
|
|
13
13
|
message: string;
|
|
14
14
|
}>;
|
|
15
|
-
export declare const has_sveltekit_library: (package_json?: Package_Json, sveltekit_config?: Parsed_Sveltekit_Config) => Result<object, {
|
|
15
|
+
export declare const has_sveltekit_library: (package_json?: Package_Json, sveltekit_config?: Parsed_Sveltekit_Config, dep_name?: string) => Result<object, {
|
|
16
16
|
message: string;
|
|
17
17
|
}>;
|
|
18
18
|
export declare const sveltekit_sync: (sveltekit_cli?: string | Cli) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit_helpers.d.ts","sourceRoot":"../src/lib/","sources":["sveltekit_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"sveltekit_helpers.d.ts","sourceRoot":"../src/lib/","sources":["sveltekit_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAC,YAAY,EAAU,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAA2B,KAAK,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAE7F,OAAO,EAAmC,KAAK,GAAG,EAAC,MAAM,UAAU,CAAC;AAIpE,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAE3D,eAAO,MAAM,QAAQ,SAAS,CAAC;AAE/B,eAAO,MAAM,qBAAqB,QAAgD,CAAC;AAEnF,eAAO,MAAM,iBAAiB,QAAO,MAAM,CAAC,MAAM,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAMpE,CAAC;AAEF,eAAO,MAAM,qBAAqB,kBAClB,YAAY,qBACT,uBAAuB,wBAEvC,MAAM,CAAC,MAAM,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAkBlC,CAAC;AAEF,eAAO,MAAM,cAAc,mBACX,MAAM,GAAG,GAAG,KACzB,OAAO,CAAC,IAAI,CASd,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,2BAA2B,mBACxB,MAAM,GAAG,GAAG,KACzB,OAAO,CAAC,IAAI,CAMd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC,mBAC/B,MAAM,GAAG,GAAG,KACzB,OAAO,CAAC,IAAI,CAUd,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,kBAAkB,YACrB,sBAAsB,GAAG,SAAS,OACtC,MAAM,GAAG,GAAG,OACZ,MAAM,KACT,OAAO,CAAC,IAAI,CAmBd,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,qBAAqB,cACtB,MAAM,WACR,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAC9B,MASF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { Package_Json,
|
|
3
|
+
import { Package_Json, has_dep } from './package_json.js';
|
|
4
4
|
import { default_sveltekit_config } from './sveltekit_config.js';
|
|
5
5
|
import { SVELTEKIT_CONFIG_FILENAME, SVELTEKIT_DEV_DIRNAME } from './path_constants.js';
|
|
6
6
|
import { find_cli, spawn_cli, to_cli_name } from './cli.js';
|
|
@@ -19,7 +19,7 @@ export const has_sveltekit_app = () => {
|
|
|
19
19
|
// TODO check for routes?
|
|
20
20
|
return { ok: true };
|
|
21
21
|
};
|
|
22
|
-
export const has_sveltekit_library = (package_json, sveltekit_config = default_sveltekit_config) => {
|
|
22
|
+
export const has_sveltekit_library = (package_json, sveltekit_config = default_sveltekit_config, dep_name = SVELTE_PACKAGE_DEP_NAME) => {
|
|
23
23
|
const has_sveltekit_app_result = has_sveltekit_app();
|
|
24
24
|
if (!has_sveltekit_app_result.ok) {
|
|
25
25
|
return has_sveltekit_app_result;
|
|
@@ -27,11 +27,10 @@ export const has_sveltekit_library = (package_json, sveltekit_config = default_s
|
|
|
27
27
|
if (!existsSync(sveltekit_config.lib_path)) {
|
|
28
28
|
return { ok: false, message: `no SvelteKit lib directory found at ${sveltekit_config.lib_path}` };
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
if (!(pkg.devDependencies?.[SVELTE_PACKAGE_DEP_NAME] || pkg.dependencies?.[SVELTE_PACKAGE_DEP_NAME])) {
|
|
30
|
+
if (!has_dep(dep_name, package_json)) {
|
|
32
31
|
return {
|
|
33
32
|
ok: false,
|
|
34
|
-
message: `no dependency found in package.json for ${
|
|
33
|
+
message: `no dependency found in package.json for ${dep_name}, install it with \`npm i -D ${dep_name}\``,
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
36
|
return { ok: true };
|
package/dist/upgrade.task.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from '@ryanatkn/belt/process.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { Task_Error } from './task.js';
|
|
4
|
-
import { load_package_json } from './package_json.js';
|
|
4
|
+
import { extract_deps, load_package_json } from './package_json.js';
|
|
5
5
|
import { Git_Origin, git_pull } from './git.js';
|
|
6
6
|
import { spawn_cli } from './cli.js';
|
|
7
7
|
export const Args = z
|
|
@@ -33,12 +33,12 @@ export const task = {
|
|
|
33
33
|
await git_pull(origin);
|
|
34
34
|
}
|
|
35
35
|
const package_json = load_package_json();
|
|
36
|
-
const all_deps =
|
|
36
|
+
const all_deps = extract_deps(package_json);
|
|
37
37
|
const deps = only.length
|
|
38
|
-
? all_deps.filter((d) => only.includes(d.
|
|
39
|
-
: all_deps.filter((d) => !_.includes(d.
|
|
38
|
+
? all_deps.filter((d) => only.includes(d.name))
|
|
39
|
+
: all_deps.filter((d) => !_.includes(d.name));
|
|
40
40
|
if (only.length && only.length !== deps.length) {
|
|
41
|
-
throw new Task_Error(`Some deps to upgrade were not found: ${only.filter((o) => !deps.find((d) => d.
|
|
41
|
+
throw new Task_Error(`Some deps to upgrade were not found: ${only.filter((o) => !deps.find((d) => d.name === o)).join(', ')}`);
|
|
42
42
|
}
|
|
43
43
|
const upgrade_items = to_upgrade_items(deps);
|
|
44
44
|
log.info(`upgrading:`, upgrade_items.join(' '));
|
|
@@ -55,26 +55,17 @@ export const task = {
|
|
|
55
55
|
await spawn_cli('gro', ['sync', '--no-install']); // don't install because we do above
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
|
-
const to_deps = (package_json) => {
|
|
59
|
-
const prod_deps = package_json.dependencies
|
|
60
|
-
? Object.entries(package_json.dependencies).map(([key, value]) => ({ key, value }))
|
|
61
|
-
: [];
|
|
62
|
-
const dev_deps = package_json.devDependencies
|
|
63
|
-
? Object.entries(package_json.devDependencies).map(([key, value]) => ({ key, value }))
|
|
64
|
-
: [];
|
|
65
|
-
return prod_deps.concat(dev_deps);
|
|
66
|
-
};
|
|
67
58
|
const EXACT_VERSION_MATCHER = /^..*@.+/;
|
|
68
59
|
const CUSTOM_TAG_MATCHER = /^[\^~><=]*.+-(.+)/;
|
|
69
60
|
// TODO hacky and limited
|
|
70
61
|
// TODO probably want to pass through exact deps as well, e.g. @foo/bar@1
|
|
71
62
|
const to_upgrade_items = (deps) => deps.map((dep) => {
|
|
72
|
-
if (EXACT_VERSION_MATCHER.test(dep.
|
|
73
|
-
return dep.
|
|
63
|
+
if (EXACT_VERSION_MATCHER.test(dep.name)) {
|
|
64
|
+
return dep.name;
|
|
74
65
|
}
|
|
75
|
-
const custom_tag_matches = CUSTOM_TAG_MATCHER.exec(dep.
|
|
66
|
+
const custom_tag_matches = CUSTOM_TAG_MATCHER.exec(dep.version);
|
|
76
67
|
if (custom_tag_matches) {
|
|
77
|
-
return dep.
|
|
68
|
+
return dep.name + '@' + custom_tag_matches[1].split('.')[0]; // I tried adding `\.?` to the end but doesn't work and I'm being lazy so I'm just splitting
|
|
78
69
|
}
|
|
79
|
-
return dep.
|
|
70
|
+
return dep.name + '@latest';
|
|
80
71
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryanatkn/gro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.139.1",
|
|
4
4
|
"description": "task runner and toolkit extending SvelteKit",
|
|
5
5
|
"motto": "generate, run, optimize",
|
|
6
6
|
"glyph": "🌰",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"typescript"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@ryanatkn/belt": "^0.25.
|
|
52
|
+
"@ryanatkn/belt": "^0.25.3",
|
|
53
53
|
"chokidar": "^4.0.1",
|
|
54
54
|
"dotenv": "^16.4.5",
|
|
55
55
|
"es-module-lexer": "^1.5.4",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@changesets/types": "^6.0.0",
|
|
71
71
|
"@ryanatkn/eslint-config": "^0.5.4",
|
|
72
72
|
"@ryanatkn/fuz": "^0.129.0",
|
|
73
|
-
"@ryanatkn/moss": "^0.
|
|
73
|
+
"@ryanatkn/moss": "^0.18.0",
|
|
74
74
|
"@sveltejs/adapter-static": "^3.0.5",
|
|
75
75
|
"@sveltejs/kit": "^2.6.1",
|
|
76
76
|
"@sveltejs/package": "^2.3.5",
|
|
@@ -298,6 +298,10 @@
|
|
|
298
298
|
"types": "./dist/modules.d.ts",
|
|
299
299
|
"default": "./dist/modules.js"
|
|
300
300
|
},
|
|
301
|
+
"./moss_helpers.js": {
|
|
302
|
+
"types": "./dist/moss_helpers.d.ts",
|
|
303
|
+
"default": "./dist/moss_helpers.js"
|
|
304
|
+
},
|
|
301
305
|
"./package_json.js": {
|
|
302
306
|
"types": "./dist/package_json.d.ts",
|
|
303
307
|
"default": "./dist/package_json.js"
|
|
@@ -438,10 +442,6 @@
|
|
|
438
442
|
"types": "./dist/test.task.d.ts",
|
|
439
443
|
"default": "./dist/test.task.js"
|
|
440
444
|
},
|
|
441
|
-
"./throttle.js": {
|
|
442
|
-
"types": "./dist/throttle.d.ts",
|
|
443
|
-
"default": "./dist/throttle.js"
|
|
444
|
-
},
|
|
445
445
|
"./typecheck.task.js": {
|
|
446
446
|
"types": "./dist/typecheck.task.d.ts",
|
|
447
447
|
"default": "./dist/typecheck.task.js"
|
|
@@ -4,6 +4,7 @@ import {has_server, gro_plugin_server} from './gro_plugin_server.js';
|
|
|
4
4
|
import {gro_plugin_sveltekit_app} from './gro_plugin_sveltekit_app.js';
|
|
5
5
|
import {has_sveltekit_app, has_sveltekit_library} from './sveltekit_helpers.js';
|
|
6
6
|
import {gro_plugin_gen} from './gro_plugin_gen.js';
|
|
7
|
+
import {load_moss_plugin} from './moss_helpers.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* This is the default config that's passed to `gro.config.ts`
|
|
@@ -15,11 +16,21 @@ import {gro_plugin_gen} from './gro_plugin_gen.js';
|
|
|
15
16
|
* - if `src/lib/server/server.ts`, assumes a Node server
|
|
16
17
|
*/
|
|
17
18
|
const config: Create_Gro_Config = async (cfg) => {
|
|
18
|
-
const [
|
|
19
|
-
|
|
19
|
+
const [
|
|
20
|
+
moss_plugin_result,
|
|
21
|
+
has_sveltekit_library_result,
|
|
22
|
+
has_server_result,
|
|
23
|
+
has_sveltekit_app_result,
|
|
24
|
+
] = await Promise.all([
|
|
25
|
+
load_moss_plugin(),
|
|
26
|
+
has_sveltekit_library(),
|
|
27
|
+
has_server(),
|
|
28
|
+
has_sveltekit_app(),
|
|
29
|
+
]);
|
|
20
30
|
|
|
21
31
|
cfg.plugins = () =>
|
|
22
32
|
[
|
|
33
|
+
moss_plugin_result.ok ? moss_plugin_result.gro_plugin_moss() : null, // must go before SvelteKit for corner case where the file is not yet built
|
|
23
34
|
has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
|
|
24
35
|
has_server_result.ok ? gro_plugin_server() : null,
|
|
25
36
|
has_sveltekit_app_result.ok
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {EMPTY_OBJECT} from '@ryanatkn/belt/object.js';
|
|
2
|
+
import {throttle} from '@ryanatkn/belt/throttle.js';
|
|
3
|
+
import {Unreachable_Error} from '@ryanatkn/belt/error.js';
|
|
2
4
|
|
|
3
5
|
import type {Plugin} from './plugin.js';
|
|
4
6
|
import type {Args} from './args.js';
|
|
5
7
|
import {paths} from './paths.js';
|
|
6
8
|
import {find_genfiles, is_gen_path} from './gen.js';
|
|
7
|
-
import {throttle} from './throttle.js';
|
|
8
9
|
import {spawn_cli} from './cli.js';
|
|
9
10
|
import type {File_Filter, Path_Id} from './path.js';
|
|
10
11
|
import type {Cleanup_Watch, Source_File} from './filer.js';
|
|
11
|
-
import {Unreachable_Error} from '@ryanatkn/belt/error.js';
|
|
12
12
|
|
|
13
13
|
const FLUSH_DEBOUNCE_DELAY = 500;
|
|
14
14
|
|
|
@@ -38,11 +38,14 @@ export const gro_plugin_gen = ({
|
|
|
38
38
|
}); // the timeout batches synchronously
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
const flush_gen_queue = throttle(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
const flush_gen_queue = throttle(
|
|
42
|
+
async () => {
|
|
43
|
+
const files = Array.from(queued_files);
|
|
44
|
+
queued_files.clear();
|
|
45
|
+
await gen(files);
|
|
46
|
+
},
|
|
47
|
+
{delay: flush_debounce_delay},
|
|
48
|
+
);
|
|
46
49
|
const gen = (files: string[] = []) => spawn_cli('gro', ['gen', ...files]);
|
|
47
50
|
|
|
48
51
|
let cleanup: Cleanup_Watch | undefined;
|
|
@@ -6,6 +6,7 @@ import {identity} from '@ryanatkn/belt/function.js';
|
|
|
6
6
|
import {strip_before, strip_end} from '@ryanatkn/belt/string.js';
|
|
7
7
|
import type {Result} from '@ryanatkn/belt/result.js';
|
|
8
8
|
import {existsSync} from 'node:fs';
|
|
9
|
+
import {throttle} from '@ryanatkn/belt/throttle.js';
|
|
9
10
|
|
|
10
11
|
import type {Plugin} from './plugin.js';
|
|
11
12
|
import {base_path_to_path_id, LIB_DIRNAME, paths} from './paths.js';
|
|
@@ -20,7 +21,6 @@ import {esbuild_plugin_sveltekit_shim_alias} from './esbuild_plugin_sveltekit_sh
|
|
|
20
21
|
import {esbuild_plugin_external_worker} from './esbuild_plugin_external_worker.js';
|
|
21
22
|
import {esbuild_plugin_sveltekit_local_imports} from './esbuild_plugin_sveltekit_local_imports.js';
|
|
22
23
|
import {esbuild_plugin_svelte} from './esbuild_plugin_svelte.js';
|
|
23
|
-
import {throttle} from './throttle.js';
|
|
24
24
|
|
|
25
25
|
// TODO sourcemap as a hoisted option? disable for production by default - or like `outpaths`, passed a `dev` param
|
|
26
26
|
|
|
@@ -208,20 +208,23 @@ export const gro_plugin_server = ({
|
|
|
208
208
|
|
|
209
209
|
timing_to_esbuild_create_context();
|
|
210
210
|
|
|
211
|
-
const rebuild = throttle(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
211
|
+
const rebuild = throttle(
|
|
212
|
+
async () => {
|
|
213
|
+
let build_result;
|
|
214
|
+
try {
|
|
215
|
+
build_result = await build_ctx!.rebuild();
|
|
216
|
+
} catch (err) {
|
|
217
|
+
log.error('[gro_plugin_server] build failed', err);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const {metafile} = build_result;
|
|
221
|
+
if (!metafile) return;
|
|
222
|
+
print_build_result(log, build_result);
|
|
223
|
+
deps = parse_deps(metafile.inputs, dir);
|
|
224
|
+
server_process?.restart();
|
|
225
|
+
},
|
|
226
|
+
{delay: rebuild_throttle_delay},
|
|
227
|
+
);
|
|
225
228
|
|
|
226
229
|
await rebuild();
|
|
227
230
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type {Result} from '@ryanatkn/belt/result.js';
|
|
2
|
+
import {existsSync} from 'node:fs';
|
|
3
|
+
import {resolve} from 'node:path';
|
|
4
|
+
|
|
5
|
+
import {has_dep, type Package_Json} from './package_json.js';
|
|
6
|
+
|
|
7
|
+
export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
|
|
8
|
+
|
|
9
|
+
// TODO plugin type?
|
|
10
|
+
export const load_moss_plugin = async (
|
|
11
|
+
package_json?: Package_Json,
|
|
12
|
+
dep_name = MOSS_PACKAGE_DEP_NAME,
|
|
13
|
+
plugin_path = `node_modules/${dep_name}/dist/gro_plugin_moss.js`, // TODO maybe lookup from its `package_json.exports`? kinda unnecessary
|
|
14
|
+
): Promise<Result<{gro_plugin_moss: any}, {message: string}>> => {
|
|
15
|
+
if (!has_dep(dep_name, package_json)) {
|
|
16
|
+
return {
|
|
17
|
+
ok: false,
|
|
18
|
+
message: `no dependency found in package.json for ${dep_name}, install it with \`npm i -D ${dep_name}\``,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const path = resolve(plugin_path);
|
|
23
|
+
if (!existsSync(path)) {
|
|
24
|
+
return {
|
|
25
|
+
ok: false,
|
|
26
|
+
// TODO warn?
|
|
27
|
+
message: `dependency on ${dep_name} detected but plugin not found at ${path}`,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const mod = await import(path);
|
|
32
|
+
return {ok: true, gro_plugin_moss: mod.gro_plugin_moss};
|
|
33
|
+
};
|
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.139.1',
|
|
9
9
|
description: 'task runner and toolkit extending SvelteKit',
|
|
10
10
|
motto: 'generate, run, optimize',
|
|
11
11
|
glyph: '🌰',
|
|
@@ -44,7 +44,7 @@ export const package_json = {
|
|
|
44
44
|
'typescript',
|
|
45
45
|
],
|
|
46
46
|
dependencies: {
|
|
47
|
-
'@ryanatkn/belt': '^0.25.
|
|
47
|
+
'@ryanatkn/belt': '^0.25.3',
|
|
48
48
|
chokidar: '^4.0.1',
|
|
49
49
|
dotenv: '^16.4.5',
|
|
50
50
|
'es-module-lexer': '^1.5.4',
|
|
@@ -62,7 +62,7 @@ export const package_json = {
|
|
|
62
62
|
'@changesets/types': '^6.0.0',
|
|
63
63
|
'@ryanatkn/eslint-config': '^0.5.4',
|
|
64
64
|
'@ryanatkn/fuz': '^0.129.0',
|
|
65
|
-
'@ryanatkn/moss': '^0.
|
|
65
|
+
'@ryanatkn/moss': '^0.18.0',
|
|
66
66
|
'@sveltejs/adapter-static': '^3.0.5',
|
|
67
67
|
'@sveltejs/kit': '^2.6.1',
|
|
68
68
|
'@sveltejs/package': '^2.3.5',
|
|
@@ -181,6 +181,7 @@ export const package_json = {
|
|
|
181
181
|
'./loader.js': {types: './dist/loader.d.ts', default: './dist/loader.js'},
|
|
182
182
|
'./module.js': {types: './dist/module.d.ts', default: './dist/module.js'},
|
|
183
183
|
'./modules.js': {types: './dist/modules.d.ts', default: './dist/modules.js'},
|
|
184
|
+
'./moss_helpers.js': {types: './dist/moss_helpers.d.ts', default: './dist/moss_helpers.js'},
|
|
184
185
|
'./package_json.js': {types: './dist/package_json.d.ts', default: './dist/package_json.js'},
|
|
185
186
|
'./package_meta.js': {types: './dist/package_meta.d.ts', default: './dist/package_meta.js'},
|
|
186
187
|
'./package.gen.js': {types: './dist/package.gen.d.ts', default: './dist/package.gen.js'},
|
|
@@ -258,7 +259,6 @@ export const package_json = {
|
|
|
258
259
|
'./task_logging.js': {types: './dist/task_logging.d.ts', default: './dist/task_logging.js'},
|
|
259
260
|
'./task.js': {types: './dist/task.d.ts', default: './dist/task.js'},
|
|
260
261
|
'./test.task.js': {types: './dist/test.task.d.ts', default: './dist/test.task.js'},
|
|
261
|
-
'./throttle.js': {types: './dist/throttle.d.ts', default: './dist/throttle.js'},
|
|
262
262
|
'./typecheck.task.js': {
|
|
263
263
|
types: './dist/typecheck.task.d.ts',
|
|
264
264
|
default: './dist/typecheck.task.js',
|
|
@@ -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.139.1',
|
|
274
274
|
modules: {
|
|
275
275
|
'.': {
|
|
276
276
|
path: 'index.ts',
|
|
@@ -658,6 +658,13 @@ export const src_json = {
|
|
|
658
658
|
{name: 'load_modules', kind: 'function'},
|
|
659
659
|
],
|
|
660
660
|
},
|
|
661
|
+
'./moss_helpers.js': {
|
|
662
|
+
path: 'moss_helpers.ts',
|
|
663
|
+
declarations: [
|
|
664
|
+
{name: 'MOSS_PACKAGE_DEP_NAME', kind: 'variable'},
|
|
665
|
+
{name: 'load_moss_plugin', kind: 'function'},
|
|
666
|
+
],
|
|
667
|
+
},
|
|
661
668
|
'./package_json.js': {
|
|
662
669
|
path: 'package_json.ts',
|
|
663
670
|
declarations: [
|
|
@@ -679,6 +686,9 @@ export const src_json = {
|
|
|
679
686
|
{name: 'update_package_json', kind: 'function'},
|
|
680
687
|
{name: 'to_package_exports', kind: 'function'},
|
|
681
688
|
{name: 'parse_repo_url', kind: 'function'},
|
|
689
|
+
{name: 'has_dep', kind: 'function'},
|
|
690
|
+
{name: 'Package_Json_Dep', kind: 'type'},
|
|
691
|
+
{name: 'extract_deps', kind: 'function'},
|
|
682
692
|
],
|
|
683
693
|
},
|
|
684
694
|
'./package_meta.js': {
|
|
@@ -1007,7 +1017,6 @@ export const src_json = {
|
|
|
1007
1017
|
{name: 'task', kind: 'variable'},
|
|
1008
1018
|
],
|
|
1009
1019
|
},
|
|
1010
|
-
'./throttle.js': {path: 'throttle.ts', declarations: [{name: 'throttle', kind: 'function'}]},
|
|
1011
1020
|
'./typecheck.task.js': {
|
|
1012
1021
|
path: 'typecheck.task.ts',
|
|
1013
1022
|
declarations: [
|
package/src/lib/package_json.ts
CHANGED
|
@@ -328,3 +328,33 @@ const parse_or_throw_formatted_error = <T extends z.ZodTypeAny>(
|
|
|
328
328
|
}
|
|
329
329
|
return parsed.data;
|
|
330
330
|
};
|
|
331
|
+
|
|
332
|
+
export const has_dep = (
|
|
333
|
+
dep_name: string,
|
|
334
|
+
package_json: Package_Json = load_package_json(),
|
|
335
|
+
): boolean =>
|
|
336
|
+
!!package_json.devDependencies?.[dep_name] ||
|
|
337
|
+
!!package_json.dependencies?.[dep_name] ||
|
|
338
|
+
!!package_json.peerDependencies?.[dep_name];
|
|
339
|
+
|
|
340
|
+
export interface Package_Json_Dep {
|
|
341
|
+
name: string;
|
|
342
|
+
version: string;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export const extract_deps = (package_json: Package_Json): Package_Json_Dep[] => {
|
|
346
|
+
const deps_by_name: Map<string, Package_Json_Dep> = new Map();
|
|
347
|
+
// Earlier versions override later ones, so peer deps goes last.
|
|
348
|
+
const add_deps = (deps: Record<string, string> | undefined) => {
|
|
349
|
+
if (!deps) return;
|
|
350
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
351
|
+
if (!deps_by_name.has(name)) {
|
|
352
|
+
deps_by_name.set(name, {name, version});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
add_deps(package_json.dependencies);
|
|
357
|
+
add_deps(package_json.devDependencies);
|
|
358
|
+
add_deps(package_json.peerDependencies);
|
|
359
|
+
return Array.from(deps_by_name.values());
|
|
360
|
+
};
|
|
@@ -3,7 +3,7 @@ import {existsSync} from 'node:fs';
|
|
|
3
3
|
import type {Logger} from '@ryanatkn/belt/log.js';
|
|
4
4
|
import {join} from 'node:path';
|
|
5
5
|
|
|
6
|
-
import {Package_Json,
|
|
6
|
+
import {Package_Json, has_dep} from './package_json.js';
|
|
7
7
|
import {default_sveltekit_config, type Parsed_Sveltekit_Config} from './sveltekit_config.js';
|
|
8
8
|
import {SVELTEKIT_CONFIG_FILENAME, SVELTEKIT_DEV_DIRNAME} from './path_constants.js';
|
|
9
9
|
import {find_cli, spawn_cli, to_cli_name, type Cli} from './cli.js';
|
|
@@ -32,6 +32,7 @@ export const has_sveltekit_app = (): Result<object, {message: string}> => {
|
|
|
32
32
|
export const has_sveltekit_library = (
|
|
33
33
|
package_json?: Package_Json,
|
|
34
34
|
sveltekit_config: Parsed_Sveltekit_Config = default_sveltekit_config,
|
|
35
|
+
dep_name = SVELTE_PACKAGE_DEP_NAME,
|
|
35
36
|
): Result<object, {message: string}> => {
|
|
36
37
|
const has_sveltekit_app_result = has_sveltekit_app();
|
|
37
38
|
if (!has_sveltekit_app_result.ok) {
|
|
@@ -42,13 +43,10 @@ export const has_sveltekit_library = (
|
|
|
42
43
|
return {ok: false, message: `no SvelteKit lib directory found at ${sveltekit_config.lib_path}`};
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
!(pkg.devDependencies?.[SVELTE_PACKAGE_DEP_NAME] || pkg.dependencies?.[SVELTE_PACKAGE_DEP_NAME])
|
|
48
|
-
) {
|
|
46
|
+
if (!has_dep(dep_name, package_json)) {
|
|
49
47
|
return {
|
|
50
48
|
ok: false,
|
|
51
|
-
message: `no dependency found in package.json for ${
|
|
49
|
+
message: `no dependency found in package.json for ${dep_name}, install it with \`npm i -D ${dep_name}\``,
|
|
52
50
|
};
|
|
53
51
|
}
|
|
54
52
|
|
package/src/lib/upgrade.task.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {spawn} from '@ryanatkn/belt/process.js';
|
|
|
2
2
|
import {z} from 'zod';
|
|
3
3
|
|
|
4
4
|
import {Task_Error, type Task} from './task.js';
|
|
5
|
-
import {load_package_json, type
|
|
5
|
+
import {extract_deps, load_package_json, type Package_Json_Dep} from './package_json.js';
|
|
6
6
|
import {Git_Origin, git_pull} from './git.js';
|
|
7
7
|
import {spawn_cli} from './cli.js';
|
|
8
8
|
|
|
@@ -41,15 +41,15 @@ export const task: Task<Args> = {
|
|
|
41
41
|
|
|
42
42
|
const package_json = load_package_json();
|
|
43
43
|
|
|
44
|
-
const all_deps =
|
|
44
|
+
const all_deps = extract_deps(package_json);
|
|
45
45
|
|
|
46
46
|
const deps = only.length
|
|
47
|
-
? all_deps.filter((d) => only.includes(d.
|
|
48
|
-
: all_deps.filter((d) => !_.includes(d.
|
|
47
|
+
? all_deps.filter((d) => only.includes(d.name))
|
|
48
|
+
: all_deps.filter((d) => !_.includes(d.name));
|
|
49
49
|
|
|
50
50
|
if (only.length && only.length !== deps.length) {
|
|
51
51
|
throw new Task_Error(
|
|
52
|
-
`Some deps to upgrade were not found: ${only.filter((o) => !deps.find((d) => d.
|
|
52
|
+
`Some deps to upgrade were not found: ${only.filter((o) => !deps.find((d) => d.name === o)).join(', ')}`,
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -72,34 +72,19 @@ export const task: Task<Args> = {
|
|
|
72
72
|
},
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
interface Dep {
|
|
76
|
-
key: string;
|
|
77
|
-
value: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const to_deps = (package_json: Package_Json): Dep[] => {
|
|
81
|
-
const prod_deps: Dep[] = package_json.dependencies
|
|
82
|
-
? Object.entries(package_json.dependencies).map(([key, value]) => ({key, value}))
|
|
83
|
-
: [];
|
|
84
|
-
const dev_deps: Dep[] = package_json.devDependencies
|
|
85
|
-
? Object.entries(package_json.devDependencies).map(([key, value]) => ({key, value}))
|
|
86
|
-
: [];
|
|
87
|
-
return prod_deps.concat(dev_deps);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
75
|
const EXACT_VERSION_MATCHER = /^..*@.+/;
|
|
91
76
|
const CUSTOM_TAG_MATCHER = /^[\^~><=]*.+-(.+)/;
|
|
92
77
|
|
|
93
78
|
// TODO hacky and limited
|
|
94
79
|
// TODO probably want to pass through exact deps as well, e.g. @foo/bar@1
|
|
95
|
-
const to_upgrade_items = (deps:
|
|
80
|
+
const to_upgrade_items = (deps: Package_Json_Dep[]): string[] =>
|
|
96
81
|
deps.map((dep) => {
|
|
97
|
-
if (EXACT_VERSION_MATCHER.test(dep.
|
|
98
|
-
return dep.
|
|
82
|
+
if (EXACT_VERSION_MATCHER.test(dep.name)) {
|
|
83
|
+
return dep.name;
|
|
99
84
|
}
|
|
100
|
-
const custom_tag_matches = CUSTOM_TAG_MATCHER.exec(dep.
|
|
85
|
+
const custom_tag_matches = CUSTOM_TAG_MATCHER.exec(dep.version);
|
|
101
86
|
if (custom_tag_matches) {
|
|
102
|
-
return dep.
|
|
87
|
+
return dep.name + '@' + custom_tag_matches[1].split('.')[0]; // I tried adding `\.?` to the end but doesn't work and I'm being lazy so I'm just splitting
|
|
103
88
|
}
|
|
104
|
-
return dep.
|
|
89
|
+
return dep.name + '@latest';
|
|
105
90
|
});
|
package/dist/throttle.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Throttles calls to a callback that returns a void promise.
|
|
3
|
-
* Immediately invokes the callback on the first call.
|
|
4
|
-
* If the throttled function is called while the promise is already pending,
|
|
5
|
-
* the call is queued to run after the pending promise completes plus `delay`,
|
|
6
|
-
* and only the last call is invoked.
|
|
7
|
-
* In other words, all calls and their args are discarded
|
|
8
|
-
* during the pending window except for the most recent.
|
|
9
|
-
* Unlike debouncing, this calls the throttled callback
|
|
10
|
-
* both on the leading and trailing edges of the delay window,
|
|
11
|
-
* and this can be customized by setting `leading` to `false`.
|
|
12
|
-
* It also differs from a queue where every call to the throttled callback eventually runs.
|
|
13
|
-
* @param cb - any function that returns a void promise
|
|
14
|
-
* @param delay - delay this many milliseconds between the pending call finishing and the next starting
|
|
15
|
-
* @param leading - if `true`, the default, the callback is called immediately
|
|
16
|
-
* @returns same as `cb`
|
|
17
|
-
*/
|
|
18
|
-
export declare const throttle: <T extends (...args: any[]) => Promise<void>>(cb: T, delay?: number, leading?: boolean) => T;
|
|
19
|
-
//# sourceMappingURL=throttle.d.ts.map
|
package/dist/throttle.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.d.ts","sourceRoot":"../src/lib/","sources":["throttle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,MAC/D,CAAC,wCAGH,CA0CF,CAAC"}
|
package/dist/throttle.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Throttles calls to a callback that returns a void promise.
|
|
3
|
-
* Immediately invokes the callback on the first call.
|
|
4
|
-
* If the throttled function is called while the promise is already pending,
|
|
5
|
-
* the call is queued to run after the pending promise completes plus `delay`,
|
|
6
|
-
* and only the last call is invoked.
|
|
7
|
-
* In other words, all calls and their args are discarded
|
|
8
|
-
* during the pending window except for the most recent.
|
|
9
|
-
* Unlike debouncing, this calls the throttled callback
|
|
10
|
-
* both on the leading and trailing edges of the delay window,
|
|
11
|
-
* and this can be customized by setting `leading` to `false`.
|
|
12
|
-
* It also differs from a queue where every call to the throttled callback eventually runs.
|
|
13
|
-
* @param cb - any function that returns a void promise
|
|
14
|
-
* @param delay - delay this many milliseconds between the pending call finishing and the next starting
|
|
15
|
-
* @param leading - if `true`, the default, the callback is called immediately
|
|
16
|
-
* @returns same as `cb`
|
|
17
|
-
*/
|
|
18
|
-
export const throttle = (cb, delay = 0, leading = true) => {
|
|
19
|
-
let pending_promise = null;
|
|
20
|
-
let next_args = null;
|
|
21
|
-
let next_promise = null;
|
|
22
|
-
let next_promise_resolve = null;
|
|
23
|
-
const defer = (args) => {
|
|
24
|
-
next_args = args;
|
|
25
|
-
if (!next_promise) {
|
|
26
|
-
next_promise = new Promise((resolve) => {
|
|
27
|
-
next_promise_resolve = resolve;
|
|
28
|
-
});
|
|
29
|
-
setTimeout(flush, delay);
|
|
30
|
-
}
|
|
31
|
-
return next_promise;
|
|
32
|
-
};
|
|
33
|
-
const flush = async () => {
|
|
34
|
-
if (!next_promise_resolve)
|
|
35
|
-
return;
|
|
36
|
-
const result = await call(next_args);
|
|
37
|
-
next_args = null;
|
|
38
|
-
next_promise = null;
|
|
39
|
-
const resolve = next_promise_resolve;
|
|
40
|
-
next_promise_resolve = null;
|
|
41
|
-
resolve(result); // resolve last to prevent synchronous call issues
|
|
42
|
-
};
|
|
43
|
-
const call = (args) => {
|
|
44
|
-
pending_promise = cb(...args);
|
|
45
|
-
void pending_promise.then(() => {
|
|
46
|
-
pending_promise = null;
|
|
47
|
-
});
|
|
48
|
-
return pending_promise;
|
|
49
|
-
};
|
|
50
|
-
return ((...args) => {
|
|
51
|
-
if (pending_promise || !leading) {
|
|
52
|
-
return defer(args);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return call(args);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
};
|
package/src/lib/throttle.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Throttles calls to a callback that returns a void promise.
|
|
3
|
-
* Immediately invokes the callback on the first call.
|
|
4
|
-
* If the throttled function is called while the promise is already pending,
|
|
5
|
-
* the call is queued to run after the pending promise completes plus `delay`,
|
|
6
|
-
* and only the last call is invoked.
|
|
7
|
-
* In other words, all calls and their args are discarded
|
|
8
|
-
* during the pending window except for the most recent.
|
|
9
|
-
* Unlike debouncing, this calls the throttled callback
|
|
10
|
-
* both on the leading and trailing edges of the delay window,
|
|
11
|
-
* and this can be customized by setting `leading` to `false`.
|
|
12
|
-
* It also differs from a queue where every call to the throttled callback eventually runs.
|
|
13
|
-
* @param cb - any function that returns a void promise
|
|
14
|
-
* @param delay - delay this many milliseconds between the pending call finishing and the next starting
|
|
15
|
-
* @param leading - if `true`, the default, the callback is called immediately
|
|
16
|
-
* @returns same as `cb`
|
|
17
|
-
*/
|
|
18
|
-
export const throttle = <T extends (...args: any[]) => Promise<void>>(
|
|
19
|
-
cb: T,
|
|
20
|
-
delay = 0,
|
|
21
|
-
leading = true,
|
|
22
|
-
): T => {
|
|
23
|
-
let pending_promise: Promise<void> | null = null;
|
|
24
|
-
let next_args: any[] | null = null;
|
|
25
|
-
let next_promise: Promise<void> | null = null;
|
|
26
|
-
let next_promise_resolve: ((value: any) => void) | null = null;
|
|
27
|
-
|
|
28
|
-
const defer = (args: any[]): Promise<void> => {
|
|
29
|
-
next_args = args;
|
|
30
|
-
if (!next_promise) {
|
|
31
|
-
next_promise = new Promise((resolve) => {
|
|
32
|
-
next_promise_resolve = resolve;
|
|
33
|
-
});
|
|
34
|
-
setTimeout(flush, delay);
|
|
35
|
-
}
|
|
36
|
-
return next_promise;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const flush = async (): Promise<void> => {
|
|
40
|
-
if (!next_promise_resolve) return;
|
|
41
|
-
const result = await call(next_args!);
|
|
42
|
-
next_args = null;
|
|
43
|
-
next_promise = null;
|
|
44
|
-
const resolve = next_promise_resolve;
|
|
45
|
-
next_promise_resolve = null;
|
|
46
|
-
resolve(result); // resolve last to prevent synchronous call issues
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const call = (args: any[]): Promise<any> => {
|
|
50
|
-
pending_promise = cb(...args);
|
|
51
|
-
void pending_promise.then(() => {
|
|
52
|
-
pending_promise = null;
|
|
53
|
-
});
|
|
54
|
-
return pending_promise;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return ((...args) => {
|
|
58
|
-
if (pending_promise || !leading) {
|
|
59
|
-
return defer(args);
|
|
60
|
-
} else {
|
|
61
|
-
return call(args);
|
|
62
|
-
}
|
|
63
|
-
}) as T;
|
|
64
|
-
};
|