@mapples/inlang 1.0.2 → 1.1.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/README.md CHANGED
@@ -1,146 +1,454 @@
1
- # @mapples/inlang
1
+ # @mapples/types
2
2
 
3
- Internal language utilities for the Mapples Open Kit. This package provides parsing and evaluation helpers for "this" references, dimension strings, and condition strings used across the Mapples ecosystem (e.g. data bindings, visibility conditions, layout).
4
-
5
- ## Features
6
-
7
- - **This references** – Parse and detect `"this"` and `"this::n"` style action/context references
8
- - **Data this** – Parse `(this)` and dot-separated paths for data binding
9
- - **Dimensions** – Parse dimension strings (e.g. `"w::50"`, `"height::100"`) for width/height
10
- - **Conditions** – Parse and evaluate condition strings (`dataProp::condition::value`) for visibility and logic
11
- - **TypeScript** – Full type definitions and TSDoc
3
+ TypeScript type definitions for the Mapples Open Kit. This package provides all the core type definitions used across the Mapples ecosystem, including component registration, form configurations, and asset management.
12
4
 
13
5
  ## Installation
14
6
 
15
7
  ```bash
16
- npm install @mapples/inlang
8
+ npm install @mapples/types
17
9
  # or
18
- yarn add @mapples/inlang
10
+ yarn add @mapples/types
19
11
  ```
20
12
 
21
13
  ## Overview
22
14
 
23
- `@mapples/inlang` is used by other Mapples packages (e.g. render, form, ui) to interpret configuration strings. It does not depend on React or React Native.
15
+ The `@mapples/types` package contains essential TypeScript interfaces and types that define the structure and behavior of components, forms, and assets in the Mapples system. These types ensure type safety and provide clear contracts for developers working with the Mapples Open Kit.
24
16
 
25
- ## API Reference
17
+ ## Core Types
26
18
 
27
- ### Constants
19
+ ### Action Types
28
20
 
29
- - **`FN_SEPARATOR`** – `'::'` – Separator used in "this", dim, and condition strings
30
- - **`DATA_THIS`** – `'(this)'` – Prefix for data-context reference (entire state)
31
- - **`DOT_SEPARATOR`** – `'.'` – Separator for object paths (e.g. `user.name`)
21
+ #### `Action`
32
22
 
33
- ### This (action/context references)
23
+ Represents a user action that occurred in the application. Actions are used for tracking user interactions, analytics, and state management.
34
24
 
35
- - **`This`** – Type: `['this', string?]`
36
- - **`isThis(value?)`** – Returns whether the string matches `"this"` or `"this::n"`
37
- - **`isDataThis(value?)`** – Returns whether the string starts with `(this)`
38
- - **`parseDataThis(value)`** – Strips `(this)` and splits by dot (path segments)
39
- - **`parseThis(value?)`** – Parses to `['this', n?]` (e.g. `"this::2"` → `['this', '2']`)
25
+ ```typescript
26
+ interface Action {
27
+ time: number; // Timestamp when the action occurred (in milliseconds since epoch)
28
+ type?: string; // Optional string identifier for the type of action
29
+ payload?: ActionPayload; // Optional payload containing additional data about the action
30
+ }
31
+ ```
40
32
 
41
- ### Dims (dimension strings)
33
+ #### `ActionPayload`
42
34
 
43
- - **`DimType`** – `'width' | 'height'`
44
- - **`Dims`** – `[DimType, number]` (e.g. `['width', 0.5]` for 50%)
45
- - **`DimsString`** – `'w' | 'h' | 'width' | 'height'`
46
- - **`parseDims(dim)`** – Parses strings like `"w::50"` or `"height::100"` to `[type, 0..1]` or `null`
35
+ Represents the payload data that can be attached to an action.
47
36
 
48
- ### State (conditions)
37
+ ```typescript
38
+ interface ActionPayload {
39
+ originalEventData?: any[]; // Original event data from the source event
40
+ data?: any; // Custom data payload specific to the action
41
+ }
42
+ ```
49
43
 
50
- #### Types
44
+ **Example:**
51
45
 
52
- - **`Conditions`** – Enum: `equals` (`'eq'`), `notEquals` (`'neq'`)
53
- - **`SimpleCondition`** – `${string}::${Conditions}::${string}`
54
- - **`BoolCondition`** – Condition string with `'true'` or `'false'` as value
55
- - **`ConditionFunc`** – `(a, b) => boolean`
56
- - **`ValueType`** – `'string' | 'number' | 'boolean' | 'dataProp'`
57
- - **`ParseConditionResult`** – `{ dataProp, condition, valueProp, valueType }`
46
+ ```typescript
47
+ import { Action, ActionPayload } from '@mapples/types';
48
+
49
+ const userAction: Action = {
50
+ time: Date.now(),
51
+ type: 'BUTTON_PRESSED',
52
+ payload: {
53
+ data: { buttonId: 'submit', userId: '123' },
54
+ originalEventData: ['button', 'press', { x: 100, y: 200 }],
55
+ },
56
+ };
57
+ ```
58
+
59
+ ### Mapplet Types
58
60
 
59
- #### Regexp
61
+ #### `MappletType<State>`
60
62
 
61
- - **`ConditionStringRegExp`** – Regex used to split condition strings on `::` (respecting quoted segments)
63
+ Represents the configuration interface for a Mapplet application. A Mapplet is a self-contained application that can be embedded or run standalone.
62
64
 
63
- #### Utils
65
+ ```typescript
66
+ interface MappletType<State extends object = object> {
67
+ state?: State; // Optional initial state object for the Mapplet
68
+ onAction?: (action: Action) => void; // Optional callback function to handle actions
69
+ }
70
+ ```
64
71
 
65
- - **`toConditionString(...values)`** – Joins values with `FN_SEPARATOR`
66
- - **`parseConditionString(value)`** – Splits a condition string into parts (valueType default `'string'`)
67
- - **`parseCondition(value)`** – Parses `SimpleCondition | BoolCondition` into `ParseConditionResult` (handles booleans and quoted types)
68
- - **`isCondition(value)`** – Type guard for valid condition strings
69
- - **`toBool(value)`** – Converts string/boolean to boolean (`"true"` → true)
70
- - **`toNumber(value)`** – Converts string/boolean to number (booleans → 0/1)
71
- - **`parseJoin(key?)`** – Splits key by `;` and removes newlines (for multi-key data props)
72
+ **Example:**
72
73
 
