@nordcraft/core 1.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 +5 -0
- package/dist/api/LegacyToddleApi.d.ts +34 -0
- package/dist/api/LegacyToddleApi.js +178 -0
- package/dist/api/LegacyToddleApi.js.map +1 -0
- package/dist/api/ToddleApiV2.d.ts +77 -0
- package/dist/api/ToddleApiV2.js +271 -0
- package/dist/api/ToddleApiV2.js.map +1 -0
- package/dist/api/api.d.ts +49 -0
- package/dist/api/api.js +276 -0
- package/dist/api/api.js.map +1 -0
- package/dist/api/apiTypes.d.ts +125 -0
- package/dist/api/apiTypes.js +11 -0
- package/dist/api/apiTypes.js.map +1 -0
- package/dist/api/headers.d.ts +10 -0
- package/dist/api/headers.js +36 -0
- package/dist/api/headers.js.map +1 -0
- package/dist/api/template.d.ts +5 -0
- package/dist/api/template.js +7 -0
- package/dist/api/template.js.map +1 -0
- package/dist/component/ToddleComponent.d.ts +45 -0
- package/dist/component/ToddleComponent.js +373 -0
- package/dist/component/ToddleComponent.js.map +1 -0
- package/dist/component/actionUtils.d.ts +2 -0
- package/dist/component/actionUtils.js +56 -0
- package/dist/component/actionUtils.js.map +1 -0
- package/dist/component/component.types.d.ts +313 -0
- package/dist/component/component.types.js +9 -0
- package/dist/component/component.types.js.map +1 -0
- package/dist/component/isPageComponent.d.ts +2 -0
- package/dist/component/isPageComponent.js +3 -0
- package/dist/component/isPageComponent.js.map +1 -0
- package/dist/formula/ToddleFormula.d.ts +15 -0
- package/dist/formula/ToddleFormula.js +20 -0
- package/dist/formula/ToddleFormula.js.map +1 -0
- package/dist/formula/formula.d.ts +103 -0
- package/dist/formula/formula.js +186 -0
- package/dist/formula/formula.js.map +1 -0
- package/dist/formula/formulaTypes.d.ts +30 -0
- package/dist/formula/formulaTypes.js +2 -0
- package/dist/formula/formulaTypes.js.map +1 -0
- package/dist/formula/formulaUtils.d.ts +18 -0
- package/dist/formula/formulaUtils.js +240 -0
- package/dist/formula/formulaUtils.js.map +1 -0
- package/dist/styling/className.d.ts +2 -0
- package/dist/styling/className.js +52 -0
- package/dist/styling/className.js.map +1 -0
- package/dist/styling/style.css.d.ts +5 -0
- package/dist/styling/style.css.js +242 -0
- package/dist/styling/style.css.js.map +1 -0
- package/dist/styling/theme.const.d.ts +3 -0
- package/dist/styling/theme.const.js +381 -0
- package/dist/styling/theme.const.js.map +1 -0
- package/dist/styling/theme.d.ts +72 -0
- package/dist/styling/theme.js +200 -0
- package/dist/styling/theme.js.map +1 -0
- package/dist/styling/variantSelector.d.ts +123 -0
- package/dist/styling/variantSelector.js +25 -0
- package/dist/styling/variantSelector.js.map +1 -0
- package/dist/types.d.ts +97 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/collections.d.ts +21 -0
- package/dist/utils/collections.js +75 -0
- package/dist/utils/collections.js.map +1 -0
- package/dist/utils/customElements.d.ts +6 -0
- package/dist/utils/customElements.js +15 -0
- package/dist/utils/customElements.js.map +1 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +17 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/json.d.ts +5 -0
- package/dist/utils/json.js +16 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/sha1.d.ts +2 -0
- package/dist/utils/sha1.js +13 -0
- package/dist/utils/sha1.js.map +1 -0
- package/dist/utils/url.d.ts +5 -0
- package/dist/utils/url.js +27 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/utils/util.d.ts +3 -0
- package/dist/utils/util.js +4 -0
- package/dist/utils/util.js.map +1 -0
- package/package.json +18 -0
- package/src/api/LegacyToddleApi.ts +205 -0
- package/src/api/ToddleApiV2.ts +331 -0
- package/src/api/api.test.ts +319 -0
- package/src/api/api.ts +414 -0
- package/src/api/apiTypes.ts +145 -0
- package/src/api/headers.ts +41 -0
- package/src/api/template.ts +10 -0
- package/src/component/ToddleComponent.actionReferences.test.ts +75 -0
- package/src/component/ToddleComponent.formulasInComponent.test.ts +234 -0
- package/src/component/ToddleComponent.ts +470 -0
- package/src/component/actionUtils.ts +61 -0
- package/src/component/component.types.ts +362 -0
- package/src/component/isPageComponent.ts +6 -0
- package/src/formula/ToddleFormula.ts +30 -0
- package/src/formula/formula.ts +355 -0
- package/src/formula/formulaTypes.ts +45 -0
- package/src/formula/formulaUtils.ts +287 -0
- package/src/styling/className.test.ts +19 -0
- package/src/styling/className.ts +73 -0
- package/src/styling/style.css.ts +309 -0
- package/src/styling/theme.const.ts +390 -0
- package/src/styling/theme.ts +339 -0
- package/src/styling/variantSelector.ts +168 -0
- package/src/types.ts +158 -0
- package/src/utils/collections.test.ts +57 -0
- package/src/utils/collections.ts +122 -0
- package/src/utils/customElements.test.ts +40 -0
- package/src/utils/customElements.ts +16 -0
- package/src/utils/hash.test.ts +32 -0
- package/src/utils/hash.ts +18 -0
- package/src/utils/json.ts +18 -0
- package/src/utils/sha1.test.ts +50 -0
- package/src/utils/sha1.ts +17 -0
- package/src/utils/url.test.ts +17 -0
- package/src/utils/url.ts +33 -0
- package/src/utils/util.ts +8 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import type { ApiStatus, ComponentAPI, LegacyApiStatus } from '../api/apiTypes';
|
|
2
|
+
import type { Formula } from '../formula/formula';
|
|
3
|
+
import type { StyleTokenCategory } from '../styling/theme';
|
|
4
|
+
import type { RequireFields, ToddleMetadata } from '../types';
|
|
5
|
+
interface ListItem {
|
|
6
|
+
Item: unknown;
|
|
7
|
+
Index: number;
|
|
8
|
+
Parent?: ListItem;
|
|
9
|
+
}
|
|
10
|
+
export interface ComponentData {
|
|
11
|
+
Location?: {
|
|
12
|
+
page?: string;
|
|
13
|
+
path: string;
|
|
14
|
+
params: Record<string, string | null>;
|
|
15
|
+
query: Record<string, string | null>;
|
|
16
|
+
hash: string;
|
|
17
|
+
};
|
|
18
|
+
Attributes: Record<string, unknown>;
|
|
19
|
+
Variables?: Record<string, unknown>;
|
|
20
|
+
Contexts?: Record<string, Record<string, unknown>>;
|
|
21
|
+
'URL parameters'?: Record<string, string | null>;
|
|
22
|
+
'Route parameters'?: {
|
|
23
|
+
path: Record<string, string | null>;
|
|
24
|
+
query: Record<string, string | null>;
|
|
25
|
+
};
|
|
26
|
+
Apis?: Record<string, LegacyApiStatus | (ApiStatus & {
|
|
27
|
+
inputs?: Record<string, unknown>;
|
|
28
|
+
})>;
|
|
29
|
+
Args?: unknown;
|
|
30
|
+
Parameters?: Record<string, unknown>;
|
|
31
|
+
Event?: unknown;
|
|
32
|
+
ListItem?: ListItem;
|
|
33
|
+
}
|
|
34
|
+
export interface AnimationKeyframe {
|
|
35
|
+
position: number;
|
|
36
|
+
key: string;
|
|
37
|
+
value: string;
|
|
38
|
+
easing?: never;
|
|
39
|
+
}
|
|
40
|
+
export interface StyleVariant {
|
|
41
|
+
id?: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
hover?: boolean;
|
|
44
|
+
focus?: boolean;
|
|
45
|
+
focusWithin?: boolean;
|
|
46
|
+
active?: boolean;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
firstChild?: boolean;
|
|
49
|
+
lastChild?: boolean;
|
|
50
|
+
evenChild?: boolean;
|
|
51
|
+
empty?: boolean;
|
|
52
|
+
mediaQuery?: MediaQuery;
|
|
53
|
+
breakpoint: 'small' | 'medium' | 'large';
|
|
54
|
+
startingStyle?: boolean;
|
|
55
|
+
style: NodeStyleModel;
|
|
56
|
+
}
|
|
57
|
+
export type NodeStyleModel = Record<string, string>;
|
|
58
|
+
export interface TextNodeModel {
|
|
59
|
+
id?: string;
|
|
60
|
+
type: 'text';
|
|
61
|
+
condition?: Formula;
|
|
62
|
+
repeat?: Formula;
|
|
63
|
+
slot?: string;
|
|
64
|
+
repeatKey?: Formula;
|
|
65
|
+
value: Formula;
|
|
66
|
+
children?: undefined;
|
|
67
|
+
}
|
|
68
|
+
export interface ElementNodeModel {
|
|
69
|
+
id?: string;
|
|
70
|
+
type: 'element';
|
|
71
|
+
slot?: string;
|
|
72
|
+
condition?: Formula;
|
|
73
|
+
repeat?: Formula;
|
|
74
|
+
repeatKey?: Formula;
|
|
75
|
+
tag: string;
|
|
76
|
+
attrs: Partial<Record<string, Formula>>;
|
|
77
|
+
style: NodeStyleModel;
|
|
78
|
+
variants?: StyleVariant[];
|
|
79
|
+
animations?: Record<string, Record<string, AnimationKeyframe>>;
|
|
80
|
+
children: string[];
|
|
81
|
+
events: Record<string, EventModel>;
|
|
82
|
+
classes: Record<string, {
|
|
83
|
+
formula?: Formula;
|
|
84
|
+
}>;
|
|
85
|
+
'style-variables'?: Array<{
|
|
86
|
+
category: StyleTokenCategory;
|
|
87
|
+
name: string;
|
|
88
|
+
formula: Formula;
|
|
89
|
+
unit?: string;
|
|
90
|
+
}>;
|
|
91
|
+
}
|
|
92
|
+
export interface ComponentNodeModel {
|
|
93
|
+
id?: string;
|
|
94
|
+
type: 'component';
|
|
95
|
+
slot?: string;
|
|
96
|
+
path?: string;
|
|
97
|
+
name: string;
|
|
98
|
+
package?: string;
|
|
99
|
+
condition?: Formula;
|
|
100
|
+
repeat?: Formula;
|
|
101
|
+
repeatKey?: Formula;
|
|
102
|
+
style?: NodeStyleModel;
|
|
103
|
+
variants?: StyleVariant[];
|
|
104
|
+
animations?: Record<string, Record<string, AnimationKeyframe>>;
|
|
105
|
+
attrs: Record<string, Formula>;
|
|
106
|
+
children: string[];
|
|
107
|
+
events: Record<string, EventModel>;
|
|
108
|
+
}
|
|
109
|
+
export interface SlotNodeModel {
|
|
110
|
+
type: 'slot';
|
|
111
|
+
slot?: string;
|
|
112
|
+
name?: string;
|
|
113
|
+
condition?: Formula;
|
|
114
|
+
repeat?: undefined;
|
|
115
|
+
repeatKey?: undefined;
|
|
116
|
+
children: string[];
|
|
117
|
+
}
|
|
118
|
+
export type NodeModel = TextNodeModel | SlotNodeModel | ComponentNodeModel | ElementNodeModel;
|
|
119
|
+
export interface MetaEntry {
|
|
120
|
+
tag: HeadTagTypes;
|
|
121
|
+
attrs: Record<string, Formula>;
|
|
122
|
+
content: Formula;
|
|
123
|
+
}
|
|
124
|
+
export interface StaticPathSegment {
|
|
125
|
+
type: 'static';
|
|
126
|
+
optional?: boolean;
|
|
127
|
+
testValue?: undefined;
|
|
128
|
+
name: string;
|
|
129
|
+
}
|
|
130
|
+
export interface DynamicPathSegment {
|
|
131
|
+
type: 'param';
|
|
132
|
+
testValue: string;
|
|
133
|
+
optional?: boolean;
|
|
134
|
+
name: string;
|
|
135
|
+
}
|
|
136
|
+
type MediaQuery = {
|
|
137
|
+
'min-width'?: string;
|
|
138
|
+
'max-width'?: string;
|
|
139
|
+
'min-height'?: string;
|
|
140
|
+
'max-height'?: string;
|
|
141
|
+
};
|
|
142
|
+
export interface Component {
|
|
143
|
+
name: string;
|
|
144
|
+
/**
|
|
145
|
+
* version 2 indicates that the component's name is no longer prefixed, but will be automatically prefixed by the project name
|
|
146
|
+
*
|
|
147
|
+
* @default undefined (version 1)
|
|
148
|
+
* @deprecated - we are no longer using version 2 components, but we are keeping this field for backwards compatibility
|
|
149
|
+
*/
|
|
150
|
+
version?: 2;
|
|
151
|
+
page?: string;
|
|
152
|
+
route?: PageRoute | null;
|
|
153
|
+
attributes: Record<string, ComponentAttribute>;
|
|
154
|
+
variables: Record<string, ComponentVariable>;
|
|
155
|
+
formulas?: Record<string, ComponentFormula>;
|
|
156
|
+
contexts?: Record<string, ComponentContext>;
|
|
157
|
+
workflows?: Record<string, ComponentWorkflow>;
|
|
158
|
+
apis: Record<string, ComponentAPI>;
|
|
159
|
+
nodes: Record<string, NodeModel>;
|
|
160
|
+
events?: ComponentEvent[];
|
|
161
|
+
onLoad?: EventModel;
|
|
162
|
+
onAttributeChange?: EventModel;
|
|
163
|
+
exported?: boolean;
|
|
164
|
+
}
|
|
165
|
+
export interface ComponentFormula extends ToddleMetadata {
|
|
166
|
+
name: string;
|
|
167
|
+
arguments?: Array<{
|
|
168
|
+
name: string;
|
|
169
|
+
testValue: any;
|
|
170
|
+
}> | null;
|
|
171
|
+
memoize?: boolean;
|
|
172
|
+
exposeInContext?: boolean;
|
|
173
|
+
formula: Formula;
|
|
174
|
+
}
|
|
175
|
+
export interface ComponentWorkflow extends ToddleMetadata {
|
|
176
|
+
name: string;
|
|
177
|
+
parameters: Array<{
|
|
178
|
+
name: string;
|
|
179
|
+
testValue: any;
|
|
180
|
+
}>;
|
|
181
|
+
actions: ActionModel[];
|
|
182
|
+
exposeInContext?: boolean;
|
|
183
|
+
}
|
|
184
|
+
export interface ComponentContext {
|
|
185
|
+
formulas: string[];
|
|
186
|
+
workflows: string[];
|
|
187
|
+
componentName?: string;
|
|
188
|
+
package?: string;
|
|
189
|
+
}
|
|
190
|
+
export type PageComponent = RequireFields<Component, 'route'>;
|
|
191
|
+
export interface RouteDeclaration {
|
|
192
|
+
path: Array<StaticPathSegment | DynamicPathSegment>;
|
|
193
|
+
query: Record<string, {
|
|
194
|
+
name: string;
|
|
195
|
+
testValue: any;
|
|
196
|
+
}>;
|
|
197
|
+
}
|
|
198
|
+
export interface PageRoute extends RouteDeclaration {
|
|
199
|
+
info?: {
|
|
200
|
+
language?: {
|
|
201
|
+
formula: Formula;
|
|
202
|
+
};
|
|
203
|
+
title?: {
|
|
204
|
+
formula: Formula;
|
|
205
|
+
};
|
|
206
|
+
description?: {
|
|
207
|
+
formula: Formula;
|
|
208
|
+
};
|
|
209
|
+
icon?: {
|
|
210
|
+
formula: Formula;
|
|
211
|
+
};
|
|
212
|
+
charset?: {
|
|
213
|
+
formula: Formula;
|
|
214
|
+
};
|
|
215
|
+
meta?: Record<string, MetaEntry>;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
export declare enum HeadTagTypes {
|
|
219
|
+
Meta = "meta",
|
|
220
|
+
Link = "link",
|
|
221
|
+
Script = "script",
|
|
222
|
+
NoScript = "noscript",
|
|
223
|
+
Style = "style"
|
|
224
|
+
}
|
|
225
|
+
export type EventModel = {
|
|
226
|
+
trigger: string;
|
|
227
|
+
actions: ActionModel[];
|
|
228
|
+
};
|
|
229
|
+
export type CustomActionModel = {
|
|
230
|
+
type?: 'Custom';
|
|
231
|
+
package?: string;
|
|
232
|
+
name: string;
|
|
233
|
+
description?: string;
|
|
234
|
+
data?: string | number | boolean | Formula;
|
|
235
|
+
arguments?: {
|
|
236
|
+
name: string;
|
|
237
|
+
formula: Formula;
|
|
238
|
+
}[];
|
|
239
|
+
events?: Record<string, {
|
|
240
|
+
actions: ActionModel[];
|
|
241
|
+
}>;
|
|
242
|
+
version?: 2 | never;
|
|
243
|
+
label?: string;
|
|
244
|
+
};
|
|
245
|
+
export type SwitchActionModel = {
|
|
246
|
+
type: 'Switch';
|
|
247
|
+
data?: string | number | boolean | Formula;
|
|
248
|
+
cases: Array<{
|
|
249
|
+
condition: Formula;
|
|
250
|
+
actions: ActionModel[];
|
|
251
|
+
}>;
|
|
252
|
+
default: {
|
|
253
|
+
actions: ActionModel[];
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
export type VariableActionModel = {
|
|
257
|
+
type: 'SetVariable';
|
|
258
|
+
variable: string;
|
|
259
|
+
data: Formula;
|
|
260
|
+
};
|
|
261
|
+
export type FetchActionModel = {
|
|
262
|
+
type: 'Fetch';
|
|
263
|
+
api: string;
|
|
264
|
+
inputs?: Record<string, {
|
|
265
|
+
formula: Formula | null;
|
|
266
|
+
}>;
|
|
267
|
+
onSuccess: {
|
|
268
|
+
actions: ActionModel[];
|
|
269
|
+
};
|
|
270
|
+
onError: {
|
|
271
|
+
actions: ActionModel[];
|
|
272
|
+
};
|
|
273
|
+
onMessage?: {
|
|
274
|
+
actions: ActionModel[];
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
export type SetURLParameterAction = {
|
|
278
|
+
type: 'SetURLParameter';
|
|
279
|
+
parameter: string;
|
|
280
|
+
data: Formula;
|
|
281
|
+
historyMode?: 'replace' | 'push' | null;
|
|
282
|
+
};
|
|
283
|
+
export type EventActionModel = {
|
|
284
|
+
type: 'TriggerEvent';
|
|
285
|
+
event: string;
|
|
286
|
+
data: Formula;
|
|
287
|
+
};
|
|
288
|
+
export type WorkflowActionModel = {
|
|
289
|
+
type: 'TriggerWorkflow';
|
|
290
|
+
workflow: string;
|
|
291
|
+
parameters: Record<string, {
|
|
292
|
+
formula: Formula;
|
|
293
|
+
}>;
|
|
294
|
+
contextProvider?: string;
|
|
295
|
+
};
|
|
296
|
+
export type ActionModel = VariableActionModel | EventActionModel | SwitchActionModel | FetchActionModel | CustomActionModel | SetURLParameterAction | WorkflowActionModel;
|
|
297
|
+
export interface ComponentEvent extends ToddleMetadata {
|
|
298
|
+
name: string;
|
|
299
|
+
dummyEvent: any;
|
|
300
|
+
}
|
|
301
|
+
export interface ComponentVariable extends ToddleMetadata {
|
|
302
|
+
initialValue: Formula;
|
|
303
|
+
}
|
|
304
|
+
export interface ComponentAttribute extends ToddleMetadata {
|
|
305
|
+
name: string;
|
|
306
|
+
testValue: unknown;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* We must specify the namespace for some nodes when created programmatically that are not in the default namespace.
|
|
310
|
+
* We infer the namespace based on the tag name, but it would be interesting to also allow the user to specify it explicitly with the `xmlns` attribute.
|
|
311
|
+
*/
|
|
312
|
+
export type SupportedNamespaces = 'http://www.w3.org/1999/xhtml' | 'http://www.w3.org/2000/svg' | 'http://www.w3.org/1998/Math/MathML';
|
|
313
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var HeadTagTypes;
|
|
2
|
+
(function (HeadTagTypes) {
|
|
3
|
+
HeadTagTypes["Meta"] = "meta";
|
|
4
|
+
HeadTagTypes["Link"] = "link";
|
|
5
|
+
HeadTagTypes["Script"] = "script";
|
|
6
|
+
HeadTagTypes["NoScript"] = "noscript";
|
|
7
|
+
HeadTagTypes["Style"] = "style";
|
|
8
|
+
})(HeadTagTypes || (HeadTagTypes = {}));
|
|
9
|
+
//# sourceMappingURL=component.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.types.js","sourceRoot":"","sources":["../../src/component/component.types.ts"],"names":[],"mappings":"AAoQA,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,6BAAa,CAAA;IACb,iCAAiB,CAAA;IACjB,qCAAqB,CAAA;IACrB,+BAAe,CAAA;AACjB,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPageComponent.js","sourceRoot":"","sources":["../../src/component/isPageComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,SAAoB,EACQ,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Formula } from './formula';
|
|
2
|
+
import type { GlobalFormulas } from './formulaTypes';
|
|
3
|
+
export declare class ToddleFormula<Handler> {
|
|
4
|
+
private formula;
|
|
5
|
+
private globalFormulas;
|
|
6
|
+
constructor({ formula, globalFormulas, }: {
|
|
7
|
+
formula: Formula;
|
|
8
|
+
globalFormulas: GlobalFormulas<Handler>;
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Traverse all formulas in the formula.
|
|
12
|
+
* @returns An iterable that yields the path and formula.
|
|
13
|
+
*/
|
|
14
|
+
formulasInFormula(): Generator<[(string | number)[], Formula]>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getFormulasInFormula } from './formulaUtils';
|
|
2
|
+
export class ToddleFormula {
|
|
3
|
+
formula;
|
|
4
|
+
globalFormulas;
|
|
5
|
+
constructor({ formula, globalFormulas, }) {
|
|
6
|
+
this.formula = formula;
|
|
7
|
+
this.globalFormulas = globalFormulas;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Traverse all formulas in the formula.
|
|
11
|
+
* @returns An iterable that yields the path and formula.
|
|
12
|
+
*/
|
|
13
|
+
*formulasInFormula() {
|
|
14
|
+
yield* getFormulasInFormula({
|
|
15
|
+
formula: this.formula,
|
|
16
|
+
globalFormulas: this.globalFormulas,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ToddleFormula.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToddleFormula.js","sourceRoot":"","sources":["../../src/formula/ToddleFormula.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAErD,MAAM,OAAO,aAAa;IAChB,OAAO,CAAS;IAChB,cAAc,CAAyB;IAE/C,YAAY,EACV,OAAO,EACP,cAAc,GAIf;QACC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;IACtC,CAAC;IAED;;;OAGG;IACH,CAAC,iBAAiB;QAChB,KAAK,CAAC,CAAC,oBAAoB,CAAC;YAC1B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { Component, ComponentData } from '../component/component.types';
|
|
2
|
+
import type { CustomFormulaHandler, FormulaLookup, ToddleMetadata } from '../types';
|
|
3
|
+
type ShadowRoot = DocumentFragment;
|
|
4
|
+
export interface PathOperation extends ToddleMetadata {
|
|
5
|
+
type: 'path';
|
|
6
|
+
path: string[];
|
|
7
|
+
}
|
|
8
|
+
type FunctionArgument = {
|
|
9
|
+
name?: string;
|
|
10
|
+
isFunction?: boolean;
|
|
11
|
+
formula: Formula;
|
|
12
|
+
};
|
|
13
|
+
export interface FunctionOperation extends ToddleMetadata {
|
|
14
|
+
type: 'function';
|
|
15
|
+
name: string;
|
|
16
|
+
display_name?: string | null;
|
|
17
|
+
package?: string;
|
|
18
|
+
arguments: FunctionArgument[];
|
|
19
|
+
variableArguments?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface RecordOperation extends ToddleMetadata {
|
|
22
|
+
type: 'record';
|
|
23
|
+
entries: FunctionArgument[];
|
|
24
|
+
}
|
|
25
|
+
export interface ObjectOperation extends ToddleMetadata {
|
|
26
|
+
type: 'object';
|
|
27
|
+
arguments?: FunctionArgument[];
|
|
28
|
+
}
|
|
29
|
+
export interface ArrayOperation extends ToddleMetadata {
|
|
30
|
+
type: 'array';
|
|
31
|
+
arguments: Array<{
|
|
32
|
+
formula: Formula;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
export interface OrOperation extends ToddleMetadata {
|
|
36
|
+
type: 'or';
|
|
37
|
+
arguments: Array<{
|
|
38
|
+
formula: Formula;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
export interface AndOperation extends ToddleMetadata {
|
|
42
|
+
type: 'and';
|
|
43
|
+
arguments: Array<{
|
|
44
|
+
formula: Formula;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
export interface ApplyOperation extends ToddleMetadata {
|
|
48
|
+
type: 'apply';
|
|
49
|
+
name: string;
|
|
50
|
+
arguments: FunctionArgument[];
|
|
51
|
+
}
|
|
52
|
+
export interface ValueOperation extends ToddleMetadata {
|
|
53
|
+
type: 'value';
|
|
54
|
+
value: ValueOperationValue;
|
|
55
|
+
}
|
|
56
|
+
export type ValueOperationValue = string | number | boolean | null | object;
|
|
57
|
+
export interface SwitchOperation extends ToddleMetadata {
|
|
58
|
+
type: 'switch';
|
|
59
|
+
cases: Array<{
|
|
60
|
+
condition: Formula;
|
|
61
|
+
formula: Formula;
|
|
62
|
+
}>;
|
|
63
|
+
default: Formula;
|
|
64
|
+
}
|
|
65
|
+
export type Formula = FunctionOperation | RecordOperation | ObjectOperation | ArrayOperation | PathOperation | SwitchOperation | OrOperation | AndOperation | ValueOperation | ApplyOperation;
|
|
66
|
+
export type FormulaContext = {
|
|
67
|
+
component: Component;
|
|
68
|
+
formulaCache?: Record<string, {
|
|
69
|
+
get: (data: ComponentData) => any;
|
|
70
|
+
set: (data: ComponentData, result: any) => void;
|
|
71
|
+
}>;
|
|
72
|
+
data: ComponentData;
|
|
73
|
+
root?: Document | ShadowRoot | null;
|
|
74
|
+
package: string | undefined;
|
|
75
|
+
toddle: {
|
|
76
|
+
getFormula: FormulaLookup;
|
|
77
|
+
getCustomFormula: CustomFormulaHandler;
|
|
78
|
+
errors: Error[];
|
|
79
|
+
};
|
|
80
|
+
env: ToddleEnv | undefined;
|
|
81
|
+
};
|
|
82
|
+
export type ToddleServerEnv = {
|
|
83
|
+
branchName: string;
|
|
84
|
+
isServer: true;
|
|
85
|
+
request: {
|
|
86
|
+
headers: Record<string, string>;
|
|
87
|
+
cookies: Record<string, string>;
|
|
88
|
+
url: string;
|
|
89
|
+
};
|
|
90
|
+
runtime: never;
|
|
91
|
+
logErrors: boolean;
|
|
92
|
+
};
|
|
93
|
+
export type ToddleEnv = ToddleServerEnv | {
|
|
94
|
+
branchName: string;
|
|
95
|
+
isServer: false;
|
|
96
|
+
request: undefined;
|
|
97
|
+
runtime: 'page' | 'custom-element' | 'preview';
|
|
98
|
+
logErrors: boolean;
|
|
99
|
+
};
|
|
100
|
+
export declare function isFormula(f: any): f is Formula;
|
|
101
|
+
export declare function isFormulaApplyOperation(formula: Formula): formula is ApplyOperation;
|
|
102
|
+
export declare function applyFormula(formula: Formula | string | number | undefined | null | boolean, ctx: FormulaContext): any;
|
|
103
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { isDefined, toBoolean } from '../utils/util';
|
|
2
|
+
import { isToddleFormula } from './formulaTypes';
|
|
3
|
+
export function isFormula(f) {
|
|
4
|
+
return f && typeof f === 'object' && typeof f.type === 'string';
|
|
5
|
+
}
|
|
6
|
+
export function isFormulaApplyOperation(formula) {
|
|
7
|
+
return formula.type === 'apply';
|
|
8
|
+
}
|
|
9
|
+
export function applyFormula(formula, ctx) {
|
|
10
|
+
if (!isFormula(formula)) {
|
|
11
|
+
return formula;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
switch (formula.type) {
|
|
15
|
+
case 'value':
|
|
16
|
+
return formula.value;
|
|
17
|
+
case 'path': {
|
|
18
|
+
let input = ctx.data;
|
|
19
|
+
for (const key of formula.path) {
|
|
20
|
+
if (input && typeof input === 'object') {
|
|
21
|
+
input = input[key];
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return input;
|
|
28
|
+
}
|
|
29
|
+
case 'switch': {
|
|
30
|
+
for (const branch of formula.cases) {
|
|
31
|
+
if (toBoolean(applyFormula(branch.condition, ctx))) {
|
|
32
|
+
return applyFormula(branch.formula, ctx);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return applyFormula(formula.default, ctx);
|
|
36
|
+
}
|
|
37
|
+
case 'or': {
|
|
38
|
+
for (const entry of formula.arguments) {
|
|
39
|
+
if (toBoolean(applyFormula(entry.formula, ctx))) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
case 'and': {
|
|
46
|
+
for (const entry of formula.arguments) {
|
|
47
|
+
if (!toBoolean(applyFormula(entry.formula, ctx))) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
case 'function': {
|
|
54
|
+
const packageName = formula.package ?? ctx.package;
|
|
55
|
+
const newFunc = (ctx.toddle ??
|
|
56
|
+
globalThis.toddle)?.getCustomFormula(formula.name, packageName);
|
|
57
|
+
const legacyFunc = (ctx.toddle ?? globalThis.toddle).getFormula(formula.name);
|
|
58
|
+
if (isDefined(newFunc)) {
|
|
59
|
+
const args = formula.arguments.reduce((args, arg, i) => ({
|
|
60
|
+
...args,
|
|
61
|
+
[arg.name ?? `${i}`]: arg.isFunction
|
|
62
|
+
? (Args) => applyFormula(arg.formula, {
|
|
63
|
+
...ctx,
|
|
64
|
+
data: {
|
|
65
|
+
...ctx.data,
|
|
66
|
+
Args: ctx.data.Args
|
|
67
|
+
? { ...Args, '@toddle.parent': ctx.data.Args }
|
|
68
|
+
: Args,
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
: applyFormula(arg.formula, ctx),
|
|
72
|
+
}), {});
|
|
73
|
+
try {
|
|
74
|
+
return isToddleFormula(newFunc)
|
|
75
|
+
? applyFormula(newFunc.formula, {
|
|
76
|
+
...ctx,
|
|
77
|
+
data: { ...ctx.data, Args: args },
|
|
78
|
+
})
|
|
79
|
+
: newFunc.handler(args, {
|
|
80
|
+
root: ctx.root ?? document,
|
|
81
|
+
env: ctx.env,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
ctx.toddle.errors.push(e);
|
|
86
|
+
if (ctx.env?.logErrors) {
|
|
87
|
+
console.error(e);
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (typeof legacyFunc === 'function') {
|
|
93
|
+
const args = (formula.arguments ?? []).map((arg) => arg.isFunction
|
|
94
|
+
? (Args) => applyFormula(arg.formula, {
|
|
95
|
+
...ctx,
|
|
96
|
+
data: {
|
|
97
|
+
...ctx.data,
|
|
98
|
+
Args: ctx.data.Args
|
|
99
|
+
? { ...Args, '@toddle.parent': ctx.data.Args }
|
|
100
|
+
: Args,
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
: applyFormula(arg.formula, ctx));
|
|
104
|
+
try {
|
|
105
|
+
return legacyFunc(args, ctx);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
ctx.toddle.errors.push(e);
|
|
109
|
+
if (ctx.env?.logErrors) {
|
|
110
|
+
console.error(e);
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (ctx.env?.logErrors) {
|
|
116
|
+
console.error(`Could not find formula ${formula.name} in package ${packageName ?? ''}`, formula);
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
case 'object':
|
|
121
|
+
return Object.fromEntries(formula.arguments?.map((entry) => [
|
|
122
|
+
entry.name,
|
|
123
|
+
applyFormula(entry.formula, ctx),
|
|
124
|
+
]) ?? []);
|
|
125
|
+
case 'record': // object used to be called record, there are still examples in the wild.
|
|
126
|
+
return Object.fromEntries(formula.entries.map((entry) => [
|
|
127
|
+
entry.name,
|
|
128
|
+
applyFormula(entry.formula, ctx),
|
|
129
|
+
]));
|
|
130
|
+
case 'array':
|
|
131
|
+
return formula.arguments.map((entry) => applyFormula(entry.formula, ctx));
|
|
132
|
+
case 'apply': {
|
|
133
|
+
const componentFormula = ctx.component.formulas?.[formula.name];
|
|
134
|
+
if (!componentFormula) {
|
|
135
|
+
if (ctx.env?.logErrors) {
|
|
136
|
+
console.log('Component does not have a formula with the name ', formula.name);
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const Input = Object.fromEntries(formula.arguments.map((arg) => arg.isFunction
|
|
141
|
+
? [
|
|
142
|
+
arg.name,
|
|
143
|
+
(Args) => applyFormula(arg.formula, {
|
|
144
|
+
...ctx,
|
|
145
|
+
data: {
|
|
146
|
+
...ctx.data,
|
|
147
|
+
Args: ctx.data.Args
|
|
148
|
+
? { ...Args, '@toddle.parent': ctx.data.Args }
|
|
149
|
+
: Args,
|
|
150
|
+
},
|
|
151
|
+
}),
|
|
152
|
+
]
|
|
153
|
+
: [arg.name, applyFormula(arg.formula, ctx)]));
|
|
154
|
+
const data = {
|
|
155
|
+
...ctx.data,
|
|
156
|
+
Args: ctx.data.Args
|
|
157
|
+
? { ...Input, '@toddle.parent': ctx.data.Args }
|
|
158
|
+
: Input,
|
|
159
|
+
};
|
|
160
|
+
const cache = ctx.formulaCache?.[formula.name]?.get(data);
|
|
161
|
+
if (cache?.hit) {
|
|
162
|
+
return cache.data;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const result = applyFormula(componentFormula.formula, {
|
|
166
|
+
...ctx,
|
|
167
|
+
data,
|
|
168
|
+
});
|
|
169
|
+
ctx.formulaCache?.[formula.name]?.set(data, result);
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
default:
|
|
174
|
+
if (ctx.env?.logErrors) {
|
|
175
|
+
console.error('Could not recognize formula', formula);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch (e) {
|
|
180
|
+
if (ctx.env?.logErrors) {
|
|
181
|
+
console.error(e);
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=formula.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formula.js","sourceRoot":"","sources":["../../src/formula/formula.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAiIhD,MAAM,UAAU,SAAS,CAAC,CAAM;IAC9B,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAA;AACjE,CAAC;AACD,MAAM,UAAU,uBAAuB,CACrC,OAAgB;IAEhB,OAAO,OAAO,CAAC,IAAI,KAAK,OAAO,CAAA;AACjC,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,OAA+D,EAC/D,GAAmB;IAEnB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QACxB,OAAO,OAAO,CAAA;IAChB,CAAC;IACD,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