@ankhorage/runtime 4.1.2 → 5.0.2

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 (86) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +6 -6
  3. package/dist/RuntimeRenderer.d.ts +7 -7
  4. package/dist/RuntimeRenderer.d.ts.map +1 -1
  5. package/dist/RuntimeRenderer.js +40 -80
  6. package/dist/RuntimeRenderer.js.map +1 -1
  7. package/dist/RuntimeRendererConfig.d.ts +7 -22
  8. package/dist/RuntimeRendererConfig.d.ts.map +1 -1
  9. package/dist/RuntimeRendererConfig.js +5 -8
  10. package/dist/RuntimeRendererConfig.js.map +1 -1
  11. package/dist/RuntimeScreen.d.ts.map +1 -1
  12. package/dist/RuntimeScreen.js +10 -5
  13. package/dist/RuntimeScreen.js.map +1 -1
  14. package/dist/bindings.d.ts +4 -8
  15. package/dist/bindings.d.ts.map +1 -1
  16. package/dist/bindings.js +2 -4
  17. package/dist/bindings.js.map +1 -1
  18. package/dist/index.d.ts +10 -12
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +5 -6
  21. package/dist/index.js.map +1 -1
  22. package/dist/runtimeActionRegistry.d.ts +19 -24
  23. package/dist/runtimeActionRegistry.d.ts.map +1 -1
  24. package/dist/runtimeActionRegistry.js +90 -306
  25. package/dist/runtimeActionRegistry.js.map +1 -1
  26. package/dist/runtimeApiCapabilities.d.ts +11 -0
  27. package/dist/runtimeApiCapabilities.d.ts.map +1 -0
  28. package/dist/runtimeApiCapabilities.js +67 -0
  29. package/dist/runtimeApiCapabilities.js.map +1 -0
  30. package/dist/runtimeBindings.d.ts +28 -17
  31. package/dist/runtimeBindings.d.ts.map +1 -1
  32. package/dist/runtimeBindings.js +157 -197
  33. package/dist/runtimeBindings.js.map +1 -1
  34. package/dist/runtimeCapabilityExecutor.d.ts +8 -0
  35. package/dist/runtimeCapabilityExecutor.d.ts.map +1 -0
  36. package/dist/runtimeCapabilityExecutor.js +21 -0
  37. package/dist/runtimeCapabilityExecutor.js.map +1 -0
  38. package/dist/runtimeEventExecution.d.ts +1 -4
  39. package/dist/runtimeEventExecution.d.ts.map +1 -1
  40. package/dist/runtimeEventExecution.js.map +1 -1
  41. package/dist/runtimeEventOperationLifecycle.d.ts +4 -3
  42. package/dist/runtimeEventOperationLifecycle.d.ts.map +1 -1
  43. package/dist/runtimeEventOperationLifecycle.js +5 -5
  44. package/dist/runtimeEventOperationLifecycle.js.map +1 -1
  45. package/dist/runtimeNodeProps.d.ts +12 -24
  46. package/dist/runtimeNodeProps.d.ts.map +1 -1
  47. package/dist/runtimeNodeProps.js +27 -121
  48. package/dist/runtimeNodeProps.js.map +1 -1
  49. package/dist/runtimeRepeat.d.ts +6 -2
  50. package/dist/runtimeRepeat.d.ts.map +1 -1
  51. package/dist/runtimeRepeat.js +29 -108
  52. package/dist/runtimeRepeat.js.map +1 -1
  53. package/dist/runtimeScreenLoaders.d.ts +27 -42
  54. package/dist/runtimeScreenLoaders.d.ts.map +1 -1
  55. package/dist/runtimeScreenLoaders.js +113 -273
  56. package/dist/runtimeScreenLoaders.js.map +1 -1
  57. package/package.json +12 -6
  58. package/paradox/badges/npm.svg +3 -3
  59. package/paradox/components.md +6 -7
  60. package/paradox/diagrams/architecture-overview.mmd +25 -79
  61. package/paradox/diagrams/export-graph.mmd +67 -105
  62. package/paradox/diagrams/module-relationships.mmd +19 -59
  63. package/paradox/diagrams/sequences/apply-runtime-binding-data-path.mmd +14 -0
  64. package/paradox/diagrams/sequences/create-component-event-from-handler-args.mmd +0 -13
  65. package/paradox/diagrams/sequences/create-runtime-screen-loader-request-key.mmd +5 -0
  66. package/paradox/diagrams/sequences/execute-runtime-binding-invocation.mmd +19 -0
  67. package/paradox/diagrams/sequences/resolve-binding-input-map-sync.mmd +5 -0
  68. package/paradox/diagrams/sequences/resolve-binding-input-map.mmd +5 -0
  69. package/paradox/diagrams/sequences/runtime-screen.mmd +6 -3
  70. package/paradox/diagrams/sequences/use-runtime-screen-operation-loaders.mmd +6 -3
  71. package/paradox/exports.json +610 -848
  72. package/paradox/exports.md +280 -308
  73. package/paradox/index.html +1120 -2266
  74. package/paradox/paradox.json +2724 -5528
  75. package/dist/runtimeApiOperations.d.ts +0 -8
  76. package/dist/runtimeApiOperations.d.ts.map +0 -1
  77. package/dist/runtimeApiOperations.js +0 -38
  78. package/dist/runtimeApiOperations.js.map +0 -1
  79. package/dist/runtimeApiSelection.d.ts +0 -8
  80. package/dist/runtimeApiSelection.d.ts.map +0 -1
  81. package/dist/runtimeApiSelection.js +0 -52
  82. package/dist/runtimeApiSelection.js.map +0 -1
  83. package/dist/runtimeDbPersist.d.ts +0 -34
  84. package/dist/runtimeDbPersist.d.ts.map +0 -1
  85. package/dist/runtimeDbPersist.js +0 -73
  86. package/dist/runtimeDbPersist.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ import type { RuntimeCapabilityExecutor } from './runtimeBindings';
