@c9up/ream 0.2.21 → 0.2.22
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/dev/hotConfig.d.ts +23 -0
- package/dist/dev/hotConfig.d.ts.map +1 -0
- package/dist/dev/hotConfig.js +37 -0
- package/dist/dev/hotConfig.js.map +1 -0
- package/dist/hot.js +4 -27
- package/dist/hot.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/events.win32-x64-msvc.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/scheduler.win32-x64-msvc.node +0 -0
- package/src/dev/hotConfig.ts +42 -0
- package/src/hot.ts +4 -33
- package/src/index.ts +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading `hotHook` out of the application's package.json.
|
|
3
|
+
*
|
|
4
|
+
* The boundaries are the APPLICATION's to declare, as they are upstream: they
|
|
5
|
+
* depend on a layout the framework does not own, and hot-hook requires every
|
|
6
|
+
* file matching one to be dynamically imported — a glob that also catches a
|
|
7
|
+
* statically imported service reports `shouldBeReloadable` and costs a FULL
|
|
8
|
+
* reload, worse than the restart it replaced. `ream new` writes the block;
|
|
9
|
+
* `ream doctor` reports its absence.
|
|
10
|
+
*
|
|
11
|
+
* Extracted from the loader entry so the parsing can be tested: that entry
|
|
12
|
+
* registers an ESM loader the moment it is imported, which a test cannot undo.
|
|
13
|
+
*/
|
|
14
|
+
export interface HotHookConfig {
|
|
15
|
+
root?: string;
|
|
16
|
+
boundaries?: string[];
|
|
17
|
+
restart?: string[];
|
|
18
|
+
ignore?: string[];
|
|
19
|
+
throwWhenBoundariesAreNotDynamicallyImported?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Read `hotHook` out of a parsed package.json, with no assumptions. */
|
|
22
|
+
export declare function readHotHookConfig(pkg: unknown): HotHookConfig;
|
|
23
|
+
//# sourceMappingURL=hotConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotConfig.d.ts","sourceRoot":"","sources":["../../src/dev/hotConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,4CAA4C,CAAC,EAAE,OAAO,CAAA;CACvD;AAED,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAkB7D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading `hotHook` out of the application's package.json.
|
|
3
|
+
*
|
|
4
|
+
* The boundaries are the APPLICATION's to declare, as they are upstream: they
|
|
5
|
+
* depend on a layout the framework does not own, and hot-hook requires every
|
|
6
|
+
* file matching one to be dynamically imported — a glob that also catches a
|
|
7
|
+
* statically imported service reports `shouldBeReloadable` and costs a FULL
|
|
8
|
+
* reload, worse than the restart it replaced. `ream new` writes the block;
|
|
9
|
+
* `ream doctor` reports its absence.
|
|
10
|
+
*
|
|
11
|
+
* Extracted from the loader entry so the parsing can be tested: that entry
|
|
12
|
+
* registers an ESM loader the moment it is imported, which a test cannot undo.
|
|
13
|
+
*/
|
|
14
|
+
/** Read `hotHook` out of a parsed package.json, with no assumptions. */
|
|
15
|
+
export function readHotHookConfig(pkg) {
|
|
16
|
+
if (typeof pkg !== 'object' || pkg === null)
|
|
17
|
+
return {};
|
|
18
|
+
const raw = Reflect.get(pkg, 'hotHook');
|
|
19
|
+
if (typeof raw !== 'object' || raw === null)
|
|
20
|
+
return {};
|
|
21
|
+
const stringArray = (key) => {
|
|
22
|
+
const value = Reflect.get(raw, key);
|
|
23
|
+
if (!Array.isArray(value))
|
|
24
|
+
return undefined;
|
|
25
|
+
return value.filter((entry) => typeof entry === 'string');
|
|
26
|
+
};
|
|
27
|
+
const root = Reflect.get(raw, 'root');
|
|
28
|
+
const strict = Reflect.get(raw, 'throwWhenBoundariesAreNotDynamicallyImported');
|
|
29
|
+
return {
|
|
30
|
+
root: typeof root === 'string' ? root : undefined,
|
|
31
|
+
boundaries: stringArray('boundaries'),
|
|
32
|
+
restart: stringArray('restart'),
|
|
33
|
+
ignore: stringArray('ignore'),
|
|
34
|
+
throwWhenBoundariesAreNotDynamicallyImported: typeof strict === 'boolean' ? strict : undefined,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=hotConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotConfig.js","sourceRoot":"","sources":["../../src/dev/hotConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,wEAAwE;AACxE,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,EAAE,CAAA;IACtD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,EAAE,CAAA;IACtD,MAAM,WAAW,GAAG,CAAC,GAAW,EAAwB,EAAE;QACxD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAA;QAC3C,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAA;IAC5E,CAAC,CAAA;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,8CAA8C,CAAC,CAAA;IAC/E,OAAO;QACL,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QACjD,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC;QACrC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC;QAC/B,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC;QAC7B,4CAA4C,EAAE,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;KAC/F,CAAA;AACH,CAAC"}
|
package/dist/hot.js
CHANGED
|
@@ -26,42 +26,19 @@
|
|
|
26
26
|
* upstream's behaviour, unmodified.
|
|
27
27
|
*/
|
|
28
28
|
import { hotReloadHappened } from './dev/hmr.js';
|
|
29
|
+
import { readHotHookConfig } from './dev/hotConfig.js';
|
|
29
30
|
/** Exit code meaning "restart me" — see `EXIT_RESTART` in the CLI's dev module. */
|
|
30
31
|
const FULL_RELOAD_EXIT_CODE = 75;
|
|
31
|
-
/** Read `hotHook` out of the application's package.json, with no assumptions. */
|
|
32
|
-
function readConfig(pkg) {
|
|
33
|
-
if (typeof pkg !== 'object' || pkg === null)
|
|
34
|
-
return {};
|
|
35
|
-
const raw = Reflect.get(pkg, 'hotHook');
|
|
36
|
-
if (typeof raw !== 'object' || raw === null)
|
|
37
|
-
return {};
|
|
38
|
-
const stringArray = (key) => {
|
|
39
|
-
const value = Reflect.get(raw, key);
|
|
40
|
-
if (!Array.isArray(value))
|
|
41
|
-
return undefined;
|
|
42
|
-
return value.filter((entry) => typeof entry === 'string');
|
|
43
|
-
};
|
|
44
|
-
const root = Reflect.get(raw, 'root');
|
|
45
|
-
const strict = Reflect.get(raw, 'throwWhenBoundariesAreNotDynamicallyImported');
|
|
46
|
-
return {
|
|
47
|
-
root: typeof root === 'string' ? root : undefined,
|
|
48
|
-
boundaries: stringArray('boundaries'),
|
|
49
|
-
restart: stringArray('restart'),
|
|
50
|
-
ignore: stringArray('ignore'),
|
|
51
|
-
throwWhenBoundariesAreNotDynamicallyImported: typeof strict === 'boolean' ? strict : undefined,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
32
|
const { readFile } = await import('node:fs/promises');
|
|
55
33
|
const { dirname, resolve } = await import('node:path');
|
|
56
34
|
const packageJsonPath = resolve(process.cwd(), 'package.json');
|
|
57
35
|
let config = {};
|
|
58
36
|
try {
|
|
59
|
-
config =
|
|
37
|
+
config = readHotHookConfig(JSON.parse(await readFile(packageJsonPath, 'utf8')));
|
|
60
38
|
}
|
|
61
39
|
catch {
|
|
62
|
-
// No package.json, or unreadable:
|
|
63
|
-
// boundaries
|
|
64
|
-
// behaviour, not a failure worth stopping dev over.
|
|
40
|
+
// No package.json, or unreadable: fall through to the conventional
|
|
41
|
+
// boundaries below rather than stopping dev over it.
|
|
65
42
|
}
|
|
66
43
|
// `hot-hook` is an optional peer, declared by the application because it is a
|
|
67
44
|
// dev dependency there and has no business in a production install. Imported by
|
package/dist/hot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hot.js","sourceRoot":"","sources":["../src/hot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"hot.js","sourceRoot":"","sources":["../src/hot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAsB,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE1E,mFAAmF;AACnF,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAchC,MAAM,EAAE,QAAQ,EAA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YAAY,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,KAAK,IAAI,CAAA;IAC1E,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,GAAG,EAAE,IAAI,CAAC;IACd,GAAG,MAAM;IACT,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;IAC9E,0EAA0E;IAC1E,8CAA8C;IAC9C,iBAAiB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC;CAC7D,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -121,5 +121,5 @@ export { BaseEvent, Emitter, type EmitterResolver, type ListenerClass, } from '.
|
|
|
121
121
|
export { type BufferedEvent, type BufferedEventName, type EventFinder, EventsBuffer, } from './events/EventsBuffer.js';
|
|
122
122
|
export type { ErrorReporter, LockBackend, LockBackendFactory, LockRedisClient, LockRedisResolver, RunTaskOutcome, ScheduleEvent, ScheduleEventSink, ScheduleInvocation, ScheduleMetadata, ScheduleProviderOptions, SchedulerConfig, SchedulerOptions, ScheduleTaskCompletedEvent, ScheduleTaskFailedEvent, ScheduleTaskSkippedEvent, ScheduleTaskStartedEvent, TaskInfo, TaskStats, } from './scheduler/index.js';
|
|
123
123
|
export { defineSchedulerConfig, getScheduleMetadata, locks, MemoryLockBackend, RedisLockBackend, SCHEDULE_METADATA_KEY, Schedule, ScheduleProvider, Scheduler, StatsTracker, } from './scheduler/index.js';
|
|
124
|
-
export declare const VERSION = "0.2.
|
|
124
|
+
export declare const VERSION = "0.2.22";
|
|
125
125
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -92,5 +92,5 @@ export { defineConfig as defineEventsConfig } from './events/config.js';
|
|
|
92
92
|
export { BaseEvent, Emitter, } from './events/Emitter.js';
|
|
93
93
|
export { EventsBuffer, } from './events/EventsBuffer.js';
|
|
94
94
|
export { defineSchedulerConfig, getScheduleMetadata, locks, MemoryLockBackend, RedisLockBackend, SCHEDULE_METADATA_KEY, Schedule, ScheduleProvider, Scheduler, StatsTracker, } from './scheduler/index.js';
|
|
95
|
-
export const VERSION = '0.2.
|
|
95
|
+
export const VERSION = '0.2.22';
|
|
96
96
|
//# sourceMappingURL=index.js.map
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading `hotHook` out of the application's package.json.
|
|
3
|
+
*
|
|
4
|
+
* The boundaries are the APPLICATION's to declare, as they are upstream: they
|
|
5
|
+
* depend on a layout the framework does not own, and hot-hook requires every
|
|
6
|
+
* file matching one to be dynamically imported — a glob that also catches a
|
|
7
|
+
* statically imported service reports `shouldBeReloadable` and costs a FULL
|
|
8
|
+
* reload, worse than the restart it replaced. `ream new` writes the block;
|
|
9
|
+
* `ream doctor` reports its absence.
|
|
10
|
+
*
|
|
11
|
+
* Extracted from the loader entry so the parsing can be tested: that entry
|
|
12
|
+
* registers an ESM loader the moment it is imported, which a test cannot undo.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export interface HotHookConfig {
|
|
16
|
+
root?: string
|
|
17
|
+
boundaries?: string[]
|
|
18
|
+
restart?: string[]
|
|
19
|
+
ignore?: string[]
|
|
20
|
+
throwWhenBoundariesAreNotDynamicallyImported?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Read `hotHook` out of a parsed package.json, with no assumptions. */
|
|
24
|
+
export function readHotHookConfig(pkg: unknown): HotHookConfig {
|
|
25
|
+
if (typeof pkg !== 'object' || pkg === null) return {}
|
|
26
|
+
const raw = Reflect.get(pkg, 'hotHook')
|
|
27
|
+
if (typeof raw !== 'object' || raw === null) return {}
|
|
28
|
+
const stringArray = (key: string): string[] | undefined => {
|
|
29
|
+
const value = Reflect.get(raw, key)
|
|
30
|
+
if (!Array.isArray(value)) return undefined
|
|
31
|
+
return value.filter((entry): entry is string => typeof entry === 'string')
|
|
32
|
+
}
|
|
33
|
+
const root = Reflect.get(raw, 'root')
|
|
34
|
+
const strict = Reflect.get(raw, 'throwWhenBoundariesAreNotDynamicallyImported')
|
|
35
|
+
return {
|
|
36
|
+
root: typeof root === 'string' ? root : undefined,
|
|
37
|
+
boundaries: stringArray('boundaries'),
|
|
38
|
+
restart: stringArray('restart'),
|
|
39
|
+
ignore: stringArray('ignore'),
|
|
40
|
+
throwWhenBoundariesAreNotDynamicallyImported: typeof strict === 'boolean' ? strict : undefined,
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/hot.ts
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
import { hotReloadHappened } from './dev/hmr.js'
|
|
30
|
+
import { type HotHookConfig, readHotHookConfig } from './dev/hotConfig.js'
|
|
30
31
|
|
|
31
32
|
/** Exit code meaning "restart me" — see `EXIT_RESTART` in the CLI's dev module. */
|
|
32
33
|
const FULL_RELOAD_EXIT_CODE = 75
|
|
@@ -43,46 +44,16 @@ interface HotHook {
|
|
|
43
44
|
}): Promise<void>
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
interface HotHookConfig {
|
|
47
|
-
root?: string
|
|
48
|
-
boundaries?: string[]
|
|
49
|
-
restart?: string[]
|
|
50
|
-
ignore?: string[]
|
|
51
|
-
throwWhenBoundariesAreNotDynamicallyImported?: boolean
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Read `hotHook` out of the application's package.json, with no assumptions. */
|
|
55
|
-
function readConfig(pkg: unknown): HotHookConfig {
|
|
56
|
-
if (typeof pkg !== 'object' || pkg === null) return {}
|
|
57
|
-
const raw = Reflect.get(pkg, 'hotHook')
|
|
58
|
-
if (typeof raw !== 'object' || raw === null) return {}
|
|
59
|
-
const stringArray = (key: string): string[] | undefined => {
|
|
60
|
-
const value = Reflect.get(raw, key)
|
|
61
|
-
if (!Array.isArray(value)) return undefined
|
|
62
|
-
return value.filter((entry): entry is string => typeof entry === 'string')
|
|
63
|
-
}
|
|
64
|
-
const root = Reflect.get(raw, 'root')
|
|
65
|
-
const strict = Reflect.get(raw, 'throwWhenBoundariesAreNotDynamicallyImported')
|
|
66
|
-
return {
|
|
67
|
-
root: typeof root === 'string' ? root : undefined,
|
|
68
|
-
boundaries: stringArray('boundaries'),
|
|
69
|
-
restart: stringArray('restart'),
|
|
70
|
-
ignore: stringArray('ignore'),
|
|
71
|
-
throwWhenBoundariesAreNotDynamicallyImported: typeof strict === 'boolean' ? strict : undefined,
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
47
|
const { readFile } = await import('node:fs/promises')
|
|
76
48
|
const { dirname, resolve } = await import('node:path')
|
|
77
49
|
|
|
78
50
|
const packageJsonPath = resolve(process.cwd(), 'package.json')
|
|
79
51
|
let config: HotHookConfig = {}
|
|
80
52
|
try {
|
|
81
|
-
config =
|
|
53
|
+
config = readHotHookConfig(JSON.parse(await readFile(packageJsonPath, 'utf8')))
|
|
82
54
|
} catch {
|
|
83
|
-
// No package.json, or unreadable:
|
|
84
|
-
// boundaries
|
|
85
|
-
// behaviour, not a failure worth stopping dev over.
|
|
55
|
+
// No package.json, or unreadable: fall through to the conventional
|
|
56
|
+
// boundaries below rather than stopping dev over it.
|
|
86
57
|
}
|
|
87
58
|
|
|
88
59
|
// `hot-hook` is an optional peer, declared by the application because it is a
|
package/src/index.ts
CHANGED