73
- #### Conditions (evaluators)
74
+ ```typescript
75
+ import { MappletType, Action } from '@mapples/types';
76
+
77
+ interface MyAppState {
78
+ user: { name: string; email: string };
79
+ settings: { theme: string };
80
+ }
81
+
82
+ const myMapplet: MappletType<MyAppState> = {
83
+ state: {
84
+ user: { name: 'John', email: 'john@example.com' },
85
+ settings: { theme: 'dark' },
86
+ },
87
+ onAction: (action: Action) => {
88
+ console.log('Mapplet action:', action);
89
+ // Handle analytics, logging, etc.
90
+ },
91
+ };
92
+ ```
74
93
 
75
- - **`eq`** – `(a, b) => a === b`
76
- - **`notEq`** – `(a, b) => a !== b`
77
- - **`conditionMap`** – `Record<Conditions, ConditionFunc>` mapping enum to functions
94
+ ### Asset Types
78
95
 
79
- ## Usage examples
96
+ #### `AssetType`
97
+
98
+ Represents the different types of assets that can be used in the Mapples system.
80
99
 
81
100
  ```typescript
82
- import {
83
- isThis,
84
- isDataThis,
85
- parseDataThis,
86
- parseThis,
87
- parseDims,
88
- DATA_THIS,
89
- FN_SEPARATOR,
90
- } from '@mapples/inlang';
101
+ type AssetType = 'image' | 'video' | 'icon' | 'font' | 'json';
102
+ ```
103
+
104
+ **Example:**
105
+
106
+ ```typescript
107
+ import { AssetType } from '@mapples/types';
108
+
109
+ const imageAsset: AssetType = 'image';
110
+ const videoAsset: AssetType = 'video';
111
+ ```
112
+
113
+ ### Component Types
114
+
115
+ #### `RegisteredComponent<T>`
116
+
117
+ Defines the structure for registering components in the Mapples component system. This interface contains all the metadata needed to make a component available in the visual editor.
118
+
119
+ ```typescript
120
+ interface RegisteredComponent<T extends object = object> {
121
+ type: string; // Unique component identifier
122
+ groupId: string; // Group this component belongs to
123
+ label: string; // Display name
124
+ Component: ComponentType<PropsWithChildren<T>>; // React component
125
+ Icon: ComponentType<SvgProps>; // Icon for component palette
126
+ initialProps: T; // Default props
127
+ styleKeys: StyleKey[]; // Available style properties
128
+ props: PropsFormField[]; // Property form fields
129
+ actionProps: string[]; // Action-triggering properties
130
+ hidden?: boolean; // Hide from palette
131
+ hasChildren?: boolean; // Can contain children
132
+ }
133
+ ```
134
+
135
+ **Example:**
136
+
137
+ ```typescript
138
+ import { RegisteredComponent } from '@mapples/types';
139
+
140
+ interface ButtonProps {
141
+ text: string;
142
+ disabled?: boolean;
143
+ onPress?: () => void;
144
+ }
145
+
146
+ const buttonComponent: RegisteredComponent<ButtonProps> = {
147
+ type: 'Button',
148
+ groupId: 'inputs',
149
+ label: 'Button',
150
+ Component: Button,
151
+ Icon: ButtonIcon,
152
+ initialProps: { text: 'Click me' },
153
+ styleKeys: [backgroundColorStyle, textColorStyle],
154
+ props: [textField, disabledField],
155
+ actionProps: ['onPress'],
156
+ };
157
+ ```
158
+
159
+ #### `RegisteredComponentsGroup`
160
+
161
+ Represents a group of components in the component palette.
162
+
163
+ ```typescript
164
+ interface RegisteredComponentsGroup {
165
+ id: string; // Unique group identifier
166
+ label: string; // Display name
167
+ Icon: ComponentType<SvgProps>; // Group icon
168
+ }
169
+ ```
170
+
171
+ #### `RegisteredComponents`
172
+
173
+ A registry mapping component types to their definitions.
174
+
175
+ ```typescript
176
+ type RegisteredComponents = Record<string, RegisteredComponent>;
177
+ ```
178
+
179
+ #### `StyleKey`
180
+
181
+ Defines a style property configuration.
182
+
183
+ ```typescript
184
+ interface StyleKey {
185
+ label: string; // Human-readable label
186
+ value: string; // CSS property name
187
+ forms: StyleFormType[]; // Applicable form types
188
+ }
189
+ ```
190
+
191
+ ### Form Types
192
+
193
+ #### `StyleFormType`
194
+
195
+ Enum representing different categories of style forms.
91
196
 
92
- // This
93
- isThis('"this"'); // true
94
- isThis('"this::1"'); // true
95
- parseThis('"this::2"'); // ['this', '2']
197
+ ```typescript
198
+ enum StyleFormType {
199
+ Dimension = 'Dimension', // Width, height, min/max dimensions
200
+ Image = 'Image', // Background images, object fit
201
+ Text = 'Text', // Text color, alignment
202
+ Typography = 'Typography', // Font family, size, weight
203
+ Position = 'Position', // Top, left, right, bottom
204
+ Surface = 'Surface', // Background color, opacity
205
+ ScrollSurface = 'ScrollSurface', // Scrollable surface properties
206
+ Borders = 'Borders', // Border width, color, radius
207
+ Shadow = 'Shadow', // Box shadow, elevation
208
+ Spacing = 'Spacing', // Margin, padding
209
+ Svg = 'Svg', // SVG-related properties
210
+ }
211
+ ```
212
+
213
+ #### `PropsFormType`
214
+
215
+ Enum for property form field types.
216
+
217
+ ```typescript
218
+ enum PropsFormType {
219
+ Text = 'Text', // Text input field
220
+ Select = 'Select', // Single selection dropdown
221
+ Switch = 'Switch', // Boolean toggle
222
+ MultiSelect = 'MultiSelect', // Multiple selection dropdown
223
+ }
224
+ ```
96
225
 
97
- // Data this
98
- isDataThis('(this)'); // true
99
- isDataThis('(this).user.name'); // true
100
- parseDataThis('(this).user.name'); // ['user', 'name']
226
+ #### `PropsFormField`
101
227
 
