assign-gingerly 0.0.84 → 0.0.86
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/DX/emojis.js +5 -3
- package/DX/emojis.ts +5 -3
- package/DX/paths.js +2 -2
- package/DX/paths.ts +23 -23
- package/README.md +46 -1218
- package/ScopedParserRegistry.js +2 -2
- package/ScopedParserRegistry.ts +6 -6
- package/SplitParser.js +48 -0
- package/SplitParser.ts +89 -0
- package/assignFrom.js +78 -2
- package/assignFrom.ts +80 -2
- package/inferencer/types/NewCustomElementFeature.md +3 -1
- package/inferencer/types/NewHTMLFirstCustomElement.md +68 -1
- package/inferencer/types/assign-gingerly/types.d.ts +43 -5
- package/package.json +13 -4
- package/parseWithAttrs.js +109 -25
- package/parseWithAttrs.ts +135 -31
- package/parserRegistry.js +5 -4
- package/parserRegistry.ts +10 -12
- package/processHandlerCommands.js +5 -55
- package/processHandlerCommands.ts +6 -51
- package/{handlers → syncOps}/join.js +61 -73
- package/syncOps/join.ts +62 -0
- package/syncOps/registry.js +15 -0
- package/syncOps/registry.ts +19 -0
- package/types/assign-gingerly/types.d.ts +43 -5
- package/utils/resolveLhsPath.js +68 -0
- package/utils/resolveLhsPath.ts +81 -0
- package/handlers/join.ts +0 -79
package/DX/emojis.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* import { builtInEmoji } from 'assign-gingerly/builtInEmoji.js';
|
|
8
8
|
*
|
|
9
9
|
* assignFrom(target, {
|
|
10
|
-
* '?.el =>': { do: '
|
|
10
|
+
* '?.el =>': { do: '🏷️', get: { template: [...] } }
|
|
11
11
|
* }, { from: vm, handlers: builtInEmoji });
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
@@ -17,14 +17,16 @@
|
|
|
17
17
|
* |-------|---------|
|
|
18
18
|
* | 📦 | builtIns.lazyLoad |
|
|
19
19
|
* | 🎚️ | builtIns.lazyLoadSwitch |
|
|
20
|
-
* | 🔗 | builtIns.join |
|
|
21
20
|
* | 🏷️ | builtIns.microDataJoin |
|
|
22
21
|
* | 📋 | builtIns.manageTemplateList |
|
|
22
|
+
*
|
|
23
|
+
* `join` is no longer a `do:` handler — it moved to the synchronous ` =&` operator
|
|
24
|
+
* (see syncOps/join.ts) and isn't looked up through options.handlers, so it has no
|
|
25
|
+
* emoji alias here.
|
|
23
26
|
*/
|
|
24
27
|
export const builtInEmoji = {
|
|
25
28
|
'📦': 'builtIns.lazyLoad',
|
|
26
29
|
'🎚️': 'builtIns.lazyLoadSwitch',
|
|
27
|
-
'🔗': 'builtIns.join',
|
|
28
30
|
'🏷️': 'builtIns.microDataJoin',
|
|
29
31
|
'📋': 'builtIns.manageTemplateList',
|
|
30
32
|
'📊': 'builtIns.rangeSelector',
|
package/DX/emojis.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* import { builtInEmoji } from 'assign-gingerly/builtInEmoji.js';
|
|
8
8
|
*
|
|
9
9
|
* assignFrom(target, {
|
|
10
|
-
* '?.el =>': { do: '
|
|
10
|
+
* '?.el =>': { do: '🏷️', get: { template: [...] } }
|
|
11
11
|
* }, { from: vm, handlers: builtInEmoji });
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -18,14 +18,16 @@
|
|
|
18
18
|
* |-------|---------|
|
|
19
19
|
* | 📦 | builtIns.lazyLoad |
|
|
20
20
|
* | 🎚️ | builtIns.lazyLoadSwitch |
|
|
21
|
-
* | 🔗 | builtIns.join |
|
|
22
21
|
* | 🏷️ | builtIns.microDataJoin |
|
|
23
22
|
* | 📋 | builtIns.manageTemplateList |
|
|
23
|
+
*
|
|
24
|
+
* `join` is no longer a `do:` handler — it moved to the synchronous ` =&` operator
|
|
25
|
+
* (see syncOps/join.ts) and isn't looked up through options.handlers, so it has no
|
|
26
|
+
* emoji alias here.
|
|
24
27
|
*/
|
|
25
28
|
export const builtInEmoji= {
|
|
26
29
|
'📦': 'builtIns.lazyLoad',
|
|
27
30
|
'🎚️': 'builtIns.lazyLoadSwitch',
|
|
28
|
-
'🔗': 'builtIns.join',
|
|
29
31
|
'🏷️': 'builtIns.microDataJoin',
|
|
30
32
|
'📋': 'builtIns.manageTemplateList',
|
|
31
33
|
'📊': 'builtIns.rangeSelector',
|
package/DX/paths.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* const $ = paths<Person>();
|
|
17
17
|
*
|
|
18
|
-
* // Use sp (split into parts) to create arrays for
|
|
18
|
+
* // Use sp (split into parts) to create arrays for the ' =&' join op:
|
|
19
19
|
* const value = sp`${$.lastName}, ${$.firstName}`;
|
|
20
20
|
* // ['?.lastName', ', ', '?.firstName']
|
|
21
21
|
*
|
|
@@ -321,7 +321,7 @@ export function forEachKeyIn(keys, factory, options) {
|
|
|
321
321
|
* string representation — no `.Path` call needed inside sp template literals.
|
|
322
322
|
*
|
|
323
323
|
* Arrays passed as interpolations are preserved as nested arrays (for
|
|
324
|
-
* all-or-nothing optional segments in
|
|
324
|
+
* all-or-nothing optional segments in the ' =&' join op).
|
|
325
325
|
*
|
|
326
326
|
* @example
|
|
327
327
|
* const $ = paths<Person>();
|
package/DX/paths.ts
CHANGED
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
*
|
|
16
16
|
* const $ = paths<Person>();
|
|
17
17
|
*
|
|
18
|
-
* // Use sp (split into parts) to create arrays for
|
|
18
|
+
* // Use sp (split into parts) to create arrays for the ' =&' join op:
|
|
19
19
|
* const value = sp`${$.lastName}, ${$.firstName}`;
|
|
20
20
|
* // ['?.lastName', ', ', '?.firstName']
|
|
21
21
|
*
|
|
22
|
-
* // Use .Path for raw string contexts (object keys, plain arrays):
|
|
23
|
-
* const key = $.textContent.Path; // '?.textContent'
|
|
22
|
+
* // Use .Path for raw string contexts (object keys, plain arrays):
|
|
23
|
+
* const key = $.textContent.Path; // '?.textContent'
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -102,25 +102,25 @@ export interface PathsOptions {
|
|
|
102
102
|
/**
|
|
103
103
|
* Create a proxy for id-ref paths (#[varName]).
|
|
104
104
|
* After the initial #[varName], further property access chains with ?. from the resolved element.
|
|
105
|
-
* .Path returns the #[varName] prefix (optionally with further ?. path).
|
|
105
|
+
* .Path returns the #[varName] prefix (optionally with further ?. path).
|
|
106
106
|
*/
|
|
107
107
|
function createIdRefProxy(idRef: string, options?: PathsOptions): any {
|
|
108
108
|
function handler() {}
|
|
109
109
|
Object.defineProperty(handler, PATH_SYMBOL, { value: idRef });
|
|
110
110
|
return new Proxy(handler, {
|
|
111
111
|
get(_, prop: string | symbol) {
|
|
112
|
-
if (prop === 'Path' || prop === PATH_SYMBOL) {
|
|
113
|
-
return idRef;
|
|
114
|
-
}
|
|
112
|
+
if (prop === 'Path' || prop === PATH_SYMBOL) {
|
|
113
|
+
return idRef;
|
|
114
|
+
}
|
|
115
115
|
if (typeof prop === 'symbol') return undefined;
|
|
116
116
|
|
|
117
117
|
const reservedToken = getReservedToken(prop);
|
|
118
118
|
if (reservedToken === 'Each') {
|
|
119
119
|
return createIdRefProxy(appendPathSegment(idRef, '@each'), options);
|
|
120
120
|
}
|
|
121
|
-
if (reservedToken && reservedToken !== 'Path') {
|
|
122
|
-
return createIdRefProxy(appendCommandSuffix(idRef, reservedToken), options);
|
|
123
|
-
}
|
|
121
|
+
if (reservedToken && reservedToken !== 'Path') {
|
|
122
|
+
return createIdRefProxy(appendCommandSuffix(idRef, reservedToken), options);
|
|
123
|
+
}
|
|
124
124
|
|
|
125
125
|
// Chain further path segments after the id ref
|
|
126
126
|
const chained = appendPathSegment(idRef, String(prop));
|
|
@@ -162,16 +162,16 @@ function createPathProxy(prefix: string, options?: PathsOptions): any {
|
|
|
162
162
|
|
|
163
163
|
return new Proxy(handler, {
|
|
164
164
|
get(_, prop: string | symbol) {
|
|
165
|
-
if (prop === 'Path' || prop === PATH_SYMBOL) {
|
|
166
|
-
return serializePath(prefix);
|
|
167
|
-
}
|
|
165
|
+
if (prop === 'Path' || prop === PATH_SYMBOL) {
|
|
166
|
+
return serializePath(prefix);
|
|
167
|
+
}
|
|
168
168
|
// Ignore symbol access (Symbol.iterator, Symbol.toPrimitive, etc.)
|
|
169
169
|
if (typeof prop === 'symbol') return undefined;
|
|
170
170
|
|
|
171
171
|
const reservedToken = getReservedToken(String(prop));
|
|
172
|
-
if (reservedToken === 'Path') {
|
|
173
|
-
return serializePath(prefix);
|
|
174
|
-
}
|
|
172
|
+
if (reservedToken === 'Path') {
|
|
173
|
+
return serializePath(prefix);
|
|
174
|
+
}
|
|
175
175
|
if (reservedToken === 'Each') {
|
|
176
176
|
return createPathProxy(appendPathSegment(prefix, '@each'), options);
|
|
177
177
|
}
|
|
@@ -231,14 +231,14 @@ function createPathProxy(prefix: string, options?: PathsOptions): any {
|
|
|
231
231
|
*
|
|
232
232
|
* @example
|
|
233
233
|
* const $ = paths<Person>();
|
|
234
|
-
* $.lastName.Path // '?.lastName'
|
|
235
|
-
* $.address.city.Path // '?.address?.city'
|
|
234
|
+
* $.lastName.Path // '?.lastName'
|
|
235
|
+
* $.address.city.Path // '?.address?.city'
|
|
236
236
|
*
|
|
237
237
|
* // With aka (reverse alias applied):
|
|
238
238
|
* const $ = paths<MyEl>({ aka: { q: 'querySelector' } });
|
|
239
|
-
* $.querySelector('.user').textContent.Path // '?.q?..user?.textContent'
|
|
239
|
+
* $.querySelector('.user').textContent.Path // '?.q?..user?.textContent'
|
|
240
240
|
*
|
|
241
|
-
* // Inside sp template literals, .Path is not needed:
|
|
241
|
+
* // Inside sp template literals, .Path is not needed:
|
|
242
242
|
* sp`${$.lastName}, ${$.firstName}` // ['?.lastName', ', ', '?.firstName']
|
|
243
243
|
*/
|
|
244
244
|
export function paths<T>(options?: PathsOptions): PathProxy<T> {
|
|
@@ -246,7 +246,7 @@ export function paths<T>(options?: PathsOptions): PathProxy<T> {
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
|
-
* Create an assignment pair: { [lhs.Path]: rhs.Path }.
|
|
249
|
+
* Create an assignment pair: { [lhs.Path]: rhs.Path }.
|
|
250
250
|
* Used to express "set this target to this source value" in a spreadable form.
|
|
251
251
|
*
|
|
252
252
|
* @example
|
|
@@ -373,10 +373,10 @@ export function forEachKeyIn<T>(
|
|
|
373
373
|
* Interleaves static string segments with interpolated values.
|
|
374
374
|
*
|
|
375
375
|
* Path proxy objects are auto-detected and converted to their `?.`-prefixed
|
|
376
|
-
* string representation — no `.Path` call needed inside sp template literals.
|
|
376
|
+
* string representation — no `.Path` call needed inside sp template literals.
|
|
377
377
|
*
|
|
378
378
|
* Arrays passed as interpolations are preserved as nested arrays (for
|
|
379
|
-
* all-or-nothing optional segments in
|
|
379
|
+
* all-or-nothing optional segments in the ' =&' join op).
|
|
380
380
|
*
|
|
381
381
|
* @example
|
|
382
382
|
* const $ = paths<Person>();
|