@atscript/ui-fns 0.1.150 → 0.1.152
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/index.cjs +15 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +15 -5
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -2,9 +2,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let _atscript_ui = require("@atscript/ui");
|
|
3
3
|
//#region src/runtime/fn-compiler.ts
|
|
4
4
|
const pool = new (require("@prostojs/deserialize-fn")).FNPool();
|
|
5
|
+
const fieldFns = /* @__PURE__ */ new Map();
|
|
6
|
+
const topFns = /* @__PURE__ */ new Map();
|
|
5
7
|
/**
|
|
6
8
|
* Compiles a field-level function string from a `@ui.form.fn.*` / `@ui.table.fn.*` annotation
|
|
7
|
-
* into a callable function.
|
|
9
|
+
* into a callable function. Compiled once per string and cached (via FNPool).
|
|
8
10
|
*
|
|
9
11
|
* The function string should be an arrow or regular function expression:
|
|
10
12
|
* `"(v, data, ctx, entry) => !data.firstName"`
|
|
@@ -13,8 +15,12 @@ const pool = new (require("@prostojs/deserialize-fn")).FNPool();
|
|
|
13
15
|
* `{ v, data, context, entry }`
|
|
14
16
|
*/
|
|
15
17
|
function compileFieldFn(fnStr) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
let fn = fieldFns.get(fnStr);
|
|
19
|
+
if (!fn) {
|
|
20
|
+
fn = pool.getFn(`return (${fnStr})(v, data, context, entry)`);
|
|
21
|
+
fieldFns.set(fnStr, fn);
|
|
22
|
+
}
|
|
23
|
+
return fn;
|
|
18
24
|
}
|
|
19
25
|
/**
|
|
20
26
|
* Compiles a form-level function string from a `@ui.form.fn.title` or similar annotation.
|
|
@@ -26,8 +32,12 @@ function compileFieldFn(fnStr) {
|
|
|
26
32
|
* `{ data, context }`
|
|
27
33
|
*/
|
|
28
34
|
function compileTopFn(fnStr) {
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
let fn = topFns.get(fnStr);
|
|
36
|
+
if (!fn) {
|
|
37
|
+
fn = pool.getFn(`return (${fnStr})(data, context)`);
|
|
38
|
+
topFns.set(fnStr, fn);
|
|
39
|
+
}
|
|
40
|
+
return fn;
|
|
31
41
|
}
|
|
32
42
|
/**
|
|
33
43
|
* Compiles a validator function string.
|
package/dist/index.d.cts
CHANGED
|
@@ -37,7 +37,7 @@ interface TFieldEvaluated {
|
|
|
37
37
|
//#region src/runtime/fn-compiler.d.ts
|
|
38
38
|
/**
|
|
39
39
|
* Compiles a field-level function string from a `@ui.form.fn.*` / `@ui.table.fn.*` annotation
|
|
40
|
-
* into a callable function.
|
|
40
|
+
* into a callable function. Compiled once per string and cached (via FNPool).
|
|
41
41
|
*
|
|
42
42
|
* The function string should be an arrow or regular function expression:
|
|
43
43
|
* `"(v, data, ctx, entry) => !data.firstName"`
|
package/dist/index.d.mts
CHANGED
|
@@ -37,7 +37,7 @@ interface TFieldEvaluated {
|
|
|
37
37
|
//#region src/runtime/fn-compiler.d.ts
|
|
38
38
|
/**
|
|
39
39
|
* Compiles a field-level function string from a `@ui.form.fn.*` / `@ui.table.fn.*` annotation
|
|
40
|
-
* into a callable function.
|
|
40
|
+
* into a callable function. Compiled once per string and cached (via FNPool).
|
|
41
41
|
*
|
|
42
42
|
* The function string should be an arrow or regular function expression:
|
|
43
43
|
* `"(v, data, ctx, entry) => !data.firstName"`
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,11 @@ import { META_READONLY, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI
|
|
|
2
2
|
import { FNPool } from "@prostojs/deserialize-fn";
|
|
3
3
|
//#region src/runtime/fn-compiler.ts
|
|
4
4
|
const pool = new FNPool();
|
|
5
|
+
const fieldFns = /* @__PURE__ */ new Map();
|
|
6
|
+
const topFns = /* @__PURE__ */ new Map();
|
|
5
7
|
/**
|
|
6
8
|
* Compiles a field-level function string from a `@ui.form.fn.*` / `@ui.table.fn.*` annotation
|
|
7
|
-
* into a callable function.
|
|
9
|
+
* into a callable function. Compiled once per string and cached (via FNPool).
|
|
8
10
|
*
|
|
9
11
|
* The function string should be an arrow or regular function expression:
|
|
10
12
|
* `"(v, data, ctx, entry) => !data.firstName"`
|
|
@@ -13,8 +15,12 @@ const pool = new FNPool();
|
|
|
13
15
|
* `{ v, data, context, entry }`
|
|
14
16
|
*/
|
|
15
17
|
function compileFieldFn(fnStr) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
let fn = fieldFns.get(fnStr);
|
|
19
|
+
if (!fn) {
|
|
20
|
+
fn = pool.getFn(`return (${fnStr})(v, data, context, entry)`);
|
|
21
|
+
fieldFns.set(fnStr, fn);
|
|
22
|
+
}
|
|
23
|
+
return fn;
|
|
18
24
|
}
|
|
19
25
|
/**
|
|
20
26
|
* Compiles a form-level function string from a `@ui.form.fn.title` or similar annotation.
|
|
@@ -26,8 +32,12 @@ function compileFieldFn(fnStr) {
|
|
|
26
32
|
* `{ data, context }`
|
|
27
33
|
*/
|
|
28
34
|
function compileTopFn(fnStr) {
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
let fn = topFns.get(fnStr);
|
|
36
|
+
if (!fn) {
|
|
37
|
+
fn = pool.getFn(`return (${fnStr})(data, context)`);
|
|
38
|
+
topFns.set(fnStr, fn);
|
|
39
|
+
}
|
|
40
|
+
return fn;
|
|
31
41
|
}
|
|
32
42
|
/**
|
|
33
43
|
* Compiles a validator function string.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/ui-fns",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.152",
|
|
4
4
|
"description": "Dynamic fn-compiled field properties for @atscript/ui (opt-in, uses new Function)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@prostojs/deserialize-fn": "^0.0.
|
|
51
|
-
"@atscript/ui": "^0.1.
|
|
50
|
+
"@prostojs/deserialize-fn": "^0.0.6",
|
|
51
|
+
"@atscript/ui": "^0.1.152"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@atscript/core": "^0.1.
|
|
55
|
-
"@atscript/typescript": "^0.1.
|
|
54
|
+
"@atscript/core": "^0.1.102",
|
|
55
|
+
"@atscript/typescript": "^0.1.102",
|
|
56
56
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@atscript/core": "^0.1.
|
|
60
|
-
"@atscript/typescript": "^0.1.
|
|
59
|
+
"@atscript/core": "^0.1.102",
|
|
60
|
+
"@atscript/typescript": "^0.1.102"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "vp pack",
|