102
- // Dims
103
- parseDims('"w::50"'); // ['width', 0.5]
104
- parseDims('"h::100"'); // ['height', 1]
105
- parseDims('"width"'); // ['width', 1]
228
+ Configuration for component property form fields.
229
+
230
+ ```typescript
231
+ interface PropsFormField {
232
+ propsKey: string; // Property key in component props
233
+ label: string; // Form field label
234
+ options?: PropsFormFieldOptions; // Options for select fields
235
+ type: PropsFormType; // Form field type
236
+ dataProp?: boolean; // Can be bound to data sources
237
+ }
238
+ ```
239
+
240
+ **Example:**
241
+
242
+ ```typescript
243
+ import { PropsFormField, PropsFormType } from '@mapples/types';
244
+
245
+ const textField: PropsFormField = {
246
+ propsKey: 'text',
247
+ label: 'Button Text',
248
+ type: PropsFormType.Text,
249
+ };
250
+
251
+ const sizeField: PropsFormField = {
252
+ propsKey: 'size',
253
+ label: 'Size',
254
+ type: PropsFormType.Select,
255
+ options: [
256
+ { label: 'Small', value: 'sm' },
257
+ { label: 'Medium', value: 'md' },
258
+ { label: 'Large', value: 'lg' },
259
+ ],
260
+ };
106
261
  ```
107
262
 
263
+ #### `PropsFormFieldOption`
264
+
265
+ Represents an option in select/multi-select fields.
266
+
267
+ ```typescript
268
+ interface PropsFormFieldOption {
269
+ label: string; // Display text
270
+ value: string; // Stored value
271
+ }
272
+ ```
273
+
274
+ #### `PropsFormFieldOptions`
275
+
276
+ Union type for form field options.
277
+
278
+ ```typescript
279
+ type PropsFormFieldOptions =
280
+ | PropsFormFieldOption[] // Array of options
281
+ | 'typography' // Special typography type
282
+ | AssetType; // Asset type for asset selection
283
+ ```
284
+
285
+ #### `ActionFormProps`
286
+
287
+ Configuration for action properties.
288
+
289
+ ```typescript
290
+ interface ActionFormProps {
291
+ propsKey: string; // Action property key
292
+ label: string; // Form field label
293
+ }
294
+ ```
295
+
296
+ #### `PropsFieldConfig`
297
+
298
+ Mapping of form types to their React components.
299
+
300
+ ```typescript
301
+ type PropsFieldConfig = Record<PropsFormType, ComponentType<PropsFormField>>;
302
+ ```
303
+
304
+ ## Usage Examples
305
+
306
+ ### Registering a Component
307
+
108
308
  ```typescript
109
309
  import {
110
- parseCondition,
111
- isCondition,
112
- toBool,
113
- toNumber,
114
- Conditions,
115
- conditionMap,
116
- } from '@mapples/inlang';
310
+ RegisteredComponent,
311
+ PropsFormField,
312
+ PropsFormType,
313
+ StyleFormType,
314
+ StyleKey,
315
+ } from '@mapples/types';
316
+
317
+ // Define component props
318
+ interface MyButtonProps {
319
+ text: string;
320
+ variant: 'primary' | 'secondary';
321
+ disabled?: boolean;
322
+ }
323
+
324
+ // Create style keys
325
+ const backgroundColorStyle: StyleKey = {
326
+ label: 'Background Color',
327
+ value: 'backgroundColor',
328
+ forms: [StyleFormType.Surface],
329
+ };
330
+
331
+ // Create form fields
332
+ const textField: PropsFormField = {
333
+ propsKey: 'text',
334
+ label: 'Button Text',
335
+ type: PropsFormType.Text,
336
+ };
337
+
338
+ const variantField: PropsFormField = {
339
+ propsKey: 'variant',
340
+ label: 'Variant',
341
+ type: PropsFormType.Select,
342
+ options: [
343
+ { label: 'Primary', value: 'primary' },
344
+ { label: 'Secondary', value: 'secondary' },
345
+ ],
346
+ };
347
+
348
+ // Register the component
349
+ const myButtonComponent: RegisteredComponent<MyButtonProps> = {
350
+ type: 'MyButton',
351
+ groupId: 'custom',
352
+ label: 'My Button',
353
+ Component: MyButton,
354
+ Icon: MyButtonIcon,
355
+ initialProps: {
356
+ text: 'Click me',
357
+ variant: 'primary',
358
+ },
359
+ styleKeys: [backgroundColorStyle],
360
+ props: [textField, variantField],
361
+ actionProps: ['onPress'],
362
+ };
363
+ ```
364
+
365
+ ### Creating a Component Group
117
366
 
118
- const r = parseCondition('user.age::eq::18' as any);
119
- // r.dataProp === 'user.age', r.condition === Conditions.equals, r.valueProp === '18'
367
+ ```typescript
368
+ import { RegisteredComponentsGroup } from '@mapples/types';
120
369
 
121
- const br = parseCondition('user.active::eq::true' as any);
122
- // br.valueProp === true, br.valueType === 'boolean'
370
+ const customGroup: RegisteredComponentsGroup = {
371
+ id: 'custom',
372
+ label: 'Custom Components',
373
+ Icon: CustomIcon,
374
+ };
375
+ ```
123
376
 
124
- isCondition('user.role::eq::admin'); // true
125
- toBool('true'); // true
126
- toNumber('42'); // 42
377
+ ### Working with Form Fields
127
378
 
128
- const fn = conditionMap[Conditions.equals];
129
- fn(1, 1); // true
379
+ ```typescript
380
+ import {
381
+ PropsFormField,
382
+ PropsFormType,
383
+ PropsFormFieldOptions,
384
+ } from '@mapples/types';
385
+
386
+ // Text field
387
+ const nameField: PropsFormField = {
388
+ propsKey: 'name',
389
+ label: 'Name',
390
+ type: PropsFormType.Text,
391
+ };
392
+
393
+ // Select field with options
394
+ const statusField: PropsFormField = {
395
+ propsKey: 'status',
396
+ label: 'Status',
397
+ type: PropsFormType.Select,
398
+ options: [
399
+ { label: 'Active', value: 'active' },
400
+ { label: 'Inactive', value: 'inactive' },
401
+ { label: 'Pending', value: 'pending' },
402
+ ],
403
+ };
404
+
405
+ // Asset selection field
406
+ const imageField: PropsFormField = {
407
+ propsKey: 'image',
408
+ label: 'Image',
409
+ type: PropsFormType.Select,
410
+ options: 'image', // AssetType
411
+ };
412
+
413
+ // Typography field
414
+ const fontField: PropsFormField = {
415
+ propsKey: 'font',
416
+ label: 'Font',
417
+ type: PropsFormType.Select,
418
+ options: 'typography',
419
+ };
130
420
  ```