2
+ export interface RuntimeCapabilityExecutorComposition {
3
+ readonly apiCapabilityExecutor: RuntimeCapabilityExecutor;
4
+ readonly capabilityExecutor?: RuntimeCapabilityExecutor;
5
+ }
6
+ /*** Routes manifest-owned API capabilities before delegating application-owned capabilities. */
7
+ export declare function composeRuntimeCapabilityExecutor(composition: RuntimeCapabilityExecutorComposition): RuntimeCapabilityExecutor;
8
+ //# sourceMappingURL=runtimeCapabilityExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeCapabilityExecutor.d.ts","sourceRoot":"","sources":["../src/runtimeCapabilityExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,oCAAoC;IACnD,QAAQ,CAAC,qBAAqB,EAAE,yBAAyB,CAAC;IAC1D,QAAQ,CAAC,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;CACzD;AAED,gGAAgG;AAChG,wBAAgB,gCAAgC,CAC9C,WAAW,EAAE,oCAAoC,GAChD,yBAAyB,CAK3B"}
@@ -0,0 +1,21 @@
1
+ /*** Routes manifest-owned API capabilities before delegating application-owned capabilities. */
2
+ export function composeRuntimeCapabilityExecutor(composition) {
3
+ return async (args) => args.capability.startsWith('api.')
4
+ ? composition.apiCapabilityExecutor(args)
5
+ : executeApplicationCapabilityAsync(args, composition.capabilityExecutor);
6
+ }
7
+ async function executeApplicationCapabilityAsync(args, capabilityExecutor) {
8
+ if (capabilityExecutor !== undefined)
9
+ return capabilityExecutor(args);
10
+ return {
11
+ diagnostics: [
12
+ {
13
+ code: 'missing-operation',
14
+ message: `Capability '${args.capability}' has no configured executor.`,
15
+ severity: 'error',
16
+ },
17
+ ],
18
+ ok: false,
19
+ };
20
+ }
21
+ //# sourceMappingURL=runtimeCapabilityExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeCapabilityExecutor.js","sourceRoot":"","sources":["../src/runtimeCapabilityExecutor.ts"],"names":[],"mappings":"AAWA,gGAAgG;AAChG,MAAM,UAAU,gCAAgC,CAC9C,WAAiD;IAEjD,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE,CACpB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC;QAChC,CAAC,CAAC,WAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC;QACzC,CAAC,CAAC,iCAAiC,CAAC,IAAI,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;AAChF,CAAC;AAED,KAAK,UAAU,iCAAiC,CAC9C,IAAoC,EACpC,kBAAyD;IAEzD,IAAI,kBAAkB,KAAK,SAAS;QAAE,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtE,OAAO;QACL,WAAW,EAAE;YACX;gBACE,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EAAE,eAAe,IAAI,CAAC,UAAU,+BAA+B;gBACtE,QAAQ,EAAE,OAAO;aAClB;SACF;QACD,EAAE,EAAE,KAAK;KACV,CAAC;AACJ,CAAC","sourcesContent":["import type {\n RuntimeCapabilityExecutionArgs,\n RuntimeCapabilityExecutionResult,\n RuntimeCapabilityExecutor,\n} from './runtimeBindings';\n\nexport interface RuntimeCapabilityExecutorComposition {\n readonly apiCapabilityExecutor: RuntimeCapabilityExecutor;\n readonly capabilityExecutor?: RuntimeCapabilityExecutor;\n}\n\n/*** Routes manifest-owned API capabilities before delegating application-owned capabilities. */\nexport function composeRuntimeCapabilityExecutor(\n composition: RuntimeCapabilityExecutorComposition,\n): RuntimeCapabilityExecutor {\n return async (args) =>\n args.capability.startsWith('api.')\n ? composition.apiCapabilityExecutor(args)\n : executeApplicationCapabilityAsync(args, composition.capabilityExecutor);\n}\n\nasync function executeApplicationCapabilityAsync(\n args: RuntimeCapabilityExecutionArgs,\n capabilityExecutor: RuntimeCapabilityExecutor | undefined,\n): Promise<RuntimeCapabilityExecutionResult> {\n if (capabilityExecutor !== undefined) return capabilityExecutor(args);\n return {\n diagnostics: [\n {\n code: 'missing-operation',\n message: `Capability '${args.capability}' has no configured executor.`,\n severity: 'error',\n },\n ],\n ok: false,\n };\n}\n"]}
@@ -1,11 +1,8 @@
1
1
  import type { DataSourceDiagnostic } from '@ankhorage/contracts';
2
2
  import { type RuntimeComponentEventDispatchArgs } from './runtimeActionRegistry';
3
- import type { RuntimeActionHandlers } from './RuntimeRendererConfig';
4
3
  export interface RuntimeEventDiagnosticsReporter {
5
4
  readonly onDiagnostics?: (diagnostics: readonly DataSourceDiagnostic[]) => void;
6
5
  readonly consoleImpl?: Pick<Console, 'error' | 'warn'>;
7
6
  }
8
- export declare function dispatchRuntimeComponentEventWithReporting(args: RuntimeComponentEventDispatchArgs & RuntimeEventDiagnosticsReporter & {
9
- readonly actionHandlers?: RuntimeActionHandlers;
10
- }): Promise<readonly DataSourceDiagnostic[]>;
7
+ export declare function dispatchRuntimeComponentEventWithReporting(args: RuntimeComponentEventDispatchArgs & RuntimeEventDiagnosticsReporter): Promise<readonly DataSourceDiagnostic[]>;
11
8
  //# sourceMappingURL=runtimeEventExecution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeEventExecution.d.ts","sourceRoot":"","sources":["../src/runtimeEventExecution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAEL,KAAK,iCAAiC,EACvC,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,oBAAoB,EAAE,KAAK,IAAI,CAAC;IAChF,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;CACxD;AAED,wBAAsB,0CAA0C,CAC9D,IAAI,EAAE,iCAAiC,GACrC,+BAA+B,GAAG;IAChC,QAAQ,CAAC,cAAc,CAAC,EAAE,qBAAqB,CAAC;CACjD,GACF,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAmB1C"}
