@stonecrop/stonecrop 0.13.11 → 0.13.14
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/src/client-handler.d.ts +43 -0
- package/dist/src/client-handler.d.ts.map +1 -0
- package/dist/src/client-handler.js +42 -0
- package/dist/src/stores/operation-log.d.ts.map +1 -1
- package/dist/stonecrop.js +7 -9
- package/dist/stonecrop.js.map +1 -1
- package/package.json +4 -4
- package/src/stores/operation-log.ts +7 -9
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clientHandler execution
|
|
3
|
+
* Pure executor for docbuilder-authored client handlers.
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Named capabilities injected into a clientHandler body as function parameters.
|
|
8
|
+
* The caller (the assembly composable) owns what each name resolves to — typically
|
|
9
|
+
* `router`, `record`, `runAction`, and a read-only `graphql`.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export type ClientHandlerApi = Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Execute a docbuilder-authored `clientHandler` body against an injected API map.
|
|
16
|
+
*
|
|
17
|
+
* `code` is a function *body* (statements), not a full function — authored in the
|
|
18
|
+
* docbuilder code editor and stored on `ActionDefinition.clientHandler`. It is compiled
|
|
19
|
+
* with the AsyncFunction constructor, so `await` works directly. Each key of `api`
|
|
20
|
+
* becomes a parameter name bound to its value, so a handler can reference `router`,
|
|
21
|
+
* `record`, `runAction`, etc. by name.
|
|
22
|
+
*
|
|
23
|
+
* This executor is deliberately concern-free: it performs no routing, dispatch, or HST
|
|
24
|
+
* writes itself — the caller assembles `api`. The injected set is an *intent* contract,
|
|
25
|
+
* not a sandbox (an AsyncFunction body can still reach `fetch`/`window`); enforcement of
|
|
26
|
+
* what a handler may actually do lives server-side, not here.
|
|
27
|
+
*
|
|
28
|
+
* Errors are propagated to the caller as a rejected promise — syntax errors at compile
|
|
29
|
+
* time and thrown errors / rejections at run time — so callers handle both uniformly.
|
|
30
|
+
*
|
|
31
|
+
* @param code - the clientHandler body, e.g. `"router.push('/users')"`
|
|
32
|
+
* @param api - named capabilities injected as parameters (default: none)
|
|
33
|
+
* @returns whatever the body returns (typically `void`)
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* await executeClientHandler("await runAction('Assign', [record.id])", { runAction, record })
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare function executeClientHandler(code: string, api?: ClientHandlerApi): Promise<unknown>;
|
|
43
|
+
//# sourceMappingURL=client-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-handler.d.ts","sourceRoot":"","sources":["../../src/client-handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAStD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,gBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,CAIrG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clientHandler execution
|
|
3
|
+
* Pure executor for docbuilder-authored client handlers.
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
// AsyncFunction is not a global; reach it via an async function's constructor so authored
|
|
7
|
+
// bodies can use top-level `await` without writing an async wrapper.
|
|
8
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- an async function's constructor is always the AsyncFunction constructor
|
|
9
|
+
const AsyncFunction = Object.getPrototypeOf(async () => { }).constructor;
|
|
10
|
+
/**
|
|
11
|
+
* Execute a docbuilder-authored `clientHandler` body against an injected API map.
|
|
12
|
+
*
|
|
13
|
+
* `code` is a function *body* (statements), not a full function — authored in the
|
|
14
|
+
* docbuilder code editor and stored on `ActionDefinition.clientHandler`. It is compiled
|
|
15
|
+
* with the AsyncFunction constructor, so `await` works directly. Each key of `api`
|
|
16
|
+
* becomes a parameter name bound to its value, so a handler can reference `router`,
|
|
17
|
+
* `record`, `runAction`, etc. by name.
|
|
18
|
+
*
|
|
19
|
+
* This executor is deliberately concern-free: it performs no routing, dispatch, or HST
|
|
20
|
+
* writes itself — the caller assembles `api`. The injected set is an *intent* contract,
|
|
21
|
+
* not a sandbox (an AsyncFunction body can still reach `fetch`/`window`); enforcement of
|
|
22
|
+
* what a handler may actually do lives server-side, not here.
|
|
23
|
+
*
|
|
24
|
+
* Errors are propagated to the caller as a rejected promise — syntax errors at compile
|
|
25
|
+
* time and thrown errors / rejections at run time — so callers handle both uniformly.
|
|
26
|
+
*
|
|
27
|
+
* @param code - the clientHandler body, e.g. `"router.push('/users')"`
|
|
28
|
+
* @param api - named capabilities injected as parameters (default: none)
|
|
29
|
+
* @returns whatever the body returns (typically `void`)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* await executeClientHandler("await runAction('Assign', [record.id])", { runAction, record })
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export async function executeClientHandler(code, api = {}) {
|
|
39
|
+
const names = Object.keys(api);
|
|
40
|
+
const fn = new AsyncFunction(...names, code);
|
|
41
|
+
return fn(...names.map(name => api[name]));
|
|
42
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-log.d.ts","sourceRoot":"","sources":["../../../src/stores/operation-log.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,KAAK,EAEX,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,oB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AAE;uBA1BrD,oBAAoB;oCAmCL,MAAM,UAAU,MAAM;yBAmBnD,MAAM,cACH,MAAM,cACN,MAAM,EAAE,WACZ,SAAS,GAAG,SAAS,GAAG,SAAS,UACjC,MAAM,KACZ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA3SmB,OAAO,CAAC,kBAAkB,CAAC;8BAkBtB,iBAAiB,WAAU,eAAe;;gCA0DxC,MAAM,KAAG,MAAM,GAAG,IAAI;;kBA2EpC,OAAO,KAAG,OAAO;kBAiDjB,OAAO,KAAG,OAAO;;gCAkEH,MAAM,aAAa,MAAM,KAAG,YAAY,EAAE;uBA1BrD,oBAAoB;oCAmCL,MAAM,UAAU,MAAM;yBAmBnD,MAAM,cACH,MAAM,cACN,MAAM,EAAE,WACZ,SAAS,GAAG,SAAS,GAAG,SAAS,UACjC,MAAM,KACZ,MAAM;oLA6MR,CAAA"}
|
package/dist/stonecrop.js
CHANGED
|
@@ -361,15 +361,13 @@ const Ie = Ci("hst-operation-log", () => {
|
|
|
361
361
|
for (let y = r.value; y >= 0 && t.value[y]?.reversible; y--)
|
|
362
362
|
v++;
|
|
363
363
|
return v;
|
|
364
|
-
}), c = J(() => t.value.length - 1 - r.value), f = J(
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
})
|
|
372
|
-
);
|
|
364
|
+
}), c = J(() => t.value.length - 1 - r.value), f = J(() => ({
|
|
365
|
+
canUndo: s.value,
|
|
366
|
+
canRedo: a.value,
|
|
367
|
+
undoCount: u.value,
|
|
368
|
+
redoCount: c.value,
|
|
369
|
+
currentIndex: r.value
|
|
370
|
+
}));
|
|
373
371
|
function h(v) {
|
|
374
372
|
e.value = { ...e.value, ...v }, e.value.enablePersistence && (E(), X()), e.value.enableCrossTabSync && Y();
|
|
375
373
|
}
|