131
421
 
132
- ## Integration
422
+ ## Integration with Other Packages
133
423
 
134
- Used by:
424
+ This types package is used throughout the Mapples ecosystem:
135
425
 
136
- - **@mapples/render** – Data props and condition-based visibility
137
- - **@mapples/form** – Field bindings and conditional logic
138
- - **@mapples/ui** – Component props and layout hints
426
+ - **@mapples/action**: Uses `Action` and `ActionPayload` types for action management
427
+ - **@mapples/state**: Uses state-related types for state management
428
+ - **@mapples/ui**: Uses `RegisteredComponent` and related types for component registration
429
+ - **@mapples/form**: Uses `PropsFormField` and form-related types for property editing
430
+ - **@mapples/style**: Uses `StyleKey` and `StyleFormType` for styling configuration
431
+ - **@mapples/render**: Uses component types for rendering components
139
432
 
140
- ## License
433
+ ## Type Safety
141
434
 
142
- MIT
435
+ All types in this package are designed to provide maximum type safety and IntelliSense support. When working with Mapples components, you'll get:
143
436
 
144
- ## Author
437
+ - Autocomplete for all properties
438
+ - Type checking for component props
439
+ - Validation for form field configurations
440
+ - IntelliSense for style properties
145
441
 
146
- Oleksandr Soloviov – [mapples.org](https://mapples.org/people/olek_soloviov)
442
+ ## Contributing
443
+
444
+ When adding new types to this package:
445
+
446
+ 1. Follow the existing naming conventions
447
+ 2. Add comprehensive TSDoc comments
448
+ 3. Include usage examples
449
+ 4. Update this README with new types
450
+ 5. Ensure all types are exported from the main index file
451
+
452
+ ## License
453
+
454
+ MIT
@@ -1,7 +1,7 @@
1
- /** Separator used in "this", dim, and condition strings. @public */
1
+ /** Separator used between parts of function-call and condition strings (e.g. `"key::value"`). */
2
2
  export declare const FN_SEPARATOR = "::";
3
- /** Prefix for data-context reference (entire state). @public */
3
+ /** Prefix token that identifies a `(this)` data reference in inline-lang expressions. */
4
4
  export declare const DATA_THIS = "(this)";
5
- /** Separator for object paths (e.g. user.name). @public */
5
+ /** Separator used when splitting dot-notation property paths. */
6
6
  export declare const DOT_SEPARATOR = ".";
7
7
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,gEAAgE;AAChE,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC,2DAA2D;AAC3D,eAAO,MAAM,aAAa,MAAM,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,yFAAyF;AACzF,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC,iEAAiE;AACjE,eAAO,MAAM,aAAa,MAAM,CAAC"}
package/dist/constants.js CHANGED
@@ -1,7 +1,7 @@
1
- /** Separator used in "this", dim, and condition strings. @public */
1
+ /** Separator used between parts of function-call and condition strings (e.g. `"key::value"`). */
2
2
  export const FN_SEPARATOR = '::';
3
- /** Prefix for data-context reference (entire state). @public */
3
+ /** Prefix token that identifies a `(this)` data reference in inline-lang expressions. */
4
4
  export const DATA_THIS = '(this)';
5
- /** Separator for object paths (e.g. user.name). @public */
5
+ /** Separator used when splitting dot-notation property paths. */
6
6
  export const DOT_SEPARATOR = '.';
7
7
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AAEjC,gEAAgE;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAElC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AAEjC,yFAAyF;AACzF,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAElC,iEAAiE;AACjE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC"}
package/dist/dims.d.ts CHANGED
@@ -1,13 +1,41 @@
1
- /** Dimension axis: width or height. @public */
1
+ /** The canonical dimension axis: either `'width'` or `'height'`. */
2
2
  export type DimType = 'width' | 'height';
3
- /** Parsed dimension: [axis, multiplier 0..1]. @public */
3
+ /**
4
+ * A parsed dimension tuple: `[axis, fraction]`.
5
+ *
6
+ * `fraction` is a value in the range `[0, 1]` representing the percentage of
7
+ * the parent container's corresponding axis, or `1` when no percentage is
8
+ * specified.
9
+ */
4
10
  export type Dims = [DimType, number];
5
- /** Allowed dimension string keys. @public */
11
+ /**
12
+ * The string tokens recognised as dimension axis shorthands in inline-lang
13
+ * expressions (`'w'` and `'h'` are short forms; `'width'`/`'height'` are the
14
+ * long forms).
15
+ */
6
16
  export type DimsString = 'w' | 'h' | 'width' | 'height';
7
17
  /**
8
- * Parses a dimension string like `"w::50"` or `"height::100"` into [type, 0..1].
9
- * @param dim - Quoted string e.g. `"w::50"` (50% width), `"height"` (100% height)
10
- * @returns Tuple [DimType, number] or null if format is invalid
18
+ * Parses a dimension string into a `Dims` tuple.
19
+ *
20
+ * Dimension strings follow the pattern `<axis>[::percentage]`, where `axis` is
21
+ * one of `w`, `h`, `width`, or `height`, and the optional `percentage` suffix
22
+ * (separated by `::`) is an integer representing a percentage (e.g. `"w::50"`
23
+ * yields `['width', 0.5]`). When no percentage is provided the fraction
24
+ * defaults to `1`.
25
+ *
26
+ * Returns `null` for any string that does not match the expected pattern.
27
+ *
28
+ * @param dim - The dimension string to parse (e.g. `"w"`, `"height::75"`).
29
+ * @returns A `[DimType, fraction]` tuple, or `null` if the string is invalid.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * parseDims('w'); // ['width', 1]
34
+ * parseDims('h::50'); // ['height', 0.5]
35
+ * parseDims('width::100'); // ['width', 1]
36
+ * parseDims('invalid'); // null
37
+ * ```
38
+ *
11
39
  * @public
12
40
  */
13
41
  export declare const parseDims: (dim: string) => Dims | null;
@@ -1 +1 @@
1
- {"version":3,"file":"dims.d.ts","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAIA,+CAA+C;AAC/C,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEzC,yDAAyD;AACzD,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAErC,6CAA6C;AAC7C,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC;AASxD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,IAAI,GAAG,IAS9C,CAAC"}
1
+ {"version":3,"file":"dims.d.ts","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAIA,oEAAoE;AACpE,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC;AASxD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,IAAI,GAAG,IAS9C,CAAC"}
package/dist/dims.js CHANGED
@@ -7,9 +7,27 @@ const mapDimsType = {
7
7
  height: 'height',
8
8
  };
9
9
  /**
10
- * Parses a dimension string like `"w::50"` or `"height::100"` into [type, 0..1].
11
- * @param dim - Quoted string e.g. `"w::50"` (50% width), `"height"` (100% height)
12
- * @returns Tuple [DimType, number] or null if format is invalid
10
+ * Parses a dimension string into a `Dims` tuple.
11
+ *
12
+ * Dimension strings follow the pattern `<axis>[::percentage]`, where `axis` is
13
+ * one of `w`, `h`, `width`, or `height`, and the optional `percentage` suffix
14
+ * (separated by `::`) is an integer representing a percentage (e.g. `"w::50"`
15
+ * yields `['width', 0.5]`). When no percentage is provided the fraction
16
+ * defaults to `1`.
17
+ *
18
+ * Returns `null` for any string that does not match the expected pattern.
19
+ *
20
+ * @param dim - The dimension string to parse (e.g. `"w"`, `"height::75"`).
21
+ * @returns A `[DimType, fraction]` tuple, or `null` if the string is invalid.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * parseDims('w'); // ['width', 1]
26
+ * parseDims('h::50'); // ['height', 0.5]
27
+ * parseDims('width::100'); // ['width', 1]
28
+ * parseDims('invalid'); // null
29
+ * ```
30
+ *
13
31
  * @public
14
32
  */
15
33
  export const parseDims = (dim) => {
package/dist/dims.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dims.js","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,uBAAuB,YAAY,SAAS,CAAC,CAAC;AAW3E,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,QAAQ;IACX,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAe,EAAE;IACpD,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAE1C,OAAO,CAAC,WAAW,CAAC,IAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
1
+ {"version":3,"file":"dims.js","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,uBAAuB,YAAY,SAAS,CAAC,CAAC;AAqB3E,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,QAAQ;IACX,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAe,EAAE;IACpD,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAE1C,OAAO,CAAC,WAAW,CAAC,IAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,3 @@
1
- /**
2
- * @packageDocumentation
3
- * @module @mapples/inlang
4
- *
5
- * Internal language utilities for the Mapples Open Kit: parsing and evaluation
6
- * of "this" references, dimension strings, and condition strings used across
7
- * data bindings, visibility conditions, and layout.
8
- */
9
1
  export * from './this';
10
2
  export * from './state';
11
3
  export * from './dims';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,3 @@
1
- /**
2
- * @packageDocumentation
3
- * @module @mapples/inlang
4
- *
5
- * Internal language utilities for the Mapples Open Kit: parsing and evaluation
6
- * of "this" references, dimension strings, and condition strings used across
7
- * data bindings, visibility conditions, and layout.
8
- */
9
1
  export * from './this';
10
2
  export * from './state';
11
3
  export * from './dims';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
@@ -1,8 +1,22 @@
1
1
  import { ConditionFunc, Conditions } from './types';
2
- /** Equality condition: (a, b) => a === b. @public */
2
+ /** Strict-equality condition: returns `true` when `a === b`. */
3
3
  export declare const eq: ConditionFunc;
4
- /** Not-equals condition: (a, b) => a !== b. @public */
4
+ /** Strict-inequality condition: returns `true` when `a !== b`. */
5
5
  export declare const notEq: ConditionFunc;
6
- /** Map from Conditions enum to evaluator functions. @public */
6
+ /**
7
+ * Lookup map from each {@link Conditions} operator to its corresponding
8
+ * {@link ConditionFunc} implementation.
9
+ *
10
+ * Use this map to resolve a condition operator string to an executable function
11
+ * at runtime.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const fn = conditionMap[Conditions.equals];
16
+ * fn('foo', 'foo'); // true
17
+ * ```
18
+ *
19
+ * @public
20
+ */
7
21
  export declare const conditionMap: Record<Conditions, ConditionFunc>;
8
22
  //# sourceMappingURL=conditions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/state/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,qDAAqD;AACrD,eAAO,MAAM,EAAE,EAAE,aAAiC,CAAC;AAEnD,uDAAuD;AACvD,eAAO,MAAM,KAAK,EAAE,aAAiC,CAAC;AAEtD,+DAA+D;AAC/D,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAG1D,CAAC"}
1
+ {"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/state/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,gEAAgE;AAChE,eAAO,MAAM,EAAE,EAAE,aAAiC,CAAC;AAEnD,kEAAkE;AAClE,eAAO,MAAM,KAAK,EAAE,aAAiC,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAG1D,CAAC"}
@@ -1,9 +1,23 @@
1
1
  import { Conditions } from './types';
2
- /** Equality condition: (a, b) => a === b. @public */
2
+ /** Strict-equality condition: returns `true` when `a === b`. */
3
3
  export const eq = (a, b) => a === b;
4
- /** Not-equals condition: (a, b) => a !== b. @public */
4
+ /** Strict-inequality condition: returns `true` when `a !== b`. */
5
5
  export const notEq = (a, b) => a !== b;
6
- /** Map from Conditions enum to evaluator functions. @public */
6
+ /**
7
+ * Lookup map from each {@link Conditions} operator to its corresponding
8
+ * {@link ConditionFunc} implementation.
9
+ *
10
+ * Use this map to resolve a condition operator string to an executable function
11
+ * at runtime.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const fn = conditionMap[Conditions.equals];
16
+ * fn('foo', 'foo'); // true
17
+ * ```
18
+ *
19
+ * @public
20
+ */
7
21
  export const conditionMap = {
8
22
  [Conditions.equals]: eq,
9
23
  [Conditions.notEquals]: notEq,
@@ -1 +1 @@
1
- {"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/state/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,qDAAqD;AACrD,MAAM,CAAC,MAAM,EAAE,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAEnD,uDAAuD;AACvD,MAAM,CAAC,MAAM,KAAK,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAEtD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAsC;IAC7D,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE;IACvB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,KAAK;CAC9B,CAAC"}
1
+ {"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/state/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,gEAAgE;AAChE,MAAM,CAAC,MAAM,EAAE,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAEnD,kEAAkE;AAClE,MAAM,CAAC,MAAM,KAAK,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,YAAY,GAAsC;IAC7D,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE;IACvB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,KAAK;CAC9B,CAAC"}
@@ -1,7 +1,9 @@
1
1
  /**
2
- * Regex to split condition strings on `::` while respecting quoted segments.
3
- * Used so values like `"a::b"` are not split on the inner `::`.
4
- * @public
2
+ * Regular expression used to split a condition string on the `::` separator,
3
+ * ignoring any `::` sequences that appear inside double-quoted substrings.
4
+ *
5
+ * This lookahead-based pattern ensures that quoted values (e.g. `"foo::bar"`)
6
+ * are treated as atomic tokens rather than split mid-value.
5
7
  */
6
8
  export declare const ConditionStringRegExp: RegExp;
7
9
  //# sourceMappingURL=regexp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"regexp.d.ts","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAkC,CAAC"}
1
+ {"version":3,"file":"regexp.d.ts","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAkC,CAAC"}
@@ -1,7 +1,9 @@
1
1
  /**
2
- * Regex to split condition strings on `::` while respecting quoted segments.
3
- * Used so values like `"a::b"` are not split on the inner `::`.
4
- * @public
2
+ * Regular expression used to split a condition string on the `::` separator,
3
+ * ignoring any `::` sequences that appear inside double-quoted substrings.
4
+ *
5
+ * This lookahead-based pattern ensures that quoted values (e.g. `"foo::bar"`)
6
+ * are treated as atomic tokens rather than split mid-value.
5
7
  */
6
8
  export const ConditionStringRegExp = /::(?=(?:[^"]*"[^"]*")*[^"]*$)/;
7
9
  //# sourceMappingURL=regexp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,+BAA+B,CAAC"}
1
+ {"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,+BAA+B,CAAC"}
@@ -59,10 +59,10 @@ export type ValueType = 'string' | 'number' | 'boolean' | 'dataProp';
59
59
  * the condition operator, the value to compare against, and the type of that value.
60
60
  *
61
61
  * @interface ParseConditionResult
62
- * @property {string} dataProp - The data property path to evaluate
63
- * @property {Conditions} condition - The condition operator to use
64
- * @property {string | boolean} valueProp - The value to compare against
65
- * @property {ValueType} valueType - The type of the value (string, number, boolean, or dataProp)
62
+ * @property dataProp - The data property path to evaluate
63
+ * @property condition - The condition operator to use
64
+ * @property valueProp - The value to compare against
65
+ * @property valueType - The type of the value (string, number, boolean, or dataProp)
66
66
  * @public
67
67
  */
68
68
  export interface ParseConditionResult {
@@ -1,16 +1,39 @@
1
1
  import { BoolCondition, ParseConditionResult, SimpleCondition } from './types';
2
2
  /**
3
- * Joins values with FN_SEPARATOR to build a condition string.
4
- * @param values - Parts to join (e.g. dataProp, condition, value)
5
- * @returns Single string with `::` between parts
3
+ * Joins one or more string parts into a single `::` -separated condition
4
+ * string.
5
+ *
6
+ * @param values - The parts to join (e.g. a data-prop, condition operator, and
7
+ * comparison value).
8
+ * @returns A `::` -delimited string (e.g. `"user.age::eq::18"`).
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * toConditionString('user.age', 'eq', '18'); // 'user.age::eq::18'
13
+ * ```
14
+ *
6
15
  * @public
7
16
  */
8
17
  export declare const toConditionString: (...values: string[]) => string;
9
18
  /**
10
- * Splits a condition string into parts; valueType is defaulted to 'string'.
11
- * For full parsing (booleans, quoted types, dataProp) use parseCondition.
12
- * @param value - Raw condition string
13
- * @returns ParseConditionResult with valueType 'string'
19
+ * Parses a raw condition string into its component parts without type coercion
20
+ * of the value.
21
+ *
22
+ * Unlike {@link parseCondition}, this function does not attempt to convert the
23
+ * value to a boolean or detect quoted/typed literals — it returns the raw
24
+ * string fragments and always sets `valueType` to `'string'`. Prefer
25
+ * {@link parseCondition} when the full type-aware parsing is needed.
26
+ *
27
+ * @param value - The raw condition string to parse (e.g. `"user.age::eq::18"`).
28
+ * @returns A {@link ParseConditionResult} with `valueType` always set to
29
+ * `'string'`.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * parseConditionString('user.age::eq::18');
34
+ * // { dataProp: 'user.age', condition: 'eq', valueProp: '18', valueType: 'string' }
35
+ * ```
36
+ *
14
37
  * @public
15
38
  */
16
39
  export declare const parseConditionString: (value: string) => ParseConditionResult;
@@ -103,9 +126,23 @@ export declare const toBool: (value: string | boolean) => boolean;
103
126
  */
104
127
  export declare const toNumber: (value: string | boolean) => number;
105
128
  /**
106
- * Splits a multi-key string by `;` and strips newlines. Used for data-prop keys that join multiple paths.
107
- * @param key - Optional string (e.g. "user.name;user.email; ")
108
- * @returns Array of segments, or undefined if key is undefined
129
+ * Strips newline characters from `key` and splits it on semicolons, returning
130
+ * an array of the resulting segments.
131
+ *
132
+ * Returns `undefined` when `key` is `undefined`.
133
+ *
134
+ * @param key - An optional semicolon-delimited string, possibly containing
135
+ * newline characters.
136
+ * @returns An array of string segments, or `undefined` if `key` is not
137
+ * provided.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * parseJoin('a;b;c'); // ['a', 'b', 'c']
142
+ * parseJoin('a;\nb'); // ['a', 'b']
143
+ * parseJoin(undefined); // undefined
144
+ * ```
145
+ *
109
146
  * @public
110
147
  */
111
148
  export declare const parseJoin: (key?: string) => string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/state/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAEb,oBAAoB,EACpB,eAAe,EAEhB,MAAM,SAAS,CAAC;AAWjB;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,MAAM,EAAE,WAEpD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,oBAWpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,eAAe,GAAG,aAAa,KACrC,oBAgCF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAKrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,GAAG,OAAO,YAI7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,GAAG,OAAO,WAU/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,yBAErC,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/state/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAEb,oBAAoB,EACpB,eAAe,EAEhB,MAAM,SAAS,CAAC;AAWjB;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,MAAM,EAAE,WAEpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,oBAWpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,eAAe,GAAG,aAAa,KACrC,oBAgCF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAKrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,GAAG,OAAO,YAI7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,GAAG,OAAO,WAU/C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,yBAErC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FN_SEPARATOR } from '@mapples/inlang';
1
+ import { FN_SEPARATOR } from '../constants';
2
2
  import { ConditionStringRegExp } from './regexp';
3
3
  const mapTypes = {
4
4
  str: 'string',
@@ -9,19 +9,42 @@ const mapTypes = {
9
9
  boolean: 'boolean',
10
10
  };
11
11
  /**
12
- * Joins values with FN_SEPARATOR to build a condition string.
13
- * @param values - Parts to join (e.g. dataProp, condition, value)
14
- * @returns Single string with `::` between parts
12
+ * Joins one or more string parts into a single `::` -separated condition
13
+ * string.
14
+ *
15
+ * @param values - The parts to join (e.g. a data-prop, condition operator, and
16
+ * comparison value).
17
+ * @returns A `::` -delimited string (e.g. `"user.age::eq::18"`).
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * toConditionString('user.age', 'eq', '18'); // 'user.age::eq::18'
22
+ * ```
23
+ *
15
24
  * @public
16
25
  */
17
26
  export const toConditionString = (...values) => {
18
27
  return values.join(FN_SEPARATOR);
19
28
  };
20
29
  /**
21
- * Splits a condition string into parts; valueType is defaulted to 'string'.
22
- * For full parsing (booleans, quoted types, dataProp) use parseCondition.
23
- * @param value - Raw condition string
24
- * @returns ParseConditionResult with valueType 'string'
30
+ * Parses a raw condition string into its component parts without type coercion
31
+ * of the value.
32
+ *
33
+ * Unlike {@link parseCondition}, this function does not attempt to convert the
34
+ * value to a boolean or detect quoted/typed literals — it returns the raw
35
+ * string fragments and always sets `valueType` to `'string'`. Prefer
36
+ * {@link parseCondition} when the full type-aware parsing is needed.
37
+ *
38
+ * @param value - The raw condition string to parse (e.g. `"user.age::eq::18"`).
39
+ * @returns A {@link ParseConditionResult} with `valueType` always set to
40
+ * `'string'`.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * parseConditionString('user.age::eq::18');
45
+ * // { dataProp: 'user.age', condition: 'eq', valueProp: '18', valueType: 'string' }
46
+ * ```
47
+ *
25
48
  * @public
26
49
  */
27
50
  export const parseConditionString = (value) => {
@@ -166,9 +189,23 @@ export const toNumber = (value) => {
166
189
  return numValue;
167
190
  };
168
191
  /**
169
- * Splits a multi-key string by `;` and strips newlines. Used for data-prop keys that join multiple paths.
170
- * @param key - Optional string (e.g. "user.name;user.email; ")
171
- * @returns Array of segments, or undefined if key is undefined
192
+ * Strips newline characters from `key` and splits it on semicolons, returning
193
+ * an array of the resulting segments.
194
+ *
195
+ * Returns `undefined` when `key` is `undefined`.
196
+ *
197
+ * @param key - An optional semicolon-delimited string, possibly containing
198
+ * newline characters.
199
+ * @returns An array of string segments, or `undefined` if `key` is not
200
+ * provided.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * parseJoin('a;b;c'); // ['a', 'b', 'c']
205
+ * parseJoin('a;\nb'); // ['a', 'b']
206
+ * parseJoin(undefined); // undefined
207
+ * ```
208
+ *
172
209
  * @public
173
210
  */
174
211
  export const parseJoin = (key) => {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/state/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AASjD,MAAM,QAAQ,GAAG;IACf,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,MAAgB,EAAE,EAAE;IACvD,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAwB,EAAE;IAC1E,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,KAAK;SAC3C,IAAI,EAAE;SACN,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAEhC,OAAO;QACL,QAAQ;QACR,SAAS,EAAE,SAAuB;QAClC,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,QAAQ;KACpB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAsC,EAChB,EAAE;IACxB,M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AAO,KAAK,KAAK,QAAQ;QACzB,2DAA2D,CAAC,IAAI,CAAC,KAAK,CAAC,CACxE,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAuB,EAAE,EAAE;IAChD,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAE7C,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAuB,EAAE,EAAE;IAClD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE/B,IAAI,KAAK,CAAC,QAAQ,CAAC;QAAE,OAAO,CAAC,CAAC;IAE9B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAY,EAAE,EAAE;IACxC,OAAO,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC,CAAC"}
package/dist/this.d.ts CHANGED
@@ -1,33 +1,78 @@
1
1
  /**
2
- * Tuple for parsed action/context "this" reference: `['this', optionalIndex]`.
3
- * @public
2
+ * Parsed representation of a `this` reference in an inline-lang expression.
3
+ *
4
+ * The first element is always `'this'`. The optional second element is a
5
+ * numeric index string when the reference targets a specific iteration item
6
+ * (e.g. `"this::0"` → `['this', '0']`).
4
7
  */
5
8
  export type This = ['this', string?];
6
9
  /**
7
- * Returns whether the string matches an action "this" reference: `"this"` or `"this::n"`.
8
- * @param value - String to test (e.g. from config)
9
- * @returns True if the value is a quoted "this" or "this::n" reference
10
+ * Returns `true` when `value` is a quoted `this` reference string.
11
+ *
12
+ * Matches the literal value `"this"` as well as indexed variants such as
13
+ * `"this::0"`.
14
+ *
15
+ * @param value - The string to test.
16
+ * @returns `true` if `value` is a `this` reference, `false` otherwise.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * isThis('"this"'); // true
21
+ * isThis('"this::0"'); // true
22
+ * isThis('other'); // false
23
+ * ```
24
+ *
10
25
  * @public
11
26
  */
12
27
  export declare const isThis: (value?: string) => boolean;
13
28
  /**
14
- * Returns whether the string is a data-context reference starting with `(this)`.
15
- * @param value - String to test
16
- * @returns True if the value starts with DATA_THIS
29
+ * Returns `true` when `value` begins with the `(this)` data-reference prefix.
30
+ *
31
+ * @param value - The string to test.
32
+ * @returns `true` if `value` is a `(this)` data reference, `false` otherwise.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * isDataThis('(this).name'); // true
37
+ * isDataThis('other'); // false
38
+ * ```
39
+ *
17
40
  * @public
18
41
  */
19
42
  export declare const isDataThis: (value?: string) => boolean | undefined;
20
43
  /**
21
- * Strips the `(this)` prefix and splits the rest by dot into path segments.
22
- * @param value - Full data-this string (e.g. `(this).user.name`)
23
- * @returns Array of path segments
44
+ * Strips the `(this)` prefix from a data-reference string and splits the
45
+ * remaining dot-notation path into an array of property segments.
46
+ *
47
+ * @param value - A `(this)`-prefixed data-reference string (e.g. `"(this).user.name"`).
48
+ * @returns An array of path segments after the `(this)` prefix (e.g. `['', 'user', 'name']`).
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * parseDataThis('(this).user.name'); // ['', 'user', 'name']
53
+ * parseDataThis('(this)'); // ['']
54
+ * ```
55
+ *
24
56
  * @public
25
57
  */
26
58
  export declare const parseDataThis: (value: string) => string[];
27
59
  /**
28
- * Parses a quoted "this" or "this::n" string into a This tuple.
29
- * @param value - Quoted string (e.g. `"this"` or `"this::2"`)
30
- * @returns `['this']` or `['this', n]`; if value is falsy returns `['this']`
60
+ * Parses a quoted `this` reference string into a `This` tuple.
61
+ *
62
+ * Strips the surrounding quotes and splits on `::` to separate the `'this'`
63
+ * keyword from an optional index. When `value` is `undefined` or empty,
64
+ * returns the bare `['this']` tuple.
65
+ *
66
+ * @param value - An optional quoted `this` reference string (e.g. `'"this::0"'`).
67
+ * @returns A `This` tuple representing the reference.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * parseThis('"this"'); // ['this']
72
+ * parseThis('"this::0"'); // ['this', '0']
73
+ * parseThis(undefined); // ['this']
74
+ * ```
75
+ *
31
76
  * @public
32
77
  */
33
78
  export declare const parseThis: (value?: string) => This;
@@ -1 +1 @@
1
- {"version":3,"file":"this.d.ts","sourceRoot":"","sources":["../src/this.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,YAEpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,wBAExC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,aAE1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,IAE1C,CAAC"}
1
+ {"version":3,"file":"this.d.ts","sourceRoot":"","sources":["../src/this.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,YAEpC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,wBAExC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,aAE1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,IAE1C,CAAC"}
package/dist/this.js CHANGED
@@ -1,36 +1,78 @@
1
1
  import { DATA_THIS, DOT_SEPARATOR, FN_SEPARATOR } from './constants';
2
2
  const actionThisRegExp = new RegExp(`^"this(${FN_SEPARATOR}\\d+)?"$`);
3
3
  /**
4
- * Returns whether the string matches an action "this" reference: `"this"` or `"this::n"`.
5
- * @param value - String to test (e.g. from config)
6
- * @returns True if the value is a quoted "this" or "this::n" reference
4
+ * Returns `true` when `value` is a quoted `this` reference string.
5
+ *
6
+ * Matches the literal value `"this"` as well as indexed variants such as
7
+ * `"this::0"`.
8
+ *
9
+ * @param value - The string to test.
10
+ * @returns `true` if `value` is a `this` reference, `false` otherwise.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * isThis('"this"'); // true
15
+ * isThis('"this::0"'); // true
16
+ * isThis('other'); // false
17
+ * ```
18
+ *
7
19
  * @public
8
20
  */
9
21
  export const isThis = (value) => {
10
22
  return actionThisRegExp.test(value || '');
11
23
  };
12
24
  /**
13
- * Returns whether the string is a data-context reference starting with `(this)`.
14
- * @param value - String to test
15
- * @returns True if the value starts with DATA_THIS
25
+ * Returns `true` when `value` begins with the `(this)` data-reference prefix.
26
+ *
27
+ * @param value - The string to test.
28
+ * @returns `true` if `value` is a `(this)` data reference, `false` otherwise.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * isDataThis('(this).name'); // true
33
+ * isDataThis('other'); // false
34
+ * ```
35
+ *
16
36
  * @public
17
37
  */
18
38
  export const isDataThis = (value) => {
19
39
  return value?.startsWith(DATA_THIS);
20
40
  };
21
41
  /**
22
- * Strips the `(this)` prefix and splits the rest by dot into path segments.
23
- * @param value - Full data-this string (e.g. `(this).user.name`)
24
- * @returns Array of path segments
42
+ * Strips the `(this)` prefix from a data-reference string and splits the
43
+ * remaining dot-notation path into an array of property segments.
44
+ *
45
+ * @param value - A `(this)`-prefixed data-reference string (e.g. `"(this).user.name"`).
46
+ * @returns An array of path segments after the `(this)` prefix (e.g. `['', 'user', 'name']`).
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * parseDataThis('(this).user.name'); // ['', 'user', 'name']
51
+ * parseDataThis('(this)'); // ['']
52
+ * ```
53
+ *
25
54
  * @public
26
55
  */
27
56
  export const parseDataThis = (value) => {
28
57
  return value.replace(DATA_THIS, '').split(DOT_SEPARATOR);
29
58
  };
30
59
  /**
31
- * Parses a quoted "this" or "this::n" string into a This tuple.
32
- * @param value - Quoted string (e.g. `"this"` or `"this::2"`)
33
- * @returns `['this']` or `['this', n]`; if value is falsy returns `['this']`
60
+ * Parses a quoted `this` reference string into a `This` tuple.
61
+ *
62
+ * Strips the surrounding quotes and splits on `::` to separate the `'this'`
63
+ * keyword from an optional index. When `value` is `undefined` or empty,
64
+ * returns the bare `['this']` tuple.
65
+ *
66
+ * @param value - An optional quoted `this` reference string (e.g. `'"this::0"'`).
67
+ * @returns A `This` tuple representing the reference.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * parseThis('"this"'); // ['this']
72
+ * parseThis('"this::0"'); // ['this', '0']
73
+ * parseThis(undefined); // ['this']
74
+ * ```
75
+ *
34
76
  * @public
35
77
  */
36
78
  export const parseThis = (value) => {
package/dist/this.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"this.js","sourceRoot":"","sources":["../src/this.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAErE,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,UAAU,YAAY,UAAU,CAAC,CAAC;AAQtE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE;IACvC,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,IAA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C,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,EAAE;IAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;AAC3D,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAQ,EAAE;IAChD,OAAO,KAAK,CAAC,CAAC,CAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7E,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapples/inlang",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {