@moku-labs/worker 0.8.0 → 0.8.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/{cli-By06KF-9.mjs → cli-DNW8_355.mjs} +62 -24
- package/dist/{cli-DkoPBbJC.cjs → cli-l-AOWzhR.cjs} +62 -24
- package/dist/cli.cjs +1 -1
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/{index-BuY9o1u0.d.cts → index-BDkgen4r.d.cts} +25 -3
- package/dist/{index-BuY9o1u0.d.mts → index-BDkgen4r.d.mts} +25 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -1701,7 +1701,8 @@ const buildSite = async (ctx, webBuild) => {
|
|
|
1701
1701
|
* @file deploy plugin — debounced filesystem watcher for dev.
|
|
1702
1702
|
*
|
|
1703
1703
|
* Watches the top-level directories implied by the config globs (recursive) and fires a debounced
|
|
1704
|
-
* change callback with the
|
|
1704
|
+
* change callback with the SET of paths changed in the window (so a burst of edits coalesces into
|
|
1705
|
+
* one rebuild that knows every changed file). Uses node:fs.watch — no extra dependency.
|
|
1705
1706
|
* Node-only; never imported by the runtime Worker bundle.
|
|
1706
1707
|
*/
|
|
1707
1708
|
/**
|
|
@@ -1724,27 +1725,29 @@ const watchDirectories = (globs) => {
|
|
|
1724
1725
|
return [...directories];
|
|
1725
1726
|
};
|
|
1726
1727
|
/**
|
|
1727
|
-
* Watch the directories implied by `globs` and fire `onChange` (debounced by `debounceMs`) with
|
|
1728
|
-
*
|
|
1728
|
+
* Watch the directories implied by `globs` and fire `onChange` (debounced by `debounceMs`) with the
|
|
1729
|
+
* distinct set of paths changed within the window. Missing directories are skipped silently.
|
|
1729
1730
|
*
|
|
1730
1731
|
* @param globs - Watch globs.
|
|
1731
1732
|
* @param debounceMs - Coalesce rapid changes into one callback within this window.
|
|
1732
|
-
* @param onChange - Called with the
|
|
1733
|
+
* @param onChange - Called with the changed paths (snapshot of the window) after the debounce settles.
|
|
1733
1734
|
* @returns A handle whose close() stops all watchers and cancels any pending callback.
|
|
1734
1735
|
* @example
|
|
1735
1736
|
* ```ts
|
|
1736
|
-
* const handle = watchPaths(["src/**\/*.ts"], 120,
|
|
1737
|
+
* const handle = watchPaths(["src/**\/*.ts"], 120, paths => rebuild(paths));
|
|
1737
1738
|
* handle.close();
|
|
1738
1739
|
* ```
|
|
1739
1740
|
*/
|
|
1740
1741
|
const watchPaths = (globs, debounceMs, onChange) => {
|
|
1741
1742
|
let timer;
|
|
1742
|
-
|
|
1743
|
+
const changed = /* @__PURE__ */ new Set();
|
|
1743
1744
|
const fire = (changedPath) => {
|
|
1744
|
-
|
|
1745
|
+
changed.add(changedPath);
|
|
1745
1746
|
if (timer !== void 0) clearTimeout(timer);
|
|
1746
1747
|
timer = setTimeout(() => {
|
|
1747
|
-
|
|
1748
|
+
const batch = [...changed];
|
|
1749
|
+
changed.clear();
|
|
1750
|
+
onChange(batch);
|
|
1748
1751
|
}, debounceMs);
|
|
1749
1752
|
};
|
|
1750
1753
|
const watchers = [];
|
|
@@ -1874,27 +1877,50 @@ const realDevDeps = () => ({
|
|
|
1874
1877
|
*/
|
|
1875
1878
|
const d1MigrationBindings = (ctx) => ctx.has("d1") ? ctx.require(d1Plugin).deployManifest().filter((manifest) => manifest.migrations !== void 0).map((manifest) => manifest.binding) : [];
|
|
1876
1879
|
/**
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
1880
|
+
* One-line description of a changed-path batch for the `dev:phase rebuild` detail: the single path,
|
|
1881
|
+
* or the first path plus a `(+N more)` tail. Empty batches (defensive) read as "site".
|
|
1882
|
+
*
|
|
1883
|
+
* @param paths - The changed paths the watcher coalesced for this rebuild.
|
|
1884
|
+
* @returns The detail string for the rebuild phase event.
|
|
1885
|
+
* @example
|
|
1886
|
+
* ```ts
|
|
1887
|
+
* describeChanges(["src/a.ts", "src/b.css"]); // "src/a.ts (+1 more)"
|
|
1888
|
+
* ```
|
|
1889
|
+
*/
|
|
1890
|
+
const describeChanges = (paths) => {
|
|
1891
|
+
const [first, ...rest] = paths;
|
|
1892
|
+
if (first === void 0) return "site";
|
|
1893
|
+
return rest.length === 0 ? first : `${first} (+${String(rest.length)} more)`;
|
|
1894
|
+
};
|
|
1895
|
+
/**
|
|
1896
|
+
* Rebuild the site once for a changed-path batch and announce the result. The FAST path is the
|
|
1897
|
+
* incremental `onChange(changedPaths)` hook (e.g. `web.cli.update`) when wired; otherwise it falls
|
|
1898
|
+
* back to a full `webBuild()` rebuild (via deps.build) — the prior behavior. A failed rebuild keeps
|
|
1899
|
+
* the session alive (it just emits dev:error and serves the last good build). Both paths share one
|
|
1900
|
+
* `dev:phase rebuild` → `dev:rebuilt`/`dev:error` envelope so the branded dev TUI is identical.
|
|
1879
1901
|
*
|
|
1880
1902
|
* @param ctx - The deploy plugin context.
|
|
1881
1903
|
* @param deps - The injected dev deps.
|
|
1882
|
-
* @param
|
|
1883
|
-
* @param
|
|
1904
|
+
* @param changedPaths - The paths that triggered the rebuild (the watcher's debounced set).
|
|
1905
|
+
* @param hooks - The consumer rebuild hooks.
|
|
1906
|
+
* @param hooks.webBuild - Full rebuild (used when `onChange` is absent — the prior behavior).
|
|
1907
|
+
* @param hooks.onChange - Incremental rebuild for the changed set (the fast path when wired).
|
|
1884
1908
|
* @returns Resolves once the rebuild attempt completes.
|
|
1885
1909
|
* @example
|
|
1886
1910
|
* ```ts
|
|
1887
|
-
* await rebuild(ctx, deps, "src/app.tsx",
|
|
1911
|
+
* await rebuild(ctx, deps, ["src/app.tsx"], { onChange: c => web.cli.update(c) });
|
|
1888
1912
|
* ```
|
|
1889
1913
|
*/
|
|
1890
|
-
const rebuild = async (ctx, deps,
|
|
1914
|
+
const rebuild = async (ctx, deps, changedPaths, hooks) => {
|
|
1891
1915
|
ctx.emit("dev:phase", {
|
|
1892
1916
|
phase: "rebuild",
|
|
1893
|
-
detail:
|
|
1917
|
+
detail: describeChanges(changedPaths)
|
|
1894
1918
|
});
|
|
1895
1919
|
const started = deps.now();
|
|
1896
1920
|
try {
|
|
1897
|
-
|
|
1921
|
+
let files;
|
|
1922
|
+
if (hooks.onChange) files = fileCountOf(await hooks.onChange(changedPaths));
|
|
1923
|
+
else files = (await deps.build(ctx, hooks.webBuild)).files;
|
|
1898
1924
|
ctx.emit("dev:rebuilt", {
|
|
1899
1925
|
files,
|
|
1900
1926
|
ms: deps.now() - started
|
|
@@ -1910,17 +1936,20 @@ const rebuild = async (ctx, deps, changedPath, webBuild) => {
|
|
|
1910
1936
|
* @param ctx - The deploy plugin context (config + emit + require/has).
|
|
1911
1937
|
* @param opts - Optional options.
|
|
1912
1938
|
* @param opts.port - Local dev port (default 8787).
|
|
1913
|
-
* @param opts.webBuild -
|
|
1939
|
+
* @param opts.webBuild - Cold-build hook (also the per-change rebuild when `onChange` is omitted).
|
|
1940
|
+
* @param opts.onChange - Incremental per-change rebuild hook (e.g. `c => web.cli.update(c)`); when
|
|
1941
|
+
* set, each debounced change rebuilds only the changed paths instead of a full `webBuild()`.
|
|
1914
1942
|
* @param deps - Injected side effects (real ones from realDevDeps in production).
|
|
1915
1943
|
* @returns Resolves when the session ends (SIGINT).
|
|
1916
1944
|
* @example
|
|
1917
1945
|
* ```ts
|
|
1918
|
-
* await runDev(ctx, { port: 8787, webBuild: () => web.cli.build() }, realDevDeps());
|
|
1946
|
+
* await runDev(ctx, { port: 8787, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) }, realDevDeps());
|
|
1919
1947
|
* ```
|
|
1920
1948
|
*/
|
|
1921
1949
|
const runDev = async (ctx, opts, deps) => {
|
|
1922
1950
|
const port = opts?.port ?? 8787;
|
|
1923
1951
|
const webBuild = opts?.webBuild;
|
|
1952
|
+
const onChange = opts?.onChange;
|
|
1924
1953
|
ctx.emit("dev:phase", {
|
|
1925
1954
|
phase: "build",
|
|
1926
1955
|
detail: "site"
|
|
@@ -1952,7 +1981,10 @@ const runDev = async (ctx, opts, deps) => {
|
|
|
1952
1981
|
ctx.config.configFile,
|
|
1953
1982
|
"--live-reload"
|
|
1954
1983
|
]);
|
|
1955
|
-
const watcher = deps.watch(ctx.config.watch, ctx.config.debounceMs, (
|
|
1984
|
+
const watcher = deps.watch(ctx.config.watch, ctx.config.debounceMs, (changedPaths) => rebuild(ctx, deps, changedPaths, {
|
|
1985
|
+
webBuild,
|
|
1986
|
+
onChange
|
|
1987
|
+
}));
|
|
1956
1988
|
await Promise.race([deps.untilSignal(), child.whenExited]);
|
|
1957
1989
|
ctx.emit("dev:phase", { phase: "stopping" });
|
|
1958
1990
|
watcher.close();
|
|
@@ -3225,11 +3257,13 @@ const createDeployApi = (ctx) => ({
|
|
|
3225
3257
|
* @param opts - Optional options.
|
|
3226
3258
|
* @param opts.port - Local dev port (default 8787).
|
|
3227
3259
|
* @param opts.stage - Stage for the generated config's resource names (defaults to the app stage).
|
|
3228
|
-
* @param opts.webBuild -
|
|
3260
|
+
* @param opts.webBuild - Cold-build the web site (e.g. `() => webApp.cli.build()`); also the
|
|
3261
|
+
* per-change rebuild when `onChange` is omitted.
|
|
3262
|
+
* @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`).
|
|
3229
3263
|
* @returns Resolves when the dev session ends.
|
|
3230
3264
|
* @example
|
|
3231
3265
|
* ```ts
|
|
3232
|
-
* await api.dev({ port: 8787, webBuild: () => web.cli.build() });
|
|
3266
|
+
* await api.dev({ port: 8787, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
|
|
3233
3267
|
* ```
|
|
3234
3268
|
*/
|
|
3235
3269
|
async dev(opts) {
|
|
@@ -3482,11 +3516,14 @@ const createCliApi = (ctx) => ({
|
|
|
3482
3516
|
* @param opts - Optional local dev options.
|
|
3483
3517
|
* @param opts.port - Local dev port to bind. Defaults to 8787 when omitted.
|
|
3484
3518
|
* @param opts.stage - Stage for the generated wrangler config; falls back to `--stage` then the app stage.
|
|
3485
|
-
* @param opts.webBuild -
|
|
3519
|
+
* @param opts.webBuild - Cold-build the web site (e.g. `() => webApp.cli.build()`); also the
|
|
3520
|
+
* per-change rebuild when `onChange` is omitted.
|
|
3521
|
+
* @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`),
|
|
3522
|
+
* so each change rebuilds only the changed paths instead of a full `webBuild()`.
|
|
3486
3523
|
* @returns Resolves when the dev session ends.
|
|
3487
3524
|
* @example
|
|
3488
3525
|
* ```ts
|
|
3489
|
-
* await api.dev({ port: 7878, webBuild: () => web.cli.build() });
|
|
3526
|
+
* await api.dev({ port: 7878, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
|
|
3490
3527
|
* ```
|
|
3491
3528
|
*/
|
|
3492
3529
|
async dev(opts) {
|
|
@@ -3500,7 +3537,8 @@ const createCliApi = (ctx) => ({
|
|
|
3500
3537
|
await ctx.require(deployPlugin).dev({
|
|
3501
3538
|
...opts?.port === void 0 ? {} : { port: opts.port },
|
|
3502
3539
|
...stage === void 0 ? {} : { stage },
|
|
3503
|
-
...opts?.webBuild ? { webBuild: opts.webBuild } : {}
|
|
3540
|
+
...opts?.webBuild ? { webBuild: opts.webBuild } : {},
|
|
3541
|
+
...opts?.onChange ? { onChange: opts.onChange } : {}
|
|
3504
3542
|
});
|
|
3505
3543
|
ui.check(true, "dev session stopped cleanly");
|
|
3506
3544
|
} catch (error) {
|
|
@@ -1724,7 +1724,8 @@ const buildSite = async (ctx, webBuild) => {
|
|
|
1724
1724
|
* @file deploy plugin — debounced filesystem watcher for dev.
|
|
1725
1725
|
*
|
|
1726
1726
|
* Watches the top-level directories implied by the config globs (recursive) and fires a debounced
|
|
1727
|
-
* change callback with the
|
|
1727
|
+
* change callback with the SET of paths changed in the window (so a burst of edits coalesces into
|
|
1728
|
+
* one rebuild that knows every changed file). Uses node:fs.watch — no extra dependency.
|
|
1728
1729
|
* Node-only; never imported by the runtime Worker bundle.
|
|
1729
1730
|
*/
|
|
1730
1731
|
/**
|
|
@@ -1747,27 +1748,29 @@ const watchDirectories = (globs) => {
|
|
|
1747
1748
|
return [...directories];
|
|
1748
1749
|
};
|
|
1749
1750
|
/**
|
|
1750
|
-
* Watch the directories implied by `globs` and fire `onChange` (debounced by `debounceMs`) with
|
|
1751
|
-
*
|
|
1751
|
+
* Watch the directories implied by `globs` and fire `onChange` (debounced by `debounceMs`) with the
|
|
1752
|
+
* distinct set of paths changed within the window. Missing directories are skipped silently.
|
|
1752
1753
|
*
|
|
1753
1754
|
* @param globs - Watch globs.
|
|
1754
1755
|
* @param debounceMs - Coalesce rapid changes into one callback within this window.
|
|
1755
|
-
* @param onChange - Called with the
|
|
1756
|
+
* @param onChange - Called with the changed paths (snapshot of the window) after the debounce settles.
|
|
1756
1757
|
* @returns A handle whose close() stops all watchers and cancels any pending callback.
|
|
1757
1758
|
* @example
|
|
1758
1759
|
* ```ts
|
|
1759
|
-
* const handle = watchPaths(["src/**\/*.ts"], 120,
|
|
1760
|
+
* const handle = watchPaths(["src/**\/*.ts"], 120, paths => rebuild(paths));
|
|
1760
1761
|
* handle.close();
|
|
1761
1762
|
* ```
|
|
1762
1763
|
*/
|
|
1763
1764
|
const watchPaths = (globs, debounceMs, onChange) => {
|
|
1764
1765
|
let timer;
|
|
1765
|
-
|
|
1766
|
+
const changed = /* @__PURE__ */ new Set();
|
|
1766
1767
|
const fire = (changedPath) => {
|
|
1767
|
-
|
|
1768
|
+
changed.add(changedPath);
|
|
1768
1769
|
if (timer !== void 0) clearTimeout(timer);
|
|
1769
1770
|
timer = setTimeout(() => {
|
|
1770
|
-
|
|
1771
|
+
const batch = [...changed];
|
|
1772
|
+
changed.clear();
|
|
1773
|
+
onChange(batch);
|
|
1771
1774
|
}, debounceMs);
|
|
1772
1775
|
};
|
|
1773
1776
|
const watchers = [];
|
|
@@ -1897,27 +1900,50 @@ const realDevDeps = () => ({
|
|
|
1897
1900
|
*/
|
|
1898
1901
|
const d1MigrationBindings = (ctx) => ctx.has("d1") ? ctx.require(d1Plugin).deployManifest().filter((manifest) => manifest.migrations !== void 0).map((manifest) => manifest.binding) : [];
|
|
1899
1902
|
/**
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1903
|
+
* One-line description of a changed-path batch for the `dev:phase rebuild` detail: the single path,
|
|
1904
|
+
* or the first path plus a `(+N more)` tail. Empty batches (defensive) read as "site".
|
|
1905
|
+
*
|
|
1906
|
+
* @param paths - The changed paths the watcher coalesced for this rebuild.
|
|
1907
|
+
* @returns The detail string for the rebuild phase event.
|
|
1908
|
+
* @example
|
|
1909
|
+
* ```ts
|
|
1910
|
+
* describeChanges(["src/a.ts", "src/b.css"]); // "src/a.ts (+1 more)"
|
|
1911
|
+
* ```
|
|
1912
|
+
*/
|
|
1913
|
+
const describeChanges = (paths) => {
|
|
1914
|
+
const [first, ...rest] = paths;
|
|
1915
|
+
if (first === void 0) return "site";
|
|
1916
|
+
return rest.length === 0 ? first : `${first} (+${String(rest.length)} more)`;
|
|
1917
|
+
};
|
|
1918
|
+
/**
|
|
1919
|
+
* Rebuild the site once for a changed-path batch and announce the result. The FAST path is the
|
|
1920
|
+
* incremental `onChange(changedPaths)` hook (e.g. `web.cli.update`) when wired; otherwise it falls
|
|
1921
|
+
* back to a full `webBuild()` rebuild (via deps.build) — the prior behavior. A failed rebuild keeps
|
|
1922
|
+
* the session alive (it just emits dev:error and serves the last good build). Both paths share one
|
|
1923
|
+
* `dev:phase rebuild` → `dev:rebuilt`/`dev:error` envelope so the branded dev TUI is identical.
|
|
1902
1924
|
*
|
|
1903
1925
|
* @param ctx - The deploy plugin context.
|
|
1904
1926
|
* @param deps - The injected dev deps.
|
|
1905
|
-
* @param
|
|
1906
|
-
* @param
|
|
1927
|
+
* @param changedPaths - The paths that triggered the rebuild (the watcher's debounced set).
|
|
1928
|
+
* @param hooks - The consumer rebuild hooks.
|
|
1929
|
+
* @param hooks.webBuild - Full rebuild (used when `onChange` is absent — the prior behavior).
|
|
1930
|
+
* @param hooks.onChange - Incremental rebuild for the changed set (the fast path when wired).
|
|
1907
1931
|
* @returns Resolves once the rebuild attempt completes.
|
|
1908
1932
|
* @example
|
|
1909
1933
|
* ```ts
|
|
1910
|
-
* await rebuild(ctx, deps, "src/app.tsx",
|
|
1934
|
+
* await rebuild(ctx, deps, ["src/app.tsx"], { onChange: c => web.cli.update(c) });
|
|
1911
1935
|
* ```
|
|
1912
1936
|
*/
|
|
1913
|
-
const rebuild = async (ctx, deps,
|
|
1937
|
+
const rebuild = async (ctx, deps, changedPaths, hooks) => {
|
|
1914
1938
|
ctx.emit("dev:phase", {
|
|
1915
1939
|
phase: "rebuild",
|
|
1916
|
-
detail:
|
|
1940
|
+
detail: describeChanges(changedPaths)
|
|
1917
1941
|
});
|
|
1918
1942
|
const started = deps.now();
|
|
1919
1943
|
try {
|
|
1920
|
-
|
|
1944
|
+
let files;
|
|
1945
|
+
if (hooks.onChange) files = fileCountOf(await hooks.onChange(changedPaths));
|
|
1946
|
+
else files = (await deps.build(ctx, hooks.webBuild)).files;
|
|
1921
1947
|
ctx.emit("dev:rebuilt", {
|
|
1922
1948
|
files,
|
|
1923
1949
|
ms: deps.now() - started
|
|
@@ -1933,17 +1959,20 @@ const rebuild = async (ctx, deps, changedPath, webBuild) => {
|
|
|
1933
1959
|
* @param ctx - The deploy plugin context (config + emit + require/has).
|
|
1934
1960
|
* @param opts - Optional options.
|
|
1935
1961
|
* @param opts.port - Local dev port (default 8787).
|
|
1936
|
-
* @param opts.webBuild -
|
|
1962
|
+
* @param opts.webBuild - Cold-build hook (also the per-change rebuild when `onChange` is omitted).
|
|
1963
|
+
* @param opts.onChange - Incremental per-change rebuild hook (e.g. `c => web.cli.update(c)`); when
|
|
1964
|
+
* set, each debounced change rebuilds only the changed paths instead of a full `webBuild()`.
|
|
1937
1965
|
* @param deps - Injected side effects (real ones from realDevDeps in production).
|
|
1938
1966
|
* @returns Resolves when the session ends (SIGINT).
|
|
1939
1967
|
* @example
|
|
1940
1968
|
* ```ts
|
|
1941
|
-
* await runDev(ctx, { port: 8787, webBuild: () => web.cli.build() }, realDevDeps());
|
|
1969
|
+
* await runDev(ctx, { port: 8787, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) }, realDevDeps());
|
|
1942
1970
|
* ```
|
|
1943
1971
|
*/
|
|
1944
1972
|
const runDev = async (ctx, opts, deps) => {
|
|
1945
1973
|
const port = opts?.port ?? 8787;
|
|
1946
1974
|
const webBuild = opts?.webBuild;
|
|
1975
|
+
const onChange = opts?.onChange;
|
|
1947
1976
|
ctx.emit("dev:phase", {
|
|
1948
1977
|
phase: "build",
|
|
1949
1978
|
detail: "site"
|
|
@@ -1975,7 +2004,10 @@ const runDev = async (ctx, opts, deps) => {
|
|
|
1975
2004
|
ctx.config.configFile,
|
|
1976
2005
|
"--live-reload"
|
|
1977
2006
|
]);
|
|
1978
|
-
const watcher = deps.watch(ctx.config.watch, ctx.config.debounceMs, (
|
|
2007
|
+
const watcher = deps.watch(ctx.config.watch, ctx.config.debounceMs, (changedPaths) => rebuild(ctx, deps, changedPaths, {
|
|
2008
|
+
webBuild,
|
|
2009
|
+
onChange
|
|
2010
|
+
}));
|
|
1979
2011
|
await Promise.race([deps.untilSignal(), child.whenExited]);
|
|
1980
2012
|
ctx.emit("dev:phase", { phase: "stopping" });
|
|
1981
2013
|
watcher.close();
|
|
@@ -3248,11 +3280,13 @@ const createDeployApi = (ctx) => ({
|
|
|
3248
3280
|
* @param opts - Optional options.
|
|
3249
3281
|
* @param opts.port - Local dev port (default 8787).
|
|
3250
3282
|
* @param opts.stage - Stage for the generated config's resource names (defaults to the app stage).
|
|
3251
|
-
* @param opts.webBuild -
|
|
3283
|
+
* @param opts.webBuild - Cold-build the web site (e.g. `() => webApp.cli.build()`); also the
|
|
3284
|
+
* per-change rebuild when `onChange` is omitted.
|
|
3285
|
+
* @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`).
|
|
3252
3286
|
* @returns Resolves when the dev session ends.
|
|
3253
3287
|
* @example
|
|
3254
3288
|
* ```ts
|
|
3255
|
-
* await api.dev({ port: 8787, webBuild: () => web.cli.build() });
|
|
3289
|
+
* await api.dev({ port: 8787, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
|
|
3256
3290
|
* ```
|
|
3257
3291
|
*/
|
|
3258
3292
|
async dev(opts) {
|
|
@@ -3505,11 +3539,14 @@ const createCliApi = (ctx) => ({
|
|
|
3505
3539
|
* @param opts - Optional local dev options.
|
|
3506
3540
|
* @param opts.port - Local dev port to bind. Defaults to 8787 when omitted.
|
|
3507
3541
|
* @param opts.stage - Stage for the generated wrangler config; falls back to `--stage` then the app stage.
|
|
3508
|
-
* @param opts.webBuild -
|
|
3542
|
+
* @param opts.webBuild - Cold-build the web site (e.g. `() => webApp.cli.build()`); also the
|
|
3543
|
+
* per-change rebuild when `onChange` is omitted.
|
|
3544
|
+
* @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`),
|
|
3545
|
+
* so each change rebuilds only the changed paths instead of a full `webBuild()`.
|
|
3509
3546
|
* @returns Resolves when the dev session ends.
|
|
3510
3547
|
* @example
|
|
3511
3548
|
* ```ts
|
|
3512
|
-
* await api.dev({ port: 7878, webBuild: () => web.cli.build() });
|
|
3549
|
+
* await api.dev({ port: 7878, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
|
|
3513
3550
|
* ```
|
|
3514
3551
|
*/
|
|
3515
3552
|
async dev(opts) {
|
|
@@ -3523,7 +3560,8 @@ const createCliApi = (ctx) => ({
|
|
|
3523
3560
|
await ctx.require(deployPlugin).dev({
|
|
3524
3561
|
...opts?.port === void 0 ? {} : { port: opts.port },
|
|
3525
3562
|
...stage === void 0 ? {} : { stage },
|
|
3526
|
-
...opts?.webBuild ? { webBuild: opts.webBuild } : {}
|
|
3563
|
+
...opts?.webBuild ? { webBuild: opts.webBuild } : {},
|
|
3564
|
+
...opts?.onChange ? { onChange: opts.onChange } : {}
|
|
3527
3565
|
});
|
|
3528
3566
|
ui.check(true, "dev session stopped cleanly");
|
|
3529
3567
|
} catch (error) {
|
package/dist/cli.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cli = require("./cli-
|
|
2
|
+
const require_cli = require("./cli-l-AOWzhR.cjs");
|
|
3
3
|
exports.cliPlugin = require_cli.cliPlugin;
|
|
4
4
|
exports.deployPlugin = require_cli.deployPlugin;
|
package/dist/cli.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-
|
|
1
|
+
import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-BDkgen4r.cjs";
|
|
2
2
|
export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-
|
|
1
|
+
import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-BDkgen4r.mjs";
|
|
2
2
|
export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as deployPlugin, t as cliPlugin } from "./cli-
|
|
1
|
+
import { n as deployPlugin, t as cliPlugin } from "./cli-DNW8_355.mjs";
|
|
2
2
|
export { cliPlugin, deployPlugin };
|
|
@@ -102,6 +102,23 @@ type WorkerPluginCtx<Config, State, Events extends Record<string, unknown> = Rec
|
|
|
102
102
|
* ```
|
|
103
103
|
*/
|
|
104
104
|
type WebBuild = () => Promise<unknown>;
|
|
105
|
+
/**
|
|
106
|
+
* A per-change INCREMENTAL rebuild hook wired in from the consumer's dev script — e.g.
|
|
107
|
+
* `(changes) => webApp.cli.update(changes)`. The fast counterpart to {@link WebBuild}: `dev`
|
|
108
|
+
* calls {@link WebBuild} ONCE for the cold build, then (when this hook is wired) calls `onChange`
|
|
109
|
+
* with the set of paths changed in the debounce window so the web build can rebuild only what
|
|
110
|
+
* changed instead of doing a full `webBuild()` every keystroke. Omit it and `dev` keeps doing a
|
|
111
|
+
* full `webBuild()` per change (the prior behavior). Like {@link WebBuild} it may resolve ANYTHING
|
|
112
|
+
* (the web build's own summary); the value is read opportunistically for a `files` count.
|
|
113
|
+
*
|
|
114
|
+
* @param changes - The paths changed since the last rebuild (the watcher's debounced set).
|
|
115
|
+
* @returns Resolves when the incremental rebuild completes.
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* await server.cli.dev({ webBuild: () => web.cli.build(), onChange: changes => web.cli.update(changes) });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
type OnChange = (changes: readonly string[]) => Promise<unknown>;
|
|
105
122
|
/** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
|
|
106
123
|
type Config$1 = {
|
|
107
124
|
/**
|
|
@@ -268,22 +285,26 @@ type Api = {
|
|
|
268
285
|
* when omitted. A failure renders a branded `✗` line and sets a non-zero exit code rather than
|
|
269
286
|
* throwing a raw stack trace.
|
|
270
287
|
*
|
|
271
|
-
* @param opts - Optional port, stage, and
|
|
288
|
+
* @param opts - Optional port, stage, cold-build hook, and incremental change hook.
|
|
272
289
|
* @param opts.port - Local dev port to bind. Defaults to 8787 when omitted.
|
|
273
290
|
* @param opts.stage - Stage for the generated wrangler config's resource names. Falls back to the
|
|
274
291
|
* `--stage` CLI flag, then the app's configured stage. Pass it explicitly from a script for a
|
|
275
292
|
* self-documenting `dev({ stage })` instead of relying on the hidden flag.
|
|
276
|
-
* @param opts.webBuild -
|
|
293
|
+
* @param opts.webBuild - Cold-build the web site (e.g. `() => webApp.cli.build()`); also the
|
|
294
|
+
* per-change rebuild when `onChange` is omitted.
|
|
295
|
+
* @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`),
|
|
296
|
+
* so each change rebuilds only the changed paths instead of a full `webBuild()` every keystroke.
|
|
277
297
|
* @returns Resolves when the dev session ends.
|
|
278
298
|
* @example
|
|
279
299
|
* ```ts
|
|
280
|
-
* await app.cli.dev({ stage: "dev", port: 7878, webBuild: () => web.cli.build() });
|
|
300
|
+
* await app.cli.dev({ stage: "dev", port: 7878, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
|
|
281
301
|
* ```
|
|
282
302
|
*/
|
|
283
303
|
dev(opts?: {
|
|
284
304
|
port?: number;
|
|
285
305
|
stage?: string;
|
|
286
306
|
webBuild?: WebBuild;
|
|
307
|
+
onChange?: OnChange;
|
|
287
308
|
}): Promise<void>;
|
|
288
309
|
/**
|
|
289
310
|
* One-command Cloudflare deploy (delegates to deploy.run). Guided/interactive by default; pass
|
|
@@ -415,6 +436,7 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
|
|
|
415
436
|
port?: number;
|
|
416
437
|
stage?: string;
|
|
417
438
|
webBuild?: WebBuild;
|
|
439
|
+
onChange?: OnChange;
|
|
418
440
|
}): Promise<void>;
|
|
419
441
|
seed(sqlFile: string, opts?: {
|
|
420
442
|
stage?: string;
|
|
@@ -102,6 +102,23 @@ type WorkerPluginCtx<Config, State, Events extends Record<string, unknown> = Rec
|
|
|
102
102
|
* ```
|
|
103
103
|
*/
|
|
104
104
|
type WebBuild = () => Promise<unknown>;
|
|
105
|
+
/**
|
|
106
|
+
* A per-change INCREMENTAL rebuild hook wired in from the consumer's dev script — e.g.
|
|
107
|
+
* `(changes) => webApp.cli.update(changes)`. The fast counterpart to {@link WebBuild}: `dev`
|
|
108
|
+
* calls {@link WebBuild} ONCE for the cold build, then (when this hook is wired) calls `onChange`
|
|
109
|
+
* with the set of paths changed in the debounce window so the web build can rebuild only what
|
|
110
|
+
* changed instead of doing a full `webBuild()` every keystroke. Omit it and `dev` keeps doing a
|
|
111
|
+
* full `webBuild()` per change (the prior behavior). Like {@link WebBuild} it may resolve ANYTHING
|
|
112
|
+
* (the web build's own summary); the value is read opportunistically for a `files` count.
|
|
113
|
+
*
|
|
114
|
+
* @param changes - The paths changed since the last rebuild (the watcher's debounced set).
|
|
115
|
+
* @returns Resolves when the incremental rebuild completes.
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* await server.cli.dev({ webBuild: () => web.cli.build(), onChange: changes => web.cli.update(changes) });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
type OnChange = (changes: readonly string[]) => Promise<unknown>;
|
|
105
122
|
/** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
|
|
106
123
|
type Config$1 = {
|
|
107
124
|
/**
|
|
@@ -268,22 +285,26 @@ type Api = {
|
|
|
268
285
|
* when omitted. A failure renders a branded `✗` line and sets a non-zero exit code rather than
|
|
269
286
|
* throwing a raw stack trace.
|
|
270
287
|
*
|
|
271
|
-
* @param opts - Optional port, stage, and
|
|
288
|
+
* @param opts - Optional port, stage, cold-build hook, and incremental change hook.
|
|
272
289
|
* @param opts.port - Local dev port to bind. Defaults to 8787 when omitted.
|
|
273
290
|
* @param opts.stage - Stage for the generated wrangler config's resource names. Falls back to the
|
|
274
291
|
* `--stage` CLI flag, then the app's configured stage. Pass it explicitly from a script for a
|
|
275
292
|
* self-documenting `dev({ stage })` instead of relying on the hidden flag.
|
|
276
|
-
* @param opts.webBuild -
|
|
293
|
+
* @param opts.webBuild - Cold-build the web site (e.g. `() => webApp.cli.build()`); also the
|
|
294
|
+
* per-change rebuild when `onChange` is omitted.
|
|
295
|
+
* @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`),
|
|
296
|
+
* so each change rebuilds only the changed paths instead of a full `webBuild()` every keystroke.
|
|
277
297
|
* @returns Resolves when the dev session ends.
|
|
278
298
|
* @example
|
|
279
299
|
* ```ts
|
|
280
|
-
* await app.cli.dev({ stage: "dev", port: 7878, webBuild: () => web.cli.build() });
|
|
300
|
+
* await app.cli.dev({ stage: "dev", port: 7878, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
|
|
281
301
|
* ```
|
|
282
302
|
*/
|
|
283
303
|
dev(opts?: {
|
|
284
304
|
port?: number;
|
|
285
305
|
stage?: string;
|
|
286
306
|
webBuild?: WebBuild;
|
|
307
|
+
onChange?: OnChange;
|
|
287
308
|
}): Promise<void>;
|
|
288
309
|
/**
|
|
289
310
|
* One-command Cloudflare deploy (delegates to deploy.run). Guided/interactive by default; pass
|
|
@@ -415,6 +436,7 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
|
|
|
415
436
|
port?: number;
|
|
416
437
|
stage?: string;
|
|
417
438
|
webBuild?: WebBuild;
|
|
439
|
+
onChange?: OnChange;
|
|
418
440
|
}): Promise<void>;
|
|
419
441
|
seed(sqlFile: string, opts?: {
|
|
420
442
|
stage?: string;
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cli = require("./cli-
|
|
2
|
+
const require_cli = require("./cli-l-AOWzhR.cjs");
|
|
3
3
|
let _moku_labs_common = require("@moku-labs/common");
|
|
4
4
|
//#region src/env-provider.ts
|
|
5
5
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as WorkerConfig, c as WorkerPluginCtx, i as ResourceManifest, n as cliPlugin, o as WorkerEnv, r as ExternalManifest, s as WorkerEvents, t as deployPlugin } from "./index-
|
|
1
|
+
import { a as WorkerConfig, c as WorkerPluginCtx, i as ResourceManifest, n as cliPlugin, o as WorkerEnv, r as ExternalManifest, s as WorkerEvents, t as deployPlugin } from "./index-BDkgen4r.cjs";
|
|
2
2
|
import { envPlugin, logPlugin } from "@moku-labs/common";
|
|
3
3
|
import { PluginCtx, PluginCtx as PluginCtx$1, PluginInstance } from "@moku-labs/core";
|
|
4
4
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as WorkerConfig, c as WorkerPluginCtx, i as ResourceManifest, n as cliPlugin, o as WorkerEnv, r as ExternalManifest, s as WorkerEvents, t as deployPlugin } from "./index-
|
|
1
|
+
import { a as WorkerConfig, c as WorkerPluginCtx, i as ResourceManifest, n as cliPlugin, o as WorkerEnv, r as ExternalManifest, s as WorkerEvents, t as deployPlugin } from "./index-BDkgen4r.mjs";
|
|
2
2
|
import { envPlugin, logPlugin } from "@moku-labs/common";
|
|
3
3
|
import { PluginCtx, PluginCtx as PluginCtx$1, PluginInstance } from "@moku-labs/core";
|
|
4
4
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as kvPlugin, c as d1Plugin, d as createCore, f as createPlugin$1, i as queuesPlugin, l as bindingsPlugin, n as deployPlugin, o as durableObjectsPlugin, p as stagePlugin, r as storagePlugin, s as defineDurableObject, t as cliPlugin, u as coreConfig } from "./cli-
|
|
1
|
+
import { a as kvPlugin, c as d1Plugin, d as createCore, f as createPlugin$1, i as queuesPlugin, l as bindingsPlugin, n as deployPlugin, o as durableObjectsPlugin, p as stagePlugin, r as storagePlugin, s as defineDurableObject, t as cliPlugin, u as coreConfig } from "./cli-DNW8_355.mjs";
|
|
2
2
|
import { envPlugin, logPlugin } from "@moku-labs/common";
|
|
3
3
|
//#region src/env-provider.ts
|
|
4
4
|
/**
|
package/package.json
CHANGED