@ankhorage/runtime 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/ManifestContext.d.ts.map +1 -1
- package/dist/ManifestContext.js +6 -6
- package/dist/ManifestContext.js.map +1 -1
- package/dist/RuntimeRenderer.d.ts.map +1 -1
- package/dist/RuntimeRenderer.js +22 -38
- package/dist/RuntimeRenderer.js.map +1 -1
- package/dist/RuntimeRendererConfig.d.ts.map +1 -1
- package/dist/RuntimeRendererConfig.js +4 -6
- package/dist/RuntimeRendererConfig.js.map +1 -1
- package/dist/RuntimeScreen.js +1 -1
- package/dist/RuntimeScreen.js.map +1 -1
- package/dist/runtimeMediaCache.d.ts.map +1 -1
- package/dist/runtimeMediaCache.js +3 -5
- package/dist/runtimeMediaCache.js.map +1 -1
- package/dist/runtimeNodeProps.d.ts +6 -1
- package/dist/runtimeNodeProps.d.ts.map +1 -1
- package/dist/runtimeNodeProps.js +6 -5
- package/dist/runtimeNodeProps.js.map +1 -1
- package/dist/runtimeScreenLoaders.d.ts.map +1 -1
- package/dist/runtimeScreenLoaders.js +24 -28
- package/dist/runtimeScreenLoaders.js.map +1 -1
- package/dist/useRuntimeMediaProps.d.ts.map +1 -1
- package/dist/useRuntimeMediaProps.js +11 -27
- package/dist/useRuntimeMediaProps.js.map +1 -1
- package/package.json +21 -9
- package/paradox/badges/npm.svg +3 -3
- package/paradox/components.md +1 -1
- package/paradox/diagrams/architecture-overview.mmd +14 -0
- package/paradox/diagrams/export-graph.mmd +5 -0
- package/paradox/diagrams/module-relationships.mmd +9 -0
- package/paradox/diagrams/sequences/runtime-renderer-config-provider.mmd +3 -3
- package/paradox/diagrams/sequences/runtime-screen.mmd +3 -3
- package/paradox/diagrams/sequences/use-manifest-context.mmd +3 -3
- package/paradox/diagrams/sequences/use-manifest.mmd +3 -3
- package/paradox/diagrams/sequences/use-optional-manifest-context.mmd +3 -3
- package/paradox/diagrams/sequences/use-runtime-renderer-config.mmd +3 -3
- package/paradox/exports.json +12 -12
- package/paradox/exports.md +12 -12
- package/paradox/index.html +250 -89
- package/paradox/paradox.json +376 -108
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeNodeProps.js","sourceRoot":"","sources":["../src/runtimeNodeProps.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,sBAAsB,EAA2C,MAAM,mBAAmB,CAAC;AAGpG,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,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAChD,OAAO,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC;AAC9D,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CACjG,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,yBAAyB,CAAC,IAAe;IAChD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;Q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AAC,CAAC;YACL,CAAC,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,KAAK,CAAC;YACtB,IAAI,cAAc,GAAG,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACvD,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,cAAc,GAAG,CAAC,GAAG,WAAsB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC;gBACxE,oBAAoB,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YACpD,CAAC;YACD,YAAY,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC;QACrC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import type {\n ApiDefinitionList,\n ComponentDataBindingRegistry,\n DbAdapter,\n DbRealtimeAdapter,\n StateAdapter,\n UiNode,\n} from '@ankhorage/contracts';\n\nimport { resolveRuntimeBindings, type RuntimeBindingOperationResultCache } from './runtimeBindings';\nimport type { RuntimeAction, RuntimeRendererConfig } from './RuntimeRendererConfig';\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 (\n typeof value === 'object' && value !== null && 'type' in value && typeof value.type === 'string'\n );\n}\n\nfunction isCallbackProp(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n\nfunction isNonEmptyActionId(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0;\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?: ApiDefinitionList;\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') {\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, (...args: unknown[]) => void>;\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 actionHandler = actionHandlerCache.get(actionObject);\n if (!actionHandler) {\n actionHandler = () => {\n handleAction(actionObject);\n };\n actionHandlerCache.set(actionObject, actionHandler);\n }\n wrappedProps[key] = actionHandler;\n return;\n }\n\n if (isNonEmptyActionId(value)) {\n const actionId = value.trim();\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":"AASA,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,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK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,CAAC;QACrC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import type {\n ApiDefinitionList,\n ComponentDataBindingRegistry,\n DbAdapter,\n DbRealtimeAdapter,\n StateAdapter,\n UiNode,\n} from '@ankhorage/contracts';\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 (\n typeof value === 'object' && value !== null && 'type' in value && typeof value.type === 'string'\n );\n}\n\nfunction isCallbackProp(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n\nfunction isNonEmptyActionId(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0;\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?: ApiDefinitionList;\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') {\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.trim();\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeScreenLoaders.d.ts","sourceRoot":"","sources":["../src/runtimeScreenLoaders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,mCAAmC,EACnC,UAAU,EACX,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAGL,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,KAAK,+BAA+B,EACrC,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACtD,QAAQ,CAAC,gBAAgB,EAAE,kCAAkC,CAAC;IAC9D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,2CAA2C;IAC1D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACtD,QAAQ,CAAC,gBAAgB,EAAE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,CAAC;CACnD,CAiBA;AAED,wBAAsB,oCAAoC,CAAC,IAAI,EAAE;IAC/D,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,QAAQ,CAAC,IAAI,CAAC,EAAE,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACxD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,+BAA+B,CAAC;IAC5D,QAAQ,CAAC,gBAAgB,CAAC,EAAE,kCAAkC,CAAC;IAC/D,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,SAAS,mCAAmC,EAAE,CAAC;CAClE,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAcvD;AA0ED,wBAAgB,gCAAgC,CAAC,IAAI,EAAE;IACrD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,QAAQ,CAAC,IAAI,CAAC,EAAE,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACxD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,+BAA+B,CAAC;IAC5D,QAAQ,CAAC,gBAAgB,CAAC,EAAE,kCAAkC,CAAC;IAC/D,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,oBAAoB,EAAE,KAAK,IAAI,CAAC;IAChF,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,GAAG,iCAAiC,CA8FpC"}
|
|
@@ -154,14 +154,15 @@ function executePreparedRuntimeScreenOperationLoaders(args) {
|
|
|
154
154
|
})();
|
|
155
155
|
}
|
|
156
156
|
export function useRuntimeScreenOperationLoaders(args) {
|
|
157
|
-
const
|
|
157
|
+
const { apis, bindingContext, executeOperation, onDiagnostics, operationResults, screen } = args;
|
|
158
|
+
const loaders = React.useMemo(() => resolveScreenOperationLoaders(screen), [screen]);
|
|
158
159
|
const hasLoaders = loaders.length > 0;
|
|
159
160
|
const plan = React.useMemo(() => createRuntimeScreenOperationLoaderPlan({
|
|
160
|
-
bindingContext
|
|
161
|
+
bindingContext,
|
|
161
162
|
loaders,
|
|
162
|
-
operationResults
|
|
163
|
-
screenId:
|
|
164
|
-
}), [
|
|
163
|
+
operationResults,
|
|
164
|
+
screenId: screen.id,
|
|
165
|
+
}), [bindingContext, loaders, operationResults, screen.id]);
|
|
165
166
|
const { requestKey } = plan;
|
|
166
167
|
const emptyState = React.useMemo(() => createIdleRuntimeScreenOperationLoaderState({
|
|
167
168
|
dependencyKey: requestKey,
|
|
@@ -169,50 +170,45 @@ export function useRuntimeScreenOperationLoaders(args) {
|
|
|
169
170
|
const [state, setState] = React.useState(() => hasLoaders
|
|
170
171
|
? createPendingRuntimeScreenOperationLoaderState({ dependencyKey: requestKey })
|
|
171
172
|
: emptyState);
|
|
172
|
-
const
|
|
173
|
+
const pendingState = React.useMemo(() => state.dependencyKey === requestKey
|
|
174
|
+
? state
|
|
175
|
+
: createPendingRuntimeScreenOperationLoaderState({
|
|
176
|
+
dependencyKey: requestKey,
|
|
177
|
+
previousState: state,
|
|
178
|
+
}), [requestKey, state]);
|
|
179
|
+
const effectiveState = hasLoaders ? pendingState : emptyState;
|
|
173
180
|
const lastDiagnosticsKeyRef = React.useRef(null);
|
|
174
|
-
const latestStateRef = React.useRef(state);
|
|
175
181
|
const lifecycleRef = React.useRef(createRuntimeScreenOperationLoaderLifecycle());
|
|
176
|
-
const executionArgsByRequestKeyRef = React.useRef({});
|
|
177
|
-
executionArgsByRequestKeyRef.current[requestKey] = {
|
|
178
|
-
apis: args.apis,
|
|
179
|
-
executeOperation: args.executeOperation,
|
|
180
|
-
plan,
|
|
181
|
-
screen: args.screen,
|
|
182
|
-
};
|
|
183
|
-
latestStateRef.current = state;
|
|
184
182
|
React.useEffect(() => {
|
|
185
183
|
const request = beginRuntimeScreenOperationLoaderRequest({
|
|
186
184
|
hasLoaders,
|
|
187
185
|
lifecycle: lifecycleRef.current,
|
|
188
186
|
requestKey,
|
|
189
|
-
state
|
|
187
|
+
state,
|
|
190
188
|
});
|
|
191
189
|
lifecycleRef.current = request.lifecycle;
|
|
192
|
-
if (request.state !== latestStateRef.current) {
|
|
193
|
-
setState(request.state);
|
|
194
|
-
}
|
|
195
190
|
if (!request.shouldExecute || request.requestId === undefined) {
|
|
196
191
|
return;
|
|
197
192
|
}
|
|
198
193
|
const { requestId } = request;
|
|
199
194
|
void (async () => {
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
195
|
+
const result = await executePreparedRuntimeScreenOperationLoaders({
|
|
196
|
+
apis,
|
|
197
|
+
executeOperation,
|
|
198
|
+
plan,
|
|
199
|
+
screen,
|
|
200
|
+
});
|
|
205
201
|
setState((currentState) => {
|
|
206
202
|
const completion = completeRuntimeScreenOperationLoaderRequest({
|
|
207
203
|
lifecycle: lifecycleRef.current,
|
|
208
204
|
requestId,
|
|
209
205
|
result,
|
|
210
|
-
state: currentState,
|
|
206
|
+
state: currentState.dependencyKey === requestKey ? currentState : request.state,
|
|
211
207
|
});
|
|
212
208
|
return completion.accepted ? completion.state : currentState;
|
|
213
209
|
});
|
|
214
210
|
})();
|
|
215
|
-
}, [hasLoaders, requestKey]);
|
|
211
|
+
}, [apis, executeOperation, hasLoaders, plan, requestKey, screen, state]);
|
|
216
212
|
React.useEffect(() => {
|
|
217
213
|
if (effectiveState.diagnostics.length === 0) {
|
|
218
214
|
return;
|
|
@@ -222,8 +218,8 @@ export function useRuntimeScreenOperationLoaders(args) {
|
|
|
222
218
|
return;
|
|
223
219
|
}
|
|
224
220
|
lastDiagnosticsKeyRef.current = diagnosticsKey;
|
|
225
|
-
|
|
226
|
-
}, [
|
|
221
|
+
onDiagnostics?.(effectiveState.diagnostics);
|
|
222
|
+
}, [effectiveState.diagnostics, onDiagnostics]);
|
|
227
223
|
return effectiveState;
|
|
228
224
|
}
|
|
229
225
|
function createRuntimeScreenOperationLoaderPlan(args)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,GAAG,qBAAqB,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7E,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC","sourcesContent":["import type {\n BindingValue,\n DataSourceDiagnostic,\n OperationScreenDataLoaderDefinition,\n ScreenSpec,\n} from '@ankhorage/contracts';\nimport React from 'react';\n\nimport { resolveRuntimeBindingOperationSelection } from './runtimeApiSelection';\nimport {\n createRuntimeBindingOperationKey,\n resolveBindingInputMapSync,\n type RuntimeBindingOperationExecutor,\n type RuntimeBindingOperationResultCache,\n type RuntimeBindingResolutionContext,\n} from './runtimeBindings';\n\nexport interface RuntimeScreenOperationLoaderState {\n readonly dependencyKey: string;\n readonly diagnostics: readonly DataSourceDiagnostic[];\n readonly operationResults: RuntimeBindingOperationResultCache;\n readonly renderVersion: number;\n}\n\nexport interface RuntimeScreenOperationLoaderExecutionResult {\n readonly dependencyKey: string;\n readonly diagnostics: readonly DataSourceDiagnostic[];\n readonly operationResults: RuntimeBindingOperationResultCache;\n}\n\nexport interface RuntimeScreenOperationLoaderLifecycle {\n readonly activeRequestId: number;\n readonly activeRequestKey: string | null;\n}\n\nconst EMPTY_RUNTIME_SCREEN_OPERATION_LOADER_DIAGNOSTICS = Object.freeze(\n [],\n) as readonly DataSourceDiagnostic[];\nconst EMPTY_RUNTIME_SCREEN_OPERATION_RESULTS = Object.freeze(\n {},\n) as RuntimeBindingOperationResultCache;\n\nexport function resolveScreenOperationLoaders(\n screen: ScreenSpec,\n): readonly OperationScreenDataLoaderDefinition[] {\n return screen.dataLoaders ?? [];\n}\n\nexport function createRuntimeScreenLoaderRequestKey(args: {\n readonly screenId: string;\n readonly loaders: readonly OperationScreenDataLoaderDefinition[];\n readonly bindingContext?: Record<string, unknown>;\n readonly operationResults?: RuntimeBindingOperationResultCache;\n}): string {\n return createRuntimeScreenOperationLoaderPlan({\n bindingContext: args.bindingContext,\n loaders: args.loaders,\n operationResults: args.operationResults,\n screenId: args.screenId,\n }).requestKey;\n}\n\nexport function createRuntimeScreenOperationLoaderLifecycle(): RuntimeScreenOperationLoaderLifecycle {\n return {\n activeRequestId: 0,\n activeRequestKey: null,\n };\n}\n\nexport function createIdleRuntimeScreenOperationLoaderState(args: {\n readonly dependencyKey: string;\n readonly previousState?: RuntimeScreenOperationLoaderState;\n}): RuntimeScreenOperationLoaderState {\n return {\n dependencyKey: args.dependencyKey,\n diagnostics: EMPTY_RUNTIME_SCREEN_OPERATION_LOADER_DIAGNOSTICS,\n operationResults: EMPTY_RUNTIME_SCREEN_OPERATION_RESULTS,\n renderVersion: args.previousState?.renderVersion ?? 0,\n };\n}\n\nexport function createPendingRuntimeScreenOperationLoaderState(args: {\n readonly dependencyKey: string;\n readonly previousState?: RuntimeScreenOperationLoaderState;\n}): RuntimeScreenOperationLoaderState {\n return {\n dependencyKey: args.dependencyKey,\n diagnostics: [],\n operationResults: {},\n renderVersion: (args.previousState?.renderVersion ?? -1) + 1,\n };\n}\n\nexport function beginRuntimeScreenOperationLoaderRequest(args: {\n readonly hasLoaders: boolean;\n readonly lifecycle: RuntimeScreenOperationLoaderLifecycle;\n readonly requestKey: string;\n readonly state: RuntimeScreenOperationLoaderState;\n}): {\n readonly lifecycle: RuntimeScreenOperationLoaderLifecycle;\n readonly requestId?: number;\n readonly shouldExecute: boolean;\n readonly state: RuntimeScreenOperationLoaderState;\n} {\n if (!args.hasLoaders) {\n if (args.lifecycle.activeRequestKey === null) {\n return {\n lifecycle: args.lifecycle,\n shouldExecute: false,\n state: args.state,\n };\n }\n\n return {\n lifecycle: {\n activeRequestId: args.lifecycle.activeRequestId + 1,\n activeRequestKey: null,\n },\n shouldExecute: false,\n state: args.state,\n };\n }\n\n if (args.lifecycle.activeRequestKey === args.requestKey) {\n return {\n lifecycle: args.lifecycle,\n shouldExecute: false,\n state: args.state,\n };\n }\n\n const requestId = args.lifecycle.activeRequestId + 1;\n\n return {\n lifecycle: {\n activeRequestId: requestId,\n activeRequestKey: args.requestKey,\n },\n requestId,\n shouldExecute: true,\n state:\n args.state.dependencyKey === args.requestKey\n ? args.state\n : createPendingRuntimeScreenOperationLoaderState({\n dependencyKey: args.requestKey,\n previousState: args.state,\n }),\n };\n}\n\nexport function completeRuntimeScreenOperationLoaderRequest(args: {\n readonly lifecycle: RuntimeScreenOperationLoaderLifecycle;\n readonly requestId: number;\n readonly result: RuntimeScreenOperationLoaderExecutionResult;\n readonly state: RuntimeScreenOperationLoaderState;\n}): {\n readonly accepted: boolean;\n readonly state: RuntimeScreenOperationLoaderState;\n} {\n if (args.lifecycle.activeRequestId !== args.requestId) {\n return {\n accepted: false,\n state: args.state,\n };\n }\n\n return {\n accepted: true,\n state: {\n dependencyKey: args.result.dependencyKey,\n diagnostics: args.result.diagnostics,\n operationResults: args.result.operationResults,\n renderVersion: args.state.renderVersion,\n },\n };\n}\n\nexport async function executeRuntimeScreenOperationLoaders(args: {\n readonly bindingContext?: Record<string, unknown>;\n readonly apis?: RuntimeBindingResolutionContext['apis'];\n readonly executeOperation?: RuntimeBindingOperationExecutor;\n readonly operationResults?: RuntimeBindingOperationResultCache;\n readonly screen: ScreenSpec;\n readonly loaders: readonly OperationScreenDataLoaderDefinition[];\n}): Promise<RuntimeScreenOperationLoaderExecutionResult> {\n const plan = createRuntimeScreenOperationLoaderPlan({\n bindingContext: args.bindingContext,\n loaders: args.loaders,\n operationResults: args.operationResults,\n screenId: args.screen.id,\n });\n\n return executePreparedRuntimeScreenOperationLoaders({\n apis: args.apis,\n executeOperation: args.executeOperation,\n plan,\n screen: args.screen,\n });\n}\n\nfunction executePreparedRuntimeScreenOperationLoaders(args: {\n readonly apis?: RuntimeBindingResolutionContext['apis'];\n readonly executeOperation?: RuntimeBindingOperationExecutor;\n readonly plan: RuntimeScreenOperationLoaderPlan;\n readonly screen: ScreenSpec;\n}): Promise<RuntimeScreenOperationLoaderExecutionResult> {\n const diagnostics: DataSourceDiagnostic[] = [...args.plan.diagnostics];\n\n if (args.plan.loaders.length === 0) {\n return Promise.resolve({\n dependencyKey: args.plan.requestKey,\n diagnostics,\n operationResults: {},\n });\n }\n\n if (args.executeOperation === undefined) {\n diagnostics.push(\n ...args.plan.loaders.map((preparedLoader) =>\n createScreenOperationLoaderDiagnostic(\n preparedLoader.loader,\n 'missing-adapter',\n 'Screen API operation loader requires an injected operation executor.',\n ),\n ),\n );\n\n return Promise.resolve({\n dependencyKey: args.plan.requestKey,\n diagnostics,\n operationResults: {},\n });\n }\n const { executeOperation } = args;\n\n return (async () => {\n const operationResults: Record<string, BindingValue | undefined> = {};\n\n for (const preparedLoader of args.plan.loaders) {\n const selection = resolveRuntimeBindingOperationSelection(\n preparedLoader.loader.operation,\n args.apis,\n diagnostics,\n );\n if (selection === undefined) {\n continue;\n }\n\n const result = await executeOperation({\n api: selection.api,\n endpoint: selection.endpoint,\n input: preparedLoader.input,\n node: args.screen.root,\n operation: preparedLoader.loader.operation,\n });\n diagnostics.push(...(result.diagnostics ?? []));\n\n if (!result.ok) {\n continue;\n }\n\n operationResults[preparedLoader.operationKey] = result.data;\n }\n\n return {\n dependencyKey: args.plan.requestKey,\n diagnostics,\n operationResults,\n };\n })();\n}\n\nexport function useRuntimeScreenOperationLoaders(args: {\n readonly bindingContext?: Record<string, unknown>;\n readonly apis?: RuntimeBindingResolutionContext['apis'];\n readonly executeOperation?: RuntimeBindingOperationExecutor;\n readonly operationResults?: RuntimeBindingOperationResultCache;\n readonly onDiagnostics?: (diagnostics: readonly DataSourceDiagnostic[]) => void;\n readonly screen: ScreenSpec;\n}): RuntimeScreenOperationLoaderState {\n const loaders = React.useMemo(() => resolveScreenOperationLoaders(args.screen), [args.screen]);\n const hasLoaders = loaders.length > 0;\n const plan = React.useMemo(\n () =>\n createRuntimeScreenOperationLoaderPlan({\n bindingContext: args.bindingContext,\n loaders,\n operationResults: args.operationResults,\n screenId: args.screen.id,\n }),\n [args.bindingContext, args.operationResults, args.screen.id, loaders],\n );\n const { requestKey } = plan;\n const emptyState = React.useMemo(\n () =>\n createIdleRuntimeScreenOperationLoaderState({\n dependencyKey: requestKey,\n }),\n [requestKey],\n );\n const [state, setState] = React.useState<RuntimeScreenOperationLoaderState>(() =>\n hasLoaders\n ? createPendingRuntimeScreenOperationLoaderState({ dependencyKey: requestKey })\n : emptyState,\n );\n const effectiveState = hasLoaders ? state : emptyState;\n const lastDiagnosticsKeyRef = React.useRef<string | null>(null);\n const latestStateRef = React.useRef(state);\n const lifecycleRef = React.useRef<RuntimeScreenOperationLoaderLifecycle>(\n createRuntimeScreenOperationLoaderLifecycle(),\n );\n const executionArgsByRequestKeyRef = React.useRef<\n Record<string, RuntimeScreenPreparedExecutionArgs>\n >({});\n\n executionArgsByRequestKeyRef.current[requestKey] = {\n apis: args.apis,\n executeOperation: args.executeOperation,\n plan,\n screen: args.screen,\n };\n latestStateRef.current = state;\n\n React.useEffect(() => {\n const request = beginRuntimeScreenOperationLoaderRequest({\n hasLoaders,\n lifecycle: lifecycleRef.current,\n requestKey,\n state: latestStateRef.current,\n });\n\n lifecycleRef.current = request.lifecycle;\n\n if (request.state !== latestStateRef.current) {\n setState(request.state);\n }\n\n if (!request.shouldExecute || request.requestId === undefined) {\n return;\n }\n const { requestId } = request;\n\n void (async () => {\n const executionArgs = executionArgsByRequestKeyRef.current[requestKey];\n if (executionArgs === undefined) {\n return;\n }\n\n const result = await executePreparedRuntimeScreenOperationLoaders(executionArgs);\n\n setState((currentState) => {\n const completion = completeRuntimeScreenOperationLoaderRequest({\n lifecycle: lifecycleRef.current,\n requestId,\n result,\n state: currentState,\n });\n\n return completion.accepted ? completion.state : currentState;\n });\n })();\n }, [hasLoaders, requestKey]);\n\n React.useEffect(() => {\n if (effectiveState.diagnostics.length === 0) {\n return;\n }\n\n const diagnosticsKey = stableSerialize(effectiveState.diagnostics);\n if (lastDiagnosticsKeyRef.current === diagnosticsKey) {\n return;\n }\n\n lastDiagnosticsKeyRef.current = diagnosticsKey;\n args.onDiagnostics?.(effectiveState.diagnostics);\n }, [args.onDiagnostics, effectiveState.diagnostics]);\n\n return effectiveState;\n}\n\ninterface PreparedRuntimeScreenOperationLoader {\n readonly input?: BindingValue;\n readonly loader: OperationScreenDataLoaderDefinition;\n readonly operationKey: string;\n}\n\ninterface RuntimeScreenOperationLoaderPlan {\n readonly diagnostics: readonly DataSourceDiagnostic[];\n readonly loaders: readonly PreparedRuntimeScreenOperationLoader[];\n readonly requestKey: string;\n}\n\ninterface RuntimeScreenPreparedExecutionArgs {\n readonly apis?: RuntimeBindingResolutionContext['apis'];\n readonly executeOperation?: RuntimeBindingOperationExecutor;\n readonly plan: RuntimeScreenOperationLoaderPlan;\n readonly screen: ScreenSpec;\n}\n\nfunction createRuntimeScreenOperationLoaderPlan(args: {\n readonly bindingContext?: Record<string, unknown>;\n readonly loaders: readonly OperationScreenDataLoaderDefinition[];\n readonly operationResults?: RuntimeBindingOperationResultCache;\n readonly screenId: string;\n}): RuntimeScreenOperationLoaderPlan {\n if (args.loaders.length === 0) {\n return {\n diagnostics: EMPTY_RUNTIME_SCREEN_OPERATION_LOADER_DIAGNOSTICS,\n loaders: [],\n requestKey: createRuntimeScreenOperationLoaderIdleKey(args.screenId),\n };\n }\n\n const diagnostics: DataSourceDiagnostic[] = [];\n const preparedLoaders: PreparedRuntimeScreenOperationLoader[] = [];\n const operationKeys = new Set<string>();\n\n for (const loader of args.loaders) {\n const input = resolveBindingInputMapSync(\n loader.input,\n {\n context: args.bindingContext,\n operationResults: args.operationResults,\n },\n diagnostics,\n );\n const operationKey = createRuntimeBindingOperationKey(loader.operation);\n if (operationKeys.has(operationKey)) {\n diagnostics.push(\n createScreenOperationLoaderDiagnostic(\n loader,\n 'duplicate-operation-id',\n `Screen operation loaders must not reuse operation key '${operationKey}' on the same screen.`,\n ),\n );\n continue;\n }\n\n operationKeys.add(operationKey);\n preparedLoaders.push({\n input,\n loader,\n operationKey,\n });\n }\n\n return {\n diagnostics,\n loaders: preparedLoaders,\n requestKey: createRuntimeScreenOperationLoaderPlanRequestKey({\n loaders: preparedLoaders,\n screenId: args.screenId,\n }),\n };\n}\n\nfunction createRuntimeScreenOperationLoaderPlanRequestKey(args: {\n readonly loaders: readonly PreparedRuntimeScreenOperationLoader[];\n readonly screenId: string;\n}): string {\n return stableSerialize({\n loaders: args.loaders.map((loader) => ({\n id: loader.loader.id,\n input: loader.input,\n operation: loader.loader.operation,\n operationKey: loader.operationKey,\n })),\n screenId: args.screenId,\n });\n}\n\nfunction createScreenOperationLoaderDiagnostic(\n loader: OperationScreenDataLoaderDefinition,\n code: DataSourceDiagnostic['code'],\n message: string,\n): DataSourceDiagnostic {\n return {\n apiId: loader.operation.apiId,\n code,\n endpointId: loader.operation.endpointId,\n operationId: loader.operation.operationId,\n message,\n severity: 'error',\n };\n}\n\nfunction createRuntimeScreenOperationLoaderIdleKey(screenId: string): string {\n return `screen:${screenId}:no-operation-loaders`;\n}\n\nfunction stableSerialize(value: unknown): string {\n return JSON.stringify(sortSerializableValue(value));\n}\n\nfunction sortSerializableValue(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(sortSerializableValue);\n }\n\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n return Object.keys(value)\n .sort((left, right) => left.localeCompare(right))\n .reduce<Record<string, unknown>>((result, key) => {\n result[key] = sortSerializableValue((value as Record<string, unknown>)[key]);\n return result;\n }, {});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtimeScreenLoaders.js","sourceRoot":"","sources":["../src/runtimeScreenLoaders.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAI3B,MAAM,mBAAmB,CAAC;AAoB3B,MAAM,iDAAiD,GAAG,MAAM,CAAC,MAAM,CACrE,EAAE,CACgC,CAAC;AACrC,MAAM,sCAAsC,GAAG,MAAM,CAAC,MAAM,CAC1D,EAAE,CACmC,CAAC;A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,OAAO,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;SACtB,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;SAChD,MAAM,CAA0B,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QAC/C,MAAM,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7E,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC","sourcesContent":["import type {\n BindingValue,\n DataSourceDiagnostic,\n OperationScreenDataLoaderDefinition,\n ScreenSpec,\n} from '@ankhorage/contracts';\nimport React from 'react';\n\nimport { resolveRuntimeBindingOperationSelection } from './runtimeApiSelection';\nimport {\n createRuntimeBindingOperationKey,\n resolveBindingInputMapSync,\n type RuntimeBindingOperationExecutor,\n type RuntimeBindingOperationResultCache,\n type RuntimeBindingResolutionContext,\n} from './runtimeBindings';\n\nexport interface RuntimeScreenOperationLoaderState {\n readonly dependencyKey: string;\n readonly diagnostics: readonly DataSourceDiagnostic[];\n readonly operationResults: RuntimeBindingOperationResultCache;\n readonly renderVersion: number;\n}\n\nexport interface RuntimeScreenOperationLoaderExecutionResult {\n readonly dependencyKey: string;\n readonly diagnostics: readonly DataSourceDiagnostic[];\n readonly operationResults: RuntimeBindingOperationResultCache;\n}\n\nexport interface RuntimeScreenOperationLoaderLifecycle {\n readonly activeRequestId: number;\n readonly activeRequestKey: string | null;\n}\n\nconst EMPTY_RUNTIME_SCREEN_OPERATION_LOADER_DIAGNOSTICS = Object.freeze(\n [],\n) as readonly DataSourceDiagnostic[];\nconst EMPTY_RUNTIME_SCREEN_OPERATION_RESULTS = Object.freeze(\n {},\n) as RuntimeBindingOperationResultCache;\n\nexport function resolveScreenOperationLoaders(\n screen: ScreenSpec,\n): readonly OperationScreenDataLoaderDefinition[] {\n return screen.dataLoaders ?? [];\n}\n\nexport function createRuntimeScreenLoaderRequestKey(args: {\n readonly screenId: string;\n readonly loaders: readonly OperationScreenDataLoaderDefinition[];\n readonly bindingContext?: Record<string, unknown>;\n readonly operationResults?: RuntimeBindingOperationResultCache;\n}): string {\n return createRuntimeScreenOperationLoaderPlan({\n bindingContext: args.bindingContext,\n loaders: args.loaders,\n operationResults: args.operationResults,\n screenId: args.screenId,\n }).requestKey;\n}\n\nexport function createRuntimeScreenOperationLoaderLifecycle(): RuntimeScreenOperationLoaderLifecycle {\n return {\n activeRequestId: 0,\n activeRequestKey: null,\n };\n}\n\nexport function createIdleRuntimeScreenOperationLoaderState(args: {\n readonly dependencyKey: string;\n readonly previousState?: RuntimeScreenOperationLoaderState;\n}): RuntimeScreenOperationLoaderState {\n return {\n dependencyKey: args.dependencyKey,\n diagnostics: EMPTY_RUNTIME_SCREEN_OPERATION_LOADER_DIAGNOSTICS,\n operationResults: EMPTY_RUNTIME_SCREEN_OPERATION_RESULTS,\n renderVersion: args.previousState?.renderVersion ?? 0,\n };\n}\n\nexport function createPendingRuntimeScreenOperationLoaderState(args: {\n readonly dependencyKey: string;\n readonly previousState?: RuntimeScreenOperationLoaderState;\n}): RuntimeScreenOperationLoaderState {\n return {\n dependencyKey: args.dependencyKey,\n diagnostics: [],\n operationResults: {},\n renderVersion: (args.previousState?.renderVersion ?? -1) + 1,\n };\n}\n\nexport function beginRuntimeScreenOperationLoaderRequest(args: {\n readonly hasLoaders: boolean;\n readonly lifecycle: RuntimeScreenOperationLoaderLifecycle;\n readonly requestKey: string;\n readonly state: RuntimeScreenOperationLoaderState;\n}): {\n readonly lifecycle: RuntimeScreenOperationLoaderLifecycle;\n readonly requestId?: number;\n readonly shouldExecute: boolean;\n readonly state: RuntimeScreenOperationLoaderState;\n} {\n if (!args.hasLoaders) {\n if (args.lifecycle.activeRequestKey === null) {\n return {\n lifecycle: args.lifecycle,\n shouldExecute: false,\n state: args.state,\n };\n }\n\n return {\n lifecycle: {\n activeRequestId: args.lifecycle.activeRequestId + 1,\n activeRequestKey: null,\n },\n shouldExecute: false,\n state: args.state,\n };\n }\n\n if (args.lifecycle.activeRequestKey === args.requestKey) {\n return {\n lifecycle: args.lifecycle,\n shouldExecute: false,\n state: args.state,\n };\n }\n\n const requestId = args.lifecycle.activeRequestId + 1;\n\n return {\n lifecycle: {\n activeRequestId: requestId,\n activeRequestKey: args.requestKey,\n },\n requestId,\n shouldExecute: true,\n state:\n args.state.dependencyKey === args.requestKey\n ? args.state\n : createPendingRuntimeScreenOperationLoaderState({\n dependencyKey: args.requestKey,\n previousState: args.state,\n }),\n };\n}\n\nexport function completeRuntimeScreenOperationLoaderRequest(args: {\n readonly lifecycle: RuntimeScreenOperationLoaderLifecycle;\n readonly requestId: number;\n readonly result: RuntimeScreenOperationLoaderExecutionResult;\n readonly state: RuntimeScreenOperationLoaderState;\n}): {\n readonly accepted: boolean;\n readonly state: RuntimeScreenOperationLoaderState;\n} {\n if (args.lifecycle.activeRequestId !== args.requestId) {\n return {\n accepted: false,\n state: args.state,\n };\n }\n\n return {\n accepted: true,\n state: {\n dependencyKey: args.result.dependencyKey,\n diagnostics: args.result.diagnostics,\n operationResults: args.result.operationResults,\n renderVersion: args.state.renderVersion,\n },\n };\n}\n\nexport async function executeRuntimeScreenOperationLoaders(args: {\n readonly bindingContext?: Record<string, unknown>;\n readonly apis?: RuntimeBindingResolutionContext['apis'];\n readonly executeOperation?: RuntimeBindingOperationExecutor;\n readonly operationResults?: RuntimeBindingOperationResultCache;\n readonly screen: ScreenSpec;\n readonly loaders: readonly OperationScreenDataLoaderDefinition[];\n}): Promise<RuntimeScreenOperationLoaderExecutionResult> {\n const plan = createRuntimeScreenOperationLoaderPlan({\n bindingContext: args.bindingContext,\n loaders: args.loaders,\n operationResults: args.operationResults,\n screenId: args.screen.id,\n });\n\n return executePreparedRuntimeScreenOperationLoaders({\n apis: args.apis,\n executeOperation: args.executeOperation,\n plan,\n screen: args.screen,\n });\n}\n\nfunction executePreparedRuntimeScreenOperationLoaders(args: {\n readonly apis?: RuntimeBindingResolutionContext['apis'];\n readonly executeOperation?: RuntimeBindingOperationExecutor;\n readonly plan: RuntimeScreenOperationLoaderPlan;\n readonly screen: ScreenSpec;\n}): Promise<RuntimeScreenOperationLoaderExecutionResult> {\n const diagnostics: DataSourceDiagnostic[] = [...args.plan.diagnostics];\n\n if (args.plan.loaders.length === 0) {\n return Promise.resolve({\n dependencyKey: args.plan.requestKey,\n diagnostics,\n operationResults: {},\n });\n }\n\n if (args.executeOperation === undefined) {\n diagnostics.push(\n ...args.plan.loaders.map((preparedLoader) =>\n createScreenOperationLoaderDiagnostic(\n preparedLoader.loader,\n 'missing-adapter',\n 'Screen API operation loader requires an injected operation executor.',\n ),\n ),\n );\n\n return Promise.resolve({\n dependencyKey: args.plan.requestKey,\n diagnostics,\n operationResults: {},\n });\n }\n const { executeOperation } = args;\n\n return (async () => {\n const operationResults: Record<string, BindingValue | undefined> = {};\n\n for (const preparedLoader of args.plan.loaders) {\n const selection = resolveRuntimeBindingOperationSelection(\n preparedLoader.loader.operation,\n args.apis,\n diagnostics,\n );\n if (selection === undefined) {\n continue;\n }\n\n const result = await executeOperation({\n api: selection.api,\n endpoint: selection.endpoint,\n input: preparedLoader.input,\n node: args.screen.root,\n operation: preparedLoader.loader.operation,\n });\n diagnostics.push(...(result.diagnostics ?? []));\n\n if (!result.ok) {\n continue;\n }\n\n operationResults[preparedLoader.operationKey] = result.data;\n }\n\n return {\n dependencyKey: args.plan.requestKey,\n diagnostics,\n operationResults,\n };\n })();\n}\n\nexport function useRuntimeScreenOperationLoaders(args: {\n readonly bindingContext?: Record<string, unknown>;\n readonly apis?: RuntimeBindingResolutionContext['apis'];\n readonly executeOperation?: RuntimeBindingOperationExecutor;\n readonly operationResults?: RuntimeBindingOperationResultCache;\n readonly onDiagnostics?: (diagnostics: readonly DataSourceDiagnostic[]) => void;\n readonly screen: ScreenSpec;\n}): RuntimeScreenOperationLoaderState {\n const { apis, bindingContext, executeOperation, onDiagnostics, operationResults, screen } = args;\n const loaders = React.useMemo(() => resolveScreenOperationLoaders(screen), [screen]);\n const hasLoaders = loaders.length > 0;\n const plan = React.useMemo(\n () =>\n createRuntimeScreenOperationLoaderPlan({\n bindingContext,\n loaders,\n operationResults,\n screenId: screen.id,\n }),\n [bindingContext, loaders, operationResults, screen.id],\n );\n const { requestKey } = plan;\n const emptyState = React.useMemo(\n () =>\n createIdleRuntimeScreenOperationLoaderState({\n dependencyKey: requestKey,\n }),\n [requestKey],\n );\n const [state, setState] = React.useState<RuntimeScreenOperationLoaderState>(() =>\n hasLoaders\n ? createPendingRuntimeScreenOperationLoaderState({ dependencyKey: requestKey })\n : emptyState,\n );\n const pendingState = React.useMemo(\n () =>\n state.dependencyKey === requestKey\n ? state\n : createPendingRuntimeScreenOperationLoaderState({\n dependencyKey: requestKey,\n previousState: state,\n }),\n [requestKey, state],\n );\n const effectiveState = hasLoaders ? pendingState : emptyState;\n const lastDiagnosticsKeyRef = React.useRef<string | null>(null);\n const lifecycleRef = React.useRef<RuntimeScreenOperationLoaderLifecycle>(\n createRuntimeScreenOperationLoaderLifecycle(),\n );\n\n React.useEffect(() => {\n const request = beginRuntimeScreenOperationLoaderRequest({\n hasLoaders,\n lifecycle: lifecycleRef.current,\n requestKey,\n state,\n });\n\n lifecycleRef.current = request.lifecycle;\n\n if (!request.shouldExecute || request.requestId === undefined) {\n return;\n }\n const { requestId } = request;\n\n void (async () => {\n const result = await executePreparedRuntimeScreenOperationLoaders({\n apis,\n executeOperation,\n plan,\n screen,\n });\n\n setState((currentState) => {\n const completion = completeRuntimeScreenOperationLoaderRequest({\n lifecycle: lifecycleRef.current,\n requestId,\n result,\n state: currentState.dependencyKey === requestKey ? currentState : request.state,\n });\n\n return completion.accepted ? completion.state : currentState;\n });\n })();\n }, [apis, executeOperation, hasLoaders, plan, requestKey, screen, state]);\n\n React.useEffect(() => {\n if (effectiveState.diagnostics.length === 0) {\n return;\n }\n\n const diagnosticsKey = stableSerialize(effectiveState.diagnostics);\n if (lastDiagnosticsKeyRef.current === diagnosticsKey) {\n return;\n }\n\n lastDiagnosticsKeyRef.current = diagnosticsKey;\n onDiagnostics?.(effectiveState.diagnostics);\n }, [effectiveState.diagnostics, onDiagnostics]);\n\n return effectiveState;\n}\n\ninterface PreparedRuntimeScreenOperationLoader {\n readonly input?: BindingValue;\n readonly loader: OperationScreenDataLoaderDefinition;\n readonly operationKey: string;\n}\n\ninterface RuntimeScreenOperationLoaderPlan {\n readonly diagnostics: readonly DataSourceDiagnostic[];\n readonly loaders: readonly PreparedRuntimeScreenOperationLoader[];\n readonly requestKey: string;\n}\n\nfunction createRuntimeScreenOperationLoaderPlan(args: {\n readonly bindingContext?: Record<string, unknown>;\n readonly loaders: readonly OperationScreenDataLoaderDefinition[];\n readonly operationResults?: RuntimeBindingOperationResultCache;\n readonly screenId: string;\n}): RuntimeScreenOperationLoaderPlan {\n if (args.loaders.length === 0) {\n return {\n diagnostics: EMPTY_RUNTIME_SCREEN_OPERATION_LOADER_DIAGNOSTICS,\n loaders: [],\n requestKey: createRuntimeScreenOperationLoaderIdleKey(args.screenId),\n };\n }\n\n const diagnostics: DataSourceDiagnostic[] = [];\n const preparedLoaders: PreparedRuntimeScreenOperationLoader[] = [];\n const operationKeys = new Set<string>();\n\n for (const loader of args.loaders) {\n const input = resolveBindingInputMapSync(\n loader.input,\n {\n context: args.bindingContext,\n operationResults: args.operationResults,\n },\n diagnostics,\n );\n const operationKey = createRuntimeBindingOperationKey(loader.operation);\n if (operationKeys.has(operationKey)) {\n diagnostics.push(\n createScreenOperationLoaderDiagnostic(\n loader,\n 'duplicate-operation-id',\n `Screen operation loaders must not reuse operation key '${operationKey}' on the same screen.`,\n ),\n );\n continue;\n }\n\n operationKeys.add(operationKey);\n preparedLoaders.push({\n input,\n loader,\n operationKey,\n });\n }\n\n return {\n diagnostics,\n loaders: preparedLoaders,\n requestKey: createRuntimeScreenOperationLoaderPlanRequestKey({\n loaders: preparedLoaders,\n screenId: args.screenId,\n }),\n };\n}\n\nfunction createRuntimeScreenOperationLoaderPlanRequestKey(args: {\n readonly loaders: readonly PreparedRuntimeScreenOperationLoader[];\n readonly screenId: string;\n}): string {\n return stableSerialize({\n loaders: args.loaders.map((loader) => ({\n id: loader.loader.id,\n input: loader.input,\n operation: loader.loader.operation,\n operationKey: loader.operationKey,\n })),\n screenId: args.screenId,\n });\n}\n\nfunction createScreenOperationLoaderDiagnostic(\n loader: OperationScreenDataLoaderDefinition,\n code: DataSourceDiagnostic['code'],\n message: string,\n): DataSourceDiagnostic {\n return {\n apiId: loader.operation.apiId,\n code,\n endpointId: loader.operation.endpointId,\n operationId: loader.operation.operationId,\n message,\n severity: 'error',\n };\n}\n\nfunction createRuntimeScreenOperationLoaderIdleKey(screenId: string): string {\n return `screen:${screenId}:no-operation-loaders`;\n}\n\nfunction stableSerialize(value: unknown): string {\n return JSON.stringify(sortSerializableValue(value));\n}\n\nfunction sortSerializableValue(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(sortSerializableValue);\n }\n\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n return Object.keys(value)\n .sort((left, right) => left.localeCompare(right))\n .reduce<Record<string, unknown>>((result, key) => {\n result[key] = sortSerializableValue((value as Record<string, unknown>)[key]);\n return result;\n }, {});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRuntimeMediaProps.d.ts","sourceRoot":"","sources":["../src/useRuntimeMediaProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAKL,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAEjC,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,yBAAyB,CAAC;IACvD,QAAQ,CAAC,KAAK,EAAE,2BAA2B,CAAC;CAC7C,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"useRuntimeMediaProps.d.ts","sourceRoot":"","sources":["../src/useRuntimeMediaProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAKL,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAEjC,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,yBAAyB,CAAC;IACvD,QAAQ,CAAC,KAAK,EAAE,2BAA2B,CAAC;CAC7C,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA2C1B"}
|
|
@@ -3,12 +3,10 @@ import { collectRuntimeMediaReferenceIds, createSyncRuntimeMediaResolutionMap, r
|
|
|
3
3
|
export function useRuntimeMediaProps(args) {
|
|
4
4
|
const ids = collectRuntimeMediaReferenceIds(args.props);
|
|
5
5
|
const idsKey = ids.join('\u0000');
|
|
6
|
-
const [asyncResolved, setAsyncResolved] = React.useState(() => new Map());
|
|
6
|
+
const [asyncResolved, setAsyncResolved] = React.useState(() => ({ idsKey, values: new Map() }));
|
|
7
7
|
React.useEffect(() => {
|
|
8
8
|
let active = true;
|
|
9
9
|
const effectIds = idsKey.length === 0 ? [] : idsKey.split('\u0000');
|
|
10
|
-
const currentIds = new Set(effectIds);
|
|
11
|
-
setAsyncResolved((current) => filterResolvedValues(current, currentIds));
|
|
12
10
|
for (const id of effectIds) {
|
|
13
11
|
const asset = args.mediaAssets?.[id];
|
|
14
12
|
if (!asset || asset.source.kind === 'url')
|
|
@@ -17,11 +15,12 @@ export function useRuntimeMediaProps(args) {
|
|
|
17
15
|
if (!active || value === null)
|
|
18
16
|
return;
|
|
19
17
|
setAsyncResolved((current) => {
|
|
20
|
-
|
|
18
|
+
const currentValues = current.idsKey === idsKey ? current.values : new Map();
|
|
19
|
+
if (currentValues.get(id) === value)
|
|
21
20
|
return current;
|
|
22
|
-
const next = new Map(
|
|
21
|
+
const next = new Map(currentValues);
|
|
23
22
|
next.set(id, value);
|
|
24
|
-
return next;
|
|
23
|
+
return { idsKey, values: next };
|
|
25
24
|
});
|
|
26
25
|
});
|
|
27
26
|
}
|
|
@@ -31,30 +30,15 @@ export function useRuntimeMediaProps(args) {
|
|
|
31
30
|
}, [args.cache, args.mediaAssets, args.resolveMediaAsset, idsKey]);
|
|
32
31
|
const resolved = createSyncRuntimeMediaResolutionMap(ids, args.mediaAssets);
|
|
33
32
|
const currentIds = new Set(ids);
|
|
34
|
-
asyncResolved.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
if (asyncResolved.idsKey === idsKey) {
|
|
34
|
+
asyncResolved.values.forEach((value, id) => {
|
|
35
|
+
if (currentIds.has(id))
|
|
36
|
+
resolved.set(id, value);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
38
39
|
const replaced = replaceRuntimeMediaReferences(args.props, resolved);
|
|
39
40
|
return isRecord(replaced) ? replaced : {};
|
|
40
41
|
}
|
|
41
|
-
function filterResolvedValues(current, ids) {
|
|
42
|
-
const next = new Map();
|
|
43
|
-
current.forEach((value, id) => {
|
|
44
|
-
if (ids.has(id))
|
|
45
|
-
next.set(id, value);
|
|
46
|
-
});
|
|
47
|
-
return mapsEqual(current, next) ? current : next;
|
|
48
|
-
}
|
|
49
|
-
function mapsEqual(left, right) {
|
|
50
|
-
if (left.size !== right.size)
|
|
51
|
-
return false;
|
|
52
|
-
for (const [key, value] of left) {
|
|
53
|
-
if (right.get(key) !== value)
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
42
|
function isRecord(value) {
|
|
59
43
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
60
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRuntimeMediaProps.js","sourceRoot":"","sources":["../src/useRuntimeMediaProps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,+BAA+B,EAC/B,mCAAmC,EACnC,6BAA6B,EAC7B,wBAAwB,GAIzB,MAAM,gBAAgB,CAAC;AAExB,MAAM,UAAU,oBAAoB,CAAC,IAKpC;IACC,MAAM,GAAG,GAAG,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"useRuntimeMediaProps.js","sourceRoot":"","sources":["../src/useRuntimeMediaProps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,+BAA+B,EAC/B,mCAAmC,EACnC,6BAA6B,EAC7B,wBAAwB,GAIzB,MAAM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esContent":["import type { MediaAssetRegistry } from '@ankhorage/contracts';\nimport React from 'react';\n\nimport {\n collectRuntimeMediaReferenceIds,\n createSyncRuntimeMediaResolutionMap,\n replaceRuntimeMediaReferences,\n resolveRuntimeMediaAsset,\n type RuntimeMediaAssetResolver,\n type RuntimeMediaResolutionCache,\n type RuntimeResolvedMediaValue,\n} from './runtimeMedia';\n\nexport function useRuntimeMediaProps(args: {\n readonly props: Record<string, unknown>;\n readonly mediaAssets?: MediaAssetRegistry;\n readonly resolveMediaAsset?: RuntimeMediaAssetResolver;\n readonly cache: RuntimeMediaResolutionCache;\n}): Record<string, unknown> {\n const ids = collectRuntimeMediaReferenceIds(args.props);\n const idsKey = ids.join('\\u0000');\n const [asyncResolved, setAsyncResolved] = React.useState<{\n readonly idsKey: string;\n readonly values: ReadonlyMap<string, RuntimeResolvedMediaValue>;\n }>(() => ({ idsKey, values: new Map() }));\n\n React.useEffect(() => {\n let active = true;\n const effectIds = idsKey.length === 0 ? [] : idsKey.split('\\u0000');\n\n for (const id of effectIds) {\n const asset = args.mediaAssets?.[id];\n if (!asset || asset.source.kind === 'url') continue;\n\n void resolveRuntimeMediaAsset(asset, args.resolveMediaAsset, args.cache).then((value) => {\n if (!active || value === null) return;\n setAsyncResolved((current) => {\n const currentValues = current.idsKey === idsKey ? current.values : new Map();\n if (currentValues.get(id) === value) return current;\n const next = new Map(currentValues);\n next.set(id, value);\n return { idsKey, values: next };\n });\n });\n }\n\n return () => {\n active = false;\n };\n }, [args.cache, args.mediaAssets, args.resolveMediaAsset, idsKey]);\n\n const resolved = createSyncRuntimeMediaResolutionMap(ids, args.mediaAssets);\n const currentIds = new Set(ids);\n if (asyncResolved.idsKey === idsKey) {\n asyncResolved.values.forEach((value, id) => {\n if (currentIds.has(id)) resolved.set(id, value);\n });\n }\n\n const replaced = replaceRuntimeMediaReferences(args.props, resolved);\n return isRecord(replaced) ? replaced : {};\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/runtime",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Platform-neutral runtime renderer, contracts, and helpers for Ankhorage generated apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": "24.x"
|
|
8
|
+
},
|
|
6
9
|
"publishConfig": {
|
|
7
10
|
"access": "public"
|
|
8
11
|
},
|
|
@@ -68,19 +71,28 @@
|
|
|
68
71
|
"@ankhorage/data-sources": "^2.0.0"
|
|
69
72
|
},
|
|
70
73
|
"peerDependencies": {
|
|
71
|
-
"react": "19.
|
|
72
|
-
"react-native": "0.
|
|
74
|
+
"react": "19.2.3",
|
|
75
|
+
"react-native": "0.86.2",
|
|
76
|
+
"react-native-web": "~0.21.0"
|
|
77
|
+
},
|
|
78
|
+
"peerDependenciesMeta": {
|
|
79
|
+
"react-native-web": {
|
|
80
|
+
"optional": true
|
|
81
|
+
}
|
|
73
82
|
},
|
|
74
83
|
"devDependencies": {
|
|
75
|
-
"@ankhorage/devtools": "^1.
|
|
84
|
+
"@ankhorage/devtools": "^1.6.0",
|
|
76
85
|
"@ankhorage/paradox": "^0.1.21",
|
|
77
86
|
"@changesets/cli": "^2.31.0",
|
|
78
87
|
"@types/bun": "^1.3.14",
|
|
79
|
-
"@types/node": "^
|
|
80
|
-
"@types/react": "^19.2.
|
|
81
|
-
"react": "19.
|
|
82
|
-
"react
|
|
83
|
-
"
|
|
88
|
+
"@types/node": "^24.13.3",
|
|
89
|
+
"@types/react": "^19.2.18",
|
|
90
|
+
"@types/react-dom": "^19.2.4",
|
|
91
|
+
"react": "19.2.3",
|
|
92
|
+
"react-dom": "19.2.3",
|
|
93
|
+
"react-native": "0.86.2",
|
|
94
|
+
"react-native-web": "~0.21.0",
|
|
95
|
+
"typescript": "~6.0.3"
|
|
84
96
|
},
|
|
85
97
|
"sideEffects": false,
|
|
86
98
|
"packageManager": "bun@1.3.14"
|
package/paradox/badges/npm.svg
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="90" height="20" role="img" aria-label="npm:
|
|
2
|
-
<title>npm:
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="90" height="20" role="img" aria-label="npm: v2.1.0">
|
|
2
|
+
<title>npm: v2.1.0</title>
|
|
3
3
|
<rect width="38" height="20" fill="#374151"/>
|
|
4
4
|
<rect x="38" width="52" height="20" fill="#cb3837"/>
|
|
5
5
|
<text x="19" y="14" fill="#ffffff" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11" text-anchor="middle">npm</text>
|
|
6
|
-
<text x="64" y="14" fill="#ffffff" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11" text-anchor="middle">
|
|
6
|
+
<text x="64" y="14" fill="#ffffff" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11" text-anchor="middle">v2.1.0</text>
|
|
7
7
|
</svg>
|
package/paradox/components.md
CHANGED
|
@@ -4,11 +4,20 @@ graph TD
|
|
|
4
4
|
package__ankhorage_runtime --> entrypoint_src_index_ts
|
|
5
5
|
module_paradox_config_ts["paradox.config.ts"]
|
|
6
6
|
package__ankhorage_runtime -.-> module_paradox_config_ts
|
|
7
|
+
module_src_bindings_test_ts["src/bindings.test.ts"]
|
|
8
|
+
package__ankhorage_runtime -.-> module_src_bindings_test_ts
|
|
9
|
+
module_src_bindings_test_ts --> module_src_bindings_ts
|
|
10
|
+
module_src_bindings_ts["src/bindings.ts"]
|
|
11
|
+
package__ankhorage_runtime -.-> module_src_bindings_ts
|
|
7
12
|
module_src_componentRegistry_ts["src/componentRegistry.ts"]
|
|
8
13
|
package__ankhorage_runtime -.-> module_src_componentRegistry_ts
|
|
9
14
|
module_src_index_ts["src/index.ts"]
|
|
10
15
|
module_src_ManifestContext_tsx["src/ManifestContext.tsx"]
|
|
11
16
|
package__ankhorage_runtime -.-> module_src_ManifestContext_tsx
|
|
17
|
+
module_src_react19Compatibility_test_tsx["src/react19Compatibility.test.tsx"]
|
|
18
|
+
package__ankhorage_runtime -.-> module_src_react19Compatibility_test_tsx
|
|
19
|
+
module_src_react19Compatibility_test_tsx --> module_src_ManifestContext_tsx
|
|
20
|
+
module_src_react19Compatibility_test_tsx --> module_src_RuntimeRendererConfig_tsx
|
|
12
21
|
module_src_registry_test_ts["src/registry.test.ts"]
|
|
13
22
|
package__ankhorage_runtime -.-> module_src_registry_test_ts
|
|
14
23
|
module_src_registry_test_ts --> module_src_registry_tsx
|
|
@@ -164,6 +173,11 @@ graph TD
|
|
|
164
173
|
module_src_useRuntimeMediaProps_ts["src/useRuntimeMediaProps.ts"]
|
|
165
174
|
package__ankhorage_runtime -.-> module_src_useRuntimeMediaProps_ts
|
|
166
175
|
module_src_useRuntimeMediaProps_ts --> module_src_runtimeMedia_ts
|
|
176
|
+
module_tests_reactNativeWebCompatibility_fixture_tsx["tests/reactNativeWebCompatibility.fixture.tsx"]
|
|
177
|
+
package__ankhorage_runtime -.-> module_tests_reactNativeWebCompatibility_fixture_tsx
|
|
178
|
+
module_tests_reactNativeWebCompatibility_fixture_tsx --> module_src_RuntimeRenderer_tsx
|
|
179
|
+
module_tests_reactNativeWebCompatibility_test_ts["tests/reactNativeWebCompatibility.test.ts"]
|
|
180
|
+
package__ankhorage_runtime -.-> module_tests_reactNativeWebCompatibility_test_ts
|
|
167
181
|
module_tests_runtime_test_ts["tests/runtime.test.ts"]
|
|
168
182
|
package__ankhorage_runtime -.-> module_tests_runtime_test_ts
|
|
169
183
|
module_tests_runtime_test_ts --> module_src_runtimeManifest_ts
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
graph LR
|
|
2
2
|
module_paradox_config_ts["paradox.config.ts"]
|
|
3
|
+
module_src_bindings_test_ts["src/bindings.test.ts"]
|
|
4
|
+
module_src_bindings_ts["src/bindings.ts"]
|
|
3
5
|
module_src_componentRegistry_ts["src/componentRegistry.ts"]
|
|
4
6
|
module_src_index_ts["src/index.ts"]
|
|
5
7
|
module_src_ManifestContext_tsx["src/ManifestContext.tsx"]
|
|
8
|
+
module_src_react19Compatibility_test_tsx["src/react19Compatibility.test.tsx"]
|
|
6
9
|
module_src_registry_test_ts["src/registry.test.ts"]
|
|
7
10
|
module_src_registry_tsx["src/registry.tsx"]
|
|
8
11
|
module_src_rendering_test_ts["src/rendering.test.ts"]
|
|
@@ -45,6 +48,8 @@ graph LR
|
|
|
45
48
|
module_src_runtimeStateAdapter_ts["src/runtimeStateAdapter.ts"]
|
|
46
49
|
module_src_runtimeStateAdapterConfig_test_ts["src/runtimeStateAdapterConfig.test.ts"]
|
|
47
50
|
module_src_useRuntimeMediaProps_ts["src/useRuntimeMediaProps.ts"]
|
|
51
|
+
module_tests_reactNativeWebCompatibility_fixture_tsx["tests/reactNativeWebCompatibility.fixture.tsx"]
|
|
52
|
+
module_tests_reactNativeWebCompatibility_test_ts["tests/reactNativeWebCompatibility.test.ts"]
|
|
48
53
|
module_tests_runtime_test_ts["tests/runtime.test.ts"]
|
|
49
54
|
export_ComponentRegistry["ComponentRegistry"]
|
|
50
55
|
module_src_componentRegistry_ts --> export_ComponentRegistry
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
graph LR
|
|
2
2
|
module_paradox_config_ts["paradox.config.ts"]
|
|
3
|
+
module_src_bindings_test_ts["src/bindings.test.ts"]
|
|
4
|
+
module_src_bindings_ts["src/bindings.ts"]
|
|
3
5
|
module_src_componentRegistry_ts["src/componentRegistry.ts"]
|
|
4
6
|
module_src_index_ts["src/index.ts"]
|
|
5
7
|
module_src_ManifestContext_tsx["src/ManifestContext.tsx"]
|
|
8
|
+
module_src_react19Compatibility_test_tsx["src/react19Compatibility.test.tsx"]
|
|
6
9
|
module_src_registry_test_ts["src/registry.test.ts"]
|
|
7
10
|
module_src_registry_tsx["src/registry.tsx"]
|
|
8
11
|
module_src_rendering_test_ts["src/rendering.test.ts"]
|
|
@@ -45,7 +48,12 @@ graph LR
|
|
|
45
48
|
module_src_runtimeStateAdapter_ts["src/runtimeStateAdapter.ts"]
|
|
46
49
|
module_src_runtimeStateAdapterConfig_test_ts["src/runtimeStateAdapterConfig.test.ts"]
|
|
47
50
|
module_src_useRuntimeMediaProps_ts["src/useRuntimeMediaProps.ts"]
|
|
51
|
+
module_tests_reactNativeWebCompatibility_fixture_tsx["tests/reactNativeWebCompatibility.fixture.tsx"]
|
|
52
|
+
module_tests_reactNativeWebCompatibility_test_ts["tests/reactNativeWebCompatibility.test.ts"]
|
|
48
53
|
module_tests_runtime_test_ts["tests/runtime.test.ts"]
|
|
54
|
+
module_src_bindings_test_ts --> module_src_bindings_ts
|
|
55
|
+
module_src_react19Compatibility_test_tsx --> module_src_ManifestContext_tsx
|
|
56
|
+
module_src_react19Compatibility_test_tsx --> module_src_RuntimeRendererConfig_tsx
|
|
49
57
|
module_src_registry_test_ts --> module_src_registry_tsx
|
|
50
58
|
module_src_rendering_test_ts --> module_src_registry_tsx
|
|
51
59
|
module_src_rendering_test_ts --> module_src_rendering_ts
|
|
@@ -117,4 +125,5 @@ graph LR
|
|
|
117
125
|
module_src_runtimeStateAdapterConfig_test_ts --> module_src_runtimeNodeProps_ts
|
|
118
126
|
module_src_runtimeStateAdapterConfig_test_ts --> module_src_RuntimeRendererConfig_tsx
|
|
119
127
|
module_src_useRuntimeMediaProps_ts --> module_src_runtimeMedia_ts
|
|
128
|
+
module_tests_reactNativeWebCompatibility_fixture_tsx --> module_src_RuntimeRenderer_tsx
|
|
120
129
|
module_tests_runtime_test_ts --> module_src_runtimeManifest_ts
|
|
@@ -4,9 +4,9 @@ sequenceDiagram
|
|
|
4
4
|
participant participant_mergeRecordConfig as mergeRecordConfig
|
|
5
5
|
participant participant_mergeRuntimeRendererConfig as mergeRuntimeRendererConfig
|
|
6
6
|
participant participant_RuntimeRendererConfigProvider as RuntimeRendererConfigProvider
|
|
7
|
-
participant
|
|
8
|
-
participant_RuntimeRendererConfigProvider->>
|
|
9
|
-
|
|
7
|
+
participant participant_use as use
|
|
8
|
+
participant_RuntimeRendererConfigProvider->>participant_use: use()
|
|
9
|
+
participant_use-->>participant_RuntimeRendererConfigProvider: return
|
|
10
10
|
participant_RuntimeRendererConfigProvider->>participant_mergeRuntimeRendererConfig: mergeRuntimeRendererConfig()
|
|
11
11
|
participant_mergeRuntimeRendererConfig->>participant_mergeRecordConfig: mergeRecordConfig()
|
|
12
12
|
participant_mergeRecordConfig-->>participant_mergeRuntimeRendererConfig: return
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
sequenceDiagram
|
|
2
2
|
participant participant_createRuntimeScreenOperationLoaderLifecycle as createRuntimeScreenOperationLoaderLifecycle
|
|
3
3
|
participant participant_RuntimeScreen as RuntimeScreen
|
|
4
|
-
participant
|
|
4
|
+
participant participant_use as use
|
|
5
5
|
participant participant_useRuntimeRendererConfig as useRuntimeRendererConfig
|
|
6
6
|
participant participant_useRuntimeScreenOperationLoaders as useRuntimeScreenOperationLoaders
|
|
7
7
|
participant_RuntimeScreen->>participant_useRuntimeRendererConfig: useRuntimeRendererConfig()
|
|
8
|
-
participant_useRuntimeRendererConfig->>
|
|
9
|
-
|
|
8
|
+
participant_useRuntimeRendererConfig->>participant_use: use()
|
|
9
|
+
participant_use-->>participant_useRuntimeRendererConfig: return
|
|
10
10
|
participant_useRuntimeRendererConfig-->>participant_RuntimeScreen: return
|
|
11
11
|
participant_RuntimeScreen->>participant_useRuntimeScreenOperationLoaders: useRuntimeScreenOperationLoaders()
|
|
12
12
|
participant_useRuntimeScreenOperationLoaders->>participant_createRuntimeScreenOperationLoaderLifecycle: createRuntimeScreenOperationLoaderLifecycle()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sequenceDiagram
|
|
2
|
-
participant
|
|
2
|
+
participant participant_use as use
|
|
3
3
|
participant participant_useManifestContext as useManifestContext
|
|
4
|
-
participant_useManifestContext->>
|
|
5
|
-
|
|
4
|
+
participant_useManifestContext->>participant_use: use()
|
|
5
|
+
participant_use-->>participant_useManifestContext: return
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sequenceDiagram
|
|
2
|
-
participant
|
|
2
|
+
participant participant_use as use
|
|
3
3
|
participant participant_useManifest as useManifest
|
|
4
|
-
participant_useManifest->>
|
|
5
|
-
|
|
4
|
+
participant_useManifest->>participant_use: use()
|
|
5
|
+
participant_use-->>participant_useManifest: return
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sequenceDiagram
|
|
2
|
-
participant
|
|
2
|
+
participant participant_use as use
|
|
3
3
|
participant participant_useOptionalManifestContext as useOptionalManifestContext
|
|
4
|
-
participant_useOptionalManifestContext->>
|
|
5
|
-
|
|
4
|
+
participant_useOptionalManifestContext->>participant_use: use()
|
|
5
|
+
participant_use-->>participant_useOptionalManifestContext: return
|