@brett_lamy/ui 3.1.0 → 5.0.0
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/README.md +4 -4
- package/dist/components/animated-height.d.ts +3 -1
- package/dist/components/animated-height.d.ts.map +1 -1
- package/dist/components/animated-height.js +11 -11
- package/dist/components/artifact-chat-container.d.ts.map +1 -1
- package/dist/components/artifact-chat-container.js +81 -82
- package/dist/components/button.d.ts +4 -3
- package/dist/components/button.d.ts.map +1 -1
- package/dist/components/button.js +22 -9
- package/dist/components/canvas.d.ts +91 -0
- package/dist/components/canvas.d.ts.map +1 -0
- package/dist/components/canvas.js +296 -0
- package/dist/components/composer/composer-cards.d.ts +55 -0
- package/dist/components/composer/composer-cards.d.ts.map +1 -0
- package/dist/components/composer/composer-cards.js +351 -0
- package/dist/components/composer/composer.d.ts +9 -1
- package/dist/components/composer/composer.d.ts.map +1 -1
- package/dist/components/composer/composer.js +179 -154
- package/dist/components/context-menu.d.ts +25 -0
- package/dist/components/context-menu.d.ts.map +1 -0
- package/dist/components/context-menu.js +127 -0
- package/dist/components/credenza.d.ts.map +1 -1
- package/dist/components/credenza.js +52 -92
- package/dist/components/cron-editor.d.ts +47 -0
- package/dist/components/cron-editor.d.ts.map +1 -0
- package/dist/components/cron-editor.js +297 -0
- package/dist/components/dropdown-menu.d.ts +3 -1
- package/dist/components/dropdown-menu.d.ts.map +1 -1
- package/dist/components/dropdown-menu.js +5 -5
- package/dist/components/edge-drawer.d.ts.map +1 -1
- package/dist/components/edge-drawer.js +1 -0
- package/dist/components/file-upload.d.ts +121 -0
- package/dist/components/file-upload.d.ts.map +1 -0
- package/dist/components/file-upload.js +405 -0
- package/dist/components/filter-input.d.ts +22 -0
- package/dist/components/filter-input.d.ts.map +1 -0
- package/dist/components/filter-input.js +126 -0
- package/dist/components/filter.d.ts +154 -0
- package/dist/components/filter.d.ts.map +1 -0
- package/dist/components/filter.js +815 -0
- package/dist/components/floating-chat.d.ts.map +1 -1
- package/dist/components/floating-chat.js +71 -88
- package/dist/components/floating-sheet.d.ts +21 -5
- package/dist/components/floating-sheet.d.ts.map +1 -1
- package/dist/components/floating-sheet.js +113 -116
- package/dist/components/markdown-editor.d.ts +2 -0
- package/dist/components/markdown-editor.d.ts.map +1 -1
- package/dist/components/markdown-editor.js +46 -45
- package/dist/components/markdown-view.d.ts +6 -1
- package/dist/components/markdown-view.d.ts.map +1 -1
- package/dist/components/markdown-view.js +13 -11
- package/dist/components/navigation-stack.d.ts +3 -5
- package/dist/components/navigation-stack.d.ts.map +1 -1
- package/dist/components/navigation-stack.js +212 -382
- package/dist/components/passkey-enroll-dialog.d.ts +36 -0
- package/dist/components/passkey-enroll-dialog.d.ts.map +1 -0
- package/dist/components/passkey-enroll-dialog.js +234 -0
- package/dist/components/result-table.d.ts +38 -0
- package/dist/components/result-table.d.ts.map +1 -0
- package/dist/components/result-table.js +161 -0
- package/dist/components/schema-tree.d.ts +19 -0
- package/dist/components/schema-tree.d.ts.map +1 -0
- package/dist/components/schema-tree.js +172 -0
- package/dist/components/side-drawer.d.ts.map +1 -1
- package/dist/components/side-drawer.js +117 -143
- package/dist/components/slider.d.ts.map +1 -1
- package/dist/components/slider.js +4 -1
- package/dist/components/spinner-shapes.d.ts +263 -0
- package/dist/components/spinner-shapes.d.ts.map +1 -0
- package/dist/components/spinner-shapes.js +771 -0
- package/dist/components/spinner.d.ts +133 -3
- package/dist/components/spinner.d.ts.map +1 -1
- package/dist/components/spinner.js +445 -29
- package/dist/components/sql-console.d.ts +28 -0
- package/dist/components/sql-console.d.ts.map +1 -0
- package/dist/components/sql-console.js +348 -0
- package/dist/components/sql-editor.d.ts +47 -0
- package/dist/components/sql-editor.d.ts.map +1 -0
- package/dist/components/sql-editor.js +170 -0
- package/dist/components/tab-view.d.ts +2 -2
- package/dist/components/tab-view.d.ts.map +1 -1
- package/dist/components/tab-view.js +63 -49
- package/dist/components/tailscale-login-button.d.ts +53 -0
- package/dist/components/tailscale-login-button.d.ts.map +1 -0
- package/dist/components/tailscale-login-button.js +197 -0
- package/dist/components/time-input.d.ts +46 -0
- package/dist/components/time-input.d.ts.map +1 -0
- package/dist/components/time-input.js +258 -0
- package/dist/components/toast.d.ts +5 -2
- package/dist/components/toast.d.ts.map +1 -1
- package/dist/components/toast.js +249 -125
- package/dist/components/vault-gate.d.ts +60 -0
- package/dist/components/vault-gate.d.ts.map +1 -0
- package/dist/components/vault-gate.js +382 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +86 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +129 -85
- package/dist/lib/back-history.d.ts +5 -0
- package/dist/lib/back-history.d.ts.map +1 -0
- package/dist/lib/back-history.js +44 -0
- package/dist/lib/canvas-math.d.ts +82 -0
- package/dist/lib/canvas-math.d.ts.map +1 -0
- package/dist/lib/canvas-math.js +226 -0
- package/dist/lib/controllable-state.d.ts +4 -0
- package/dist/lib/controllable-state.d.ts.map +1 -0
- package/dist/lib/controllable-state.js +11 -0
- package/dist/lib/cron.d.ts +55 -0
- package/dist/lib/cron.d.ts.map +1 -0
- package/dist/lib/cron.js +269 -0
- package/dist/lib/edge-swipe.d.ts +36 -0
- package/dist/lib/edge-swipe.d.ts.map +1 -0
- package/dist/lib/edge-swipe.js +73 -0
- package/dist/lib/file-upload.d.ts +187 -0
- package/dist/lib/file-upload.d.ts.map +1 -0
- package/dist/lib/file-upload.js +349 -0
- package/dist/lib/filter-query.d.ts +90 -0
- package/dist/lib/filter-query.d.ts.map +1 -0
- package/dist/lib/filter-query.js +459 -0
- package/dist/lib/filter.d.ts +120 -0
- package/dist/lib/filter.d.ts.map +1 -0
- package/dist/lib/filter.js +399 -0
- package/dist/lib/format-bytes.d.ts +3 -0
- package/dist/lib/format-bytes.d.ts.map +1 -0
- package/dist/lib/format-bytes.js +16 -0
- package/dist/lib/gpu-cron.d.ts +51 -0
- package/dist/lib/gpu-cron.d.ts.map +1 -0
- package/dist/lib/gpu-cron.js +81 -0
- package/dist/lib/gpu-query/featurize.d.ts +19 -0
- package/dist/lib/gpu-query/featurize.d.ts.map +1 -0
- package/dist/lib/gpu-query/featurize.js +88 -0
- package/dist/lib/gpu-query/index.d.ts +73 -0
- package/dist/lib/gpu-query/index.d.ts.map +1 -0
- package/dist/lib/gpu-query/index.js +117 -0
- package/dist/lib/gpu-query/kernel.wgsl.d.ts +30 -0
- package/dist/lib/gpu-query/kernel.wgsl.d.ts.map +1 -0
- package/dist/lib/gpu-query/model.d.ts +8 -0
- package/dist/lib/gpu-query/model.d.ts.map +1 -0
- package/dist/lib/gpu-query/model.js +91 -0
- package/dist/lib/gpu-query/schema.d.ts +40 -0
- package/dist/lib/gpu-query/schema.d.ts.map +1 -0
- package/dist/lib/gpu-query/schema.js +0 -0
- package/dist/lib/gpu-query/webgpu.d.ts +12 -0
- package/dist/lib/gpu-query/webgpu.d.ts.map +1 -0
- package/dist/lib/gpu-query/weights.d.ts +17 -0
- package/dist/lib/gpu-query/weights.d.ts.map +1 -0
- package/dist/lib/gpu-query/weights.js +40 -0
- package/dist/lib/gpu-query/weights.json.d.ts +3 -0
- package/dist/lib/gpu-query/weights2.js +25 -0
- package/dist/lib/gpu-time.d.ts +77 -0
- package/dist/lib/gpu-time.d.ts.map +1 -0
- package/dist/lib/gpu-time.js +260 -0
- package/dist/lib/morph-path.d.ts +22 -0
- package/dist/lib/morph-path.d.ts.map +1 -0
- package/dist/lib/morph-path.js +42 -0
- package/dist/lib/passkey.d.ts +120 -0
- package/dist/lib/passkey.d.ts.map +1 -0
- package/dist/lib/passkey.js +186 -0
- package/dist/lib/persistent-state.d.ts +9 -0
- package/dist/lib/persistent-state.d.ts.map +1 -0
- package/dist/lib/persistent-state.js +37 -0
- package/dist/lib/pglite-core.d.ts +219 -0
- package/dist/lib/pglite-core.d.ts.map +1 -0
- package/dist/lib/pglite-core.js +273 -0
- package/dist/lib/pglite-files.d.ts +7 -0
- package/dist/lib/pglite-files.d.ts.map +1 -0
- package/dist/lib/pglite-files.js +17 -0
- package/dist/lib/pglite-schema.d.ts +58 -0
- package/dist/lib/pglite-schema.d.ts.map +1 -0
- package/dist/lib/pglite-schema.js +105 -0
- package/dist/lib/pglite-storage.d.ts +33 -0
- package/dist/lib/pglite-storage.d.ts.map +1 -0
- package/dist/lib/pglite-storage.js +55 -0
- package/dist/lib/pglite-transfer.d.ts +53 -0
- package/dist/lib/pglite-transfer.d.ts.map +1 -0
- package/dist/lib/pglite-transfer.js +126 -0
- package/dist/lib/pglite.d.ts +106 -0
- package/dist/lib/pglite.d.ts.map +1 -0
- package/dist/lib/pglite.js +298 -0
- package/dist/lib/pull-to-refresh.d.ts +24 -0
- package/dist/lib/pull-to-refresh.d.ts.map +1 -0
- package/dist/lib/pull-to-refresh.js +74 -0
- package/dist/lib/scroll-hidden.d.ts +6 -0
- package/dist/lib/scroll-hidden.d.ts.map +1 -0
- package/dist/lib/scroll-hidden.js +21 -0
- package/dist/lib/sheet-drag.d.ts +10 -2
- package/dist/lib/sheet-drag.d.ts.map +1 -1
- package/dist/lib/sheet-drag.js +72 -69
- package/dist/lib/sql-format.d.ts +62 -0
- package/dist/lib/sql-format.d.ts.map +1 -0
- package/dist/lib/sql-format.js +175 -0
- package/dist/lib/sql-lex.d.ts +25 -0
- package/dist/lib/sql-lex.d.ts.map +1 -0
- package/dist/lib/sql-lex.js +135 -0
- package/dist/lib/tab-lock.d.ts +28 -0
- package/dist/lib/tab-lock.d.ts.map +1 -0
- package/dist/lib/tab-lock.js +80 -0
- package/dist/lib/tailscale-connect.d.ts +56 -0
- package/dist/lib/tailscale-connect.d.ts.map +1 -0
- package/dist/lib/tailscale-connect.js +99 -0
- package/dist/lib/tailscale-fake.d.ts +33 -0
- package/dist/lib/tailscale-fake.d.ts.map +1 -0
- package/dist/lib/tailscale-fake.js +80 -0
- package/dist/lib/tailscale-policy.d.ts +71 -0
- package/dist/lib/tailscale-policy.d.ts.map +1 -0
- package/dist/lib/tailscale-policy.js +244 -0
- package/dist/lib/tailscale-react.d.ts +20 -0
- package/dist/lib/tailscale-react.d.ts.map +1 -0
- package/dist/lib/tailscale-react.js +37 -0
- package/dist/lib/tailscale-router/bridge.d.ts +60 -0
- package/dist/lib/tailscale-router/bridge.d.ts.map +1 -0
- package/dist/lib/tailscale-router/bridge.js +198 -0
- package/dist/lib/tailscale-router/react.d.ts +19 -0
- package/dist/lib/tailscale-router/react.d.ts.map +1 -0
- package/dist/lib/tailscale-router/react.js +52 -0
- package/dist/lib/tailscale.d.ts +204 -0
- package/dist/lib/tailscale.d.ts.map +1 -0
- package/dist/lib/tailscale.js +443 -0
- package/dist/lib/title-flight.d.ts +34 -0
- package/dist/lib/title-flight.d.ts.map +1 -0
- package/dist/lib/title-flight.js +123 -0
- package/dist/lib/vault-react.d.ts +49 -0
- package/dist/lib/vault-react.d.ts.map +1 -0
- package/dist/lib/vault-react.js +196 -0
- package/dist/lib/vault-storage.d.ts +30 -0
- package/dist/lib/vault-storage.d.ts.map +1 -0
- package/dist/lib/vault-storage.js +105 -0
- package/dist/lib/vault.d.ts +200 -0
- package/dist/lib/vault.d.ts.map +1 -0
- package/dist/lib/vault.js +641 -0
- package/dist/tailscale-sw.js +332 -0
- package/package.json +35 -5
- package/dist/components/icon-button.d.ts +0 -19
- package/dist/components/icon-button.d.ts.map +0 -1
- package/dist/components/icon-button.js +0 -31
- package/dist/components/measure-h.d.ts +0 -7
- package/dist/components/measure-h.d.ts.map +0 -1
- package/dist/components/measure-h.js +0 -20
- package/dist/components/snap-sheet.d.ts +0 -13
- package/dist/components/snap-sheet.d.ts.map +0 -1
- package/dist/components/snap-sheet.js +0 -100
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
//#region src/lib/filter.ts
|
|
2
|
+
var e = {
|
|
3
|
+
select: [
|
|
4
|
+
"is",
|
|
5
|
+
"is_not",
|
|
6
|
+
"is_any_of",
|
|
7
|
+
"is_none_of"
|
|
8
|
+
],
|
|
9
|
+
multiselect: [
|
|
10
|
+
"includes_any",
|
|
11
|
+
"includes_all",
|
|
12
|
+
"includes_none"
|
|
13
|
+
],
|
|
14
|
+
boolean: ["is"],
|
|
15
|
+
date: [
|
|
16
|
+
"is",
|
|
17
|
+
"before",
|
|
18
|
+
"after",
|
|
19
|
+
"in_the_last"
|
|
20
|
+
],
|
|
21
|
+
number: [
|
|
22
|
+
"eq",
|
|
23
|
+
"neq",
|
|
24
|
+
"lt",
|
|
25
|
+
"lte",
|
|
26
|
+
"gt",
|
|
27
|
+
"gte"
|
|
28
|
+
],
|
|
29
|
+
text: [
|
|
30
|
+
"contains",
|
|
31
|
+
"not_contains",
|
|
32
|
+
"is",
|
|
33
|
+
"is_not"
|
|
34
|
+
]
|
|
35
|
+
}, t = {
|
|
36
|
+
is: "is",
|
|
37
|
+
is_not: "is not",
|
|
38
|
+
is_any_of: "is any of",
|
|
39
|
+
is_none_of: "is none of",
|
|
40
|
+
includes_any: "includes any of",
|
|
41
|
+
includes_all: "includes all of",
|
|
42
|
+
includes_none: "includes none of",
|
|
43
|
+
contains: "contains",
|
|
44
|
+
not_contains: "doesn't contain",
|
|
45
|
+
before: "before",
|
|
46
|
+
after: "after",
|
|
47
|
+
in_the_last: "in the last",
|
|
48
|
+
eq: "=",
|
|
49
|
+
neq: "≠",
|
|
50
|
+
lt: "<",
|
|
51
|
+
lte: "≤",
|
|
52
|
+
gt: ">",
|
|
53
|
+
gte: "≥"
|
|
54
|
+
};
|
|
55
|
+
function n(t) {
|
|
56
|
+
return e[t];
|
|
57
|
+
}
|
|
58
|
+
function r(t) {
|
|
59
|
+
return e[t][0];
|
|
60
|
+
}
|
|
61
|
+
function i(e, n = 2) {
|
|
62
|
+
if (n === 1) {
|
|
63
|
+
if (e === "is_any_of") return "is";
|
|
64
|
+
if (e === "is_none_of") return "is not";
|
|
65
|
+
if (e === "includes_any") return "includes";
|
|
66
|
+
if (e === "includes_none") return "does not include";
|
|
67
|
+
}
|
|
68
|
+
return t[e];
|
|
69
|
+
}
|
|
70
|
+
var a = [
|
|
71
|
+
{
|
|
72
|
+
id: "today",
|
|
73
|
+
label: "Today"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "yesterday",
|
|
77
|
+
label: "Yesterday"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "this_week",
|
|
81
|
+
label: "This week"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "last_week",
|
|
85
|
+
label: "Last week"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "last_7_days",
|
|
89
|
+
label: "Last 7 days"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "last_30_days",
|
|
93
|
+
label: "Last 30 days"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "this_month",
|
|
97
|
+
label: "This month"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "last_month",
|
|
101
|
+
label: "Last month"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: "this_year",
|
|
105
|
+
label: "This year"
|
|
106
|
+
}
|
|
107
|
+
], o = [
|
|
108
|
+
"day",
|
|
109
|
+
"week",
|
|
110
|
+
"month",
|
|
111
|
+
"year"
|
|
112
|
+
], s = 0;
|
|
113
|
+
function c() {
|
|
114
|
+
return s += 1, `flt_${s.toString(36)}`;
|
|
115
|
+
}
|
|
116
|
+
function l(e) {
|
|
117
|
+
switch (e) {
|
|
118
|
+
case "select":
|
|
119
|
+
case "multiselect": return [];
|
|
120
|
+
case "boolean": return !0;
|
|
121
|
+
case "date": return {
|
|
122
|
+
type: "preset",
|
|
123
|
+
preset: "today"
|
|
124
|
+
};
|
|
125
|
+
case "number": return 0;
|
|
126
|
+
default: return "";
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
var u = (e) => {
|
|
130
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return !1;
|
|
131
|
+
let t = e;
|
|
132
|
+
return t.type === "preset" ? a.some((e) => e.id === t.preset) : t.type === "date" ? typeof t.date == "string" && v(t.date) !== null : t.type === "relative" && typeof t.amount == "number" && Number.isFinite(t.amount) && t.amount > 0 && o.includes(t.unit);
|
|
133
|
+
};
|
|
134
|
+
function d(e) {
|
|
135
|
+
let t = e.value;
|
|
136
|
+
return Array.isArray(t) ? t.length > 0 : typeof t == "boolean" ? !0 : typeof t == "number" ? Number.isFinite(t) : typeof t == "string" ? t.trim().length > 0 : u(t);
|
|
137
|
+
}
|
|
138
|
+
function f(t, n, r) {
|
|
139
|
+
let i = e[t.kind], a = i.includes(n) ? n : i[0], o = r;
|
|
140
|
+
if (t.kind === "select") {
|
|
141
|
+
let e = Array.isArray(r) ? r.length : 0;
|
|
142
|
+
e > 1 && a === "is" ? a = "is_any_of" : e > 1 && a === "is_not" ? a = "is_none_of" : e === 1 && a === "is_any_of" ? a = "is" : e === 1 && a === "is_none_of" && (a = "is_not");
|
|
143
|
+
}
|
|
144
|
+
return t.kind === "date" && (a === "in_the_last" && !(u(r) && r.type === "relative") ? o = {
|
|
145
|
+
type: "relative",
|
|
146
|
+
amount: 7,
|
|
147
|
+
unit: "day"
|
|
148
|
+
} : a !== "in_the_last" && u(r) && r.type === "relative" && (o = {
|
|
149
|
+
type: "preset",
|
|
150
|
+
preset: "last_7_days"
|
|
151
|
+
})), {
|
|
152
|
+
operator: a,
|
|
153
|
+
value: o
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function p(e, t, n) {
|
|
157
|
+
return {
|
|
158
|
+
...t,
|
|
159
|
+
...f(e, t.operator, n)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function m(t, n, r) {
|
|
163
|
+
if (!e[t.kind].includes(r)) return n;
|
|
164
|
+
let i = n.value;
|
|
165
|
+
return t.kind === "select" && (r === "is" || r === "is_not") && Array.isArray(i) && i.length > 1 && (i = i.slice(0, 1)), t.kind === "date" && ({value: i} = f(t, r, i)), {
|
|
166
|
+
...n,
|
|
167
|
+
operator: r,
|
|
168
|
+
value: i
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function h(e, t = l(e.kind), n = r(e.kind)) {
|
|
172
|
+
return {
|
|
173
|
+
id: c(),
|
|
174
|
+
field: e.id,
|
|
175
|
+
...f(e, n, t)
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function g(e) {
|
|
179
|
+
let t = new Date(e);
|
|
180
|
+
return new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime();
|
|
181
|
+
}
|
|
182
|
+
var _ = (e, t) => {
|
|
183
|
+
let n = new Date(e);
|
|
184
|
+
return new Date(n.getFullYear(), n.getMonth(), n.getDate() + t, n.getHours(), n.getMinutes(), n.getSeconds(), n.getMilliseconds()).getTime();
|
|
185
|
+
};
|
|
186
|
+
function v(e) {
|
|
187
|
+
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
188
|
+
if (!t) return null;
|
|
189
|
+
let [n, r, i] = [
|
|
190
|
+
Number(t[1]),
|
|
191
|
+
Number(t[2]),
|
|
192
|
+
Number(t[3])
|
|
193
|
+
], a = new Date(n, r - 1, i);
|
|
194
|
+
return a.getFullYear() === n && a.getMonth() === r - 1 && a.getDate() === i ? a.getTime() : null;
|
|
195
|
+
}
|
|
196
|
+
function y(e, { now: t = Date.now(), weekStart: n = 1 } = {}) {
|
|
197
|
+
let r = typeof t == "number" ? t : t.getTime(), i = g(r), a = _(i, -((new Date(i).getDay() - n + 7) % 7)), o = new Date(r);
|
|
198
|
+
if (e.type === "date") {
|
|
199
|
+
let t = v(e.date);
|
|
200
|
+
return t === null ? null : {
|
|
201
|
+
start: t,
|
|
202
|
+
end: _(t, 1)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
if (e.type === "relative") {
|
|
206
|
+
let t = new Date(r);
|
|
207
|
+
return e.unit === "day" ? t.setDate(t.getDate() - e.amount) : e.unit === "week" ? t.setDate(t.getDate() - 7 * e.amount) : e.unit === "month" ? t.setMonth(t.getMonth() - e.amount) : t.setFullYear(t.getFullYear() - e.amount), {
|
|
208
|
+
start: t.getTime(),
|
|
209
|
+
end: r + 1
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
switch (e.preset) {
|
|
213
|
+
case "today": return {
|
|
214
|
+
start: i,
|
|
215
|
+
end: _(i, 1)
|
|
216
|
+
};
|
|
217
|
+
case "yesterday": return {
|
|
218
|
+
start: _(i, -1),
|
|
219
|
+
end: i
|
|
220
|
+
};
|
|
221
|
+
case "this_week": return {
|
|
222
|
+
start: a,
|
|
223
|
+
end: _(a, 7)
|
|
224
|
+
};
|
|
225
|
+
case "last_week": return {
|
|
226
|
+
start: _(a, -7),
|
|
227
|
+
end: a
|
|
228
|
+
};
|
|
229
|
+
case "last_7_days": return {
|
|
230
|
+
start: _(i, -6),
|
|
231
|
+
end: _(i, 1)
|
|
232
|
+
};
|
|
233
|
+
case "last_30_days": return {
|
|
234
|
+
start: _(i, -29),
|
|
235
|
+
end: _(i, 1)
|
|
236
|
+
};
|
|
237
|
+
case "this_month": return {
|
|
238
|
+
start: new Date(o.getFullYear(), o.getMonth(), 1).getTime(),
|
|
239
|
+
end: new Date(o.getFullYear(), o.getMonth() + 1, 1).getTime()
|
|
240
|
+
};
|
|
241
|
+
case "last_month": return {
|
|
242
|
+
start: new Date(o.getFullYear(), o.getMonth() - 1, 1).getTime(),
|
|
243
|
+
end: new Date(o.getFullYear(), o.getMonth(), 1).getTime()
|
|
244
|
+
};
|
|
245
|
+
case "this_year": return {
|
|
246
|
+
start: new Date(o.getFullYear(), 0, 1).getTime(),
|
|
247
|
+
end: new Date(o.getFullYear() + 1, 0, 1).getTime()
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function b(e) {
|
|
252
|
+
if (e instanceof Date) return Number.isNaN(e.getTime()) ? null : e.getTime();
|
|
253
|
+
if (typeof e == "number") return Number.isFinite(e) ? e : null;
|
|
254
|
+
if (typeof e == "string") {
|
|
255
|
+
let t = v(e);
|
|
256
|
+
if (t !== null) return t;
|
|
257
|
+
let n = Date.parse(e);
|
|
258
|
+
return Number.isNaN(n) ? null : n;
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
var x = (e) => e == null ? [] : Array.isArray(e) ? e.map(String) : [String(e)], S = (e) => typeof e == "string" ? ![
|
|
263
|
+
"",
|
|
264
|
+
"false",
|
|
265
|
+
"0",
|
|
266
|
+
"no"
|
|
267
|
+
].includes(e.toLowerCase()) : !!e, C = (e) => typeof e == "number" ? Number.isFinite(e) ? e : null : typeof e == "string" && e.trim() !== "" && Number.isFinite(Number(e)) ? Number(e) : null;
|
|
268
|
+
function w(e, t, n, r) {
|
|
269
|
+
let { operator: i, value: a } = t;
|
|
270
|
+
switch (n.kind) {
|
|
271
|
+
case "select":
|
|
272
|
+
case "multiselect": {
|
|
273
|
+
let t = x(e), n = Array.isArray(a) ? a : [];
|
|
274
|
+
if (i === "includes_all") return n.every((e) => t.includes(e));
|
|
275
|
+
let r = n.some((e) => t.includes(e));
|
|
276
|
+
return i === "is_not" || i === "is_none_of" || i === "includes_none" ? !r : r;
|
|
277
|
+
}
|
|
278
|
+
case "boolean": {
|
|
279
|
+
let t = S(e) === a;
|
|
280
|
+
return i === "is_not" ? !t : t;
|
|
281
|
+
}
|
|
282
|
+
case "number": {
|
|
283
|
+
let t = C(e), n = typeof a == "number" ? a : Number(a);
|
|
284
|
+
if (t === null) return i === "neq";
|
|
285
|
+
switch (i) {
|
|
286
|
+
case "neq": return t !== n;
|
|
287
|
+
case "lt": return t < n;
|
|
288
|
+
case "lte": return t <= n;
|
|
289
|
+
case "gt": return t > n;
|
|
290
|
+
case "gte": return t >= n;
|
|
291
|
+
default: return t === n;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
case "text": {
|
|
295
|
+
let t = e == null ? "" : String(e).toLowerCase(), n = String(a).trim().toLowerCase();
|
|
296
|
+
return i === "is" ? t === n : i === "is_not" ? t !== n : i === "not_contains" ? !t.includes(n) : t.includes(n);
|
|
297
|
+
}
|
|
298
|
+
case "date": {
|
|
299
|
+
let t = b(e);
|
|
300
|
+
if (t === null || !u(a)) return !1;
|
|
301
|
+
let n = y(a, r);
|
|
302
|
+
return n ? i === "before" ? t < n.start : i === "after" ? t >= n.end : t >= n.start && t < n.end : !1;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function T(e, t, n, r, i = {}) {
|
|
307
|
+
let a = new Map(n.map((e) => [e.id, e])), o = t.flatMap((e) => {
|
|
308
|
+
let t = a.get(e.field);
|
|
309
|
+
return t && d(e) ? [[e, t]] : [];
|
|
310
|
+
});
|
|
311
|
+
if (!o.length) return !0;
|
|
312
|
+
let s = ([t, n]) => w(r(e, t.field), t, n, i);
|
|
313
|
+
return i.match === "any" ? o.some(s) : o.every(s);
|
|
314
|
+
}
|
|
315
|
+
function E(e, t, n, r, i = {}) {
|
|
316
|
+
return e.filter((e) => T(e, t, n, r, i));
|
|
317
|
+
}
|
|
318
|
+
function D(e, t) {
|
|
319
|
+
let n = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
320
|
+
return n ? new Intl.DateTimeFormat(t, {
|
|
321
|
+
year: "numeric",
|
|
322
|
+
month: "short",
|
|
323
|
+
day: "numeric",
|
|
324
|
+
timeZone: "UTC"
|
|
325
|
+
}).format(new Date(Date.UTC(Number(n[1]), Number(n[2]) - 1, Number(n[3])))) : e;
|
|
326
|
+
}
|
|
327
|
+
function O(e, t, n = "en-US") {
|
|
328
|
+
let r = e.value;
|
|
329
|
+
return Array.isArray(r) ? r.map((e) => t?.options?.find((t) => t.value === e)?.label ?? e).join(", ") : typeof r == "boolean" ? r ? "Yes" : "No" : typeof r == "number" ? String(r) : typeof r == "string" ? r : r.type === "preset" ? a.find((e) => e.id === r.preset)?.label ?? r.preset : r.type === "date" ? D(r.date, n) : `${r.amount} ${r.unit}${r.amount === 1 ? "" : "s"}`;
|
|
330
|
+
}
|
|
331
|
+
function k(e, t, n = "en-US") {
|
|
332
|
+
let r = t.find((t) => t.id === e.field), a = Array.isArray(e.value) ? e.value.length : 2;
|
|
333
|
+
return `${r?.label ?? e.field} ${i(e.operator, a)} ${O(e, r, n)}`.trim();
|
|
334
|
+
}
|
|
335
|
+
var A = {
|
|
336
|
+
day: "d",
|
|
337
|
+
week: "w",
|
|
338
|
+
month: "m",
|
|
339
|
+
year: "y"
|
|
340
|
+
}, j = Object.fromEntries(Object.entries(A).map(([e, t]) => [t, e]));
|
|
341
|
+
function M(e) {
|
|
342
|
+
return Array.isArray(e) ? e.map(encodeURIComponent).join(",") : typeof e == "object" ? e.type === "preset" ? e.preset : e.type === "date" ? e.date : `${e.amount}${A[e.unit]}` : encodeURIComponent(String(e));
|
|
343
|
+
}
|
|
344
|
+
function N(e) {
|
|
345
|
+
return e.filter((e) => d(e)).map((e) => `${encodeURIComponent(e.field)}:${e.operator}:${M(e.value)}`).join(";");
|
|
346
|
+
}
|
|
347
|
+
function P(e) {
|
|
348
|
+
let t = a.find((t) => t.id === e);
|
|
349
|
+
if (t) return {
|
|
350
|
+
type: "preset",
|
|
351
|
+
preset: t.id
|
|
352
|
+
};
|
|
353
|
+
if (v(e) !== null) return {
|
|
354
|
+
type: "date",
|
|
355
|
+
date: e
|
|
356
|
+
};
|
|
357
|
+
let n = /^(\d+)([dwmy])$/.exec(e);
|
|
358
|
+
return n && Number(n[1]) > 0 ? {
|
|
359
|
+
type: "relative",
|
|
360
|
+
amount: Number(n[1]),
|
|
361
|
+
unit: j[n[2]]
|
|
362
|
+
} : null;
|
|
363
|
+
}
|
|
364
|
+
function F(e) {
|
|
365
|
+
try {
|
|
366
|
+
return decodeURIComponent(e);
|
|
367
|
+
} catch {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function I(t, n) {
|
|
372
|
+
let r = [];
|
|
373
|
+
for (let i of t.split(";")) {
|
|
374
|
+
let [t, a, o, ...s] = i.split(":");
|
|
375
|
+
if (!t || !a || o === void 0 || s.length) continue;
|
|
376
|
+
let l = F(t), u = n.find((e) => e.id === l);
|
|
377
|
+
if (!u || !e[u.kind].includes(a)) continue;
|
|
378
|
+
let d;
|
|
379
|
+
if (u.kind === "select" || u.kind === "multiselect") {
|
|
380
|
+
let e = o.split(",").map(F);
|
|
381
|
+
d = e.every((e) => e !== null) && o !== "" ? e : null;
|
|
382
|
+
} else if (u.kind === "boolean") d = o === "true" || o !== "false" && null;
|
|
383
|
+
else if (u.kind === "number") d = o.trim() !== "" && Number.isFinite(Number(o)) ? Number(o) : null;
|
|
384
|
+
else if (u.kind === "date") d = P(o), d && a === "in_the_last" != (d.type === "relative") && (d = null);
|
|
385
|
+
else {
|
|
386
|
+
let e = F(o);
|
|
387
|
+
d = e && e.trim() ? e : null;
|
|
388
|
+
}
|
|
389
|
+
d !== null && r.push({
|
|
390
|
+
id: c(),
|
|
391
|
+
field: u.id,
|
|
392
|
+
operator: a,
|
|
393
|
+
value: d
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return r;
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
export { a as DATE_PRESETS, e as FILTER_OPERATORS, o as RELATIVE_UNITS, f as coerceFilter, h as createFilter, c as createFilterId, y as dateRange, r as defaultOperator, k as describeFilter, O as describeValue, l as emptyValue, u as isDateValue, d as isFilterComplete, E as matchFilters, T as matchesFilters, i as operatorLabel, n as operatorsFor, I as parseFilters, N as serializeFilters, b as toTime, m as withOperator, p as withValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-bytes.d.ts","sourceRoot":"","sources":["../../src/lib/format-bytes.ts"],"names":[],"mappings":"AAEA,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUjD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/lib/format-bytes.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"B",
|
|
4
|
+
"KB",
|
|
5
|
+
"MB",
|
|
6
|
+
"GB",
|
|
7
|
+
"TB"
|
|
8
|
+
];
|
|
9
|
+
function t(t) {
|
|
10
|
+
if (!Number.isFinite(t) || t < 0) return "";
|
|
11
|
+
let n = t, r = 0;
|
|
12
|
+
for (; n >= 1024 && r < e.length - 1;) n /= 1024, r++;
|
|
13
|
+
return `${String(r === 0 || n >= 10 ? Math.round(n) : Math.round(n * 10) / 10)} ${e[r]}`;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { t as formatBytes };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CronMatch } from 'gpu-cron';
|
|
2
|
+
export type { CronMatch as GpuCronMatch };
|
|
3
|
+
type GpuCronModule = typeof import('gpu-cron');
|
|
4
|
+
/** Whether the browser exposes WebGPU at all (`navigator.gpu`). False on the server. A cheap, synchronous hint:
|
|
5
|
+
it does not mean an adapter exists. */
|
|
6
|
+
export declare function hasWebGPU(): boolean;
|
|
7
|
+
/** Loads gpu-cron (once; cached, and a failed load is retried by the next call). */
|
|
8
|
+
export declare function loadGpuCron(): Promise<GpuCronModule>;
|
|
9
|
+
/** Whether the model can run here. Resolves false (never rejects) without loading the package when there is no
|
|
10
|
+
`navigator.gpu`; otherwise loads it and asks `isAvailable()`, which also uploads the weights so the first parse is
|
|
11
|
+
warm. The answer is cached. */
|
|
12
|
+
export declare function gpuCronAvailable(): Promise<boolean>;
|
|
13
|
+
/** The cached answer of `gpuCronAvailable()` if it has resolved, else null. */
|
|
14
|
+
export declare function peekGpuCronAvailable(): boolean | null;
|
|
15
|
+
/** Parses `text` into a cron expression and its next fire times (local zone). Rejects when the model cannot run
|
|
16
|
+
(no WebGPU) or the text is too long for it. Never rejects for nonsense: see the note at the top. */
|
|
17
|
+
export declare function parseCronText(text: string, { count }?: {
|
|
18
|
+
count?: number;
|
|
19
|
+
}): Promise<CronMatch>;
|
|
20
|
+
/** A short message for an error from the model, for showing next to the input. */
|
|
21
|
+
export declare function describeCronError(error: unknown): string;
|
|
22
|
+
/** Forgets the loaded module and the availability answer. For tests and hot reload. */
|
|
23
|
+
export declare function resetGpuCron(): void;
|
|
24
|
+
export interface UseCronParseOptions {
|
|
25
|
+
/** How many upcoming fire times the model returns (they are in the local zone). Default: 5. */
|
|
26
|
+
count?: number;
|
|
27
|
+
/** Milliseconds to wait after the last change before parsing. The model serialises calls, so one per keystroke is
|
|
28
|
+
safe, but debouncing saves work. Default: 150. */
|
|
29
|
+
debounceMs?: number;
|
|
30
|
+
/** Pause everything, including the availability check. Default: true. */
|
|
31
|
+
enabled?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface CronParseState {
|
|
34
|
+
/** The latest settled answer. While `pending` it is the answer to the previous text: compare `parsedText`. */
|
|
35
|
+
result: CronMatch | null;
|
|
36
|
+
/** Why the latest parse failed, or null. */
|
|
37
|
+
error: Error | null;
|
|
38
|
+
/** True from a change of text until the parse for it settles. */
|
|
39
|
+
pending: boolean;
|
|
40
|
+
/** Whether the model can run: null until known (and while disabled), then true or false. */
|
|
41
|
+
supported: boolean | null;
|
|
42
|
+
/** The text `result` / `error` belong to, or null. */
|
|
43
|
+
parsedText: string | null;
|
|
44
|
+
}
|
|
45
|
+
/** Parses a description as you type, on the GPU: checks support first (and says so with `supported`), debounces,
|
|
46
|
+
drops out-of-order answers and cleans up on unmount. Empty text is "nothing to parse". Remember the model always
|
|
47
|
+
answers: show `result.expression` for the person to check.
|
|
48
|
+
|
|
49
|
+
const { result, supported } = useCronParse(text) // supported === false → hide the box */
|
|
50
|
+
export declare function useCronParse(text: string, { count, debounceMs, enabled }?: UseCronParseOptions): CronParseState;
|
|
51
|
+
//# sourceMappingURL=gpu-cron.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-cron.d.ts","sourceRoot":"","sources":["../../src/lib/gpu-cron.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAe1C,YAAY,EAAE,SAAS,IAAI,YAAY,EAAE,CAAC;AAE1C,KAAK,aAAa,GAAG,cAAc,UAAU,CAAC,CAAC;AAM/C;0CAC0C;AAC1C,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED,oFAAoF;AACpF,wBAAgB,WAAW,IAAI,OAAO,CAAC,aAAa,CAAC,CAKpD;AAED;;kCAEkC;AAClC,wBAAgB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAInD;AAED,+EAA+E;AAC/E,wBAAgB,oBAAoB,IAAI,OAAO,GAAG,IAAI,CAErD;AAED;uGACuG;AACvG,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAS,EAAE,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAG5G;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKxD;AAED,uFAAuF;AACvF,wBAAgB,YAAY,IAAI,IAAI,CAInC;AAID,MAAM,WAAW,mBAAmB;IAClC,+FAA+F;IAC/F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;yDACqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,8GAA8G;IAC9G,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,4CAA4C;IAC5C,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,4FAA4F;IAC5F,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,sDAAsD;IACtD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AASD;;;;+FAI+F;AAC/F,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAS,EAAE,UAAgB,EAAE,OAAc,EAAE,GAAE,mBAAwB,GAAG,cAAc,CAgDpI"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect as e, useState as t } from "react";
|
|
3
|
+
//#region src/lib/gpu-cron.ts
|
|
4
|
+
var n = null, r = null, i = null;
|
|
5
|
+
function a() {
|
|
6
|
+
return typeof navigator < "u" && "gpu" in navigator && !!navigator.gpu;
|
|
7
|
+
}
|
|
8
|
+
function o() {
|
|
9
|
+
return n ??= import("gpu-cron").catch((e) => {
|
|
10
|
+
throw n = null, e;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function s() {
|
|
14
|
+
return r ??= (a() ? o().then((e) => e.isAvailable()) : Promise.resolve(!1)).catch(() => !1).then((e) => i = e);
|
|
15
|
+
}
|
|
16
|
+
function c() {
|
|
17
|
+
return i;
|
|
18
|
+
}
|
|
19
|
+
async function l(e, { count: t = 5 } = {}) {
|
|
20
|
+
return (await o()).parse(e.trim(), { count: t });
|
|
21
|
+
}
|
|
22
|
+
function u(e) {
|
|
23
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
24
|
+
return /webgpu|adapter/i.test(t) ? "Describing a schedule needs WebGPU, which is not available here." : /characters|fits/i.test(t) ? "That description is too long. Shorten it, or type the expression below." : "The model could not read that. Try rephrasing, or type the expression below.";
|
|
25
|
+
}
|
|
26
|
+
function d(n, { count: r = 5, debounceMs: i = 150, enabled: a = !0 } = {}) {
|
|
27
|
+
let [o, u] = t(() => c()), [d, f] = t(null), p = n.trim(), m = a && o === !0 && p !== "";
|
|
28
|
+
return e(() => {
|
|
29
|
+
if (!a) return;
|
|
30
|
+
let e = !0;
|
|
31
|
+
return s().then((t) => {
|
|
32
|
+
e && u(t);
|
|
33
|
+
}), () => {
|
|
34
|
+
e = !1;
|
|
35
|
+
};
|
|
36
|
+
}, [a]), e(() => {
|
|
37
|
+
if (!m) {
|
|
38
|
+
f(null);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let e = !0, t = setTimeout(() => {
|
|
42
|
+
l(n, { count: r }).then((t) => {
|
|
43
|
+
e && f({
|
|
44
|
+
text: n,
|
|
45
|
+
count: r,
|
|
46
|
+
result: t,
|
|
47
|
+
error: null
|
|
48
|
+
});
|
|
49
|
+
}, (t) => {
|
|
50
|
+
e && f({
|
|
51
|
+
text: n,
|
|
52
|
+
count: r,
|
|
53
|
+
result: null,
|
|
54
|
+
error: t instanceof Error ? t : Error(String(t))
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}, i);
|
|
58
|
+
return () => {
|
|
59
|
+
e = !1, clearTimeout(t);
|
|
60
|
+
};
|
|
61
|
+
}, [
|
|
62
|
+
m,
|
|
63
|
+
n,
|
|
64
|
+
r,
|
|
65
|
+
i
|
|
66
|
+
]), m ? {
|
|
67
|
+
result: d?.result ?? null,
|
|
68
|
+
error: d?.error ?? null,
|
|
69
|
+
pending: !d || d.text !== n || d.count !== r,
|
|
70
|
+
supported: o,
|
|
71
|
+
parsedText: d?.text ?? null
|
|
72
|
+
} : {
|
|
73
|
+
result: null,
|
|
74
|
+
error: null,
|
|
75
|
+
pending: !1,
|
|
76
|
+
supported: a ? o : null,
|
|
77
|
+
parsedText: null
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
export { u as describeCronError, s as gpuCronAvailable, a as hasWebGPU, o as loadGpuCron, l as parseCronText, c as peekGpuCronAvailable, d as useCronParse };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Match, Schema } from './schema';
|
|
2
|
+
export declare const SLOTS = 16;
|
|
3
|
+
export declare const OFFSET: Record<string, number>;
|
|
4
|
+
export declare const FEATURE_ROWS: number;
|
|
5
|
+
export declare const PADDING_ROW: number;
|
|
6
|
+
export interface Featurized {
|
|
7
|
+
rows: number[][];
|
|
8
|
+
neighbors: Array<[number, number]>;
|
|
9
|
+
resolved: Array<Match | null>;
|
|
10
|
+
}
|
|
11
|
+
export declare function featurize(tokens: string[], schema: Schema): Featurized;
|
|
12
|
+
/**
|
|
13
|
+
* Nearest field-matching token on each side.
|
|
14
|
+
*
|
|
15
|
+
* Note this uses EXACT surface matching, not the tolerant resolver, because the
|
|
16
|
+
* Python it mirrors builds its index from surface forms directly.
|
|
17
|
+
*/
|
|
18
|
+
export declare function neighborsFor(tokens: string[], schema: Schema): Array<[number, number]>;
|
|
19
|
+
//# sourceMappingURL=featurize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"featurize.d.ts","sourceRoot":"","sources":["../../../src/lib/gpu-query/featurize.ts"],"names":[],"mappings":"AAAA;uEACuE;AAavE,OAAO,KAAK,EAAe,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE3D,eAAO,MAAM,KAAK,KAAK,CAAC;AA2BxB,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAC;AAMjD,eAAO,MAAM,YAAY,QAAS,CAAC;AACnC,eAAO,MAAM,WAAW,QAAe,CAAC;AA2BxC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;CAC/B;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAuEtE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsBtF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { buildIndex as e, enumOwners as t, resolve as n, surfaceForms as r } from "./schema.js";
|
|
2
|
+
var i = /* @__PURE__ */ "and.or.not.no.without.excluding.is.before.after.since.over.under.above.below.than.least.most.more.less.fewer.prior.later.earlier.containing.mentioning.matching.with.:.=".split("."), a = new Map(i.map((e, t) => [e, t])), o = [
|
|
3
|
+
["kind", 3],
|
|
4
|
+
["length", 8],
|
|
5
|
+
["first_char", 40],
|
|
6
|
+
["last_char", 40],
|
|
7
|
+
["word_hash", 256],
|
|
8
|
+
["devowel_hash", 128],
|
|
9
|
+
["flags", 4],
|
|
10
|
+
["field_match", 6],
|
|
11
|
+
["match_quality", 5],
|
|
12
|
+
["enum_any", 1],
|
|
13
|
+
["enum_preceding", 1],
|
|
14
|
+
["distance", 6],
|
|
15
|
+
["operator", 30],
|
|
16
|
+
["position", 4]
|
|
17
|
+
], s = {}, c = 0;
|
|
18
|
+
for (let [e, t] of o) s[e] = c, c += t;
|
|
19
|
+
var l = c, u = l, d = {
|
|
20
|
+
bool: 1,
|
|
21
|
+
enum: 2,
|
|
22
|
+
date: 3,
|
|
23
|
+
number: 4,
|
|
24
|
+
text: 5
|
|
25
|
+
}, f = [
|
|
26
|
+
1,
|
|
27
|
+
2,
|
|
28
|
+
3,
|
|
29
|
+
4,
|
|
30
|
+
6,
|
|
31
|
+
8,
|
|
32
|
+
12,
|
|
33
|
+
1e9
|
|
34
|
+
];
|
|
35
|
+
function p(e) {
|
|
36
|
+
let t = e.toLowerCase().charCodeAt(0);
|
|
37
|
+
return t >= 97 && t <= 122 ? t - 97 : t >= 48 && t <= 57 ? t - 48 + 26 : 36 + t % 4;
|
|
38
|
+
}
|
|
39
|
+
function m(e) {
|
|
40
|
+
for (let t = 0; t < f.length; t++) if (e.length <= f[t]) return t;
|
|
41
|
+
return f.length - 1;
|
|
42
|
+
}
|
|
43
|
+
function h(e) {
|
|
44
|
+
let t = e.replace(/\./g, "");
|
|
45
|
+
return t.length > 0 && /^[0-9]+$/.test(t);
|
|
46
|
+
}
|
|
47
|
+
function g(r, o) {
|
|
48
|
+
let c = e(o), l = t(o), f = r.map((e) => e.toLowerCase()), g = f.map((e) => n(e, c)), v = [], y = [], b = null, x = 99;
|
|
49
|
+
for (let e = 0; e < f.length; e++) v.push(b), y.push(x), g[e] ? (b = g[e].field, x = 0) : x < 99 && (x += 1);
|
|
50
|
+
let S = [];
|
|
51
|
+
for (let e = 0; e < r.length; e++) {
|
|
52
|
+
let t = r[e], n = f[e], o = [], c = (e, t) => {
|
|
53
|
+
e !== "word_hash" && e !== "devowel_hash" && o.push(s[e] + t);
|
|
54
|
+
}, _;
|
|
55
|
+
_ = h(n) ? 1 : /[A-Za-z_]/.test(n[0]) ? 0 : 2, c("kind", _), c("length", m(t)), c("first_char", p(t[0])), c("last_char", p(t[t.length - 1])), t[0] === t[0].toUpperCase() && /[A-Za-z]/.test(t[0]) && c("flags", 0), /[0-9]/.test(t) && c("flags", 1), (t.includes("-") || t.includes("_")) && c("flags", 2);
|
|
56
|
+
let b = g[e];
|
|
57
|
+
c("field_match", b ? d[b.kind] : 0), c("match_quality", b ? b.quality + 1 : 0);
|
|
58
|
+
let x = l.get(n);
|
|
59
|
+
if (x) {
|
|
60
|
+
c("enum_any", 0);
|
|
61
|
+
let t = v[e];
|
|
62
|
+
t !== null && x.has(t) && c("enum_preceding", 0);
|
|
63
|
+
}
|
|
64
|
+
let C = y[e];
|
|
65
|
+
c("distance", C === 99 ? 5 : Math.min(C, 4)), c("operator", a.get(n) ?? i.length);
|
|
66
|
+
let w = Math.max(1, r.length - 1);
|
|
67
|
+
c("position", Math.min(3, Math.floor(4 * e / (w + 1))));
|
|
68
|
+
let T = o.slice(0, 16);
|
|
69
|
+
for (; T.length < 16;) T.push(u);
|
|
70
|
+
S.push(T);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
rows: S,
|
|
74
|
+
neighbors: _(r, o),
|
|
75
|
+
resolved: g
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function _(e, t) {
|
|
79
|
+
let n = /* @__PURE__ */ new Set();
|
|
80
|
+
for (let e of t) for (let t of r(e)) n.add(t.toLowerCase());
|
|
81
|
+
let i = e.map((e) => n.has(e.toLowerCase())), a = Array(e.length).fill(-1), o = -1;
|
|
82
|
+
for (let t = 0; t < e.length; t++) a[t] = o, i[t] && (o = t);
|
|
83
|
+
let s = Array(e.length).fill(-1), c = -1;
|
|
84
|
+
for (let t = e.length - 1; t >= 0; t--) s[t] = c, i[t] && (c = t);
|
|
85
|
+
return e.map((e, t) => [a[t], s[t]]);
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { l as FEATURE_ROWS, s as OFFSET, u as PADDING_ROW, g as featurize, _ as neighborsFor };
|