1
+ {"version":3,"file":"runtimeEventExecution.d.ts","sourceRoot":"","sources":["../src/runtimeEventExecution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAEL,KAAK,iCAAiC,EACvC,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,oBAAoB,EAAE,KAAK,IAAI,CAAC;IAChF,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;CACxD;AAED,wBAAsB,0CAA0C,CAC9D,IAAI,EAAE,iCAAiC,GAAG,+BAA+B,GACxE,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAmB1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeEventExecution.js","sourceRoot":"","sources":["../src/runtimeEventExecution.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,6BAA6B,GAE9B,MAAM,yBAAyB,CAAC;AAQjC,MAAM,CAAC,KAAK,UAAU,0CAA0C,CAC9D,IAGG;IAEH,MAAM,WAAW,GAAG,MAAM,6BAA6B,CAAC,IAAI,CAAC,CAAC;IAE9D,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACrC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAChC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC;QAC9E,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK;QACzB,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;IAE3B,MAAM,EAAE,CAAC,qCAAqC,EAAE,WAAW,CAAC,CAAC;IAE7D,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import type { DataSourceDiagnostic } from '@ankhorage/contracts';\n\nimport {\n dispatchRuntimeComponentEvent,\n type RuntimeComponentEventDispatchArgs,\n} from './runtimeActionRegistry';\nimport type { RuntimeActionHandlers } from './RuntimeRendererConfig';\n\nexport interface RuntimeEventDiagnosticsReporter {\n readonly onDiagnostics?: (diagnostics: readonly DataSourceDiagnostic[]) => void;\n readonly consoleImpl?: Pick<Console, 'error' | 'warn'>;\n}\n\nexport async function dispatchRuntimeComponentEventWithReporting(\n args: RuntimeComponentEventDispatchArgs &\n RuntimeEventDiagnosticsReporter & {\n readonly actionHandlers?: RuntimeActionHandlers;\n },\n): Promise<readonly DataSourceDiagnostic[]> {\n const diagnostics = await dispatchRuntimeComponentEvent(args);\n\n if (args.onDiagnostics !== undefined) {\n args.onDiagnostics(diagnostics);\n return diagnostics;\n }\n\n if (diagnostics.length === 0) {\n return diagnostics;\n }\n\n const report = diagnostics.some((diagnostic) => diagnostic.severity === 'error')\n ? args.consoleImpl?.error\n : args.consoleImpl?.warn;\n\n report?.('[runtime] Event binding diagnostics', diagnostics);\n\n return diagnostics;\n}\n"]}
1
+ {"version":3,"file":"runtimeEventExecution.js","sourceRoot":"","sources":["../src/runtimeEventExecution.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,6BAA6B,GAE9B,MAAM,yBAAyB,CAAC;AAOjC,MAAM,CAAC,KAAK,UAAU,0CAA0C,CAC9D,IAAyE;IAEzE,MAAM,WAAW,GAAG,MAAM,6BAA6B,CAAC,IAAI,CAAC,CAAC;IAE9D,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACrC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAChC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC;QAC9E,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK;QACzB,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;IAE3B,MAAM,EAAE,CAAC,qCAAqC,EAAE,WAAW,CAAC,CAAC;IAE7D,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import type { DataSourceDiagnostic } from '@ankhorage/contracts';\n\nimport {\n dispatchRuntimeComponentEvent,\n type RuntimeComponentEventDispatchArgs,\n} from './runtimeActionRegistry';\n\nexport interface RuntimeEventDiagnosticsReporter {\n readonly onDiagnostics?: (diagnostics: readonly DataSourceDiagnostic[]) => void;\n readonly consoleImpl?: Pick<Console, 'error' | 'warn'>;\n}\n\nexport async function dispatchRuntimeComponentEventWithReporting(\n args: RuntimeComponentEventDispatchArgs & RuntimeEventDiagnosticsReporter,\n): Promise<readonly DataSourceDiagnostic[]> {\n const diagnostics = await dispatchRuntimeComponentEvent(args);\n\n if (args.onDiagnostics !== undefined) {\n args.onDiagnostics(diagnostics);\n return diagnostics;\n }\n\n if (diagnostics.length === 0) {\n return diagnostics;\n }\n\n const report = diagnostics.some((diagnostic) => diagnostic.severity === 'error')\n ? args.consoleImpl?.error\n : args.consoleImpl?.warn;\n\n report?.('[runtime] Event binding diagnostics', diagnostics);\n\n return diagnostics;\n}\n"]}
@@ -1,11 +1,12 @@
1
- import type { BindingOperationRef, DataSourceDiagnostic } from '@ankhorage/contracts';
1
+ import type { DataSourceDiagnostic } from '@ankhorage/contracts';
2
+ import type { Capability } from '@ankhorage/contracts/capability';
2
3
  export type RuntimeEventOperationStatus = 'idle' | 'loading' | 'success' | 'error';
3
4
  export interface RuntimeEventOperationState {
4
5
  readonly status: RuntimeEventOperationStatus;
5
6
  readonly loading: boolean;
6
7
  readonly errorMessage: string;
7
8
  readonly nodeId?: string;
8
- readonly operation?: BindingOperationRef;
9
+ readonly capability?: Capability['id'];
9
10
  }
10
11
  export interface RuntimeEventOperationInvocation {
11
12
  readonly id: number;
@@ -13,7 +14,7 @@ export interface RuntimeEventOperationInvocation {
13
14
  export interface RuntimeEventOperationLifecycle {
14
15
  start(args: {
15
16
  readonly nodeId: string;
16
- readonly operation: BindingOperationRef;
17
+ readonly capability: Capability['id'];
17
18
  }): RuntimeEventOperationInvocation | undefined;
18
19
  succeed(invocation: RuntimeEventOperationInvocation): void;
19
20
  fail(invocation: RuntimeEventOperationInvocation, message: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeEventOperationLifecycle.d.ts","sourceRoot":"","sources":["../src/runtimeEventOper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AAED;;;;;;GAMG;AACH,wBAAgB,yCAAyC,CACvD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC5C,KAAK,EAAE,0BAA0B,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUzB;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CACtD,WAAW,EAAE,SAAS,oBAAoB,EAAE,GAC3C,MAAM,CAKR"}
@@ -13,7 +13,7 @@ export const IDLE_RUNTIME_EVENT_OPERATION_STATE = {
13
13
  export function createRuntimeEventOperationLifecycle(onStateChange) {
14
14
  let nextInvocationId = 0;
15
15
  let activeInvocationId;
16
- let activeOperation;
16
+ let activeCapability;
17
17
  let activeNodeId;
18
18
  const finish = (invocation, status, errorMessage) => {
19
19
  if (activeInvocationId !== invocation.id)
@@ -23,19 +23,19 @@ export function createRuntimeEventOperationLifecycle(onStateChange) {
23
23
  loading: false,
24
24
  errorMessage,
25
25
  nodeId: activeNodeId,
26
- operation: activeOperation,
26
+ capability: activeCapability,
27
27
  });
28
28
  activeInvocationId = undefined;
29
29
  };
30
30
  return {
31
- start({ nodeId, operation }) {
31
+ start({ capability, nodeId }) {
32
32
  if (activeInvocationId !== undefined)
33
33
  return undefined;
34
34
  nextInvocationId += 1;
35
35
  activeInvocationId = nextInvocationId;
36
36
  activeNodeId = nodeId;
37
- activeOperation = operation;
38
- onStateChange({ status: 'loading', loading: true, errorMessage: '', nodeId, operation });
37
+ activeCapability = capability;
38
+ onStateChange({ status: 'loading', loading: true, errorMessage: '', nodeId, capability });
39
39
  return { id: activeInvocationId };
40
40
  },
41
41
  succeed(invocation) {
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeEventOperationLifecycle.js","sourceRoot":"","sources":["../src/runtimeEventOperationLifecycle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAyBrD,MAAM,CAAC,MAAM,kCAAkC,GAA+B;IAC5E,MAA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;;;;GAMG;AACH,MAAM,UAAU,yCAAyC,CACvD,OAA4C,EAC5C,KAAiC;IAEjC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAElE,OAAO;QACL,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;QAClB,OAAO,EAAE;YACP,GAAG,OAAO;YACV,cAAc,EAAE,KAAK;SACtB;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wCAAwC,CACtD,WAA4C;IAE5C,OAAO,CACL,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC,EAAE,OAAO;QAC1E,yDAAyD,CAC1D,CAAC;AACJ,CAAC","sourcesContent":["import type { BindingOperationRef, DataSourceDiagnostic } from '@ankhorage/contracts';\nimport { isRecord } from '@ankhorage/utility/object';\n\nexport type RuntimeEventOperationStatus = 'idle' | 'loading' | 'success' | 'error';\n\nexport interface RuntimeEventOperationState {\n readonly status: RuntimeEventOperationStatus;\n readonly loading: boolean;\n readonly errorMessage: string;\n readonly nodeId?: string;\n readonly operation?: BindingOperationRef;\n}\n\nexport interface RuntimeEventOperationInvocation {\n readonly id: number;\n}\n\nexport interface RuntimeEventOperationLifecycle {\n start(args: {\n readonly nodeId: string;\n readonly operation: BindingOperationRef;\n }): RuntimeEventOperationInvocation | undefined;\n succeed(invocation: RuntimeEventOperationInvocation): void;\n fail(invocation: RuntimeEventOperationInvocation, message: string): void;\n}\n\nexport const IDLE_RUNTIME_EVENT_OPERATION_STATE: RuntimeEventOperationState = {\n status: 'idle',\n loading: false,\n errorMessage: '',\n};\n\n/**\n * Creates a single-flight lifecycle controller for component-triggered API operations.\n *\n * @param onStateChange - Receives bindable lifecycle snapshots.\n * @returns A controller that rejects concurrent starts and ignores stale completions.\n */\nexport function createRuntimeEventOperationLifecycle(\n onStateChange: (state: RuntimeEventOperationState) => void,\n): RuntimeEventOperationLifecycle {\n let nextInvocationId = 0;\n let activeInvocationId: number | undefined;\n let activeOperation: BindingOperationRef | undefined;\n let activeNodeId: string | undefined;\n\n const finish = (\n invocation: RuntimeEventOperationInvocation,\n status: Extract<RuntimeEventOperationStatus, 'success' | 'error'>,\n errorMessage: string,\n ) => {\n if (activeInvocationId !== invocation.id) return;\n\n onStateChange({\n status,\n loading: false,\n errorMessage,\n nodeId: activeNodeId,\n operation: activeOperation,\n });\n activeInvocationId = undefined;\n };\n\n return {\n start({ nodeId, operation }) {\n if (activeInvocationId !== undefined) return undefined;\n\n nextInvocationId += 1;\n activeInvocationId = nextInvocationId;\n activeNodeId = nodeId;\n activeOperation = operation;\n onStateChange({ status: 'loading', loading: true, errorMessage: '', nodeId, operation });\n\n return { id: activeInvocationId };\n },\n succeed(invocation) {\n finish(invocation, 'success', '');\n },\n fail(invocation, message) {\n finish(invocation, 'error', message);\n },\n };\n}\n\n/**\n * Adds the public Runtime event-operation namespace without replacing caller context.\n *\n * @param context - Existing manifest binding context.\n * @param state - Current event-operation lifecycle snapshot.\n * @returns Context exposing `runtime.eventOperation` for ordinary context bindings.\n */\nexport function createRuntimeEventOperationBindingContext(\n context: Record<string, unknown> | undefined,\n state: RuntimeEventOperationState,\n): Record<string, unknown> {\n const runtime = isRecord(context?.runtime) ? context.runtime : {};\n\n return {\n ...(context ?? {}),\n runtime: {\n ...runtime,\n eventOperation: state,\n },\n };\n}\n\n/**\n * Selects a stable, human-readable error for inline presentation.\n *\n * @param diagnostics - Diagnostics produced while resolving or executing the operation.\n * @returns The first error message, or a safe generic fallback.\n */\nexport function resolveRuntimeEventOperationErrorMessage(\n diagnostics: readonly DataSourceDiagnostic[],\n): string {\n return (\n diagnostics.find((diagnostic) => diagnostic.severity === 'error')?.message ??\n 'The operation could not be completed. Please try again.'\n );\n}\n"]}
1
+ {"version":3,"file":"runtimeEventOperationLifecycle.js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E,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,IAAI,CAAC,UAAU,EAAE,OAAO;YACtB,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yCAAyC,CACvD,OAA4C,EAC5C,KAAiC;IAEjC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAElE,OAAO;QACL,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;QAClB,OAAO,EAAE;YACP,GAAG,OAAO;YACV,cAAc,EAAE,KAAK;SACtB;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wCAAwC,CACtD,WAA4C;IAE5C,OAAO,CACL,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC,EAAE,OAAO;QAC1E,yDAAyD,CAC1D,CAAC;AACJ,CAAC","sourcesContent":["import type { DataSourceDiagnostic } from '@ankhorage/contracts';\nimport type { Capability } from '@ankhorage/contracts/capability';\nimport { isRecord } from '@ankhorage/utility/object';\n\nexport type RuntimeEventOperationStatus = 'idle' | 'loading' | 'success' | 'error';\n\nexport interface RuntimeEventOperationState {\n readonly status: RuntimeEventOperationStatus;\n readonly loading: boolean;\n readonly errorMessage: string;\n readonly nodeId?: string;\n readonly capability?: Capability['id'];\n}\n\nexport interface RuntimeEventOperationInvocation {\n readonly id: number;\n}\n\nexport interface RuntimeEventOperationLifecycle {\n start(args: {\n readonly nodeId: string;\n readonly capability: Capability['id'];\n }): RuntimeEventOperationInvocation | undefined;\n succeed(invocation: RuntimeEventOperationInvocation): void;\n fail(invocation: RuntimeEventOperationInvocation, message: string): void;\n}\n\nexport const IDLE_RUNTIME_EVENT_OPERATION_STATE: RuntimeEventOperationState = {\n status: 'idle',\n loading: false,\n errorMessage: '',\n};\n\n/**\n * Creates a single-flight lifecycle controller for component-triggered API operations.\n *\n * @param onStateChange - Receives bindable lifecycle snapshots.\n * @returns A controller that rejects concurrent starts and ignores stale completions.\n */\nexport function createRuntimeEventOperationLifecycle(\n onStateChange: (state: RuntimeEventOperationState) => void,\n): RuntimeEventOperationLifecycle {\n let nextInvocationId = 0;\n let activeInvocationId: number | undefined;\n let activeCapability: Capability['id'] | undefined;\n let activeNodeId: string | undefined;\n\n const finish = (\n invocation: RuntimeEventOperationInvocation,\n status: Extract<RuntimeEventOperationStatus, 'success' | 'error'>,\n errorMessage: string,\n ) => {\n if (activeInvocationId !== invocation.id) return;\n\n onStateChange({\n status,\n loading: false,\n errorMessage,\n nodeId: activeNodeId,\n capability: activeCapability,\n });\n activeInvocationId = undefined;\n };\n\n return {\n start({ capability, nodeId }) {\n if (activeInvocationId !== undefined) return undefined;\n\n nextInvocationId += 1;\n activeInvocationId = nextInvocationId;\n activeNodeId = nodeId;\n activeCapability = capability;\n onStateChange({ status: 'loading', loading: true, errorMessage: '', nodeId, capability });\n\n return { id: activeInvocationId };\n },\n succeed(invocation) {\n finish(invocation, 'success', '');\n },\n fail(invocation, message) {\n finish(invocation, 'error', message);\n },\n };\n}\n\n/**\n * Adds the public Runtime event-operation namespace without replacing caller context.\n *\n * @param context - Existing manifest binding context.\n * @param state - Current event-operation lifecycle snapshot.\n * @returns Context exposing `runtime.eventOperation` for ordinary context bindings.\n */\nexport function createRuntimeEventOperationBindingContext(\n context: Record<string, unknown> | undefined,\n state: RuntimeEventOperationState,\n): Record<string, unknown> {\n const runtime = isRecord(context?.runtime) ? context.runtime : {};\n\n return {\n ...(context ?? {}),\n runtime: {\n ...runtime,\n eventOperation: state,\n },\n };\n}\n\n/**\n * Selects a stable, human-readable error for inline presentation.\n *\n * @param diagnostics - Diagnostics produced while resolving or executing the operation.\n * @returns The first error message, or a safe generic fallback.\n */\nexport function resolveRuntimeEventOperationErrorMessage(\n diagnostics: readonly DataSourceDiagnostic[],\n): string {\n return (\n diagnostics.find((diagnostic) => diagnostic.severity === 'error')?.message ??\n 'The operation could not be completed. Please try again.'\n );\n}\n"]}
@@ -1,27 +1,15 @@
1
- import type { ApiDefinitionRegistry, ComponentDataBindingRegistry, DbAdapter, DbRealtimeAdapter, StateAdapter, UiNode } from '@ankhorage/contracts';
2
- import { type RuntimeBindingOperationResultCache } from './runtimeBindings';
3
- import type { RuntimeAction, RuntimeRendererConfig } from './RuntimeRendererConfig';
4
- interface RuntimeActionHandlerCacheEntry {
5
- readonly handleAction: (action: RuntimeAction) => void;
6
- readonly handler: (...args: unknown[]) => void;
7
- }
1
+ import type { ComponentDataBindingRegistry, DbAdapter, DbRealtimeAdapter, StateAdapter, UiNode } from '@ankhorage/contracts';
2
+ import { type RuntimeBindingResultCache } from './runtimeBindings';
3
+ import type { RuntimeRendererConfig } from './RuntimeRendererConfig';
4
+ /*** Resolves a node's authored props and synchronous binding expressions for one render pass. */
8
5
  export declare function resolveRuntimeNodeProps(args: {
9
- node: UiNode;
10
- resolveNodeProps?: RuntimeRendererConfig['resolveNodeProps'];
11
- stateAdapter?: StateAdapter;
12
- dbAdapter?: DbAdapter;
13
- dbRealtimeAdapter?: DbRealtimeAdapter;
14
- bindingContext?: Record<string, unknown>;
15
- apis?: ApiDefinitionRegistry;
16
- dataBindings?: ComponentDataBindingRegistry;
17
- operationResults?: RuntimeBindingOperationResultCache;
6
+ readonly node: UiNode;
7
+ readonly resolveNodeProps?: RuntimeRendererConfig['resolveNodeProps'];
8
+ readonly stateAdapter?: StateAdapter;
9
+ readonly dbAdapter?: DbAdapter;
10
+ readonly dbRealtimeAdapter?: DbRealtimeAdapter;
11
+ readonly bindingContext?: Record<string, unknown>;
12
+ readonly dataBindings?: ComponentDataBindingRegistry;
13
+ readonly resultSlots?: RuntimeBindingResultCache;
18
14
  }): Record<string, unknown>;
19
- export declare function wrapRuntimeActionProps(args: {
20
- props: Record<string, unknown>;
21
- disableActions: boolean;
22
- handleAction: (action: RuntimeAction) => void;
23
- actionHandlerCache: WeakMap<object, RuntimeActionHandlerCacheEntry>;
24
- functionHandlerCache: WeakMap<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
25
- }): Record<string, unknown>;
26
- export {};
27
15
  //# sourceMappingURL=runtimeNodeProps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeNodeProps.d.ts","sourceRoot":"","sources":["../src/runtimeNodeProps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACP,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAA0B,KAAK,kCAAkC,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEpF,UAAU,8BAA8B;IACtC,QAAQ,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IACvD,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CAChD;AAqED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC7D,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,YAAY,CAAC,EAAE,4BAA4B,CAAC;IAC5C,gBAAgB,CAAC,EAAE,kCAAkC,CAAC;CACvD,GAAG,MAAM,CA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Q,CAAC,YAAY,CAAC,EAAE,4BAA4B,CAAC;IACrD,QAAQ,CAAC,WAAW,CAAC,EAAE,yBAAyB,CAAC;CAClD,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoB1B"}
@@ -1,133 +1,39 @@
1
- import { isCapabilityId } from '@ankhorage/capability';
2
1
  import { isMediaAssetReference } from '@ankhorage/contracts';
3
2
  import { resolveRuntimeBindings } from './runtimeBindings';
4
- function isRecord(value) {
5
- return typeof value === 'object' && value !== null && !Array.isArray(value);
6
- }
7
- function isPlainObject(value) {
8
- if (!isRecord(value)) {
9
- return false;
10
- }
11
- const prototype = Reflect.getPrototypeOf(value);
12
- return prototype === Object.prototype || prototype === null;
13
- }
14
- function hasActionShape(value) {
15
- return isRecord(value) && isCapabilityId(value.type);
16
- }
17
- function isCallbackProp(value) {
18
- return typeof value === 'function';
19
- }
20
- function isNonEmptyActionId(value) {
21
- return isCapabilityId(value);
22
- }
23
- function createStringActionPayload(args) {
24
- if (args.length === 0) {
25
- return {};
26
- }
27
- const [firstArg] = args;
28
- if (isPlainObject(firstArg)) {
29
- return { payload: firstArg };
30
- }
31
- return {
32
- payload: {
33
- args,
34
- },
35
- };
36
- }
37
- const noopRuntimeActionHandler = () => undefined;
38
- function resolveImageAssetUrl(value) {
39
- if (typeof value === 'string') {
40
- const url = value.trim();
41
- return url.length ? url : null;
42
- }
43
- if (!isRecord(value) || typeof value.kind !== 'string') {
44
- return null;
45
- }
46
- if (value.kind === 'url' && typeof value.url === 'string') {
47
- const url = value.url.trim();
48
- return url.length ? url : null;
49
- }
50
- if (value.kind === 'storage' && typeof value.publicUrl === 'string') {
51
- const publicUrl = value.publicUrl.trim();
52
- return publicUrl.length ? publicUrl : null;
53
- }
54
- return null;
55
- }
3
+ /*** Resolves a node's authored props and synchronous binding expressions for one render pass. */
56
4
  export function resolveRuntimeNodeProps(args) {
57
- const { node, resolveNodeProps } = args;
58
- const baseProps = {
59
- testID: node.id,
60
- ...(node.props ?? {}),
61
- };
62
- if (node.type === 'Image' && !isMediaAssetReference(baseProps.source)) {
63
- const resolvedSource = resolveImageAssetUrl(baseProps.source);
64
- if (resolvedSource !== null)
65
- baseProps.source = resolvedSource;
5
+ const props = { testID: args.node.id, ...(args.node.props ?? {}) };
6
+ if (args.node.type === 'Image' && !isMediaAssetReference(props.source)) {
7
+ const source = resolveImageAssetUrl(props.source);
8
+ if (source === undefined)
9
+ delete props.source;
66
10
  else
67
- delete baseProps.source;
68
- }
69
- if (node.style) {
70
- baseProps.style = baseProps.style ? [baseProps.style, node.style] : node.style;
11
+ props.source = source;
71
12
  }
72
- const bindingResult = resolveRuntimeBindings({
73
- apis: args.apis,
13
+ if (args.node.style)
14
+ props.style = props.style ? [props.style, args.node.style] : args.node.style;
15
+ const binding = resolveRuntimeBindings({
74
16
  context: args.bindingContext,
75
17
  dataBindings: args.dataBindings,
76
- node,
77
- operationResults: args.operationResults,
78
- props: baseProps,
18
+ node: args.node,
19
+ props,
20
+ resultSlots: args.resultSlots,
79
21
  stateAdapter: args.stateAdapter,
80
22
  });
81
- return resolveNodeProps
82
- ? resolveNodeProps({ node, props: bindingResult.props })
83
- : bindingResult.props;
23
+ return args.resolveNodeProps
24
+ ? args.resolveNodeProps({ node: args.node, props: binding.props })
25
+ : binding.props;
84
26
  }
85
- export function wrapRuntimeActionProps(args) {
86
- const { props, disableActions, handleAction, actionHandlerCache, functionHandlerCache } = args;
87
- const wrappedProps = { ...props };
88
- Object.keys(wrappedProps).forEach((key) => {
89
- if (!key.startsWith('on')) {
90
- return;
91
- }
92
- const value = wrappedProps[key];
93
- if (disableActions) {
94
- wrappedProps[key] =
95
- hasActionShape(value) || isNonEmptyActionId(value) ? noopRuntimeActionHandler : undefined;
96
- return;
97
- }
98
- if (hasActionShape(value)) {
99
- const actionObject = value;
100
- let cachedActionHandler = actionHandlerCache.get(actionObject);
101
- if (cachedActionHandler?.handleAction !== handleAction) {
102
- const actionHandler = () => {
103
- handleAction(actionObject);
104
- };
105
- cachedActionHandler = { handleAction, handler: actionHandler };
106
- actionHandlerCache.set(actionObject, cachedActionHandler);
107
- }
108
- wrappedProps[key] = cachedActionHandler.handler;
109
- return;
110
- }
111
- if (isNonEmptyActionId(value)) {
112
- const actionId = value;
113
- wrappedProps[key] = (...handlerArgs) => {
114
- handleAction({
115
- type: actionId,
116
- ...createStringActionPayload(handlerArgs),
117
- });
118
- };
119
- return;
120
- }
121
- if (isCallbackProp(value)) {
122
- const handler = value;
123
- let wrappedHandler = functionHandlerCache.get(handler);
124
- if (!wrappedHandler) {
125
- wrappedHandler = (...handlerArgs) => handler(...handlerArgs);
126
- functionHandlerCache.set(handler, wrappedHandler);
127
- }
128
- wrappedProps[key] = wrappedHandler;
129
- }
130
- });
131
- return wrappedProps;
27
+ function resolveImageAssetUrl(value) {
28
+ if (typeof value === 'string')
29
+ return value.trim() || undefined;
30
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
31
+ return undefined;
32
+ const record = value;
33
+ if (record.kind === 'url' && typeof record.url === 'string')
34
+ return record.url.trim() || undefined;
35
+ if (record.kind === 'storage' && typeof record.publicUrl === 'string')
36
+ return record.publicUrl.trim() || undefined;
37
+ return undefined;
132
38
  }
133
39
  //# sourceMappingURL=runtimeNodeProps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeNodeProps.js","sourceRoot":"","sources":["../src/runtimeNodeProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AASvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,EAAE,sBAAsB,EAA2C,MAAM,mBAAmB,CAAC;AAQpG,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,I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ACH,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { isCapabilityId } from '@ankhorage/capability';\nimport type {\n ApiDefinitionRegistry,\n ComponentDataBindingRegistry,\n DbAdapter,\n DbRealtimeAdapter,\n StateAdapter,\n UiNode,\n} from '@ankhorage/contracts';\nimport { isMediaAssetReference } from '@ankhorage/contracts';\nimport type { Capability } from '@ankhorage/contracts/capability';\n\nimport { resolveRuntimeBindings, type RuntimeBindingOperationResultCache } from './runtimeBindings';\nimport type { RuntimeAction, RuntimeRendererConfig } from './RuntimeRendererConfig';\n\ninterface RuntimeActionHandlerCacheEntry {\n readonly handleAction: (action: RuntimeAction) => void;\n readonly handler: (...args: unknown[]) => void;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (!isRecord(value)) {\n return false;\n }\n\n const prototype = Reflect.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction hasActionShape(value: unknown): value is RuntimeAction {\n return isRecord(value) && isCapabilityId(value.type);\n}\n\nfunction isCallbackProp(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n\nfunction isNonEmptyActionId(value: unknown): value is Capability['id'] {\n return isCapabilityId(value);\n}\n\nfunction createStringActionPayload(args: unknown[]): { payload?: object } {\n if (args.length === 0) {\n return {};\n }\n\n const [firstArg] = args;\n if (isPlainObject(firstArg)) {\n return { payload: firstArg };\n }\n\n return {\n payload: {\n args,\n },\n };\n}\n\nconst noopRuntimeActionHandler = () => undefined;\n\nfunction resolveImageAssetUrl(value: unknown): string | null {\n if (typeof value === 'string') {\n const url = value.trim();\n return url.length ? url : null;\n }\n\n if (!isRecord(value) || typeof value.kind !== 'string') {\n return null;\n }\n\n if (value.kind === 'url' && typeof value.url === 'string') {\n const url = value.url.trim();\n return url.length ? url : null;\n }\n\n if (value.kind === 'storage' && typeof value.publicUrl === 'string') {\n const publicUrl = value.publicUrl.trim();\n return publicUrl.length ? publicUrl : null;\n }\n\n return null;\n}\n\nexport function resolveRuntimeNodeProps(args: {\n node: UiNode;\n resolveNodeProps?: RuntimeRendererConfig['resolveNodeProps'];\n stateAdapter?: StateAdapter;\n dbAdapter?: DbAdapter;\n dbRealtimeAdapter?: DbRealtimeAdapter;\n bindingContext?: Record<string, unknown>;\n apis?: ApiDefinitionRegistry;\n dataBindings?: ComponentDataBindingRegistry;\n operationResults?: RuntimeBindingOperationResultCache;\n}): Record<string, unknown> {\n const { node, resolveNodeProps } = args;\n\n const baseProps: Record<string, unknown> = {\n testID: node.id,\n ...(node.props ?? {}),\n };\n\n if (node.type === 'Image' && !isMediaAssetReference(baseProps.source)) {\n const resolvedSource = resolveImageAssetUrl(baseProps.source);\n if (resolvedSource !== null) baseProps.source = resolvedSource;\n else delete baseProps.source;\n }\n\n if (node.style) {\n baseProps.style = baseProps.style ? [baseProps.style, node.style] : node.style;\n }\n\n const bindingResult = resolveRuntimeBindings({\n apis: args.apis,\n context: args.bindingContext,\n dataBindings: args.dataBindings,\n node,\n operationResults: args.operationResults,\n props: baseProps,\n stateAdapter: args.stateAdapter,\n });\n\n return resolveNodeProps\n ? resolveNodeProps({ node, props: bindingResult.props })\n : bindingResult.props;\n}\n\nexport function wrapRuntimeActionProps(args: {\n props: Record<string, unknown>;\n disableActions: boolean;\n handleAction: (action: RuntimeAction) => void;\n actionHandlerCache: WeakMap<object, RuntimeActionHandlerCacheEntry>;\n functionHandlerCache: WeakMap<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;\n}): Record<string, unknown> {\n const { props, disableActions, handleAction, actionHandlerCache, functionHandlerCache } = args;\n const wrappedProps: Record<string, unknown> = { ...props };\n\n Object.keys(wrappedProps).forEach((key) => {\n if (!key.startsWith('on')) {\n return;\n }\n\n const value = wrappedProps[key];\n\n if (disableActions) {\n wrappedProps[key] =\n hasActionShape(value) || isNonEmptyActionId(value) ? noopRuntimeActionHandler : undefined;\n return;\n }\n\n if (hasActionShape(value)) {\n const actionObject = value;\n let cachedActionHandler = actionHandlerCache.get(actionObject);\n if (cachedActionHandler?.handleAction !== handleAction) {\n const actionHandler = () => {\n handleAction(actionObject);\n };\n cachedActionHandler = { handleAction, handler: actionHandler };\n actionHandlerCache.set(actionObject, cachedActionHandler);\n }\n wrappedProps[key] = cachedActionHandler.handler;\n return;\n }\n\n if (isNonEmptyActionId(value)) {\n const actionId = value;\n wrappedProps[key] = (...handlerArgs: unknown[]) => {\n handleAction({\n type: actionId,\n ...createStringActionPayload(handlerArgs),\n });\n };\n return;\n }\n\n if (isCallbackProp(value)) {\n const handler = value;\n let wrappedHandler = functionHandlerCache.get(handler);\n if (!wrappedHandler) {\n wrappedHandler = (...handlerArgs: unknown[]) => handler(...handlerArgs);\n functionHandlerCache.set(handler, wrappedHandler);\n }\n wrappedProps[key] = wrappedHandler;\n }\n });\n\n return wrappedProps;\n}\n"]}
1
+ {"version":3,"file":"runtimeNodeProps.js","sourceRoot":"","sources":["../src/runtimeNodeProps.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAkC,MAAM,mBAAmB,CAAC;AAG3F,iGAAiG;AACjG,MAAM,UAAU,uBAAuB,CAAC,IASvC;IACC,MAAM,KAAK,GAA4B,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;IAC5F,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACvE,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,MAAM,KAAK,SAAS;YAAE,OA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AAM,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QACnE,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type {\n ComponentDataBindingRegistry,\n DbAdapter,\n DbRealtimeAdapter,\n StateAdapter,\n UiNode,\n} from '@ankhorage/contracts';\nimport { isMediaAssetReference } from '@ankhorage/contracts';\n\nimport { resolveRuntimeBindings, type RuntimeBindingResultCache } from './runtimeBindings';\nimport type { RuntimeRendererConfig } from './RuntimeRendererConfig';\n\n/*** Resolves a node's authored props and synchronous binding expressions for one render pass. */\nexport function resolveRuntimeNodeProps(args: {\n readonly node: UiNode;\n readonly resolveNodeProps?: RuntimeRendererConfig['resolveNodeProps'];\n readonly stateAdapter?: StateAdapter;\n readonly dbAdapter?: DbAdapter;\n readonly dbRealtimeAdapter?: DbRealtimeAdapter;\n readonly bindingContext?: Record<string, unknown>;\n readonly dataBindings?: ComponentDataBindingRegistry;\n readonly resultSlots?: RuntimeBindingResultCache;\n}): Record<string, unknown> {\n const props: Record<string, unknown> = { testID: args.node.id, ...(args.node.props ?? {}) };\n if (args.node.type === 'Image' && !isMediaAssetReference(props.source)) {\n const source = resolveImageAssetUrl(props.source);\n if (source === undefined) delete props.source;\n else props.source = source;\n }\n if (args.node.style) props.style = props.style ? [props.style, args.node.style] : args.node.style;\n\n const binding = resolveRuntimeBindings({\n context: args.bindingContext,\n dataBindings: args.dataBindings,\n node: args.node,\n props,\n resultSlots: args.resultSlots,\n stateAdapter: args.stateAdapter,\n });\n return args.resolveNodeProps\n ? args.resolveNodeProps({ node: args.node, props: binding.props })\n : binding.props;\n}\n\nfunction resolveImageAssetUrl(value: unknown): string | undefined {\n if (typeof value === 'string') return value.trim() || undefined;\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (record.kind === 'url' && typeof record.url === 'string')\n return record.url.trim() || undefined;\n if (record.kind === 'storage' && typeof record.publicUrl === 'string')\n return record.publicUrl.trim() || undefined;\n return undefined;\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import type { BindingValue, DataSourceDiagnostic, UiNode, UiNodeRepeatSpec } from '@ankhorage/contracts';
2
- import { type RuntimeBindingOperationResultWriter, type RuntimeBindingResolutionContext } from './runtimeBindings';
2
+ import { type RuntimeBindingResolutionContext, type RuntimeBindingResultWriter } from './runtimeBindings';
3
3
  export interface RuntimeRepeatResolutionContext extends RuntimeBindingResolutionContext {
4
4
  readonly node: UiNode;
5
- readonly writeOperationResult?: RuntimeBindingOperationResultWriter;
5
+ readonly writeResultSlot?: RuntimeBindingResultWriter;
6
6
  }
7
7
  export interface RuntimeRepeatItemsResult {
8
8
  readonly items: readonly BindingValue[];
@@ -11,13 +11,17 @@ export interface RuntimeRepeatItemsResult {
11
11
  export interface RuntimeRepeatItemsSyncResult extends RuntimeRepeatItemsResult {
12
12
  readonly status: 'ready' | 'pending';
13
13
  }
14
+ /*** Resolves an already materialized repeat expression for the current render pass. */
14
15
  export declare function resolveRuntimeRepeatItemsSync(repeat: UiNodeRepeatSpec, context: RuntimeRepeatResolutionContext): RuntimeRepeatItemsSyncResult;
16
+ /*** Resolves a repeat expression asynchronously through the canonical capability executor. */
15
17
  export declare function resolveRuntimeRepeatItemsAsync(repeat: UiNodeRepeatSpec, context: RuntimeRepeatResolutionContext): Promise<RuntimeRepeatItemsResult>;
18
+ /*** Adds one repeat item under its configured alias without discarding outer context values. */
16
19
  export declare function createRuntimeRepeatBindingContext(args: {
17
20
  readonly baseContext?: Record<string, unknown>;
18
21
  readonly item: BindingValue;
19
22
  readonly itemAlias?: string;
20
23
  }): Record<string, unknown>;
24
+ /*** Selects a stable primitive key from the repeat item, falling back to its index. */
21
25
  export declare function resolveRuntimeRepeatItemKey(args: {
22
26
  readonly item: BindingValue;
23
27
  readonly itemAlias?: string;
@@ -1 +1 @@
1
- {"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AC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE1B;AAED,uFAAuF;AACvF,wBAAgB,2BAA2B,CAAC,IAAI,EAAE;IAChD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,GAAG,MAAM,GAAG,MAAM,CAOlB"}
@@ -1,130 +1,51 @@
1
- import { resolveRuntimeBindingOperationSelection } from './runtimeApiSelection';
2
- import { applyRuntimeBindingDataPath, createRuntimeBindingOperationKey, resolveRuntimeBindingValueSourceSync, } from './runtimeBindings';
1
+ import { resolveRuntimeBindingExpression, resolveRuntimeBindingExpressionSync, } from './runtimeBindings';
2
+ /*** Resolves an already materialized repeat expression for the current render pass. */
3
3
  export function resolveRuntimeRepeatItemsSync(repeat, context) {
4
- if (repeat.source.kind !== 'operation') {
5
- const diagnostics = [];
6
- const resolved = resolveRuntimeBindingValueSourceSync(repeat.source, context, diagnostics);
7
- return {
8
- status: 'ready',
9
- ...finalizeRuntimeRepeatItems(repeat, resolved, diagnostics),
10
- };
11
- }
12
- const operationKey = createRuntimeBindingOperationKey(repeat.source.operation);
13
- const cached = context.operationResults?.[operationKey];
14
- if (cached !== undefined) {
15
- return {
16
- status: 'ready',
17
- ...finalizeRuntimeRepeatItems(repeat, applyRuntimeBindingDataPath(cached, repeat.source.path), []),
18
- };
19
- }
20
- if (context.executeOperation !== undefined) {
21
- return {
22
- status: 'pending',
23
- items: [],
24
- diagnostics: [],
25
- };
4
+ const diagnostics = [];
5
+ const value = resolveRuntimeBindingExpressionSync(repeat.source, context, diagnostics);
6
+ if (value !== undefined || context.executeCapability === undefined) {
7
+ return { status: 'ready', ...finalizeRuntimeRepeatItems(repeat, value, diagnostics) };
26
8
  }
27
- return {
28
- status: 'ready',
29
- items: [],
30
- diagnostics: [
31
- createRepeatDiagnostic(repeat, 'missing-adapter', 'Repeat API operation source requires an injected operation executor.'),
32
- ],
33
- };
9
+ return { status: 'pending', diagnostics, items: [] };
34
10
  }
11
+ /*** Resolves a repeat expression asynchronously through the canonical capability executor. */
35
12
  export async function resolveRuntimeRepeatItemsAsync(repeat, context) {
36
- if (repeat.source.kind !== 'operation') {
37
- const diagnostics = [];
38
- const resolved = await Promise.resolve(resolveRuntimeBindingValueSourceSync(repeat.source, context, diagnostics));
39
- return finalizeRuntimeRepeatItems(repeat, resolved, diagnostics);
40
- }
41
- const operationKey = createRuntimeBindingOperationKey(repeat.source.operation);
42
- const cached = context.operationResults?.[operationKey];
43
- if (cached !== undefined) {
44
- return finalizeRuntimeRepeatItems(repeat, applyRuntimeBindingDataPath(cached, repeat.source.path), []);
45
- }
46
- if (context.executeOperation === undefined) {
47
- return {
48
- items: [],
49
- diagnostics: [
50
- createRepeatDiagnostic(repeat, 'missing-adapter', 'Repeat API operation source requires an injected operation executor.'),
51
- ],
52
- };
53
- }
54
13
  const diagnostics = [];
55
- const selection = resolveRuntimeBindingOperationSelection(repeat.source.operation, context.apis, diagnostics);
56
- if (selection === undefined) {
57
- return { items: [], diagnostics };
58
- }
59
- const result = await context.executeOperation({
60
- api: selection.api,
61
- endpoint: selection.endpoint,
62
- operation: repeat.source.operation,
63
- node: context.node,
64
- });
65
- diagnostics.push(...(result.diagnostics ?? []));
66
- if (!result.ok) {
67
- return { items: [], diagnostics };
68
- }
69
- context.writeOperationResult?.(operationKey, result.data);
70
- return finalizeRuntimeRepeatItems(repeat, applyRuntimeBindingDataPath(result.data, repeat.source.path), diagnostics);
14
+ const value = await resolveRuntimeBindingExpression(repeat.source, context, diagnostics);
15
+ return finalizeRuntimeRepeatItems(repeat, value, diagnostics);
71
16
  }
17
+ /*** Adds one repeat item under its configured alias without discarding outer context values. */
72
18
  export function createRuntimeRepeatBindingContext(args) {
73
- return {
74
- ...(args.baseContext ?? {}),
75
- [args.itemAlias ?? 'item']: args.item,
76
- };
19
+ return { ...(args.baseContext ?? {}), [args.itemAlias ?? 'item']: args.item };
77
20
  }
21
+ /*** Selects a stable primitive key from the repeat item, falling back to its index. */
78
22
  export function resolveRuntimeRepeatItemKey(args) {
79
- const explicitKey = readRepeatPrimitive(args.item, args.keyPath ?? 'id');
80
- if (explicitKey !== undefined) {
81
- return explicitKey;
82
- }
83
- const fallbackId = readRepeatPrimitive(args.item, 'id');
84
- if (fallbackId !== undefined) {
85
- return fallbackId;
86
- }
87
- const fallbackItemId = readRepeatPrimitive(args.item, 'itemId');
88
- if (fallbackItemId !== undefined) {
89
- return fallbackItemId;
90
- }
91
- return args.index;
23
+ return (readRepeatPrimitive(args.item, args.keyPath ?? 'id') ??
24
+ readRepeatPrimitive(args.item, 'id') ??
25
+ readRepeatPrimitive(args.item, 'itemId') ??
26
+ args.index);
92
27
  }
93
28
  function finalizeRuntimeRepeatItems(repeat, value, diagnostics) {
94
- if (Array.isArray(value)) {
95
- return {
96
- items: value,
97
- diagnostics,
98
- };
99
- }
29
+ if (Array.isArray(value))
30
+ return { diagnostics, items: value };
100
31
  return {
101
- items: [],
102
32
  diagnostics: [
103
33
  ...diagnostics,
104
- createRepeatDiagnostic(repeat, 'invalid-config', 'Repeat source must resolve to an array.'),
34
+ {
35
+ code: 'invalid-config',
36
+ message: 'Repeat source must resolve to an array.',
37
+ severity: 'error',
38
+ },
105
39
  ],
106
- };
107
- }
108
- function createRepeatDiagnostic(repeat, code, message) {
109
- return {
110
- apiId: repeat.source.kind === 'operation' ? repeat.source.operation.apiId : undefined,
111
- endpointId: repeat.source.kind === 'operation' ? repeat.source.operation.endpointId : undefined,
112
- operationId: repeat.source.kind === 'operation' ? repeat.source.operation.operationId : undefined,
113
- code,
114
- message,
115
- severity: 'error',
40
+ items: [],
116
41
  };
117
42
  }
118
43
  function readRepeatPrimitive(value, path) {
119
- const resolved = path.split('.').reduce((currentValue, part) => {
120
- if (typeof currentValue !== 'object' || currentValue === null || Array.isArray(currentValue)) {
44
+ const resolved = path.split('.').reduce((current, part) => {
45
+ if (typeof current !== 'object' || current === null || Array.isArray(current))
121
46
  return undefined;
122
- }
123
- return currentValue[part];
47
+ return current[part];
124
48
  }, value);
125
- if (typeof resolved === 'string' || typeof resolved === 'number') {
126
- return resolved;
127
- }
128
- return undefined;
49
+ return typeof resolved === 'string' || typeof resolved === 'number' ? resolved : undefined;
129
50
  }
130
51
  //# sourceMappingURL=runtimeRepeat.js.map