assign-gingerly 0.0.75 → 0.0.77

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.
Files changed (61) hide show
  1. package/DX/installForwarding.js +1 -1
  2. package/DX/installForwarding.ts +1 -1
  3. package/README.md +2 -0
  4. package/assignFeatures.js +10 -31
  5. package/assignFeatures.ts +15 -39
  6. package/assignFrom.js +18 -17
  7. package/assignFrom.ts +23 -23
  8. package/assignFromAsync.js +14 -13
  9. package/assignFromAsync.ts +15 -15
  10. package/assignGingerly.js +87 -48
  11. package/assignGingerly.ts +177 -131
  12. package/assignPermissions/PermissionProcessor.js +166 -0
  13. package/assignPermissions/PermissionProcessor.ts +210 -0
  14. package/assignPermissions/isAllowedImportPath.js +2 -6
  15. package/assignPermissions/isAllowedImportPath.ts +3 -5
  16. package/assignPermissions/isAllowedUrl.js +18 -0
  17. package/assignPermissions/isAllowedUrl.ts +15 -0
  18. package/assignTentatively.js +9 -11
  19. package/assignTentatively.ts +11 -13
  20. package/beVigilant.js +1 -1
  21. package/beVigilant.ts +1 -1
  22. package/buildCSSQuery.js +1 -1
  23. package/buildCSSQuery.ts +1 -1
  24. package/eachTime.js +5 -6
  25. package/eachTime.ts +12 -15
  26. package/enhanceAll.js +3 -3
  27. package/enhanceAll.ts +4 -4
  28. package/evaluatePathWithAsyncMethods.js +12 -8
  29. package/evaluatePathWithAsyncMethods.ts +129 -117
  30. package/handlers/addEventListener.js +11 -11
  31. package/handlers/addEventListener.ts +12 -13
  32. package/handlers/lazyLoad.ts +7 -7
  33. package/handlers/lazyLoadSwitch.ts +3 -3
  34. package/handlers/manageTemplateList.js +10 -10
  35. package/handlers/manageTemplateList.ts +12 -12
  36. package/handlers/rangeSelector.ts +3 -3
  37. package/index.js +2 -3
  38. package/index.ts +2 -3
  39. package/inferencer/types/assign-gingerly/types.d.ts +40 -9
  40. package/inferencer/types/el-maker/types.d.ts +33 -0
  41. package/inferencer/types/scratch-box/types.d.ts +3 -0
  42. package/inferencer/types/truth-sourcer/types.d.ts +4 -0
  43. package/inferencer/types/wc-info/SimpleWCInfo.d.ts +15 -0
  44. package/package.json +24 -23
  45. package/parseWithAttrs.js +1 -1
  46. package/parseWithAttrs.ts +1 -1
  47. package/processHandlerCommands.js +5 -7
  48. package/processHandlerCommands.ts +12 -15
  49. package/{getValues.js → resolve/getValues.js} +19 -8
  50. package/{getValues.ts → resolve/getValues.ts} +331 -314
  51. package/{resolveIdRef.js → resolve/resolveIdRef.js} +1 -1
  52. package/{resolveIdRef.ts → resolve/resolveIdRef.ts} +1 -1
  53. package/{resolveValues.ts → resolve/resolveValues.ts} +1 -1
  54. package/types/assign-gingerly/types.d.ts +40 -9
  55. package/assignPermissions/restrictedProps.js +0 -43
  56. package/assignPermissions/restrictedProps.ts +0 -53
  57. package/resolveAndAssignFeatures.js +0 -36
  58. package/resolveAndAssignFeatures.ts +0 -43
  59. /package/{resolveTemplate.js → resolve/resolveTemplate.js} +0 -0
  60. /package/{resolveTemplate.ts → resolve/resolveTemplate.ts} +0 -0
  61. /package/{resolveValues.js → resolve/resolveValues.js} +0 -0
@@ -20,11 +20,11 @@
20
20
  */
21
21
 
22
22
  import type { AssignFromHandler } from '../assignFromAsync.js';
23
- import type { LazyLoadResolvedParams, LazyLoadInstantiatedContext } from '../types/assign-gingerly/types.js';
23
+ import type { LazyLoadResolvedParams, LazyLoadInstantiatedContext, PermissionProcessor } from '../types/assign-gingerly/types.js';
24
24
  import { withTransition, ensureHideStyle, DEFAULT_HIDE_CLASS } from '../transitionHelper.js';
25
25
  import { findMarkers, createMarkers, getNodesBetweenMarkers, findMarkersSibling, createMarkersSibling, MARKER_START_PREFIX, MARKER_END } from '../markerUtils.js';
26
26
  import { assignFrom } from '../assignFrom.js';
27
- import type { AssignPermissions } from '../types/assign-gingerly/types.js';
27
+
28
28
 
29
29
  export type { LazyLoadResolvedParams, LazyLoadInstantiatedContext };
30
30
 
@@ -49,16 +49,16 @@ function getMarkerName(templateEl: any): string {
49
49
  export class LazyLoadHandler implements AssignFromHandler {
50
50
  config: any;
51
51
  _options: any;
52
- _permissions?: AssignPermissions;
52
+ _permissionProcessor?: PermissionProcessor;
53
53
  static #markerCounter = 0;
54
54
 
55
55
  constructor(config: any) {
56
56
  this.config = config;
57
57
  }
58
58
 
59
- async assign(lhsTarget: any, resolvedParams: LazyLoadResolvedParams, options?: any, permissions?: AssignPermissions): Promise<void> {
59
+ async assign(lhsTarget: any, resolvedParams: LazyLoadResolvedParams, options?: any, permissionProcessor?: PermissionProcessor): Promise<void> {
60
60
  this._options = options; // Store for applyAssign access
61
- this._permissions = permissions;
61
+ this._permissionProcessor = permissionProcessor;
62
62
  const {
63
63
  if: condition,
64
64
  instantiate,
@@ -320,10 +320,10 @@ export class LazyLoadHandler implements AssignFromHandler {
320
320
  const len = Math.min(elements.length, assign.configs.length);
321
321
  for (let j = 0; j < len; j++) {
322
322
  const cfg = assign.configs[j];
323
- assignFrom(elements[j], cfg.toClone ?? {}, { from, ...cfg.withOptions }, this._permissions);
323
+ assignFrom(elements[j], cfg.toClone ?? {}, { from, ...cfg.withOptions }, this._permissionProcessor);
324
324
  }
325
325
  } else if (assign.toClone) {
326
- assignFrom(elements[0], assign.toClone, { from, ...assign.withOptions }, this._permissions);
326
+ assignFrom(elements[0], assign.toClone, { from, ...assign.withOptions }, this._permissionProcessor);
327
327
  }
328
328
  }
329
329
 
@@ -21,7 +21,7 @@
21
21
  */
22
22
 
23
23
  import { LazyLoadHandler } from './lazyLoad.js';
24
- import type { AssignPermissions } from '../types/assign-gingerly/types.js';
24
+ import type { PermissionProcessor } from '../types/assign-gingerly/types.js';
25
25
  import type { AssignFromHandler } from '../assignFromAsync.js';
26
26
  import type { LazyLoadSwitchResolvedParams } from '../types/assign-gingerly/types.js';
27
27
 
@@ -56,10 +56,10 @@ function evaluateOp(lhs: any, op: string, rhs: any): boolean {
56
56
  */
57
57
  export class LazyLoadSwitchHandler extends LazyLoadHandler implements AssignFromHandler {
58
58
 
59
- async assign(lhsTarget: any, resolvedParams: LazyLoadSwitchResolvedParams, options?: any, permissions?: AssignPermissions): Promise<void> {
59
+ async assign(lhsTarget: any, resolvedParams: LazyLoadSwitchResolvedParams, options?: any, permissionProcessor?: PermissionProcessor): Promise<void> {
60
60
  const { lhs, op = '===', rhs, ...rest } = resolvedParams;
61
61
  const condition = evaluateOp(lhs, op, rhs);
62
62
  // Delegate to parent with computed condition
63
- return super.assign(lhsTarget, { ...rest, if: condition }, options, permissions);
63
+ return super.assign(lhsTarget, { ...rest, if: condition }, options, permissionProcessor);
64
64
  }
65
65
  }
@@ -25,7 +25,7 @@
25
25
  * }, { from: vm, withMethods: ['querySelector'], protocols: { globalThis: k => globalThis[k] } });
26
26
  */
27
27
  import { findMarkers, createMarkers } from '../markerUtils.js';
28
- import { resolveValue } from '../resolveValues.js';
28
+ import { resolveValue } from '../resolve/resolveValues.js';
29
29
  import { assignFrom } from '../assignFrom.js';
30
30
  import { processInferredAssignments } from '../inferredAssignments.js';
31
31
  /**
@@ -55,7 +55,7 @@ export class ManageTemplateListHandler {
55
55
  constructor(config) {
56
56
  this.config = config;
57
57
  }
58
- async assign(lhsTarget, resolvedParams, options, permissions) {
58
+ async assign(lhsTarget, resolvedParams, options, permissionProcessor) {
59
59
  //return;
60
60
  const { forEach: items, instantiate, method = 'appendChild', forget = false, markerName, yieldEvery, } = resolvedParams;
61
61
  if (!(lhsTarget instanceof Element)) {
@@ -143,7 +143,7 @@ export class ManageTemplateListHandler {
143
143
  const len = Math.min(elements.length, configs.length);
144
144
  for (let j = 0; j < len; j++) {
145
145
  const cfg = configs[j];
146
- assignFrom(elements[j], cfg.toClone ?? {}, { from: item, ...cfg.withOptions }, permissions);
146
+ assignFrom(elements[j], cfg.toClone ?? {}, { from: item, ...cfg.withOptions }, permissionProcessor);
147
147
  }
148
148
  }
149
149
  else {
@@ -153,13 +153,13 @@ export class ManageTemplateListHandler {
153
153
  processInferred(rootEl, item, inferredConfig === true ? { byItemprop: true } : inferredConfig);
154
154
  }
155
155
  else {
156
- assignFrom(rootEl, toClone, { from: item, ...withOptions }, permissions);
156
+ assignFrom(rootEl, toClone, { from: item, ...withOptions }, permissionProcessor);
157
157
  }
158
158
  if (hostToClone && options?.from) {
159
- assignFrom(rootEl, hostToClone, { from: options.from, ...hostWithOptions }, permissions);
159
+ assignFrom(rootEl, hostToClone, { from: options.from, ...hostWithOptions }, permissionProcessor);
160
160
  }
161
161
  if (targetToClone) {
162
- assignFrom(rootEl, targetToClone, { from: lhsTarget, ...targetWithOptions }, permissions);
162
+ assignFrom(rootEl, targetToClone, { from: lhsTarget, ...targetWithOptions }, permissionProcessor);
163
163
  }
164
164
  }
165
165
  }
@@ -192,7 +192,7 @@ export class ManageTemplateListHandler {
192
192
  const len = Math.min(elements.length, configs.length);
193
193
  for (let j = 0; j < len; j++) {
194
194
  const cfg = configs[j];
195
- assignFrom(elements[j], cfg.toClone ?? {}, { from: item, ...cfg.withOptions }, permissions);
195
+ assignFrom(elements[j], cfg.toClone ?? {}, { from: item, ...cfg.withOptions }, permissionProcessor);
196
196
  }
197
197
  }
198
198
  else {
@@ -204,13 +204,13 @@ export class ManageTemplateListHandler {
204
204
  processInferred(rootEl, item, inferredConfig === true ? { byItemprop: true } : inferredConfig);
205
205
  }
206
206
  else {
207
- assignFrom(rootEl, toClone, { from: item, ...withOptions }, permissions);
207
+ assignFrom(rootEl, toClone, { from: item, ...withOptions }, permissionProcessor);
208
208
  }
209
209
  if (hostToClone && options?.from) {
210
- assignFrom(rootEl, hostToClone, { from: options.from, ...hostWithOptions }, permissions);
210
+ assignFrom(rootEl, hostToClone, { from: options.from, ...hostWithOptions }, permissionProcessor);
211
211
  }
212
212
  if (targetToClone) {
213
- assignFrom(rootEl, targetToClone, { from: lhsTarget, ...targetWithOptions }, permissions);
213
+ assignFrom(rootEl, targetToClone, { from: lhsTarget, ...targetWithOptions }, permissionProcessor);
214
214
  }
215
215
  }
216
216
  }
@@ -28,10 +28,10 @@
28
28
  import type { AssignFromHandler } from '../assignFromAsync.js';
29
29
  import type { ManageTemplateListResolvedParams } from '../types/assign-gingerly/types.js';
30
30
  import { findMarkers, createMarkers, getNodesBetweenMarkers, MARKER_START_PREFIX, MARKER_END } from '../markerUtils.js';
31
- import { resolveValue } from '../resolveValues.js';
31
+ import { resolveValue } from '../resolve/resolveValues.js';
32
32
  import { assignFrom } from '../assignFrom.js';
33
- import { processInferredAssignments } from '../inferredAssignments.js';
34
- import type { AssignPermissions } from '../types/assign-gingerly/types.js';
33
+ import { processInferredAssignments } from '../inferredAssignments.js';
34
+ import type { PermissionProcessor } from '../types/assign-gingerly/types.js';
35
35
 
36
36
  /**
37
37
  * Reserved keys in fromEachItem config — not treated as shorthand patterns.
@@ -75,7 +75,7 @@ export class ManageTemplateListHandler implements AssignFromHandler {
75
75
  this.config = config;
76
76
  }
77
77
 
78
- async assign(lhsTarget: any, resolvedParams: ManageTemplateListResolvedParams, options?: any, permissions?: AssignPermissions): Promise<void> {
78
+ async assign(lhsTarget: any, resolvedParams: ManageTemplateListResolvedParams, options?: any, permissionProcessor?: PermissionProcessor): Promise<void> {
79
79
  //return;
80
80
  const {
81
81
  forEach: items,
@@ -184,7 +184,7 @@ export class ManageTemplateListHandler implements AssignFromHandler {
184
184
  const len = Math.min(elements.length, configs.length);
185
185
  for (let j = 0; j < len; j++) {
186
186
  const cfg = configs[j];
187
- assignFrom(elements[j], cfg.toClone ?? {}, { from: item, ...cfg.withOptions }, permissions);
187
+ assignFrom(elements[j], cfg.toClone ?? {}, { from: item, ...cfg.withOptions }, permissionProcessor);
188
188
  }
189
189
  } else {
190
190
  const rootEl = existingNodes.find(n => n instanceof Element) as Element | undefined;
@@ -192,13 +192,13 @@ export class ManageTemplateListHandler implements AssignFromHandler {
192
192
  if (processInferred) {
193
193
  processInferred(rootEl, item, inferredConfig === true ? { byItemprop: true } : inferredConfig);
194
194
  } else {
195
- assignFrom(rootEl, toClone, { from: item, ...withOptions }, permissions);
195
+ assignFrom(rootEl, toClone, { from: item, ...withOptions }, permissionProcessor);
196
196
  }
197
197
  if (hostToClone && options?.from) {
198
- assignFrom(rootEl, hostToClone, { from: options.from, ...hostWithOptions }, permissions);
198
+ assignFrom(rootEl, hostToClone, { from: options.from, ...hostWithOptions }, permissionProcessor);
199
199
  }
200
200
  if (targetToClone) {
201
- assignFrom(rootEl, targetToClone, { from: lhsTarget, ...targetWithOptions }, permissions);
201
+ assignFrom(rootEl, targetToClone, { from: lhsTarget, ...targetWithOptions }, permissionProcessor);
202
202
  }
203
203
  }
204
204
  }
@@ -229,7 +229,7 @@ export class ManageTemplateListHandler implements AssignFromHandler {
229
229
  const len = Math.min(elements.length, configs.length);
230
230
  for (let j = 0; j < len; j++) {
231
231
  const cfg = configs[j];
232
- assignFrom(elements[j], cfg.toClone ?? {}, { from: item, ...cfg.withOptions }, permissions);
232
+ assignFrom(elements[j], cfg.toClone ?? {}, { from: item, ...cfg.withOptions }, permissionProcessor);
233
233
  }
234
234
  } else {
235
235
  const rootEl = clonedNodes.find(n => n instanceof Element) as Element | undefined;
@@ -240,14 +240,14 @@ export class ManageTemplateListHandler implements AssignFromHandler {
240
240
  if (processInferred) {
241
241
  processInferred(rootEl, item, inferredConfig === true ? { byItemprop: true } : inferredConfig);
242
242
  } else {
243
- assignFrom(rootEl, toClone, { from: item, ...withOptions }, permissions);
243
+ assignFrom(rootEl, toClone, { from: item, ...withOptions }, permissionProcessor);
244
244
  }
245
245
 
246
246
  if (hostToClone && options?.from) {
247
- assignFrom(rootEl, hostToClone, { from: options.from, ...hostWithOptions }, permissions);
247
+ assignFrom(rootEl, hostToClone, { from: options.from, ...hostWithOptions }, permissionProcessor);
248
248
  }
249
249
  if (targetToClone) {
250
- assignFrom(rootEl, targetToClone, { from: lhsTarget, ...targetWithOptions }, permissions);
250
+ assignFrom(rootEl, targetToClone, { from: lhsTarget, ...targetWithOptions }, permissionProcessor);
251
251
  }
252
252
  }
253
253
  }
@@ -23,7 +23,7 @@
23
23
 
24
24
  import type { AssignFromHandler } from '../assignFromAsync.js';
25
25
  import assignGingerly from '../assignGingerly.js';
26
- import type { AssignPermissions } from '../types/assign-gingerly/types.js';
26
+ import type { PermissionProcessor } from '../types/assign-gingerly/types.js';
27
27
 
28
28
  /**
29
29
  * Operator keys recognized in case objects.
@@ -73,7 +73,7 @@ export class RangeSelectorHandler implements AssignFromHandler {
73
73
  this.config = config;
74
74
  }
75
75
 
76
- async assign(lhsTarget: any, resolvedParams: any, _options?: any, permissions?: AssignPermissions): Promise<void> {
76
+ async assign(lhsTarget: any, resolvedParams: any, _options?: any, permissionProcessor?: PermissionProcessor): Promise<void> {
77
77
  const { value, when } = resolvedParams;
78
78
 
79
79
  if (!Array.isArray(when)) return;
@@ -82,7 +82,7 @@ export class RangeSelectorHandler implements AssignFromHandler {
82
82
  for (const caseObj of when) {
83
83
  if (caseMatches(value, caseObj)) {
84
84
  if (caseObj.merge && typeof caseObj.merge === 'object') {
85
- assignGingerly(lhsTarget, caseObj.merge, undefined, permissions);
85
+ assignGingerly(lhsTarget, caseObj.merge, undefined, permissionProcessor);
86
86
  }
87
87
  return; // First match wins
88
88
  }
package/index.js CHANGED
@@ -5,15 +5,14 @@ export { waitForEvent } from './waitForEvent.js';
5
5
  export { ParserRegistry, globalParserRegistry } from './parserRegistry.js';
6
6
  export { parseWithAttrs } from './parseWithAttrs.js';
7
7
  export { buildCSSQuery } from './buildCSSQuery.js';
8
- export { resolveTemplate } from './resolveTemplate.js';
8
+ export { resolveTemplate } from './resolve/resolveTemplate.js';
9
9
  export { getHost } from './getHost.js';
10
- export { resolveValues, resolveValue } from './resolveValues.js';
10
+ export { resolveValues, resolveValue } from './resolve/resolveValues.js';
11
11
  export { assignFromAsync } from './assignFromAsync.js';
12
12
  export { assignFrom } from './assignFrom.js';
13
13
  export { assignFeatures, FeaturesRegistry, captureFeatureInitVals, PropertyBag, suggestFeatureInfo, getFeatureInfoSuggestions } from './assignFeatures.js';
14
14
  export { installForwarding } from './DX/installForwarding.js';
15
15
  export { defineWithFeatures } from './defineWithFeatures.js';
16
- export { resolveAndAssignFeatures } from './resolveAndAssignFeatures.js';
17
16
  export { nudge } from './handlers/nudge.js';
18
17
  export { arr } from './handlers/arr.js';
19
18
  import './object-extension.js';
package/index.ts CHANGED
@@ -5,15 +5,14 @@ export {waitForEvent} from './waitForEvent.js';
5
5
  export {ParserRegistry, globalParserRegistry} from './parserRegistry.js';
6
6
  export {parseWithAttrs} from './parseWithAttrs.js';
7
7
  export {buildCSSQuery} from './buildCSSQuery.js';
8
- export {resolveTemplate} from './resolveTemplate.js';
8
+ export {resolveTemplate} from './resolve/resolveTemplate.js';
9
9
  export {getHost} from './getHost.js';
10
- export {resolveValues, resolveValue} from './resolveValues.js';
10
+ export {resolveValues, resolveValue} from './resolve/resolveValues.js';
11
11
  export {assignFromAsync} from './assignFromAsync.js';
12
12
  export {assignFrom} from './assignFrom.js';
13
13
  export {assignFeatures, FeaturesRegistry, captureFeatureInitVals, PropertyBag, suggestFeatureInfo, getFeatureInfoSuggestions} from './assignFeatures.js';
14
14
  export {installForwarding} from './DX/installForwarding.js';
15
15
  export {defineWithFeatures} from './defineWithFeatures.js';
16
- export {resolveAndAssignFeatures} from './resolveAndAssignFeatures.js';
17
16
  export {nudge} from './handlers/nudge.js';
18
17
  export {arr} from './handlers/arr.js';
19
18
  export {} from './handlers/manageTemplateList.js';
@@ -424,6 +424,11 @@ export interface GetValuesOptions extends IAssignGingerlyOptions {
424
424
  */
425
425
  root?: any;
426
426
 
427
+ /**
428
+ * Optional permission processor for guarding method calls during RHS resolution.
429
+ */
430
+ permissionProcessor?: PermissionProcessor;
431
+
427
432
  /**
428
433
  * Synchronous protocol handlers for resolving protocol-prefixed values.
429
434
  * Each handler receives the key portion and MUST return synchronously.
@@ -449,6 +454,11 @@ export interface ResolveValuesOptions extends IAssignGingerlyOptions {
449
454
  */
450
455
  root?: any;
451
456
 
457
+ /**
458
+ * Optional permission processor for guarding method calls during RHS resolution.
459
+ */
460
+ permissionProcessor?: PermissionProcessor;
461
+
452
462
  /**
453
463
  * Protocol handlers for resolving protocol-prefixed values (e.g., 'globalThis://key').
454
464
  * Each handler receives the key portion and returns the resolved value (sync or async).
@@ -474,6 +484,8 @@ export declare class EnhancementRegistry extends EventTarget {
474
484
  getItems(): EnhancementConfig[];
475
485
  findBySymbol(symbol: symbol | string): EnhancementConfig | undefined;
476
486
  findByEnhKey(enhKey: string | symbol): EnhancementConfig | undefined;
487
+ whenDefined(enhKey: string | symbol): Promise<void>;
488
+ _trackSetup(name: string | symbol, promise: Promise<void>): void;
477
489
  }
478
490
 
479
491
  /**
@@ -642,7 +654,7 @@ export declare function assignFeatures(
642
654
  ctr: Function,
643
655
  features: FeatureConfigsMap,
644
656
  featuresRegistry: FeaturesRegistry
645
- ): Promise<void> | undefined;
657
+ ): Promise<void>;
646
658
 
647
659
  /**
648
660
  * Captures own-properties that shadow feature getters.
@@ -695,7 +707,7 @@ export interface HandlerConfig {
695
707
  * Handlers are invoked when a LHS key ends with ' =>'.
696
708
  */
697
709
  export interface AssignFromHandler {
698
- assign(lhsTarget: any, resolvedParams: Record<string, any>, options: any, permissions?: AssignPermissions): Promise<void> | void;
710
+ assign(lhsTarget: any, resolvedParams: Record<string, any>, options: any, permissionProcessor?: PermissionProcessor): Promise<void> | void;
699
711
  }
700
712
 
701
713
  /**
@@ -873,7 +885,7 @@ export interface LazyLoadInstantiatedContext {
873
885
  export declare class LazyLoadHandler implements AssignFromHandler {
874
886
  config: any;
875
887
  constructor(config: any);
876
- assign(lhsTarget: any, resolvedParams: Record<string, any>, options?: any, permissions?: AssignPermissions): Promise<void>;
888
+ assign(lhsTarget: any, resolvedParams: Record<string, any>, options?: any, permissionProcessor?: PermissionProcessor): Promise<void>;
877
889
  protected onCloneInserted(nodes: Node[], lhsTarget: Element, resolvedParams: Record<string, any>): Promise<void>;
878
890
  }
879
891
 
@@ -931,11 +943,11 @@ export interface AddEventListenerConfig extends AssignDispatchVector {
931
943
  * Phase II+: object form for a restricted property setting.
932
944
  */
933
945
  export interface RestrictedPropSetting {
934
- prop: string;
935
- useMethod?: string; // Phase II: redirect to a safe method
936
- attr?: string; // Phase III: also watch setAttribute for this attr
937
- allowFromSameHost?: boolean; // Phase III
938
- allowCrossDomain?: boolean; // Phase III
946
+ props: string | string[];
947
+ useMethod?: string; // Phase II: redirect to a safe method
948
+ attr?: boolean | string | string[]; // Phase III: also watch setAttribute for these attrs
949
+ allowFromSameDomain?: boolean; // Phase III: allow same-origin URLs
950
+ allowCrossDomain?: boolean; // Phase III: allow any URL
939
951
  }
940
952
 
941
953
  /**
@@ -958,7 +970,8 @@ export interface AssignPermissions {
958
970
  * Restricted property settings.
959
971
  * Phase I: string entries are property names that cannot be assigned.
960
972
  * Phase II: an object with useMethod redirects ordinary assignment to that
961
- * method; command operations remain blocked. Phase III+ adds attr support.
973
+ * method; command operations remain blocked. Phase III+ adds props, attr,
974
+ * allowFromSameDomain, and allowCrossDomain support.
962
975
  *
963
976
  * NOTE: This is a property-assignment guard only. Method calls (setAttribute, etc.)
964
977
  * are not blocked — see Phase III+. Event listeners can still be registered, but
@@ -972,3 +985,21 @@ export interface AssignPermissions {
972
985
  /** Restricted method settings (Phase IV+) */
973
986
  restrictedMethodSettings?: Array<string | RestrictedMethodConfig>;
974
987
  }
988
+
989
+ //#region Permissions
990
+ export interface RestrictedPropSettingsMap {
991
+ props: Map<string, RestrictedPropSetting | undefined>;
992
+ attrs: Map<string, RestrictedPropSetting | undefined>;
993
+ }
994
+
995
+ export declare class PermissionProcessor {
996
+ constructor(permissions: AssignPermissions | undefined);
997
+ get crossDomainImports(): boolean;
998
+ get hasProps(): boolean;
999
+ get hasAttrs(): boolean;
1000
+ checkRestrictedProp(key: string): boolean;
1001
+ checkRestrictedMethod(methodName: string): boolean;
1002
+ redirectRestrictedProp(target: any, key: string, value: any): boolean;
1003
+ checkRestrictedAttributeCall(methodName: string, args: any[]): { blocked: boolean; attrName?: string };
1004
+ }
1005
+ //#endregion
@@ -0,0 +1,33 @@
1
+ import {RAConfig} from '../roundabout/types.js';
2
+ import {FontFaceFeatureConfig} from '../font-face-feature/types.js';
3
+ import {CustomData as TSCD} from '../truth-sourcer/types.js';
4
+ import {CustomData as FUCD} from '../face-up/types.js';
5
+
6
+ export interface ElMakerConfig<AllProps = any, TActions = AllProps> {
7
+ assignFeatures: {
8
+ roundabout?: {
9
+ spawn?: string,
10
+ customData: {
11
+ raConfig: RAConfig<AllProps, TActions, TActions>
12
+ }
13
+ },
14
+ fontMgr?: {
15
+ spawn?: string,
16
+ customData: {
17
+ fontFaceFeatureConfig: FontFaceFeatureConfig
18
+ }
19
+ },
20
+ templateMaker?: {
21
+ spawn?: string,
22
+ customData?: any
23
+ },
24
+ faceUp?: {
25
+ spawn?: string,
26
+ customData?: FUCD
27
+ },
28
+ truthSourcer?: {
29
+ spawn?: string,
30
+ customData?: TSCD
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,3 @@
1
+ export interface EndUserProps {
2
+ value: boolean,
3
+ }
@@ -42,3 +42,7 @@ export interface AllProps extends TruthSourcerProps {
42
42
 
43
43
  export type AP = AllProps;
44
44
  export type PAP = Partial<AP>;
45
+
46
+ export interface CustomData {
47
+ observedAttributes: string[];
48
+ }
@@ -0,0 +1,15 @@
1
+ export interface SimpleWCInfo<TProps = any, TPublicMethods = any>{
2
+ tagName: string;
3
+ cssParts?: {[key: string]: string};
4
+ props?: any;
5
+ methods?: any;
6
+ nonAttribProps?: (keyof TProps)[];
7
+ cssProps?: {[key: string]: string};
8
+ slots?: {[key: string]: string};
9
+ events?: {[key: string]: string};
10
+ name: string,
11
+ description: string,
12
+ homepage: string,
13
+ license: string,
14
+
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assign-gingerly",
3
- "version": "0.0.75",
3
+ "version": "0.0.77",
4
4
  "description": "This package provides a utility function for carefully merging one object into another.",
5
5
  "homepage": "https://github.com/bahrus/assign-gingerly#readme",
6
6
  "bugs": {
@@ -21,6 +21,7 @@
21
21
  "assignPermissions/**",
22
22
  "handlers/**",
23
23
  "inferencer/**",
24
+ "resolve/**",
24
25
  "utils/**",
25
26
  "README.md",
26
27
  "LICENSE",
@@ -39,8 +40,13 @@
39
40
  "default": "./assignTentatively.js",
40
41
  "types": "./assignTentatively.ts"
41
42
  },
42
- "./waitForEvent.js": {
43
- "default": "./waitForEvent.js"
43
+ "./buildCSSQuery.js": {
44
+ "default": "./buildCSSQuery.js",
45
+ "types": "./buildCSSQuery.ts"
46
+ },
47
+ "./object-extension.js": {
48
+ "default": "./object-extension.js",
49
+ "types": "./object-extension.ts"
44
50
  },
45
51
  "./parserRegistry.js": {
46
52
  "default": "./parserRegistry.js"
@@ -49,29 +55,25 @@
49
55
  "default": "./parseWithAttrs.js",
50
56
  "types": "./parseWithAttrs.ts"
51
57
  },
52
- "./buildCSSQuery.js": {
53
- "default": "./buildCSSQuery.js",
54
- "types": "./buildCSSQuery.ts"
55
- },
56
- "./resolveTemplate.js": {
57
- "default": "./resolveTemplate.js",
58
- "types": "./resolveTemplate.ts"
58
+ "./resolve/resolveTemplate.js": {
59
+ "default": "./resolve/resolveTemplate.js",
60
+ "types": "./resolve/resolveTemplate.ts"
59
61
  },
60
62
  "./getHost.js": {
61
63
  "default": "./getHost.js",
62
64
  "types": "./getHost.ts"
63
65
  },
64
- "./resolveValues.js": {
65
- "default": "./resolveValues.js",
66
- "types": "./resolveValues.ts"
66
+ "./resolve/resolveValues.js": {
67
+ "default": "./resolve/resolveValues.js",
68
+ "types": "./resolve/resolveValues.ts"
67
69
  },
68
- "./getValues.js": {
69
- "default": "./getValues.js",
70
- "types": "./getValues.ts"
70
+ "./resolve/getValues.js": {
71
+ "default": "./resolve/getValues.js",
72
+ "types": "./resolve/getValues.ts"
71
73
  },
72
- "./resolveIdRef.js": {
73
- "default": "./resolveIdRef.js",
74
- "types": "./resolveIdRef.ts"
74
+ "./resolve/resolveIdRef.js": {
75
+ "default": "./resolve/resolveIdRef.js",
76
+ "types": "./resolve/resolveIdRef.ts"
75
77
  },
76
78
  "./transitionHelper.js": {
77
79
  "default": "./transitionHelper.js",
@@ -85,10 +87,6 @@
85
87
  "default": "./defineWithFeatures.js",
86
88
  "types": "./defineWithFeatures.ts"
87
89
  },
88
- "./resolveAndAssignFeatures.js": {
89
- "default": "./resolveAndAssignFeatures.js",
90
- "types": "./resolveAndAssignFeatures.ts"
91
- },
92
90
  "./handlers/addEventListener.js": {
93
91
  "default": "./handlers/addEventListener.js",
94
92
  "types": "./handlers/addEventListener.ts"
@@ -200,6 +198,9 @@
200
198
  "./evaluatePathWithAsyncMethods.js": {
201
199
  "default": "./evaluatePathWithAsyncMethods.js",
202
200
  "types": "./evaluatePathWithAsyncMethods.ts"
201
+ },
202
+ "./waitForEvent.js": {
203
+ "default": "./waitForEvent.js"
203
204
  }
204
205
  },
205
206
  "main": "index.js",
package/parseWithAttrs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { globalParserRegistry, getParserRegistry } from './parserRegistry.js';
2
- import { resolveTemplate } from './resolveTemplate.js';
2
+ import { resolveTemplate } from './resolve/resolveTemplate.js';
3
3
  // Module-level cache for parsed attribute values
4
4
  // Structure: Map<configKey, Map<attrValue, parsedValue>>
5
5
  const parseCache = new Map();
package/parseWithAttrs.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AttrPatterns, AttrConfig, ParserFunction, ParserContext, SpawnContext } from './types/assign-gingerly/types';
2
2
  import { globalParserRegistry, getParserRegistry } from './parserRegistry.js';
3
- import { resolveTemplate } from './resolveTemplate.js';
3
+ import { resolveTemplate } from './resolve/resolveTemplate.js';
4
4
 
5
5
  // Module-level cache for parsed attribute values
6
6
  // Structure: Map<configKey, Map<attrValue, parsedValue>>
@@ -3,11 +3,10 @@
3
3
  *
4
4
  * Dynamically imported only when ` =>` keys are detected in the pattern.
5
5
  */
6
- import { resolveValues } from './resolveValues.js';
7
- import { getValues } from './getValues.js';
6
+ import { resolveValues } from './resolve/resolveValues.js';
7
+ import { getValues } from './resolve/getValues.js';
8
8
  import { evaluatePathWithMethods } from './assignGingerly.js';
9
9
  import { findClassPrototypeInPath } from './utils/findClassPrototypeInPath.js';
10
- import { buildRestrictedPropSet, redirectRestrictedProp } from './assignPermissions/restrictedProps.js';
11
10
  /**
12
11
  * Map of built-in handler names to their module paths.
13
12
  * These are auto-loaded on demand — no explicit import required.
@@ -79,8 +78,7 @@ async function resolveFromHandlers(name, handlers) {
79
78
  * @param options - The assignFrom options
80
79
  * @param handlerRegistry - The registry of handler classes
81
80
  */
82
- export async function processHandlerCommands(target, handlerKeys, pattern, options, permissions) {
83
- const restrictedPropSet = buildRestrictedPropSet(permissions);
81
+ export async function processHandlerCommands(target, handlerKeys, pattern, options, permissionProcessor) {
84
82
  for (const key of handlerKeys) {
85
83
  const lhsPath = key.substring(0, key.length - 3); // Remove ' =>'
86
84
  const rhs = pattern[key];
@@ -190,12 +188,12 @@ export async function processHandlerCommands(target, handlerKeys, pattern, optio
190
188
  // Instantiate and invoke the handler
191
189
  const handler = new HandlerClass(config);
192
190
  //return; //1.5ms
193
- const result = await handler.assign(lhsTarget, resolvedParams, options, permissions);
191
+ const result = await handler.assign(lhsTarget, resolvedParams, options, permissionProcessor);
194
192
  //return; //1.5ms
195
193
  // Return-value protocol: if handler returns a non-undefined value,
196
194
  // assign it back to the LHS path
197
195
  if (result !== undefined && lhsParent != null && lhsKey != null
198
- && !redirectRestrictedProp(restrictedPropSet, lhsParent, lhsKey, result)) {
196
+ && !permissionProcessor?.redirectRestrictedProp(lhsParent, lhsKey, result)) {
199
197
  lhsParent[lhsKey] = result;
200
198
  }
201
199
  }