@player-ui/async-node-plugin 1.1.0-next.5 → 1.1.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/dist/AsyncNodePlugin.native.js +11 -7
- package/dist/AsyncNodePlugin.native.js.map +1 -1
- package/dist/cjs/index.cjs +12 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +12 -3
- package/dist/index.mjs +12 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/index.test.ts +137 -0
- package/src/index.ts +20 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -451,14 +451,23 @@ var AsyncNodePluginPlugin = class {
|
|
|
451
451
|
}
|
|
452
452
|
async runAsyncNode(node, context, options) {
|
|
453
453
|
try {
|
|
454
|
+
let deliveredViaCallback = false;
|
|
454
455
|
const result = await this.basePlugin?.hooks.onAsyncNode.call(
|
|
455
456
|
node,
|
|
456
|
-
(
|
|
457
|
-
|
|
457
|
+
(streamedResult) => {
|
|
458
|
+
deliveredViaCallback = true;
|
|
459
|
+
this.parseNodeAndUpdate(
|
|
460
|
+
node,
|
|
461
|
+
context,
|
|
462
|
+
streamedResult,
|
|
463
|
+
options.parseNode
|
|
464
|
+
);
|
|
458
465
|
}
|
|
459
466
|
);
|
|
460
467
|
context.inProgressNodes.delete(node.id);
|
|
461
|
-
|
|
468
|
+
if (!deliveredViaCallback && result != null) {
|
|
469
|
+
this.parseNodeAndUpdate(node, context, result, options.parseNode);
|
|
470
|
+
}
|
|
462
471
|
} catch (e) {
|
|
463
472
|
const cause = e instanceof Error ? e : new Error(String(e));
|
|
464
473
|
const playerState = this.basePlugin?.getPlayerInstance()?.getState();
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/AsyncNodeError.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/extractNodeFromPath.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/traverseAndReplace.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/unwrapAsset.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/requiresAssetWrapper.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/isAsyncPlayerError.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/getNodeFromError.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/createAsyncTransform.ts"],"sourcesContent":["import { NodeType, getNodeID } from \"@player-ui/player\";\nimport type {\n Player,\n PlayerPlugin,\n Node,\n ParseObjectOptions,\n ParseObjectChildOptions,\n ViewInstance,\n Parser,\n ViewPlugin,\n Resolver,\n Resolve,\n} from \"@player-ui/player\";\nimport { AsyncSeriesBailHook, SyncBailHook } from \"tapable-ts\";\nimport queueMicrotask from \"queue-microtask\";\nimport { AsyncNodeError } from \"./AsyncNodeError\";\nimport { AsyncNodeInfo, AsyncPluginContext } from \"./internal-types\";\nimport { getNodeFromError } from \"./utils\";\n\nexport * from \"./types\";\nexport * from \"./transform\";\nexport * from \"./createAsyncTransform\";\n\nexport interface AsyncNodePluginOptions {\n /** A set of plugins to load */\n plugins?: AsyncNodeViewPlugin[];\n}\n\nexport interface AsyncNodeViewPlugin extends ViewPlugin {\n /** Use this to tap into the async node plugin hooks */\n applyPlugin: (asyncNodePlugin: AsyncNodePlugin) => void;\n\n applyPlayer?: (player: Player) => void;\n}\nexport type AsyncHandler = (\n node: Node.Async,\n callback?: (result: any) => void,\n) => Promise<any>;\n\nexport type AsyncContent = {\n async: true;\n flatten?: boolean;\n [key: string]: unknown;\n};\n\n/** Hook declaration for the AsyncNodePlugin */\nexport type AsyncNodeHooks = {\n /** Async hook to get content for an async node */\n onAsyncNode: AsyncSeriesBailHook<[Node.Async, (result: any) => void], any>;\n /** Sync hook to manage errors coming from the onAsyncNode hook. Return a fallback node or null to render a fallback. The first argument of passed in the call is the error thrown. */\n onAsyncNodeError: SyncBailHook<[Error, Node.Async], any>;\n};\n\nexport const AsyncNodePluginSymbol: symbol = Symbol.for(\"AsyncNodePlugin\");\n\n/**\n * Async node plugin used to resolve async nodes in the content\n * If an async node is present, allow users to provide a replacement node to be rendered when ready\n */\nexport class AsyncNodePlugin implements PlayerPlugin {\n private plugins: AsyncNodeViewPlugin[] | undefined;\n private playerInstance: Player | undefined;\n\n static Symbol: symbol = AsyncNodePluginSymbol;\n public readonly symbol: symbol = AsyncNodePlugin.Symbol;\n\n constructor(options: AsyncNodePluginOptions, asyncHandler?: AsyncHandler) {\n if (options?.plugins) {\n this.plugins = options.plugins;\n options.plugins.forEach((plugin) => {\n plugin.applyPlugin(this);\n });\n }\n\n if (asyncHandler) {\n this.hooks.onAsyncNode.tap(\n \"async\",\n async (node: Node.Async, callback) => {\n return await asyncHandler(node, callback);\n },\n );\n }\n }\n\n public readonly hooks: AsyncNodeHooks = {\n onAsyncNode: new AsyncSeriesBailHook(),\n onAsyncNodeError: new SyncBailHook(),\n };\n\n getPlayerInstance(): Player | undefined {\n return this.playerInstance;\n }\n\n name = \"AsyncNode\";\n\n apply(player: Player): void {\n this.playerInstance = player;\n\n this.plugins?.forEach((plugin) => {\n plugin.applyPlayer?.(player);\n });\n\n player.hooks.viewController.tap(this.name, (viewController) => {\n viewController.hooks.view.tap(this.name, (view) => {\n this.plugins?.forEach((plugin) => {\n plugin.apply(view);\n });\n });\n });\n }\n}\n\nexport class AsyncNodePluginPlugin implements AsyncNodeViewPlugin {\n private basePlugin: AsyncNodePlugin | undefined;\n\n name = \"AsyncNode\";\n\n /**\n * Parses the node from the result and triggers an asynchronous view update if necessary.\n * @param node The asynchronous node that might be updated.\n * @param result The result obtained from resolving the async node. This could be any data structure or value.\n * @param options Options provided for node resolution, including a potential parseNode function to process the result.\n * @param view The view instance where the node resides. This can be undefined if the view is not currently active.\n */\n private parseNodeAndUpdate(\n node: Node.Async,\n context: AsyncPluginContext,\n result: any,\n parseFunction?: (content: any) => Node.Node | null,\n ) {\n let parsedNode =\n parseFunction && result ? parseFunction(result) : undefined;\n\n if (parsedNode && node.onValueReceived) {\n parsedNode = node.onValueReceived(parsedNode);\n }\n\n this.handleAsyncUpdate(node, context, parsedNode);\n }\n\n /**\n * Updates the node asynchronously based on the result provided.\n * This method is responsible for handling the update logic of asynchronous nodes.\n * It checks if the node needs to be updated based on the new result and updates the mapping accordingly.\n * If an update is necessary, it triggers an asynchronous update on the view.\n * @param node The asynchronous node that might be updated.\n * @param newNode The new node to replace the async node.\n * @param view The view instance where the node resides. This can be undefined if the view is not currently active.\n */\n private handleAsyncUpdate(\n node: Node.Async,\n context: AsyncPluginContext,\n newNode?: Node.Node | null,\n ) {\n const { asyncNodeCache: asyncNodeInfo, viewController } = context;\n const entry = asyncNodeInfo.get(node.id);\n if (!entry) {\n throw new Error(\"Failed to update async content. Cache entry not found\");\n }\n if (entry.resolvedContent !== newNode) {\n entry.resolvedContent = newNode ? newNode : entry.asyncNode;\n viewController.updateViewAST(entry.updateNodes);\n }\n }\n\n private hasValidMapping(\n cacheEntry: AsyncNodeInfo,\n ): cacheEntry is Required<AsyncNodeInfo> {\n return (\n cacheEntry.resolvedContent !== undefined &&\n cacheEntry.resolvedContent !== cacheEntry.asyncNode\n );\n }\n\n private getOrCreateAsyncNodeCacheEntry(\n node: Node.Async,\n context: AsyncPluginContext,\n ): AsyncNodeInfo {\n const { asyncNodeCache: asyncNodeInfo } = context;\n let entry = asyncNodeInfo.get(node.id);\n if (!entry) {\n entry = {\n asyncNode: node,\n updateNodes: new Set(),\n };\n asyncNodeInfo.set(node.id, entry);\n }\n\n return entry;\n }\n\n /**\n * Handles the asynchronous API integration for resolving nodes.\n * This method sets up a hook on the resolver's `beforeResolve` event to process async nodes.\n * @param resolver The resolver instance to attach the hook to.\n * @param view\n */\n applyResolver(resolver: Resolver, context: AsyncPluginContext): void {\n const { assetIdCache } = context;\n resolver.hooks.afterNodeUpdate.tap(this.name, (original, _, update) => {\n if (\n update.node.type !== NodeType.Asset &&\n update.node.type !== NodeType.View\n ) {\n return;\n }\n\n assetIdCache.set(update.value.id, original);\n });\n\n resolver.hooks.beforeResolve.tap(this.name, (node, options) => {\n if (!this.isAsync(node)) {\n return node === null ? node : this.resolveAsyncChildren(node, context);\n }\n\n const entry = this.getOrCreateAsyncNodeCacheEntry(node, context);\n\n if (options.node) {\n entry.updateNodes = new Set([options.node]);\n context.generatedByMap.set(options.node, node.id);\n }\n\n if (entry.resolvedContent !== undefined) {\n return this.resolveAsyncChildren(entry.resolvedContent, context);\n }\n\n if (context.inProgressNodes.has(node.id)) {\n return node;\n }\n\n // Track that the node is in progress.\n context.inProgressNodes.add(node.id);\n queueMicrotask(() => {\n this.runAsyncNode(node, context, options).finally();\n });\n\n return node;\n });\n }\n\n /**\n * Replaces child async nodes with their resolved content and flattens when necessary. Resolving the children directly helps manage the `parent` reference without needing as much work within the resolver itself.\n * Handles async node chains as well to make sure all applicable nodes can get flattened.\n * @param node - The node whose children need to be resolved.\n * @param context - the async plugin context needed to reach into the cache\n * @returns The same node but with async node children mapped to their resolved AST.\n */\n private resolveAsyncChildren(\n node: Node.Node,\n context: AsyncPluginContext,\n ): Node.Node {\n if (node.type === NodeType.MultiNode) {\n // Using a while loop lets us catch when async nodes produce more async nodes that need to be flattened further\n let index = 0;\n while (index < node.values.length) {\n const childNode = node.values[index];\n if (childNode?.type !== NodeType.Async) {\n index++;\n continue;\n }\n const entry = this.getOrCreateAsyncNodeCacheEntry(childNode, context);\n\n if (!this.hasValidMapping(entry)) {\n index++;\n continue;\n }\n\n const mappedNode = entry.resolvedContent;\n const nodeSet = new Set<Node.Node>();\n if (mappedNode.type === NodeType.MultiNode && childNode.flatten) {\n mappedNode.values.forEach((v: Node.Node) => {\n v.parent = node;\n nodeSet.add(v);\n context.originalParentMap.set(v, childNode);\n });\n node.values = [\n ...node.values.slice(0, index),\n ...mappedNode.values,\n ...node.values.slice(index + 1),\n ];\n } else {\n node.values[index] = mappedNode;\n mappedNode.parent = node;\n nodeSet.add(mappedNode);\n }\n entry.updateNodes = nodeSet;\n for (const n of nodeSet) {\n context.generatedByMap.set(n, childNode.id);\n }\n }\n } else if (\"children\" in node) {\n node.children?.forEach((c) => {\n // Similar to above, using a while loop lets us handle when async nodes produce more async nodes.\n while (c.value.type === NodeType.Async) {\n const entry = this.getOrCreateAsyncNodeCacheEntry(c.value, context);\n if (!this.hasValidMapping(entry)) {\n break;\n }\n\n const mappedNode = entry.resolvedContent;\n entry.updateNodes = new Set([mappedNode]);\n context.generatedByMap.set(mappedNode, c.value.id);\n c.value = mappedNode;\n c.value.parent = node;\n }\n });\n }\n\n return node;\n }\n\n private async runAsyncNode(\n node: Node.Async,\n context: AsyncPluginContext,\n options: Resolve.NodeResolveOptions,\n ) {\n try {\n const result = await this.basePlugin?.hooks.onAsyncNode.call(\n node,\n (result) => {\n this.parseNodeAndUpdate(node, context, result, options.parseNode);\n },\n );\n\n // Stop tracking before the next update is triggered\n context.inProgressNodes.delete(node.id);\n this.parseNodeAndUpdate(node, context, result, options.parseNode);\n } catch (e: unknown) {\n const cause = e instanceof Error ? e : new Error(String(e));\n const playerState = this.basePlugin?.getPlayerInstance()?.getState();\n\n if (playerState?.status !== \"in-progress\") {\n options.logger?.warn(\n \"[AsyncNodePlugin]: An error occured during async node resolution, but the player instance is no londer running. Exception: \",\n cause,\n );\n return;\n }\n\n const error = new AsyncNodeError(\n node,\n \"An error occured during async node resolution. See cause for details.\",\n cause,\n );\n playerState.controllers.error.captureError(error);\n }\n }\n\n private isAsync(node: Node.Node | null): node is Node.Async {\n return node?.type === NodeType.Async;\n }\n\n private isDeterminedAsync(obj: unknown): obj is AsyncContent {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n Object.prototype.hasOwnProperty.call(obj, \"async\")\n );\n }\n\n applyParser(parser: Parser): void {\n parser.hooks.parseNode.tap(\n this.name,\n (\n obj: any,\n nodeType: Node.ChildrenTypes,\n options: ParseObjectOptions,\n childOptions?: ParseObjectChildOptions,\n ) => {\n if (this.isDeterminedAsync(obj)) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { async, flatten, ...rest } = obj;\n const parsedAsync = parser.parseObject(rest, nodeType, options);\n const parsedNodeId = getNodeID(parsedAsync);\n\n if (parsedAsync === null || !parsedNodeId) {\n return childOptions ? [] : null;\n }\n\n const asyncAST = parser.createASTNode(\n {\n id: parsedNodeId,\n type: NodeType.Async,\n value: parsedAsync,\n flatten,\n },\n obj,\n );\n\n if (childOptions) {\n return asyncAST\n ? [\n {\n path: [...childOptions.path, childOptions.key],\n value: asyncAST,\n },\n ]\n : [];\n }\n\n return asyncAST;\n }\n },\n );\n }\n\n apply(view: ViewInstance): void {\n view.hooks.parser.tap(\"async\", this.applyParser.bind(this));\n }\n\n applyPlayer(player: Player): void {\n // TODO: Need a better mechanism for storing the current context.\n let currentContext: AsyncPluginContext | undefined = undefined;\n let parser: Parser | undefined = undefined;\n\n player.hooks.errorController.tap(\"async\", (errorController) => {\n errorController.hooks.onError.tap(\"async\", (playerError) => {\n if (currentContext === undefined) {\n return undefined;\n }\n\n /** Try to handle the error using the onAsyncNodeError hook. Returns true if new content is provided. */\n const tryHandleError = (asyncNode: Node.Async): boolean => {\n if (this.basePlugin === undefined) {\n player.logger.warn(\n `[AsyncNodePlugin]: No plugin detected. Error handling will fail`,\n );\n }\n\n let result: any = undefined;\n result = this.basePlugin?.hooks.onAsyncNodeError.call(\n playerError,\n asyncNode,\n );\n\n if (result === undefined) {\n return false;\n }\n\n player.logger?.warn(\n \"[AsyncNodePlugin]: Async node handling failed and resolved with a fallback. Cause:\",\n playerError.message,\n );\n\n // Stop tracking before the next update is triggered\n currentContext!.inProgressNodes.delete(asyncNode.id);\n this.parseNodeAndUpdate(\n asyncNode,\n currentContext!,\n result,\n parser?.parseObject.bind(parser),\n );\n\n return true;\n };\n\n const getNextNode = (node: Node.Node): Node.Node | undefined => {\n const parent =\n currentContext?.originalParentMap.get(node) ?? node.parent;\n\n if (!parent) {\n return undefined;\n }\n\n // asyncNodeCache has current asyncNode reference more up to date with what's happening in the resolver. Sometimes AsyncNodeError has old references so this helps us move up the tree more accurately\n return this.isAsync(parent)\n ? currentContext?.asyncNodeCache.get(parent.id)?.asyncNode\n : parent;\n };\n\n let node = getNodeFromError(playerError, currentContext);\n // If the node is an async node try, to handle errors with it first.\n if (node?.type === NodeType.Async && tryHandleError(node)) {\n return true;\n }\n\n // Loop through the nodes to see if something is generated by something else. Continue until the error is handled or there are no more nodes to check\n while (node !== undefined) {\n const generatedBy = currentContext.generatedByMap.get(node);\n if (generatedBy) {\n const entry = currentContext.asyncNodeCache.get(generatedBy);\n\n if (!entry) {\n node = getNextNode(node);\n continue;\n }\n\n const { asyncNode } = entry;\n\n // Don't return false when the error isn't handled to allow for cases where one async is generated by another. Give different nodes a chance to try to recover from the error.\n if (tryHandleError(asyncNode)) {\n return true;\n }\n }\n\n node = getNextNode(node);\n }\n\n return undefined;\n });\n });\n\n player.hooks.viewController.tap(\"async\", (viewController) => {\n viewController.hooks.view.tap(\"async\", (view) => {\n view.hooks.parser.tap(this.name, (p) => {\n parser = p;\n });\n const context: AsyncPluginContext = {\n inProgressNodes: new Set(),\n view,\n viewController,\n generatedByMap: new Map(),\n assetIdCache: new Map(),\n asyncNodeCache: new Map(),\n originalParentMap: new Map(),\n };\n currentContext = context;\n\n view.hooks.resolver.tap(\"async\", (resolver) => {\n this.applyResolver(resolver, context);\n });\n });\n });\n }\n\n applyPlugin(asyncNodePlugin: AsyncNodePlugin): void {\n this.basePlugin = asyncNodePlugin;\n }\n}\n","import {\n ErrorSeverity,\n type Node,\n type PlayerErrorMetadata,\n} from \"@player-ui/player\";\n\nexport const ASYNC_ERROR_TYPE = \"ASYNC-PLUGIN\";\nexport type AsyncErrorMetadata = {\n node: Node.Async;\n};\nexport class AsyncNodeError\n extends Error\n implements PlayerErrorMetadata<AsyncErrorMetadata>\n{\n readonly type: string = ASYNC_ERROR_TYPE;\n readonly severity: ErrorSeverity = ErrorSeverity.ERROR;\n readonly metadata: AsyncErrorMetadata;\n\n constructor(\n node: Node.Async,\n message?: string,\n public readonly cause?: Error | undefined,\n ) {\n super(message);\n\n this.metadata = {\n node,\n };\n }\n}\n","import type { Node } from \"@player-ui/player\";\n\n/** Matches 2 segments where pathA matches or is a subset of pathB. Returns the number of matching segments */\nconst getMatchValue = (\n pathA: Node.PathSegment[],\n pathB: Node.PathSegment[],\n): number => {\n if (pathA.length > pathB.length) {\n return 0;\n }\n\n let matchCount = 0;\n for (let i = 0; i < pathA.length; i++) {\n if (pathA[i] === pathB[i]) {\n matchCount++;\n } else {\n return 0;\n }\n }\n\n return matchCount;\n};\n\n/** Follows the given path and returns the node. If there is no match, returns undefined */\nexport const extractNodeFromPath = (\n node: Node.Node,\n path?: string[],\n): Node.Node | undefined => {\n if (path === undefined || path.length === 0) {\n return node;\n }\n\n if (!(\"children\" in node && node.children)) {\n return undefined;\n }\n\n let matchResult = 0;\n let bestMatch: Node.Child | undefined;\n for (const child of node.children) {\n const matchValue = getMatchValue(child.path, path);\n if (matchValue > matchResult) {\n matchResult = matchValue;\n bestMatch = child;\n }\n }\n\n if (!bestMatch) {\n return undefined;\n }\n\n if (matchResult >= path.length) {\n return bestMatch.value;\n }\n\n return extractNodeFromPath(bestMatch.value, path.slice(matchResult));\n};\n","import { NodeType, Node } from \"@player-ui/player\";\n\n/** Replaces a node using the given replace function. If the node is a multi-node it does this transformation to all of its values. */\nexport const traverseAndReplace = (\n node: Node.Node,\n replaceFn: (node: Node.Node) => Node.Node,\n): Node.Node => {\n if (node.type === NodeType.MultiNode) {\n let index = 0;\n while (index < node.values.length) {\n const child = node.values[index];\n if (!child) {\n index++;\n continue;\n }\n\n const result = replaceFn(child);\n if (result.type === NodeType.MultiNode) {\n node.values = [\n ...node.values.slice(0, index),\n ...result.values,\n ...node.values.slice(index + 1),\n ];\n } else {\n node.values[index] = result;\n index++;\n }\n }\n\n return node;\n }\n\n return replaceFn(node);\n};\n","import { NodeType, Node } from \"@player-ui/player\";\n\nexport const unwrapAsset = (node: Node.Node): Node.Node => {\n if (node.type !== NodeType.Value) {\n return node;\n }\n const child = node.children?.find(\n (x) => x.path.length === 1 && x.path[0] === \"asset\",\n );\n\n if (!child) {\n return node;\n }\n\n return child.value;\n};\n","import { NodeType } from \"@player-ui/player\";\nimport type { Node } from \"@player-ui/player\";\n\nexport const requiresAssetWrapper = (node: Node.Node): boolean => {\n if (node.type === NodeType.Asset) {\n return true;\n }\n\n if (node.type !== NodeType.Applicability) {\n return false;\n }\n\n return node.value.type === NodeType.Asset;\n};\n","import { PlayerError } from \"@player-ui/player\";\nimport { ASYNC_ERROR_TYPE, AsyncErrorMetadata } from \"../AsyncNodeError\";\n\nexport const isAsyncPlayerError = (\n error: PlayerError,\n): error is PlayerError<AsyncErrorMetadata> => {\n return error.type === ASYNC_ERROR_TYPE;\n};\n","import { PlayerError, Node, ErrorTypes } from \"@player-ui/player\";\nimport { AsyncPluginContext } from \"../internal-types\";\nimport { isAsyncPlayerError } from \"./isAsyncPlayerError\";\n\n/** Get the AST Node related to a specific error if available. */\nexport const getNodeFromError = (\n playerError: PlayerError,\n context: AsyncPluginContext,\n): Node.Node | undefined => {\n if (playerError.type === ErrorTypes.RENDER) {\n const { assetId } = playerError.metadata ?? {};\n\n if (typeof assetId !== \"string\") {\n return undefined;\n }\n\n return context.assetIdCache.get(assetId);\n }\n\n if (playerError.type === ErrorTypes.VIEW) {\n const { node } = playerError.metadata ?? {};\n // TODO: Remove some of this from here. Maybe export type assertion functions from where the errors are generated?\n if (typeof node === \"object\" && node !== null && !Array.isArray(node)) {\n return node as Node.Node;\n }\n }\n\n if (isAsyncPlayerError(playerError) && playerError.metadata !== undefined) {\n // Use the node from the cache to ensure it is the latest version of the async node from the resolver\n return context.asyncNodeCache.get(playerError.metadata.node.id)?.asyncNode;\n }\n\n return undefined;\n};\n","import { Builder } from \"@player-ui/player\";\nimport type { AsyncTransformFunc } from \"./types\";\n\n/**\n * @deprecated Use {@link createAsyncTransform} to create your before transform function.\n * Util function to generate transform function for async asset\n * @param asset - async asset to apply beforeResolve transform\n * @param wrapperAssetType: container asset type\n * @param flatten: flatten the streamed in content\n * @param path: property path to add the multinode containing the next async node to\n * @returns - wrapper asset with children of transformed asset and async node\n */\n\nexport const asyncTransform: AsyncTransformFunc = (\n assetId,\n wrapperAssetType,\n asset,\n flatten,\n path = [\"values\"],\n) => {\n const id = \"async-\" + assetId;\n\n const asyncNode = Builder.asyncNode(id, flatten);\n\n let multiNode;\n let assetNode;\n\n if (asset) {\n assetNode = Builder.assetWrapper(asset);\n multiNode = Builder.multiNode(assetNode, asyncNode);\n } else {\n multiNode = Builder.multiNode(asyncNode);\n }\n\n const wrapperAsset = Builder.asset({\n id: wrapperAssetType + \"-\" + id,\n type: wrapperAssetType,\n });\n\n Builder.addChild(wrapperAsset, path, multiNode);\n\n return wrapperAsset;\n};\n","import {\n BeforeTransformFunction,\n Builder,\n Node,\n NodeType,\n} from \"@player-ui/player\";\nimport {\n extractNodeFromPath,\n requiresAssetWrapper,\n traverseAndReplace,\n unwrapAsset,\n} from \"./utils\";\n\nexport type AsyncTransformOptions = {\n /** Whether or not to flatten the results into its container. Defaults to true */\n flatten?: boolean;\n /** The path to the array within the `wrapperAssetType` that will contain the async content. Defaults to [\"values\"] */\n path?: string[];\n /** The asset type that the transform is matching against. */\n transformAssetType: string;\n /** The asset type that will contain the async content. */\n wrapperAssetType: string;\n /** Function to get any nested asset that will need to be extracted and kept when creating the wrapper asset. */\n getNestedAsset?: (node: Node.ViewOrAsset) => Node.Node | undefined;\n /** Function to get the id for the async node being generated. Defaults to creating an id with the format of async-<ASSET.ID> */\n getAsyncNodeId?: (node: Node.ViewOrAsset) => string;\n /** Where to place the async node relative to the asset from `getNestedAsset`. Defaults to \"append\" */\n asyncNodePosition?: \"append\" | \"prepend\";\n};\n\nconst defaultGetNodeId = (node: Node.ViewOrAsset): string => {\n return `async-${node.value.id}`;\n};\n\n/** Creates a BeforeTransformFunction that turns the given asset into a wrapper asset with an async node in it.\n * By setting {@link AsyncTransformOptions.flatten} to true, you can chain multiple of the same asset type to create a flow of async content that\n * exists within a single collection.\n *\n * @param options - Options for managing the transform\n * @returns The {@link BeforeTransformFunction} that can be used for your asset.\n */\nexport const createAsyncTransform = (\n options: AsyncTransformOptions,\n): BeforeTransformFunction => {\n const {\n transformAssetType,\n wrapperAssetType,\n getNestedAsset,\n getAsyncNodeId = defaultGetNodeId,\n path = [\"values\"],\n flatten = true,\n asyncNodePosition = \"append\",\n } = options;\n\n const replaceNode = (node: Node.Node): Node.Node => {\n const unwrapped = unwrapAsset(node);\n\n if (\n unwrapped.type !== NodeType.Asset ||\n unwrapped.value.type !== transformAssetType\n ) {\n return node;\n }\n\n const transformed = asyncTransform(unwrapped);\n return extractNodeFromPath(transformed, path) ?? node;\n };\n\n const replacer = (node: Node.Node) => traverseAndReplace(node, replaceNode);\n\n const asyncTransform = (node: Node.ViewOrAsset) => {\n const id = getAsyncNodeId(node);\n const asset = getNestedAsset?.(node);\n\n // If flattening is disabled, don't need to extract the multi-node when async node is resolved.\n const replaceFunction = flatten ? replacer : undefined;\n const asyncNode = Builder.asyncNode(id, flatten, replaceFunction);\n\n const values: Node.Node[] = [asyncNode];\n if (asset) {\n const otherValues = [];\n if (requiresAssetWrapper(asset)) {\n otherValues.push(Builder.assetWrapper(asset));\n } else if (asset.type === NodeType.MultiNode) {\n otherValues.push(...asset.values);\n } else {\n otherValues.push(asset);\n }\n\n if (asyncNodePosition === \"append\") {\n values.unshift(...otherValues);\n } else {\n values.push(...otherValues);\n }\n }\n\n const multiNode = Builder.multiNode(...(values as any[]));\n\n const wrapperAsset: Node.ViewOrAsset = Builder.asset({\n id: wrapperAssetType + \"-\" + id,\n type: wrapperAssetType,\n });\n\n Builder.addChild(wrapperAsset, path, multiNode);\n\n return wrapperAsset;\n };\n\n return asyncTransform;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAAoC;AAapC,wBAAkD;AAClD,6BAA2B;;;ACd3B,oBAIO;AAEA,IAAM,mBAAmB;AAIzB,IAAM,iBAAN,cACG,MAEV;AAAA,EAKE,YACE,MACA,SACgB,OAChB;AACA,UAAM,OAAO;AAFG;AAPlB,SAAS,OAAe;AACxB,SAAS,WAA0B,4BAAc;AAU/C,SAAK,WAAW;AAAA,MACd;AAAA,IACF;AAAA,EACF;AACF;;;AC1BA,IAAM,gBAAgB,CACpB,OACA,UACW;AACX,MAAI,MAAM,SAAS,MAAM,QAAQ;AAC/B,WAAO;AAAA,EACT;AAEA,MAAI,aAAa;AACjB,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,QAAI,MAAM,CAAC,MAAM,MAAM,CAAC,GAAG;AACzB;AAAA,IACF,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAGO,IAAM,sBAAsB,CACjC,MACA,SAC0B;AAC1B,MAAI,SAAS,UAAa,KAAK,WAAW,GAAG;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,EAAE,cAAc,QAAQ,KAAK,WAAW;AAC1C,WAAO;AAAA,EACT;AAEA,MAAI,cAAc;AAClB,MAAI;AACJ,aAAW,SAAS,KAAK,UAAU;AACjC,UAAM,aAAa,cAAc,MAAM,MAAM,IAAI;AACjD,QAA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;AAAA,QACN;AAEA,YAAI,OAAO,iBAAiB,aAAa,cAAc;AAEvD,YAAI,MAAM,SAAS,wBAAS,SAAS,eAAe,IAAI,GAAG;AACzD,iBAAO;AAAA,QACT;AAGA,eAAO,SAAS,QAAW;AACzB,gBAAM,cAAc,eAAe,eAAe,IAAI,IAAI;AAC1D,cAAI,aAAa;AACf,kBAAM,QAAQ,eAAe,eAAe,IAAI,WAAW;AAE3D,gBAAI,CAAC,OAAO;AACV,qBAAO,YAAY,IAAI;AACvB;AAAA,YACF;AAEA,kBAAM,EAAE,UAAU,IAAI;AAGtB,gBAAI,eAAe,SAAS,GAAG;AAC7B,qBAAO;AAAA,YACT;AAAA,UACF;AAEA,iBAAO,YAAY,IAAI;AAAA,QACzB;AAEA,eAAO;AAAA,MACT,CAAC;AAAA,IACH,CAAC;AAED,WAAO,MAAM,eAAe,IAAI,SAAS,CAAC,mBAAmB;AAC3D,qBAAe,MAAM,KAAK,IAAI,SAAS,CAAC,SAAS;AAC/C,aAAK,MAAM,OAAO,IAAI,KAAK,MAAM,CAAC,MAAM;AACtC,mBAAS;AAAA,QACX,CAAC;AACD,cAAM,UAA8B;AAAA,UAClC,iBAAiB,oBAAI,IAAI;AAAA,UACzB;AAAA,UACA;AAAA,UACA,gBAAgB,oBAAI,IAAI;AAAA,UACxB,cAAc,oBAAI,IAAI;AAAA,UACtB,gBAAgB,oBAAI,IAAI;AAAA,UACxB,mBAAmB,oBAAI,IAAI;AAAA,QAC7B;AACA,yBAAiB;AAEjB,aAAK,MAAM,SAAS,IAAI,SAAS,CAAC,aAAa;AAC7C,eAAK,cAAc,UAAU,OAAO;AAAA,QACtC,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,YAAY,iBAAwC;AAClD,SAAK,aAAa;AAAA,EACpB;AACF;","names":["import_player","import_player","import_player","import_player","import_player","import_player","import_player","asyncTransform","queueMicrotask","result","node"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/AsyncNodeError.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/extractNodeFromPath.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/traverseAndReplace.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/unwrapAsset.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/requiresAssetWrapper.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/isAsyncPlayerError.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/getNodeFromError.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/createAsyncTransform.ts"],"sourcesContent":["import { NodeType, getNodeID } from \"@player-ui/player\";\nimport type {\n Player,\n PlayerPlugin,\n Node,\n ParseObjectOptions,\n ParseObjectChildOptions,\n ViewInstance,\n Parser,\n ViewPlugin,\n Resolver,\n Resolve,\n} from \"@player-ui/player\";\nimport { AsyncSeriesBailHook, SyncBailHook } from \"tapable-ts\";\nimport queueMicrotask from \"queue-microtask\";\nimport { AsyncNodeError } from \"./AsyncNodeError\";\nimport { AsyncNodeInfo, AsyncPluginContext } from \"./internal-types\";\nimport { getNodeFromError } from \"./utils\";\n\nexport * from \"./types\";\nexport * from \"./transform\";\nexport * from \"./createAsyncTransform\";\n\nexport interface AsyncNodePluginOptions {\n /** A set of plugins to load */\n plugins?: AsyncNodeViewPlugin[];\n}\n\nexport interface AsyncNodeViewPlugin extends ViewPlugin {\n /** Use this to tap into the async node plugin hooks */\n applyPlugin: (asyncNodePlugin: AsyncNodePlugin) => void;\n\n applyPlayer?: (player: Player) => void;\n}\nexport type AsyncHandler = (\n node: Node.Async,\n callback?: (result: any) => void,\n) => Promise<any>;\n\nexport type AsyncContent = {\n async: true;\n flatten?: boolean;\n [key: string]: unknown;\n};\n\n/** Hook declaration for the AsyncNodePlugin */\nexport type AsyncNodeHooks = {\n /** Async hook to get content for an async node */\n onAsyncNode: AsyncSeriesBailHook<[Node.Async, (result: any) => void], any>;\n /** Sync hook to manage errors coming from the onAsyncNode hook. Return a fallback node or null to render a fallback. The first argument of passed in the call is the error thrown. */\n onAsyncNodeError: SyncBailHook<[Error, Node.Async], any>;\n};\n\nexport const AsyncNodePluginSymbol: symbol = Symbol.for(\"AsyncNodePlugin\");\n\n/**\n * Async node plugin used to resolve async nodes in the content\n * If an async node is present, allow users to provide a replacement node to be rendered when ready\n */\nexport class AsyncNodePlugin implements PlayerPlugin {\n private plugins: AsyncNodeViewPlugin[] | undefined;\n private playerInstance: Player | undefined;\n\n static Symbol: symbol = AsyncNodePluginSymbol;\n public readonly symbol: symbol = AsyncNodePlugin.Symbol;\n\n constructor(options: AsyncNodePluginOptions, asyncHandler?: AsyncHandler) {\n if (options?.plugins) {\n this.plugins = options.plugins;\n options.plugins.forEach((plugin) => {\n plugin.applyPlugin(this);\n });\n }\n\n if (asyncHandler) {\n this.hooks.onAsyncNode.tap(\n \"async\",\n async (node: Node.Async, callback) => {\n return await asyncHandler(node, callback);\n },\n );\n }\n }\n\n public readonly hooks: AsyncNodeHooks = {\n onAsyncNode: new AsyncSeriesBailHook(),\n onAsyncNodeError: new SyncBailHook(),\n };\n\n getPlayerInstance(): Player | undefined {\n return this.playerInstance;\n }\n\n name = \"AsyncNode\";\n\n apply(player: Player): void {\n this.playerInstance = player;\n\n this.plugins?.forEach((plugin) => {\n plugin.applyPlayer?.(player);\n });\n\n player.hooks.viewController.tap(this.name, (viewController) => {\n viewController.hooks.view.tap(this.name, (view) => {\n this.plugins?.forEach((plugin) => {\n plugin.apply(view);\n });\n });\n });\n }\n}\n\nexport class AsyncNodePluginPlugin implements AsyncNodeViewPlugin {\n private basePlugin: AsyncNodePlugin | undefined;\n\n name = \"AsyncNode\";\n\n /**\n * Parses the node from the result and triggers an asynchronous view update if necessary.\n * @param node The asynchronous node that might be updated.\n * @param result The result obtained from resolving the async node. This could be any data structure or value.\n * @param options Options provided for node resolution, including a potential parseNode function to process the result.\n * @param view The view instance where the node resides. This can be undefined if the view is not currently active.\n */\n private parseNodeAndUpdate(\n node: Node.Async,\n context: AsyncPluginContext,\n result: any,\n parseFunction?: (content: any) => Node.Node | null,\n ) {\n let parsedNode =\n parseFunction && result ? parseFunction(result) : undefined;\n\n if (parsedNode && node.onValueReceived) {\n parsedNode = node.onValueReceived(parsedNode);\n }\n\n this.handleAsyncUpdate(node, context, parsedNode);\n }\n\n /**\n * Updates the node asynchronously based on the result provided.\n * This method is responsible for handling the update logic of asynchronous nodes.\n * It checks if the node needs to be updated based on the new result and updates the mapping accordingly.\n * If an update is necessary, it triggers an asynchronous update on the view.\n * @param node The asynchronous node that might be updated.\n * @param newNode The new node to replace the async node.\n * @param view The view instance where the node resides. This can be undefined if the view is not currently active.\n */\n private handleAsyncUpdate(\n node: Node.Async,\n context: AsyncPluginContext,\n newNode?: Node.Node | null,\n ) {\n const { asyncNodeCache: asyncNodeInfo, viewController } = context;\n const entry = asyncNodeInfo.get(node.id);\n if (!entry) {\n throw new Error(\"Failed to update async content. Cache entry not found\");\n }\n if (entry.resolvedContent !== newNode) {\n entry.resolvedContent = newNode ? newNode : entry.asyncNode;\n viewController.updateViewAST(entry.updateNodes);\n }\n }\n\n private hasValidMapping(\n cacheEntry: AsyncNodeInfo,\n ): cacheEntry is Required<AsyncNodeInfo> {\n return (\n cacheEntry.resolvedContent !== undefined &&\n cacheEntry.resolvedContent !== cacheEntry.asyncNode\n );\n }\n\n private getOrCreateAsyncNodeCacheEntry(\n node: Node.Async,\n context: AsyncPluginContext,\n ): AsyncNodeInfo {\n const { asyncNodeCache: asyncNodeInfo } = context;\n let entry = asyncNodeInfo.get(node.id);\n if (!entry) {\n entry = {\n asyncNode: node,\n updateNodes: new Set(),\n };\n asyncNodeInfo.set(node.id, entry);\n }\n\n return entry;\n }\n\n /**\n * Handles the asynchronous API integration for resolving nodes.\n * This method sets up a hook on the resolver's `beforeResolve` event to process async nodes.\n * @param resolver The resolver instance to attach the hook to.\n * @param view\n */\n applyResolver(resolver: Resolver, context: AsyncPluginContext): void {\n const { assetIdCache } = context;\n resolver.hooks.afterNodeUpdate.tap(this.name, (original, _, update) => {\n if (\n update.node.type !== NodeType.Asset &&\n update.node.type !== NodeType.View\n ) {\n return;\n }\n\n assetIdCache.set(update.value.id, original);\n });\n\n resolver.hooks.beforeResolve.tap(this.name, (node, options) => {\n if (!this.isAsync(node)) {\n return node === null ? node : this.resolveAsyncChildren(node, context);\n }\n\n const entry = this.getOrCreateAsyncNodeCacheEntry(node, context);\n\n if (options.node) {\n entry.updateNodes = new Set([options.node]);\n context.generatedByMap.set(options.node, node.id);\n }\n\n if (entry.resolvedContent !== undefined) {\n return this.resolveAsyncChildren(entry.resolvedContent, context);\n }\n\n if (context.inProgressNodes.has(node.id)) {\n return node;\n }\n\n // Track that the node is in progress.\n context.inProgressNodes.add(node.id);\n queueMicrotask(() => {\n this.runAsyncNode(node, context, options).finally();\n });\n\n return node;\n });\n }\n\n /**\n * Replaces child async nodes with their resolved content and flattens when necessary. Resolving the children directly helps manage the `parent` reference without needing as much work within the resolver itself.\n * Handles async node chains as well to make sure all applicable nodes can get flattened.\n * @param node - The node whose children need to be resolved.\n * @param context - the async plugin context needed to reach into the cache\n * @returns The same node but with async node children mapped to their resolved AST.\n */\n private resolveAsyncChildren(\n node: Node.Node,\n context: AsyncPluginContext,\n ): Node.Node {\n if (node.type === NodeType.MultiNode) {\n // Using a while loop lets us catch when async nodes produce more async nodes that need to be flattened further\n let index = 0;\n while (index < node.values.length) {\n const childNode = node.values[index];\n if (childNode?.type !== NodeType.Async) {\n index++;\n continue;\n }\n const entry = this.getOrCreateAsyncNodeCacheEntry(childNode, context);\n\n if (!this.hasValidMapping(entry)) {\n index++;\n continue;\n }\n\n const mappedNode = entry.resolvedContent;\n const nodeSet = new Set<Node.Node>();\n if (mappedNode.type === NodeType.MultiNode && childNode.flatten) {\n mappedNode.values.forEach((v: Node.Node) => {\n v.parent = node;\n nodeSet.add(v);\n context.originalParentMap.set(v, childNode);\n });\n node.values = [\n ...node.values.slice(0, index),\n ...mappedNode.values,\n ...node.values.slice(index + 1),\n ];\n } else {\n node.values[index] = mappedNode;\n mappedNode.parent = node;\n nodeSet.add(mappedNode);\n }\n entry.updateNodes = nodeSet;\n for (const n of nodeSet) {\n context.generatedByMap.set(n, childNode.id);\n }\n }\n } else if (\"children\" in node) {\n node.children?.forEach((c) => {\n // Similar to above, using a while loop lets us handle when async nodes produce more async nodes.\n while (c.value.type === NodeType.Async) {\n const entry = this.getOrCreateAsyncNodeCacheEntry(c.value, context);\n if (!this.hasValidMapping(entry)) {\n break;\n }\n\n const mappedNode = entry.resolvedContent;\n entry.updateNodes = new Set([mappedNode]);\n context.generatedByMap.set(mappedNode, c.value.id);\n c.value = mappedNode;\n c.value.parent = node;\n }\n });\n }\n\n return node;\n }\n\n private async runAsyncNode(\n node: Node.Async,\n context: AsyncPluginContext,\n options: Resolve.NodeResolveOptions,\n ) {\n try {\n // Track whether the callback pushed content while the hook was pending;\n // if so it wins over the bail return (avoids the last-writer-wins race\n // that intermittently dropped streamed rows).\n let deliveredViaCallback = false;\n\n const result = await this.basePlugin?.hooks.onAsyncNode.call(\n node,\n (streamedResult) => {\n deliveredViaCallback = true;\n this.parseNodeAndUpdate(\n node,\n context,\n streamedResult,\n options.parseNode,\n );\n },\n );\n\n // Stop tracking before the next update is triggered\n context.inProgressNodes.delete(node.id);\n\n // Once the callback has delivered content it is the source of truth, so a\n // stale/empty bail return must not clobber it. Skip unless no callback ran\n // (!deliveredViaCallback) and the return carries content (result != null).\n if (!deliveredViaCallback && result != null) {\n this.parseNodeAndUpdate(node, context, result, options.parseNode);\n }\n } catch (e: unknown) {\n const cause = e instanceof Error ? e : new Error(String(e));\n const playerState = this.basePlugin?.getPlayerInstance()?.getState();\n\n if (playerState?.status !== \"in-progress\") {\n options.logger?.warn(\n \"[AsyncNodePlugin]: An error occured during async node resolution, but the player instance is no londer running. Exception: \",\n cause,\n );\n return;\n }\n\n const error = new AsyncNodeError(\n node,\n \"An error occured during async node resolution. See cause for details.\",\n cause,\n );\n playerState.controllers.error.captureError(error);\n }\n }\n\n private isAsync(node: Node.Node | null): node is Node.Async {\n return node?.type === NodeType.Async;\n }\n\n private isDeterminedAsync(obj: unknown): obj is AsyncContent {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n Object.prototype.hasOwnProperty.call(obj, \"async\")\n );\n }\n\n applyParser(parser: Parser): void {\n parser.hooks.parseNode.tap(\n this.name,\n (\n obj: any,\n nodeType: Node.ChildrenTypes,\n options: ParseObjectOptions,\n childOptions?: ParseObjectChildOptions,\n ) => {\n if (this.isDeterminedAsync(obj)) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { async, flatten, ...rest } = obj;\n const parsedAsync = parser.parseObject(rest, nodeType, options);\n const parsedNodeId = getNodeID(parsedAsync);\n\n if (parsedAsync === null || !parsedNodeId) {\n return childOptions ? [] : null;\n }\n\n const asyncAST = parser.createASTNode(\n {\n id: parsedNodeId,\n type: NodeType.Async,\n value: parsedAsync,\n flatten,\n },\n obj,\n );\n\n if (childOptions) {\n return asyncAST\n ? [\n {\n path: [...childOptions.path, childOptions.key],\n value: asyncAST,\n },\n ]\n : [];\n }\n\n return asyncAST;\n }\n },\n );\n }\n\n apply(view: ViewInstance): void {\n view.hooks.parser.tap(\"async\", this.applyParser.bind(this));\n }\n\n applyPlayer(player: Player): void {\n // TODO: Need a better mechanism for storing the current context.\n let currentContext: AsyncPluginContext | undefined = undefined;\n let parser: Parser | undefined = undefined;\n\n player.hooks.errorController.tap(\"async\", (errorController) => {\n errorController.hooks.onError.tap(\"async\", (playerError) => {\n if (currentContext === undefined) {\n return undefined;\n }\n\n /** Try to handle the error using the onAsyncNodeError hook. Returns true if new content is provided. */\n const tryHandleError = (asyncNode: Node.Async): boolean => {\n if (this.basePlugin === undefined) {\n player.logger.warn(\n `[AsyncNodePlugin]: No plugin detected. Error handling will fail`,\n );\n }\n\n let result: any = undefined;\n result = this.basePlugin?.hooks.onAsyncNodeError.call(\n playerError,\n asyncNode,\n );\n\n if (result === undefined) {\n return false;\n }\n\n player.logger?.warn(\n \"[AsyncNodePlugin]: Async node handling failed and resolved with a fallback. Cause:\",\n playerError.message,\n );\n\n // Stop tracking before the next update is triggered\n currentContext!.inProgressNodes.delete(asyncNode.id);\n this.parseNodeAndUpdate(\n asyncNode,\n currentContext!,\n result,\n parser?.parseObject.bind(parser),\n );\n\n return true;\n };\n\n const getNextNode = (node: Node.Node): Node.Node | undefined => {\n const parent =\n currentContext?.originalParentMap.get(node) ?? node.parent;\n\n if (!parent) {\n return undefined;\n }\n\n // asyncNodeCache has current asyncNode reference more up to date with what's happening in the resolver. Sometimes AsyncNodeError has old references so this helps us move up the tree more accurately\n return this.isAsync(parent)\n ? currentContext?.asyncNodeCache.get(parent.id)?.asyncNode\n : parent;\n };\n\n let node = getNodeFromError(playerError, currentContext);\n // If the node is an async node try, to handle errors with it first.\n if (node?.type === NodeType.Async && tryHandleError(node)) {\n return true;\n }\n\n // Loop through the nodes to see if something is generated by something else. Continue until the error is handled or there are no more nodes to check\n while (node !== undefined) {\n const generatedBy = currentContext.generatedByMap.get(node);\n if (generatedBy) {\n const entry = currentContext.asyncNodeCache.get(generatedBy);\n\n if (!entry) {\n node = getNextNode(node);\n continue;\n }\n\n const { asyncNode } = entry;\n\n // Don't return false when the error isn't handled to allow for cases where one async is generated by another. Give different nodes a chance to try to recover from the error.\n if (tryHandleError(asyncNode)) {\n return true;\n }\n }\n\n node = getNextNode(node);\n }\n\n return undefined;\n });\n });\n\n player.hooks.viewController.tap(\"async\", (viewController) => {\n viewController.hooks.view.tap(\"async\", (view) => {\n view.hooks.parser.tap(this.name, (p) => {\n parser = p;\n });\n const context: AsyncPluginContext = {\n inProgressNodes: new Set(),\n view,\n viewController,\n generatedByMap: new Map(),\n assetIdCache: new Map(),\n asyncNodeCache: new Map(),\n originalParentMap: new Map(),\n };\n currentContext = context;\n\n view.hooks.resolver.tap(\"async\", (resolver) => {\n this.applyResolver(resolver, context);\n });\n });\n });\n }\n\n applyPlugin(asyncNodePlugin: AsyncNodePlugin): void {\n this.basePlugin = asyncNodePlugin;\n }\n}\n","import {\n ErrorSeverity,\n type Node,\n type PlayerErrorMetadata,\n} from \"@player-ui/player\";\n\nexport const ASYNC_ERROR_TYPE = \"ASYNC-PLUGIN\";\nexport type AsyncErrorMetadata = {\n node: Node.Async;\n};\nexport class AsyncNodeError\n extends Error\n implements PlayerErrorMetadata<AsyncErrorMetadata>\n{\n readonly type: string = ASYNC_ERROR_TYPE;\n readonly severity: ErrorSeverity = ErrorSeverity.ERROR;\n readonly metadata: AsyncErrorMetadata;\n\n constructor(\n node: Node.Async,\n message?: string,\n public readonly cause?: Error | undefined,\n ) {\n super(message);\n\n this.metadata = {\n node,\n };\n }\n}\n","import type { Node } from \"@player-ui/player\";\n\n/** Matches 2 segments where pathA matches or is a subset of pathB. Returns the number of matching segments */\nconst getMatchValue = (\n pathA: Node.PathSegment[],\n pathB: Node.PathSegment[],\n): number => {\n if (pathA.length > pathB.length) {\n return 0;\n }\n\n let matchCount = 0;\n for (let i = 0; i < pathA.length; i++) {\n if (pathA[i] === pathB[i]) {\n matchCount++;\n } else {\n return 0;\n }\n }\n\n return matchCount;\n};\n\n/** Follows the given path and returns the node. If there is no match, returns undefined */\nexport const extractNodeFromPath = (\n node: Node.Node,\n path?: string[],\n): Node.Node | undefined => {\n if (path === undefined || path.length === 0) {\n return node;\n }\n\n if (!(\"children\" in node && node.children)) {\n return undefined;\n }\n\n let matchResult = 0;\n let bestMatch: Node.Child | undefined;\n for (const child of node.children) {\n const matchValue = getMatchValue(child.path, path);\n if (matchValue > matchResult) {\n matchResult = matchValue;\n bestMatch = child;\n }\n }\n\n if (!bestMatch) {\n return undefined;\n }\n\n if (matchResult >= path.length) {\n return bestMatch.value;\n }\n\n return extractNodeFromPath(bestMatch.value, path.slice(matchResult));\n};\n","import { NodeType, Node } from \"@player-ui/player\";\n\n/** Replaces a node using the given replace function. If the node is a multi-node it does this transformation to all of its values. */\nexport const traverseAndReplace = (\n node: Node.Node,\n replaceFn: (node: Node.Node) => Node.Node,\n): Node.Node => {\n if (node.type === NodeType.MultiNode) {\n let index = 0;\n while (index < node.values.length) {\n const child = node.values[index];\n if (!child) {\n index++;\n continue;\n }\n\n const result = replaceFn(child);\n if (result.type === NodeType.MultiNode) {\n node.values = [\n ...node.values.slice(0, index),\n ...result.values,\n ...node.values.slice(index + 1),\n ];\n } else {\n node.values[index] = result;\n index++;\n }\n }\n\n return node;\n }\n\n return replaceFn(node);\n};\n","import { NodeType, Node } from \"@player-ui/player\";\n\nexport const unwrapAsset = (node: Node.Node): Node.Node => {\n if (node.type !== NodeType.Value) {\n return node;\n }\n const child = node.children?.find(\n (x) => x.path.length === 1 && x.path[0] === \"asset\",\n );\n\n if (!child) {\n return node;\n }\n\n return child.value;\n};\n","import { NodeType } from \"@player-ui/player\";\nimport type { Node } from \"@player-ui/player\";\n\nexport const requiresAssetWrapper = (node: Node.Node): boolean => {\n if (node.type === NodeType.Asset) {\n return true;\n }\n\n if (node.type !== NodeType.Applicability) {\n return false;\n }\n\n return node.value.type === NodeType.Asset;\n};\n","import { PlayerError } from \"@player-ui/player\";\nimport { ASYNC_ERROR_TYPE, AsyncErrorMetadata } from \"../AsyncNodeError\";\n\nexport const isAsyncPlayerError = (\n error: PlayerError,\n): error is PlayerError<AsyncErrorMetadata> => {\n return error.type === ASYNC_ERROR_TYPE;\n};\n","import { PlayerError, Node, ErrorTypes } from \"@player-ui/player\";\nimport { AsyncPluginContext } from \"../internal-types\";\nimport { isAsyncPlayerError } from \"./isAsyncPlayerError\";\n\n/** Get the AST Node related to a specific error if available. */\nexport const getNodeFromError = (\n playerError: PlayerError,\n context: AsyncPluginContext,\n): Node.Node | undefined => {\n if (playerError.type === ErrorTypes.RENDER) {\n const { assetId } = playerError.metadata ?? {};\n\n if (typeof assetId !== \"string\") {\n return undefined;\n }\n\n return context.assetIdCache.get(assetId);\n }\n\n if (playerError.type === ErrorTypes.VIEW) {\n const { node } = playerError.metadata ?? {};\n // TODO: Remove some of this from here. Maybe export type assertion functions from where the errors are generated?\n if (typeof node === \"object\" && node !== null && !Array.isArray(node)) {\n return node as Node.Node;\n }\n }\n\n if (isAsyncPlayerError(playerError) && playerError.metadata !== undefined) {\n // Use the node from the cache to ensure it is the latest version of the async node from the resolver\n return context.asyncNodeCache.get(playerError.metadata.node.id)?.asyncNode;\n }\n\n return undefined;\n};\n","import { Builder } from \"@player-ui/player\";\nimport type { AsyncTransformFunc } from \"./types\";\n\n/**\n * @deprecated Use {@link createAsyncTransform} to create your before transform function.\n * Util function to generate transform function for async asset\n * @param asset - async asset to apply beforeResolve transform\n * @param wrapperAssetType: container asset type\n * @param flatten: flatten the streamed in content\n * @param path: property path to add the multinode containing the next async node to\n * @returns - wrapper asset with children of transformed asset and async node\n */\n\nexport const asyncTransform: AsyncTransformFunc = (\n assetId,\n wrapperAssetType,\n asset,\n flatten,\n path = [\"values\"],\n) => {\n const id = \"async-\" + assetId;\n\n const asyncNode = Builder.asyncNode(id, flatten);\n\n let multiNode;\n let assetNode;\n\n if (asset) {\n assetNode = Builder.assetWrapper(asset);\n multiNode = Builder.multiNode(assetNode, asyncNode);\n } else {\n multiNode = Builder.multiNode(asyncNode);\n }\n\n const wrapperAsset = Builder.asset({\n id: wrapperAssetType + \"-\" + id,\n type: wrapperAssetType,\n });\n\n Builder.addChild(wrapperAsset, path, multiNode);\n\n return wrapperAsset;\n};\n","import {\n BeforeTransformFunction,\n Builder,\n Node,\n NodeType,\n} from \"@player-ui/player\";\nimport {\n extractNodeFromPath,\n requiresAssetWrapper,\n traverseAndReplace,\n unwrapAsset,\n} from \"./utils\";\n\nexport type AsyncTransformOptions = {\n /** Whether or not to flatten the results into its container. Defaults to true */\n flatten?: boolean;\n /** The path to the array within the `wrapperAssetType` that will contain the async content. Defaults to [\"values\"] */\n path?: string[];\n /** The asset type that the transform is matching against. */\n transformAssetType: string;\n /** The asset type that will contain the async content. */\n wrapperAssetType: string;\n /** Function to get any nested asset that will need to be extracted and kept when creating the wrapper asset. */\n getNestedAsset?: (node: Node.ViewOrAsset) => Node.Node | undefined;\n /** Function to get the id for the async node being generated. Defaults to creating an id with the format of async-<ASSET.ID> */\n getAsyncNodeId?: (node: Node.ViewOrAsset) => string;\n /** Where to place the async node relative to the asset from `getNestedAsset`. Defaults to \"append\" */\n asyncNodePosition?: \"append\" | \"prepend\";\n};\n\nconst defaultGetNodeId = (node: Node.ViewOrAsset): string => {\n return `async-${node.value.id}`;\n};\n\n/** Creates a BeforeTransformFunction that turns the given asset into a wrapper asset with an async node in it.\n * By setting {@link AsyncTransformOptions.flatten} to true, you can chain multiple of the same asset type to create a flow of async content that\n * exists within a single collection.\n *\n * @param options - Options for managing the transform\n * @returns The {@link BeforeTransformFunction} that can be used for your asset.\n */\nexport const createAsyncTransform = (\n options: AsyncTransformOptions,\n): BeforeTransformFunction => {\n const {\n transformAssetType,\n wrapperAssetType,\n getNestedAsset,\n getAsyncNodeId = defaultGetNodeId,\n path = [\"values\"],\n flatten = true,\n asyncNodePosition = \"append\",\n } = options;\n\n const replaceNode = (node: Node.Node): Node.Node => {\n const unwrapped = unwrapAsset(node);\n\n if (\n unwrapped.type !== NodeType.Asset ||\n unwrapped.value.type !== transformAssetType\n ) {\n return node;\n }\n\n const transformed = asyncTransform(unwrapped);\n return extractNodeFromPath(transformed, path) ?? node;\n };\n\n const replacer = (node: Node.Node) => traverseAndReplace(node, replaceNode);\n\n const asyncTransform = (node: Node.ViewOrAsset) => {\n const id = getAsyncNodeId(node);\n const asset = getNestedAsset?.(node);\n\n // If flattening is disabled, don't need to extract the multi-node when async node is resolved.\n const replaceFunction = flatten ? replacer : undefined;\n const asyncNode = Builder.asyncNode(id, flatten, replaceFunction);\n\n const values: Node.Node[] = [asyncNode];\n if (asset) {\n const otherValues = [];\n if (requiresAssetWrapper(asset)) {\n otherValues.push(Builder.assetWrapper(asset));\n } else if (asset.type === NodeType.MultiNode) {\n otherValues.push(...asset.values);\n } else {\n otherValues.push(asset);\n }\n\n if (asyncNodePosition === \"append\") {\n values.unshift(...otherValues);\n } else {\n values.push(...otherValues);\n }\n }\n\n const multiNode = Builder.multiNode(...(values as any[]));\n\n const wrapperAsset: Node.ViewOrAsset = Builder.asset({\n id: wrapperAssetType + \"-\" + id,\n type: wrapperAssetType,\n });\n\n Builder.addChild(wrapperAsset, path, multiNode);\n\n return wrapperAsset;\n };\n\n return asyncTransform;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAAoC;AAapC,wBAAkD;AAClD,6BAA2B;;;ACd3B,oBAIO;AAEA,IAAM,mBAAmB;AAIzB,IAAM,iBAAN,cACG,MAEV;AAAA,EAKE,YACE,MACA,SACgB,OAChB;AACA,UAAM,OAAO;AAFG;AAPlB,SAAS,OAAe;AACxB,SAAS,WAA0B,4BAAc;AAU/C,SAAK,WAAW;AAAA,MACd;AAAA,IACF;AAAA,EACF;AACF;;;AC1BA,IAAM,gBAAgB,CACpB,OACA,UACW;AACX,MAAI,MAAM,SAAS,MAAM,QAAQ;AAC/B,WAAO;AAAA,EACT;AAEA,MAAI,aAAa;AACjB,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,QAAI,MAAM,CAAC,MAAM,MAAM,CAAC,GAAG;AACzB;AAAA,I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,UACA,gBAAgB,oBAAI,IAAI;AAAA,UACxB,cAAc,oBAAI,IAAI;AAAA,UACtB,gBAAgB,oBAAI,IAAI;AAAA,UACxB,mBAAmB,oBAAI,IAAI;AAAA,QAC7B;AACA,yBAAiB;AAEjB,aAAK,MAAM,SAAS,IAAI,SAAS,CAAC,aAAa;AAC7C,eAAK,cAAc,UAAU,OAAO;AAAA,QACtC,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,YAAY,iBAAwC;AAClD,SAAK,aAAa;AAAA,EACpB;AACF;","names":["import_player","import_player","import_player","import_player","import_player","import_player","import_player","asyncTransform","queueMicrotask","node"]}
|
package/dist/index.legacy-esm.js
CHANGED
|
@@ -418,14 +418,23 @@ var AsyncNodePluginPlugin = class {
|
|
|
418
418
|
}
|
|
419
419
|
async runAsyncNode(node, context, options) {
|
|
420
420
|
try {
|
|
421
|
+
let deliveredViaCallback = false;
|
|
421
422
|
const result = await this.basePlugin?.hooks.onAsyncNode.call(
|
|
422
423
|
node,
|
|
423
|
-
(
|
|
424
|
-
|
|
424
|
+
(streamedResult) => {
|
|
425
|
+
deliveredViaCallback = true;
|
|
426
|
+
this.parseNodeAndUpdate(
|
|
427
|
+
node,
|
|
428
|
+
context,
|
|
429
|
+
streamedResult,
|
|
430
|
+
options.parseNode
|
|
431
|
+
);
|
|
425
432
|
}
|
|
426
433
|
);
|
|
427
434
|
context.inProgressNodes.delete(node.id);
|
|
428
|
-
|
|
435
|
+
if (!deliveredViaCallback && result != null) {
|
|
436
|
+
this.parseNodeAndUpdate(node, context, result, options.parseNode);
|
|
437
|
+
}
|
|
429
438
|
} catch (e) {
|
|
430
439
|
const cause = e instanceof Error ? e : new Error(String(e));
|
|
431
440
|
const playerState = this.basePlugin?.getPlayerInstance()?.getState();
|
package/dist/index.mjs
CHANGED
|
@@ -418,14 +418,23 @@ var AsyncNodePluginPlugin = class {
|
|
|
418
418
|
}
|
|
419
419
|
async runAsyncNode(node, context, options) {
|
|
420
420
|
try {
|
|
421
|
+
let deliveredViaCallback = false;
|
|
421
422
|
const result = await this.basePlugin?.hooks.onAsyncNode.call(
|
|
422
423
|
node,
|
|
423
|
-
(
|
|
424
|
-
|
|
424
|
+
(streamedResult) => {
|
|
425
|
+
deliveredViaCallback = true;
|
|
426
|
+
this.parseNodeAndUpdate(
|
|
427
|
+
node,
|
|
428
|
+
context,
|
|
429
|
+
streamedResult,
|
|
430
|
+
options.parseNode
|
|
431
|
+
);
|
|
425
432
|
}
|
|
426
433
|
);
|
|
427
434
|
context.inProgressNodes.delete(node.id);
|
|
428
|
-
|
|
435
|
+
if (!deliveredViaCallback && result != null) {
|
|
436
|
+
this.parseNodeAndUpdate(node, context, result, options.parseNode);
|
|
437
|
+
}
|
|
429
438
|
} catch (e) {
|
|
430
439
|
const cause = e instanceof Error ? e : new Error(String(e));
|
|
431
440
|
const playerState = this.basePlugin?.getPlayerInstance()?.getState();
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/AsyncNodeError.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/extractNodeFromPath.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/traverseAndReplace.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/unwrapAsset.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/requiresAssetWrapper.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/isAsyncPlayerError.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/getNodeFromError.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/createAsyncTransform.ts"],"sourcesContent":["import { NodeType, getNodeID } from \"@player-ui/player\";\nimport type {\n Player,\n PlayerPlugin,\n Node,\n ParseObjectOptions,\n ParseObjectChildOptions,\n ViewInstance,\n Parser,\n ViewPlugin,\n Resolver,\n Resolve,\n} from \"@player-ui/player\";\nimport { AsyncSeriesBailHook, SyncBailHook } from \"tapable-ts\";\nimport queueMicrotask from \"queue-microtask\";\nimport { AsyncNodeError } from \"./AsyncNodeError\";\nimport { AsyncNodeInfo, AsyncPluginContext } from \"./internal-types\";\nimport { getNodeFromError } from \"./utils\";\n\nexport * from \"./types\";\nexport * from \"./transform\";\nexport * from \"./createAsyncTransform\";\n\nexport interface AsyncNodePluginOptions {\n /** A set of plugins to load */\n plugins?: AsyncNodeViewPlugin[];\n}\n\nexport interface AsyncNodeViewPlugin extends ViewPlugin {\n /** Use this to tap into the async node plugin hooks */\n applyPlugin: (asyncNodePlugin: AsyncNodePlugin) => void;\n\n applyPlayer?: (player: Player) => void;\n}\nexport type AsyncHandler = (\n node: Node.Async,\n callback?: (result: any) => void,\n) => Promise<any>;\n\nexport type AsyncContent = {\n async: true;\n flatten?: boolean;\n [key: string]: unknown;\n};\n\n/** Hook declaration for the AsyncNodePlugin */\nexport type AsyncNodeHooks = {\n /** Async hook to get content for an async node */\n onAsyncNode: AsyncSeriesBailHook<[Node.Async, (result: any) => void], any>;\n /** Sync hook to manage errors coming from the onAsyncNode hook. Return a fallback node or null to render a fallback. The first argument of passed in the call is the error thrown. */\n onAsyncNodeError: SyncBailHook<[Error, Node.Async], any>;\n};\n\nexport const AsyncNodePluginSymbol: symbol = Symbol.for(\"AsyncNodePlugin\");\n\n/**\n * Async node plugin used to resolve async nodes in the content\n * If an async node is present, allow users to provide a replacement node to be rendered when ready\n */\nexport class AsyncNodePlugin implements PlayerPlugin {\n private plugins: AsyncNodeViewPlugin[] | undefined;\n private playerInstance: Player | undefined;\n\n static Symbol: symbol = AsyncNodePluginSymbol;\n public readonly symbol: symbol = AsyncNodePlugin.Symbol;\n\n constructor(options: AsyncNodePluginOptions, asyncHandler?: AsyncHandler) {\n if (options?.plugins) {\n this.plugins = options.plugins;\n options.plugins.forEach((plugin) => {\n plugin.applyPlugin(this);\n });\n }\n\n if (asyncHandler) {\n this.hooks.onAsyncNode.tap(\n \"async\",\n async (node: Node.Async, callback) => {\n return await asyncHandler(node, callback);\n },\n );\n }\n }\n\n public readonly hooks: AsyncNodeHooks = {\n onAsyncNode: new AsyncSeriesBailHook(),\n onAsyncNodeError: new SyncBailHook(),\n };\n\n getPlayerInstance(): Player | undefined {\n return this.playerInstance;\n }\n\n name = \"AsyncNode\";\n\n apply(player: Player): void {\n this.playerInstance = player;\n\n this.plugins?.forEach((plugin) => {\n plugin.applyPlayer?.(player);\n });\n\n player.hooks.viewController.tap(this.name, (viewController) => {\n viewController.hooks.view.tap(this.name, (view) => {\n this.plugins?.forEach((plugin) => {\n plugin.apply(view);\n });\n });\n });\n }\n}\n\nexport class AsyncNodePluginPlugin implements AsyncNodeViewPlugin {\n private basePlugin: AsyncNodePlugin | undefined;\n\n name = \"AsyncNode\";\n\n /**\n * Parses the node from the result and triggers an asynchronous view update if necessary.\n * @param node The asynchronous node that might be updated.\n * @param result The result obtained from resolving the async node. This could be any data structure or value.\n * @param options Options provided for node resolution, including a potential parseNode function to process the result.\n * @param view The view instance where the node resides. This can be undefined if the view is not currently active.\n */\n private parseNodeAndUpdate(\n node: Node.Async,\n context: AsyncPluginContext,\n result: any,\n parseFunction?: (content: any) => Node.Node | null,\n ) {\n let parsedNode =\n parseFunction && result ? parseFunction(result) : undefined;\n\n if (parsedNode && node.onValueReceived) {\n parsedNode = node.onValueReceived(parsedNode);\n }\n\n this.handleAsyncUpdate(node, context, parsedNode);\n }\n\n /**\n * Updates the node asynchronously based on the result provided.\n * This method is responsible for handling the update logic of asynchronous nodes.\n * It checks if the node needs to be updated based on the new result and updates the mapping accordingly.\n * If an update is necessary, it triggers an asynchronous update on the view.\n * @param node The asynchronous node that might be updated.\n * @param newNode The new node to replace the async node.\n * @param view The view instance where the node resides. This can be undefined if the view is not currently active.\n */\n private handleAsyncUpdate(\n node: Node.Async,\n context: AsyncPluginContext,\n newNode?: Node.Node | null,\n ) {\n const { asyncNodeCache: asyncNodeInfo, viewController } = context;\n const entry = asyncNodeInfo.get(node.id);\n if (!entry) {\n throw new Error(\"Failed to update async content. Cache entry not found\");\n }\n if (entry.resolvedContent !== newNode) {\n entry.resolvedContent = newNode ? newNode : entry.asyncNode;\n viewController.updateViewAST(entry.updateNodes);\n }\n }\n\n private hasValidMapping(\n cacheEntry: AsyncNodeInfo,\n ): cacheEntry is Required<AsyncNodeInfo> {\n return (\n cacheEntry.resolvedContent !== undefined &&\n cacheEntry.resolvedContent !== cacheEntry.asyncNode\n );\n }\n\n private getOrCreateAsyncNodeCacheEntry(\n node: Node.Async,\n context: AsyncPluginContext,\n ): AsyncNodeInfo {\n const { asyncNodeCache: asyncNodeInfo } = context;\n let entry = asyncNodeInfo.get(node.id);\n if (!entry) {\n entry = {\n asyncNode: node,\n updateNodes: new Set(),\n };\n asyncNodeInfo.set(node.id, entry);\n }\n\n return entry;\n }\n\n /**\n * Handles the asynchronous API integration for resolving nodes.\n * This method sets up a hook on the resolver's `beforeResolve` event to process async nodes.\n * @param resolver The resolver instance to attach the hook to.\n * @param view\n */\n applyResolver(resolver: Resolver, context: AsyncPluginContext): void {\n const { assetIdCache } = context;\n resolver.hooks.afterNodeUpdate.tap(this.name, (original, _, update) => {\n if (\n update.node.type !== NodeType.Asset &&\n update.node.type !== NodeType.View\n ) {\n return;\n }\n\n assetIdCache.set(update.value.id, original);\n });\n\n resolver.hooks.beforeResolve.tap(this.name, (node, options) => {\n if (!this.isAsync(node)) {\n return node === null ? node : this.resolveAsyncChildren(node, context);\n }\n\n const entry = this.getOrCreateAsyncNodeCacheEntry(node, context);\n\n if (options.node) {\n entry.updateNodes = new Set([options.node]);\n context.generatedByMap.set(options.node, node.id);\n }\n\n if (entry.resolvedContent !== undefined) {\n return this.resolveAsyncChildren(entry.resolvedContent, context);\n }\n\n if (context.inProgressNodes.has(node.id)) {\n return node;\n }\n\n // Track that the node is in progress.\n context.inProgressNodes.add(node.id);\n queueMicrotask(() => {\n this.runAsyncNode(node, context, options).finally();\n });\n\n return node;\n });\n }\n\n /**\n * Replaces child async nodes with their resolved content and flattens when necessary. Resolving the children directly helps manage the `parent` reference without needing as much work within the resolver itself.\n * Handles async node chains as well to make sure all applicable nodes can get flattened.\n * @param node - The node whose children need to be resolved.\n * @param context - the async plugin context needed to reach into the cache\n * @returns The same node but with async node children mapped to their resolved AST.\n */\n private resolveAsyncChildren(\n node: Node.Node,\n context: AsyncPluginContext,\n ): Node.Node {\n if (node.type === NodeType.MultiNode) {\n // Using a while loop lets us catch when async nodes produce more async nodes that need to be flattened further\n let index = 0;\n while (index < node.values.length) {\n const childNode = node.values[index];\n if (childNode?.type !== NodeType.Async) {\n index++;\n continue;\n }\n const entry = this.getOrCreateAsyncNodeCacheEntry(childNode, context);\n\n if (!this.hasValidMapping(entry)) {\n index++;\n continue;\n }\n\n const mappedNode = entry.resolvedContent;\n const nodeSet = new Set<Node.Node>();\n if (mappedNode.type === NodeType.MultiNode && childNode.flatten) {\n mappedNode.values.forEach((v: Node.Node) => {\n v.parent = node;\n nodeSet.add(v);\n context.originalParentMap.set(v, childNode);\n });\n node.values = [\n ...node.values.slice(0, index),\n ...mappedNode.values,\n ...node.values.slice(index + 1),\n ];\n } else {\n node.values[index] = mappedNode;\n mappedNode.parent = node;\n nodeSet.add(mappedNode);\n }\n entry.updateNodes = nodeSet;\n for (const n of nodeSet) {\n context.generatedByMap.set(n, childNode.id);\n }\n }\n } else if (\"children\" in node) {\n node.children?.forEach((c) => {\n // Similar to above, using a while loop lets us handle when async nodes produce more async nodes.\n while (c.value.type === NodeType.Async) {\n const entry = this.getOrCreateAsyncNodeCacheEntry(c.value, context);\n if (!this.hasValidMapping(entry)) {\n break;\n }\n\n const mappedNode = entry.resolvedContent;\n entry.updateNodes = new Set([mappedNode]);\n context.generatedByMap.set(mappedNode, c.value.id);\n c.value = mappedNode;\n c.value.parent = node;\n }\n });\n }\n\n return node;\n }\n\n private async runAsyncNode(\n node: Node.Async,\n context: AsyncPluginContext,\n options: Resolve.NodeResolveOptions,\n ) {\n try {\n const result = await this.basePlugin?.hooks.onAsyncNode.call(\n node,\n (result) => {\n this.parseNodeAndUpdate(node, context, result, options.parseNode);\n },\n );\n\n // Stop tracking before the next update is triggered\n context.inProgressNodes.delete(node.id);\n this.parseNodeAndUpdate(node, context, result, options.parseNode);\n } catch (e: unknown) {\n const cause = e instanceof Error ? e : new Error(String(e));\n const playerState = this.basePlugin?.getPlayerInstance()?.getState();\n\n if (playerState?.status !== \"in-progress\") {\n options.logger?.warn(\n \"[AsyncNodePlugin]: An error occured during async node resolution, but the player instance is no londer running. Exception: \",\n cause,\n );\n return;\n }\n\n const error = new AsyncNodeError(\n node,\n \"An error occured during async node resolution. See cause for details.\",\n cause,\n );\n playerState.controllers.error.captureError(error);\n }\n }\n\n private isAsync(node: Node.Node | null): node is Node.Async {\n return node?.type === NodeType.Async;\n }\n\n private isDeterminedAsync(obj: unknown): obj is AsyncContent {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n Object.prototype.hasOwnProperty.call(obj, \"async\")\n );\n }\n\n applyParser(parser: Parser): void {\n parser.hooks.parseNode.tap(\n this.name,\n (\n obj: any,\n nodeType: Node.ChildrenTypes,\n options: ParseObjectOptions,\n childOptions?: ParseObjectChildOptions,\n ) => {\n if (this.isDeterminedAsync(obj)) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { async, flatten, ...rest } = obj;\n const parsedAsync = parser.parseObject(rest, nodeType, options);\n const parsedNodeId = getNodeID(parsedAsync);\n\n if (parsedAsync === null || !parsedNodeId) {\n return childOptions ? [] : null;\n }\n\n const asyncAST = parser.createASTNode(\n {\n id: parsedNodeId,\n type: NodeType.Async,\n value: parsedAsync,\n flatten,\n },\n obj,\n );\n\n if (childOptions) {\n return asyncAST\n ? [\n {\n path: [...childOptions.path, childOptions.key],\n value: asyncAST,\n },\n ]\n : [];\n }\n\n return asyncAST;\n }\n },\n );\n }\n\n apply(view: ViewInstance): void {\n view.hooks.parser.tap(\"async\", this.applyParser.bind(this));\n }\n\n applyPlayer(player: Player): void {\n // TODO: Need a better mechanism for storing the current context.\n let currentContext: AsyncPluginContext | undefined = undefined;\n let parser: Parser | undefined = undefined;\n\n player.hooks.errorController.tap(\"async\", (errorController) => {\n errorController.hooks.onError.tap(\"async\", (playerError) => {\n if (currentContext === undefined) {\n return undefined;\n }\n\n /** Try to handle the error using the onAsyncNodeError hook. Returns true if new content is provided. */\n const tryHandleError = (asyncNode: Node.Async): boolean => {\n if (this.basePlugin === undefined) {\n player.logger.warn(\n `[AsyncNodePlugin]: No plugin detected. Error handling will fail`,\n );\n }\n\n let result: any = undefined;\n result = this.basePlugin?.hooks.onAsyncNodeError.call(\n playerError,\n asyncNode,\n );\n\n if (result === undefined) {\n return false;\n }\n\n player.logger?.warn(\n \"[AsyncNodePlugin]: Async node handling failed and resolved with a fallback. Cause:\",\n playerError.message,\n );\n\n // Stop tracking before the next update is triggered\n currentContext!.inProgressNodes.delete(asyncNode.id);\n this.parseNodeAndUpdate(\n asyncNode,\n currentContext!,\n result,\n parser?.parseObject.bind(parser),\n );\n\n return true;\n };\n\n const getNextNode = (node: Node.Node): Node.Node | undefined => {\n const parent =\n currentContext?.originalParentMap.get(node) ?? node.parent;\n\n if (!parent) {\n return undefined;\n }\n\n // asyncNodeCache has current asyncNode reference more up to date with what's happening in the resolver. Sometimes AsyncNodeError has old references so this helps us move up the tree more accurately\n return this.isAsync(parent)\n ? currentContext?.asyncNodeCache.get(parent.id)?.asyncNode\n : parent;\n };\n\n let node = getNodeFromError(playerError, currentContext);\n // If the node is an async node try, to handle errors with it first.\n if (node?.type === NodeType.Async && tryHandleError(node)) {\n return true;\n }\n\n // Loop through the nodes to see if something is generated by something else. Continue until the error is handled or there are no more nodes to check\n while (node !== undefined) {\n const generatedBy = currentContext.generatedByMap.get(node);\n if (generatedBy) {\n const entry = currentContext.asyncNodeCache.get(generatedBy);\n\n if (!entry) {\n node = getNextNode(node);\n continue;\n }\n\n const { asyncNode } = entry;\n\n // Don't return false when the error isn't handled to allow for cases where one async is generated by another. Give different nodes a chance to try to recover from the error.\n if (tryHandleError(asyncNode)) {\n return true;\n }\n }\n\n node = getNextNode(node);\n }\n\n return undefined;\n });\n });\n\n player.hooks.viewController.tap(\"async\", (viewController) => {\n viewController.hooks.view.tap(\"async\", (view) => {\n view.hooks.parser.tap(this.name, (p) => {\n parser = p;\n });\n const context: AsyncPluginContext = {\n inProgressNodes: new Set(),\n view,\n viewController,\n generatedByMap: new Map(),\n assetIdCache: new Map(),\n asyncNodeCache: new Map(),\n originalParentMap: new Map(),\n };\n currentContext = context;\n\n view.hooks.resolver.tap(\"async\", (resolver) => {\n this.applyResolver(resolver, context);\n });\n });\n });\n }\n\n applyPlugin(asyncNodePlugin: AsyncNodePlugin): void {\n this.basePlugin = asyncNodePlugin;\n }\n}\n","import {\n ErrorSeverity,\n type Node,\n type PlayerErrorMetadata,\n} from \"@player-ui/player\";\n\nexport const ASYNC_ERROR_TYPE = \"ASYNC-PLUGIN\";\nexport type AsyncErrorMetadata = {\n node: Node.Async;\n};\nexport class AsyncNodeError\n extends Error\n implements PlayerErrorMetadata<AsyncErrorMetadata>\n{\n readonly type: string = ASYNC_ERROR_TYPE;\n readonly severity: ErrorSeverity = ErrorSeverity.ERROR;\n readonly metadata: AsyncErrorMetadata;\n\n constructor(\n node: Node.Async,\n message?: string,\n public readonly cause?: Error | undefined,\n ) {\n super(message);\n\n this.metadata = {\n node,\n };\n }\n}\n","import type { Node } from \"@player-ui/player\";\n\n/** Matches 2 segments where pathA matches or is a subset of pathB. Returns the number of matching segments */\nconst getMatchValue = (\n pathA: Node.PathSegment[],\n pathB: Node.PathSegment[],\n): number => {\n if (pathA.length > pathB.length) {\n return 0;\n }\n\n let matchCount = 0;\n for (let i = 0; i < pathA.length; i++) {\n if (pathA[i] === pathB[i]) {\n matchCount++;\n } else {\n return 0;\n }\n }\n\n return matchCount;\n};\n\n/** Follows the given path and returns the node. If there is no match, returns undefined */\nexport const extractNodeFromPath = (\n node: Node.Node,\n path?: string[],\n): Node.Node | undefined => {\n if (path === undefined || path.length === 0) {\n return node;\n }\n\n if (!(\"children\" in node && node.children)) {\n return undefined;\n }\n\n let matchResult = 0;\n let bestMatch: Node.Child | undefined;\n for (const child of node.children) {\n const matchValue = getMatchValue(child.path, path);\n if (matchValue > matchResult) {\n matchResult = matchValue;\n bestMatch = child;\n }\n }\n\n if (!bestMatch) {\n return undefined;\n }\n\n if (matchResult >= path.length) {\n return bestMatch.value;\n }\n\n return extractNodeFromPath(bestMatch.value, path.slice(matchResult));\n};\n","import { NodeType, Node } from \"@player-ui/player\";\n\n/** Replaces a node using the given replace function. If the node is a multi-node it does this transformation to all of its values. */\nexport const traverseAndReplace = (\n node: Node.Node,\n replaceFn: (node: Node.Node) => Node.Node,\n): Node.Node => {\n if (node.type === NodeType.MultiNode) {\n let index = 0;\n while (index < node.values.length) {\n const child = node.values[index];\n if (!child) {\n index++;\n continue;\n }\n\n const result = replaceFn(child);\n if (result.type === NodeType.MultiNode) {\n node.values = [\n ...node.values.slice(0, index),\n ...result.values,\n ...node.values.slice(index + 1),\n ];\n } else {\n node.values[index] = result;\n index++;\n }\n }\n\n return node;\n }\n\n return replaceFn(node);\n};\n","import { NodeType, Node } from \"@player-ui/player\";\n\nexport const unwrapAsset = (node: Node.Node): Node.Node => {\n if (node.type !== NodeType.Value) {\n return node;\n }\n const child = node.children?.find(\n (x) => x.path.length === 1 && x.path[0] === \"asset\",\n );\n\n if (!child) {\n return node;\n }\n\n return child.value;\n};\n","import { NodeType } from \"@player-ui/player\";\nimport type { Node } from \"@player-ui/player\";\n\nexport const requiresAssetWrapper = (node: Node.Node): boolean => {\n if (node.type === NodeType.Asset) {\n return true;\n }\n\n if (node.type !== NodeType.Applicability) {\n return false;\n }\n\n return node.value.type === NodeType.Asset;\n};\n","import { PlayerError } from \"@player-ui/player\";\nimport { ASYNC_ERROR_TYPE, AsyncErrorMetadata } from \"../AsyncNodeError\";\n\nexport const isAsyncPlayerError = (\n error: PlayerError,\n): error is PlayerError<AsyncErrorMetadata> => {\n return error.type === ASYNC_ERROR_TYPE;\n};\n","import { PlayerError, Node, ErrorTypes } from \"@player-ui/player\";\nimport { AsyncPluginContext } from \"../internal-types\";\nimport { isAsyncPlayerError } from \"./isAsyncPlayerError\";\n\n/** Get the AST Node related to a specific error if available. */\nexport const getNodeFromError = (\n playerError: PlayerError,\n context: AsyncPluginContext,\n): Node.Node | undefined => {\n if (playerError.type === ErrorTypes.RENDER) {\n const { assetId } = playerError.metadata ?? {};\n\n if (typeof assetId !== \"string\") {\n return undefined;\n }\n\n return context.assetIdCache.get(assetId);\n }\n\n if (playerError.type === ErrorTypes.VIEW) {\n const { node } = playerError.metadata ?? {};\n // TODO: Remove some of this from here. Maybe export type assertion functions from where the errors are generated?\n if (typeof node === \"object\" && node !== null && !Array.isArray(node)) {\n return node as Node.Node;\n }\n }\n\n if (isAsyncPlayerError(playerError) && playerError.metadata !== undefined) {\n // Use the node from the cache to ensure it is the latest version of the async node from the resolver\n return context.asyncNodeCache.get(playerError.metadata.node.id)?.asyncNode;\n }\n\n return undefined;\n};\n","import { Builder } from \"@player-ui/player\";\nimport type { AsyncTransformFunc } from \"./types\";\n\n/**\n * @deprecated Use {@link createAsyncTransform} to create your before transform function.\n * Util function to generate transform function for async asset\n * @param asset - async asset to apply beforeResolve transform\n * @param wrapperAssetType: container asset type\n * @param flatten: flatten the streamed in content\n * @param path: property path to add the multinode containing the next async node to\n * @returns - wrapper asset with children of transformed asset and async node\n */\n\nexport const asyncTransform: AsyncTransformFunc = (\n assetId,\n wrapperAssetType,\n asset,\n flatten,\n path = [\"values\"],\n) => {\n const id = \"async-\" + assetId;\n\n const asyncNode = Builder.asyncNode(id, flatten);\n\n let multiNode;\n let assetNode;\n\n if (asset) {\n assetNode = Builder.assetWrapper(asset);\n multiNode = Builder.multiNode(assetNode, asyncNode);\n } else {\n multiNode = Builder.multiNode(asyncNode);\n }\n\n const wrapperAsset = Builder.asset({\n id: wrapperAssetType + \"-\" + id,\n type: wrapperAssetType,\n });\n\n Builder.addChild(wrapperAsset, path, multiNode);\n\n return wrapperAsset;\n};\n","import {\n BeforeTransformFunction,\n Builder,\n Node,\n NodeType,\n} from \"@player-ui/player\";\nimport {\n extractNodeFromPath,\n requiresAssetWrapper,\n traverseAndReplace,\n unwrapAsset,\n} from \"./utils\";\n\nexport type AsyncTransformOptions = {\n /** Whether or not to flatten the results into its container. Defaults to true */\n flatten?: boolean;\n /** The path to the array within the `wrapperAssetType` that will contain the async content. Defaults to [\"values\"] */\n path?: string[];\n /** The asset type that the transform is matching against. */\n transformAssetType: string;\n /** The asset type that will contain the async content. */\n wrapperAssetType: string;\n /** Function to get any nested asset that will need to be extracted and kept when creating the wrapper asset. */\n getNestedAsset?: (node: Node.ViewOrAsset) => Node.Node | undefined;\n /** Function to get the id for the async node being generated. Defaults to creating an id with the format of async-<ASSET.ID> */\n getAsyncNodeId?: (node: Node.ViewOrAsset) => string;\n /** Where to place the async node relative to the asset from `getNestedAsset`. Defaults to \"append\" */\n asyncNodePosition?: \"append\" | \"prepend\";\n};\n\nconst defaultGetNodeId = (node: Node.ViewOrAsset): string => {\n return `async-${node.value.id}`;\n};\n\n/** Creates a BeforeTransformFunction that turns the given asset into a wrapper asset with an async node in it.\n * By setting {@link AsyncTransformOptions.flatten} to true, you can chain multiple of the same asset type to create a flow of async content that\n * exists within a single collection.\n *\n * @param options - Options for managing the transform\n * @returns The {@link BeforeTransformFunction} that can be used for your asset.\n */\nexport const createAsyncTransform = (\n options: AsyncTransformOptions,\n): BeforeTransformFunction => {\n const {\n transformAssetType,\n wrapperAssetType,\n getNestedAsset,\n getAsyncNodeId = defaultGetNodeId,\n path = [\"values\"],\n flatten = true,\n asyncNodePosition = \"append\",\n } = options;\n\n const replaceNode = (node: Node.Node): Node.Node => {\n const unwrapped = unwrapAsset(node);\n\n if (\n unwrapped.type !== NodeType.Asset ||\n unwrapped.value.type !== transformAssetType\n ) {\n return node;\n }\n\n const transformed = asyncTransform(unwrapped);\n return extractNodeFromPath(transformed, path) ?? node;\n };\n\n const replacer = (node: Node.Node) => traverseAndReplace(node, replaceNode);\n\n const asyncTransform = (node: Node.ViewOrAsset) => {\n const id = getAsyncNodeId(node);\n const asset = getNestedAsset?.(node);\n\n // If flattening is disabled, don't need to extract the multi-node when async node is resolved.\n const replaceFunction = flatten ? replacer : undefined;\n const asyncNode = Builder.asyncNode(id, flatten, replaceFunction);\n\n const values: Node.Node[] = [asyncNode];\n if (asset) {\n const otherValues = [];\n if (requiresAssetWrapper(asset)) {\n otherValues.push(Builder.assetWrapper(asset));\n } else if (asset.type === NodeType.MultiNode) {\n otherValues.push(...asset.values);\n } else {\n otherValues.push(asset);\n }\n\n if (asyncNodePosition === \"append\") {\n values.unshift(...otherValues);\n } else {\n values.push(...otherValues);\n }\n }\n\n const multiNode = Builder.multiNode(...(values as any[]));\n\n const wrapperAsset: Node.ViewOrAsset = Builder.asset({\n id: wrapperAssetType + \"-\" + id,\n type: wrapperAssetType,\n });\n\n Builder.addChild(wrapperAsset, path, multiNode);\n\n return wrapperAsset;\n };\n\n return asyncTransform;\n};\n"],"mappings":";AAAA,SAAS,YAAAA,WAAU,iBAAiB;AAapC,SAAS,qBAAqB,oBAAoB;AAClD,OAAO,oBAAoB;;;ACd3B;AAAA,EACE;AAAA,OAGK;AAEA,IAAM,mBAAmB;AAIzB,IAAM,iBAAN,cACG,MAEV;AAAA,EAKE,YACE,MACA,SACgB,OAChB;AACA,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e,IAAI,SAAS,CAAC,mBAAmB;AAC3D,qBAAe,MAAM,KAAK,IAAI,SAAS,CAAC,SAAS;AAC/C,aAAK,MAAM,OAAO,IAAI,KAAK,MAAM,CAAC,MAAM;AACtC,mBAAS;AAAA,QACX,CAAC;AACD,cAAM,UAA8B;AAAA,UAClC,iBAAiB,oBAAI,IAAI;AAAA,UACzB;AAAA,UACA;AAAA,UACA,gBAAgB,oBAAI,IAAI;AAAA,UACxB,cAAc,oBAAI,IAAI;AAAA,UACtB,gBAAgB,oBAAI,IAAI;AAAA,UACxB,mBAAmB,oBAAI,IAAI;AAAA,QAC7B;AACA,yBAAiB;AAEjB,aAAK,MAAM,SAAS,IAAI,SAAS,CAAC,aAAa;AAC7C,eAAK,cAAc,UAAU,OAAO;AAAA,QACtC,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,YAAY,iBAAwC;AAClD,SAAK,aAAa;AAAA,EACpB;AACF;","names":["NodeType","NodeType","NodeType","Builder","NodeType","NodeType","asyncTransform","Builder","NodeType","result","node"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/AsyncNodeError.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/extractNodeFromPath.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/traverseAndReplace.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/unwrapAsset.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/requiresAssetWrapper.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/isAsyncPlayerError.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/getNodeFromError.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/createAsyncTransform.ts"],"sourcesContent":["import { NodeType, getNodeID } from \"@player-ui/player\";\nimport type {\n Player,\n PlayerPlugin,\n Node,\n ParseObjectOptions,\n ParseObjectChildOptions,\n ViewInstance,\n Parser,\n ViewPlugin,\n Resolver,\n Resolve,\n} from \"@player-ui/player\";\nimport { AsyncSeriesBailHook, SyncBailHook } from \"tapable-ts\";\nimport queueMicrotask from \"queue-microtask\";\nimport { AsyncNodeError } from \"./AsyncNodeError\";\nimport { AsyncNodeInfo, AsyncPluginContext } from \"./internal-types\";\nimport { getNodeFromError } from \"./utils\";\n\nexport * from \"./types\";\nexport * from \"./transform\";\nexport * from \"./createAsyncTransform\";\n\nexport interface AsyncNodePluginOptions {\n /** A set of plugins to load */\n plugins?: AsyncNodeViewPlugin[];\n}\n\nexport interface AsyncNodeViewPlugin extends ViewPlugin {\n /** Use this to tap into the async node plugin hooks */\n applyPlugin: (asyncNodePlugin: AsyncNodePlugin) => void;\n\n applyPlayer?: (player: Player) => void;\n}\nexport type AsyncHandler = (\n node: Node.Async,\n callback?: (result: any) => void,\n) => Promise<any>;\n\nexport type AsyncContent = {\n async: true;\n flatten?: boolean;\n [key: string]: unknown;\n};\n\n/** Hook declaration for the AsyncNodePlugin */\nexport type AsyncNodeHooks = {\n /** Async hook to get content for an async node */\n onAsyncNode: AsyncSeriesBailHook<[Node.Async, (result: any) => void], any>;\n /** Sync hook to manage errors coming from the onAsyncNode hook. Return a fallback node or null to render a fallback. The first argument of passed in the call is the error thrown. */\n onAsyncNodeError: SyncBailHook<[Error, Node.Async], any>;\n};\n\nexport const AsyncNodePluginSymbol: symbol = Symbol.for(\"AsyncNodePlugin\");\n\n/**\n * Async node plugin used to resolve async nodes in the content\n * If an async node is present, allow users to provide a replacement node to be rendered when ready\n */\nexport class AsyncNodePlugin implements PlayerPlugin {\n private plugins: AsyncNodeViewPlugin[] | undefined;\n private playerInstance: Player | undefined;\n\n static Symbol: symbol = AsyncNodePluginSymbol;\n public readonly symbol: symbol = AsyncNodePlugin.Symbol;\n\n constructor(options: AsyncNodePluginOptions, asyncHandler?: AsyncHandler) {\n if (options?.plugins) {\n this.plugins = options.plugins;\n options.plugins.forEach((plugin) => {\n plugin.applyPlugin(this);\n });\n }\n\n if (asyncHandler) {\n this.hooks.onAsyncNode.tap(\n \"async\",\n async (node: Node.Async, callback) => {\n return await asyncHandler(node, callback);\n },\n );\n }\n }\n\n public readonly hooks: AsyncNodeHooks = {\n onAsyncNode: new AsyncSeriesBailHook(),\n onAsyncNodeError: new SyncBailHook(),\n };\n\n getPlayerInstance(): Player | undefined {\n return this.playerInstance;\n }\n\n name = \"AsyncNode\";\n\n apply(player: Player): void {\n this.playerInstance = player;\n\n this.plugins?.forEach((plugin) => {\n plugin.applyPlayer?.(player);\n });\n\n player.hooks.viewController.tap(this.name, (viewController) => {\n viewController.hooks.view.tap(this.name, (view) => {\n this.plugins?.forEach((plugin) => {\n plugin.apply(view);\n });\n });\n });\n }\n}\n\nexport class AsyncNodePluginPlugin implements AsyncNodeViewPlugin {\n private basePlugin: AsyncNodePlugin | undefined;\n\n name = \"AsyncNode\";\n\n /**\n * Parses the node from the result and triggers an asynchronous view update if necessary.\n * @param node The asynchronous node that might be updated.\n * @param result The result obtained from resolving the async node. This could be any data structure or value.\n * @param options Options provided for node resolution, including a potential parseNode function to process the result.\n * @param view The view instance where the node resides. This can be undefined if the view is not currently active.\n */\n private parseNodeAndUpdate(\n node: Node.Async,\n context: AsyncPluginContext,\n result: any,\n parseFunction?: (content: any) => Node.Node | null,\n ) {\n let parsedNode =\n parseFunction && result ? parseFunction(result) : undefined;\n\n if (parsedNode && node.onValueReceived) {\n parsedNode = node.onValueReceived(parsedNode);\n }\n\n this.handleAsyncUpdate(node, context, parsedNode);\n }\n\n /**\n * Updates the node asynchronously based on the result provided.\n * This method is responsible for handling the update logic of asynchronous nodes.\n * It checks if the node needs to be updated based on the new result and updates the mapping accordingly.\n * If an update is necessary, it triggers an asynchronous update on the view.\n * @param node The asynchronous node that might be updated.\n * @param newNode The new node to replace the async node.\n * @param view The view instance where the node resides. This can be undefined if the view is not currently active.\n */\n private handleAsyncUpdate(\n node: Node.Async,\n context: AsyncPluginContext,\n newNode?: Node.Node | null,\n ) {\n const { asyncNodeCache: asyncNodeInfo, viewController } = context;\n const entry = asyncNodeInfo.get(node.id);\n if (!entry) {\n throw new Error(\"Failed to update async content. Cache entry not found\");\n }\n if (entry.resolvedContent !== newNode) {\n entry.resolvedContent = newNode ? newNode : entry.asyncNode;\n viewController.updateViewAST(entry.updateNodes);\n }\n }\n\n private hasValidMapping(\n cacheEntry: AsyncNodeInfo,\n ): cacheEntry is Required<AsyncNodeInfo> {\n return (\n cacheEntry.resolvedContent !== undefined &&\n cacheEntry.resolvedContent !== cacheEntry.asyncNode\n );\n }\n\n private getOrCreateAsyncNodeCacheEntry(\n node: Node.Async,\n context: AsyncPluginContext,\n ): AsyncNodeInfo {\n const { asyncNodeCache: asyncNodeInfo } = context;\n let entry = asyncNodeInfo.get(node.id);\n if (!entry) {\n entry = {\n asyncNode: node,\n updateNodes: new Set(),\n };\n asyncNodeInfo.set(node.id, entry);\n }\n\n return entry;\n }\n\n /**\n * Handles the asynchronous API integration for resolving nodes.\n * This method sets up a hook on the resolver's `beforeResolve` event to process async nodes.\n * @param resolver The resolver instance to attach the hook to.\n * @param view\n */\n applyResolver(resolver: Resolver, context: AsyncPluginContext): void {\n const { assetIdCache } = context;\n resolver.hooks.afterNodeUpdate.tap(this.name, (original, _, update) => {\n if (\n update.node.type !== NodeType.Asset &&\n update.node.type !== NodeType.View\n ) {\n return;\n }\n\n assetIdCache.set(update.value.id, original);\n });\n\n resolver.hooks.beforeResolve.tap(this.name, (node, options) => {\n if (!this.isAsync(node)) {\n return node === null ? node : this.resolveAsyncChildren(node, context);\n }\n\n const entry = this.getOrCreateAsyncNodeCacheEntry(node, context);\n\n if (options.node) {\n entry.updateNodes = new Set([options.node]);\n context.generatedByMap.set(options.node, node.id);\n }\n\n if (entry.resolvedContent !== undefined) {\n return this.resolveAsyncChildren(entry.resolvedContent, context);\n }\n\n if (context.inProgressNodes.has(node.id)) {\n return node;\n }\n\n // Track that the node is in progress.\n context.inProgressNodes.add(node.id);\n queueMicrotask(() => {\n this.runAsyncNode(node, context, options).finally();\n });\n\n return node;\n });\n }\n\n /**\n * Replaces child async nodes with their resolved content and flattens when necessary. Resolving the children directly helps manage the `parent` reference without needing as much work within the resolver itself.\n * Handles async node chains as well to make sure all applicable nodes can get flattened.\n * @param node - The node whose children need to be resolved.\n * @param context - the async plugin context needed to reach into the cache\n * @returns The same node but with async node children mapped to their resolved AST.\n */\n private resolveAsyncChildren(\n node: Node.Node,\n context: AsyncPluginContext,\n ): Node.Node {\n if (node.type === NodeType.MultiNode) {\n // Using a while loop lets us catch when async nodes produce more async nodes that need to be flattened further\n let index = 0;\n while (index < node.values.length) {\n const childNode = node.values[index];\n if (childNode?.type !== NodeType.Async) {\n index++;\n continue;\n }\n const entry = this.getOrCreateAsyncNodeCacheEntry(childNode, context);\n\n if (!this.hasValidMapping(entry)) {\n index++;\n continue;\n }\n\n const mappedNode = entry.resolvedContent;\n const nodeSet = new Set<Node.Node>();\n if (mappedNode.type === NodeType.MultiNode && childNode.flatten) {\n mappedNode.values.forEach((v: Node.Node) => {\n v.parent = node;\n nodeSet.add(v);\n context.originalParentMap.set(v, childNode);\n });\n node.values = [\n ...node.values.slice(0, index),\n ...mappedNode.values,\n ...node.values.slice(index + 1),\n ];\n } else {\n node.values[index] = mappedNode;\n mappedNode.parent = node;\n nodeSet.add(mappedNode);\n }\n entry.updateNodes = nodeSet;\n for (const n of nodeSet) {\n context.generatedByMap.set(n, childNode.id);\n }\n }\n } else if (\"children\" in node) {\n node.children?.forEach((c) => {\n // Similar to above, using a while loop lets us handle when async nodes produce more async nodes.\n while (c.value.type === NodeType.Async) {\n const entry = this.getOrCreateAsyncNodeCacheEntry(c.value, context);\n if (!this.hasValidMapping(entry)) {\n break;\n }\n\n const mappedNode = entry.resolvedContent;\n entry.updateNodes = new Set([mappedNode]);\n context.generatedByMap.set(mappedNode, c.value.id);\n c.value = mappedNode;\n c.value.parent = node;\n }\n });\n }\n\n return node;\n }\n\n private async runAsyncNode(\n node: Node.Async,\n context: AsyncPluginContext,\n options: Resolve.NodeResolveOptions,\n ) {\n try {\n // Track whether the callback pushed content while the hook was pending;\n // if so it wins over the bail return (avoids the last-writer-wins race\n // that intermittently dropped streamed rows).\n let deliveredViaCallback = false;\n\n const result = await this.basePlugin?.hooks.onAsyncNode.call(\n node,\n (streamedResult) => {\n deliveredViaCallback = true;\n this.parseNodeAndUpdate(\n node,\n context,\n streamedResult,\n options.parseNode,\n );\n },\n );\n\n // Stop tracking before the next update is triggered\n context.inProgressNodes.delete(node.id);\n\n // Once the callback has delivered content it is the source of truth, so a\n // stale/empty bail return must not clobber it. Skip unless no callback ran\n // (!deliveredViaCallback) and the return carries content (result != null).\n if (!deliveredViaCallback && result != null) {\n this.parseNodeAndUpdate(node, context, result, options.parseNode);\n }\n } catch (e: unknown) {\n const cause = e instanceof Error ? e : new Error(String(e));\n const playerState = this.basePlugin?.getPlayerInstance()?.getState();\n\n if (playerState?.status !== \"in-progress\") {\n options.logger?.warn(\n \"[AsyncNodePlugin]: An error occured during async node resolution, but the player instance is no londer running. Exception: \",\n cause,\n );\n return;\n }\n\n const error = new AsyncNodeError(\n node,\n \"An error occured during async node resolution. See cause for details.\",\n cause,\n );\n playerState.controllers.error.captureError(error);\n }\n }\n\n private isAsync(node: Node.Node | null): node is Node.Async {\n return node?.type === NodeType.Async;\n }\n\n private isDeterminedAsync(obj: unknown): obj is AsyncContent {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n Object.prototype.hasOwnProperty.call(obj, \"async\")\n );\n }\n\n applyParser(parser: Parser): void {\n parser.hooks.parseNode.tap(\n this.name,\n (\n obj: any,\n nodeType: Node.ChildrenTypes,\n options: ParseObjectOptions,\n childOptions?: ParseObjectChildOptions,\n ) => {\n if (this.isDeterminedAsync(obj)) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { async, flatten, ...rest } = obj;\n const parsedAsync = parser.parseObject(rest, nodeType, options);\n const parsedNodeId = getNodeID(parsedAsync);\n\n if (parsedAsync === null || !parsedNodeId) {\n return childOptions ? [] : null;\n }\n\n const asyncAST = parser.createASTNode(\n {\n id: parsedNodeId,\n type: NodeType.Async,\n value: parsedAsync,\n flatten,\n },\n obj,\n );\n\n if (childOptions) {\n return asyncAST\n ? [\n {\n path: [...childOptions.path, childOptions.key],\n value: asyncAST,\n },\n ]\n : [];\n }\n\n return asyncAST;\n }\n },\n );\n }\n\n apply(view: ViewInstance): void {\n view.hooks.parser.tap(\"async\", this.applyParser.bind(this));\n }\n\n applyPlayer(player: Player): void {\n // TODO: Need a better mechanism for storing the current context.\n let currentContext: AsyncPluginContext | undefined = undefined;\n let parser: Parser | undefined = undefined;\n\n player.hooks.errorController.tap(\"async\", (errorController) => {\n errorController.hooks.onError.tap(\"async\", (playerError) => {\n if (currentContext === undefined) {\n return undefined;\n }\n\n /** Try to handle the error using the onAsyncNodeError hook. Returns true if new content is provided. */\n const tryHandleError = (asyncNode: Node.Async): boolean => {\n if (this.basePlugin === undefined) {\n player.logger.warn(\n `[AsyncNodePlugin]: No plugin detected. Error handling will fail`,\n );\n }\n\n let result: any = undefined;\n result = this.basePlugin?.hooks.onAsyncNodeError.call(\n playerError,\n asyncNode,\n );\n\n if (result === undefined) {\n return false;\n }\n\n player.logger?.warn(\n \"[AsyncNodePlugin]: Async node handling failed and resolved with a fallback. Cause:\",\n playerError.message,\n );\n\n // Stop tracking before the next update is triggered\n currentContext!.inProgressNodes.delete(asyncNode.id);\n this.parseNodeAndUpdate(\n asyncNode,\n currentContext!,\n result,\n parser?.parseObject.bind(parser),\n );\n\n return true;\n };\n\n const getNextNode = (node: Node.Node): Node.Node | undefined => {\n const parent =\n currentContext?.originalParentMap.get(node) ?? node.parent;\n\n if (!parent) {\n return undefined;\n }\n\n // asyncNodeCache has current asyncNode reference more up to date with what's happening in the resolver. Sometimes AsyncNodeError has old references so this helps us move up the tree more accurately\n return this.isAsync(parent)\n ? currentContext?.asyncNodeCache.get(parent.id)?.asyncNode\n : parent;\n };\n\n let node = getNodeFromError(playerError, currentContext);\n // If the node is an async node try, to handle errors with it first.\n if (node?.type === NodeType.Async && tryHandleError(node)) {\n return true;\n }\n\n // Loop through the nodes to see if something is generated by something else. Continue until the error is handled or there are no more nodes to check\n while (node !== undefined) {\n const generatedBy = currentContext.generatedByMap.get(node);\n if (generatedBy) {\n const entry = currentContext.asyncNodeCache.get(generatedBy);\n\n if (!entry) {\n node = getNextNode(node);\n continue;\n }\n\n const { asyncNode } = entry;\n\n // Don't return false when the error isn't handled to allow for cases where one async is generated by another. Give different nodes a chance to try to recover from the error.\n if (tryHandleError(asyncNode)) {\n return true;\n }\n }\n\n node = getNextNode(node);\n }\n\n return undefined;\n });\n });\n\n player.hooks.viewController.tap(\"async\", (viewController) => {\n viewController.hooks.view.tap(\"async\", (view) => {\n view.hooks.parser.tap(this.name, (p) => {\n parser = p;\n });\n const context: AsyncPluginContext = {\n inProgressNodes: new Set(),\n view,\n viewController,\n generatedByMap: new Map(),\n assetIdCache: new Map(),\n asyncNodeCache: new Map(),\n originalParentMap: new Map(),\n };\n currentContext = context;\n\n view.hooks.resolver.tap(\"async\", (resolver) => {\n this.applyResolver(resolver, context);\n });\n });\n });\n }\n\n applyPlugin(asyncNodePlugin: AsyncNodePlugin): void {\n this.basePlugin = asyncNodePlugin;\n }\n}\n","import {\n ErrorSeverity,\n type Node,\n type PlayerErrorMetadata,\n} from \"@player-ui/player\";\n\nexport const ASYNC_ERROR_TYPE = \"ASYNC-PLUGIN\";\nexport type AsyncErrorMetadata = {\n node: Node.Async;\n};\nexport class AsyncNodeError\n extends Error\n implements PlayerErrorMetadata<AsyncErrorMetadata>\n{\n readonly type: string = ASYNC_ERROR_TYPE;\n readonly severity: ErrorSeverity = ErrorSeverity.ERROR;\n readonly metadata: AsyncErrorMetadata;\n\n constructor(\n node: Node.Async,\n message?: string,\n public readonly cause?: Error | undefined,\n ) {\n super(message);\n\n this.metadata = {\n node,\n };\n }\n}\n","import type { Node } from \"@player-ui/player\";\n\n/** Matches 2 segments where pathA matches or is a subset of pathB. Returns the number of matching segments */\nconst getMatchValue = (\n pathA: Node.PathSegment[],\n pathB: Node.PathSegment[],\n): number => {\n if (pathA.length > pathB.length) {\n return 0;\n }\n\n let matchCount = 0;\n for (let i = 0; i < pathA.length; i++) {\n if (pathA[i] === pathB[i]) {\n matchCount++;\n } else {\n return 0;\n }\n }\n\n return matchCount;\n};\n\n/** Follows the given path and returns the node. If there is no match, returns undefined */\nexport const extractNodeFromPath = (\n node: Node.Node,\n path?: string[],\n): Node.Node | undefined => {\n if (path === undefined || path.length === 0) {\n return node;\n }\n\n if (!(\"children\" in node && node.children)) {\n return undefined;\n }\n\n let matchResult = 0;\n let bestMatch: Node.Child | undefined;\n for (const child of node.children) {\n const matchValue = getMatchValue(child.path, path);\n if (matchValue > matchResult) {\n matchResult = matchValue;\n bestMatch = child;\n }\n }\n\n if (!bestMatch) {\n return undefined;\n }\n\n if (matchResult >= path.length) {\n return bestMatch.value;\n }\n\n return extractNodeFromPath(bestMatch.value, path.slice(matchResult));\n};\n","import { NodeType, Node } from \"@player-ui/player\";\n\n/** Replaces a node using the given replace function. If the node is a multi-node it does this transformation to all of its values. */\nexport const traverseAndReplace = (\n node: Node.Node,\n replaceFn: (node: Node.Node) => Node.Node,\n): Node.Node => {\n if (node.type === NodeType.MultiNode) {\n let index = 0;\n while (index < node.values.length) {\n const child = node.values[index];\n if (!child) {\n index++;\n continue;\n }\n\n const result = replaceFn(child);\n if (result.type === NodeType.MultiNode) {\n node.values = [\n ...node.values.slice(0, index),\n ...result.values,\n ...node.values.slice(index + 1),\n ];\n } else {\n node.values[index] = result;\n index++;\n }\n }\n\n return node;\n }\n\n return replaceFn(node);\n};\n","import { NodeType, Node } from \"@player-ui/player\";\n\nexport const unwrapAsset = (node: Node.Node): Node.Node => {\n if (node.type !== NodeType.Value) {\n return node;\n }\n const child = node.children?.find(\n (x) => x.path.length === 1 && x.path[0] === \"asset\",\n );\n\n if (!child) {\n return node;\n }\n\n return child.value;\n};\n","import { NodeType } from \"@player-ui/player\";\nimport type { Node } from \"@player-ui/player\";\n\nexport const requiresAssetWrapper = (node: Node.Node): boolean => {\n if (node.type === NodeType.Asset) {\n return true;\n }\n\n if (node.type !== NodeType.Applicability) {\n return false;\n }\n\n return node.value.type === NodeType.Asset;\n};\n","import { PlayerError } from \"@player-ui/player\";\nimport { ASYNC_ERROR_TYPE, AsyncErrorMetadata } from \"../AsyncNodeError\";\n\nexport const isAsyncPlayerError = (\n error: PlayerError,\n): error is PlayerError<AsyncErrorMetadata> => {\n return error.type === ASYNC_ERROR_TYPE;\n};\n","import { PlayerError, Node, ErrorTypes } from \"@player-ui/player\";\nimport { AsyncPluginContext } from \"../internal-types\";\nimport { isAsyncPlayerError } from \"./isAsyncPlayerError\";\n\n/** Get the AST Node related to a specific error if available. */\nexport const getNodeFromError = (\n playerError: PlayerError,\n context: AsyncPluginContext,\n): Node.Node | undefined => {\n if (playerError.type === ErrorTypes.RENDER) {\n const { assetId } = playerError.metadata ?? {};\n\n if (typeof assetId !== \"string\") {\n return undefined;\n }\n\n return context.assetIdCache.get(assetId);\n }\n\n if (playerError.type === ErrorTypes.VIEW) {\n const { node } = playerError.metadata ?? {};\n // TODO: Remove some of this from here. Maybe export type assertion functions from where the errors are generated?\n if (typeof node === \"object\" && node !== null && !Array.isArray(node)) {\n return node as Node.Node;\n }\n }\n\n if (isAsyncPlayerError(playerError) && playerError.metadata !== undefined) {\n // Use the node from the cache to ensure it is the latest version of the async node from the resolver\n return context.asyncNodeCache.get(playerError.metadata.node.id)?.asyncNode;\n }\n\n return undefined;\n};\n","import { Builder } from \"@player-ui/player\";\nimport type { AsyncTransformFunc } from \"./types\";\n\n/**\n * @deprecated Use {@link createAsyncTransform} to create your before transform function.\n * Util function to generate transform function for async asset\n * @param asset - async asset to apply beforeResolve transform\n * @param wrapperAssetType: container asset type\n * @param flatten: flatten the streamed in content\n * @param path: property path to add the multinode containing the next async node to\n * @returns - wrapper asset with children of transformed asset and async node\n */\n\nexport const asyncTransform: AsyncTransformFunc = (\n assetId,\n wrapperAssetType,\n asset,\n flatten,\n path = [\"values\"],\n) => {\n const id = \"async-\" + assetId;\n\n const asyncNode = Builder.asyncNode(id, flatten);\n\n let multiNode;\n let assetNode;\n\n if (asset) {\n assetNode = Builder.assetWrapper(asset);\n multiNode = Builder.multiNode(assetNode, asyncNode);\n } else {\n multiNode = Builder.multiNode(asyncNode);\n }\n\n const wrapperAsset = Builder.asset({\n id: wrapperAssetType + \"-\" + id,\n type: wrapperAssetType,\n });\n\n Builder.addChild(wrapperAsset, path, multiNode);\n\n return wrapperAsset;\n};\n","import {\n BeforeTransformFunction,\n Builder,\n Node,\n NodeType,\n} from \"@player-ui/player\";\nimport {\n extractNodeFromPath,\n requiresAssetWrapper,\n traverseAndReplace,\n unwrapAsset,\n} from \"./utils\";\n\nexport type AsyncTransformOptions = {\n /** Whether or not to flatten the results into its container. Defaults to true */\n flatten?: boolean;\n /** The path to the array within the `wrapperAssetType` that will contain the async content. Defaults to [\"values\"] */\n path?: string[];\n /** The asset type that the transform is matching against. */\n transformAssetType: string;\n /** The asset type that will contain the async content. */\n wrapperAssetType: string;\n /** Function to get any nested asset that will need to be extracted and kept when creating the wrapper asset. */\n getNestedAsset?: (node: Node.ViewOrAsset) => Node.Node | undefined;\n /** Function to get the id for the async node being generated. Defaults to creating an id with the format of async-<ASSET.ID> */\n getAsyncNodeId?: (node: Node.ViewOrAsset) => string;\n /** Where to place the async node relative to the asset from `getNestedAsset`. Defaults to \"append\" */\n asyncNodePosition?: \"append\" | \"prepend\";\n};\n\nconst defaultGetNodeId = (node: Node.ViewOrAsset): string => {\n return `async-${node.value.id}`;\n};\n\n/** Creates a BeforeTransformFunction that turns the given asset into a wrapper asset with an async node in it.\n * By setting {@link AsyncTransformOptions.flatten} to true, you can chain multiple of the same asset type to create a flow of async content that\n * exists within a single collection.\n *\n * @param options - Options for managing the transform\n * @returns The {@link BeforeTransformFunction} that can be used for your asset.\n */\nexport const createAsyncTransform = (\n options: AsyncTransformOptions,\n): BeforeTransformFunction => {\n const {\n transformAssetType,\n wrapperAssetType,\n getNestedAsset,\n getAsyncNodeId = defaultGetNodeId,\n path = [\"values\"],\n flatten = true,\n asyncNodePosition = \"append\",\n } = options;\n\n const replaceNode = (node: Node.Node): Node.Node => {\n const unwrapped = unwrapAsset(node);\n\n if (\n unwrapped.type !== NodeType.Asset ||\n unwrapped.value.type !== transformAssetType\n ) {\n return node;\n }\n\n const transformed = asyncTransform(unwrapped);\n return extractNodeFromPath(transformed, path) ?? node;\n };\n\n const replacer = (node: Node.Node) => traverseAndReplace(node, replaceNode);\n\n const asyncTransform = (node: Node.ViewOrAsset) => {\n const id = getAsyncNodeId(node);\n const asset = getNestedAsset?.(node);\n\n // If flattening is disabled, don't need to extract the multi-node when async node is resolved.\n const replaceFunction = flatten ? replacer : undefined;\n const asyncNode = Builder.asyncNode(id, flatten, replaceFunction);\n\n const values: Node.Node[] = [asyncNode];\n if (asset) {\n const otherValues = [];\n if (requiresAssetWrapper(asset)) {\n otherValues.push(Builder.assetWrapper(asset));\n } else if (asset.type === NodeType.MultiNode) {\n otherValues.push(...asset.values);\n } else {\n otherValues.push(asset);\n }\n\n if (asyncNodePosition === \"append\") {\n values.unshift(...otherValues);\n } else {\n values.push(...otherValues);\n }\n }\n\n const multiNode = Builder.multiNode(...(values as any[]));\n\n const wrapperAsset: Node.ViewOrAsset = Builder.asset({\n id: wrapperAssetType + \"-\" + id,\n type: wrapperAssetType,\n });\n\n Builder.addChild(wrapperAsset, path, multiNode);\n\n return wrapperAsset;\n };\n\n return asyncTransform;\n};\n"],"mappings":";AAAA,SAAS,YAAAA,WAAU,iBAAiB;AAapC,SAAS,qBAAqB,oBAAoB;AAClD,OAAO,oBAAoB;;;ACd3B;AAAA,EACE;AAAA,OAGK;AAEA,IAAM,mBAAmB;AAIzB,IAAM,iBAAN,cACG,MAEV;AAAA,EAKE,YACE,MACA,SACgB,OAChB;AACA,UAAM,OAAO;AAFG;AAPlB,SAAS,OAAe;AACxB,SAAS,WAA0B,cAAc;AAU/C,SAAK,WAAW;AAAA,MACd;AAAA,IACF;AAAA,EACF;AACF;;;AC1BA,IAAM,gBAAgB,CACpB,OACA,UACW;AACX,MAAI,MAAM,SAAS,MAAM,QAAQ;AAC/B,WAAO;AAAA,EACT;AAEA,MAAI,aAAa;AACjB,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,QAAI,MAAM,CAAC,MAAM,MAAM,CAAC,GAAG;AACzB;AAAA,IACF,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAGO,IAAM,sBAAsB,CACjC,MACA,SAC0B;AAC1B,MAAI,SAAS,UAAa,KAAK,WAAW,GAAG;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,EAAE,cAAc,QAAQ,KAAK,WAAW;AAC1C,WAAO;AAAA,EACT;AAEA,MAAI,cAAc;AAClB,MAAI;AACJ,aAAW,SAAS,KAAK,UAAU;AACjC,UAAM,aAAa,cAAc,MAAM,MAAM,IAAI;AACjD,QAAI,aAAa,aAAa;AAC5B,oBAAc;AACd,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,MAAI,eAAe,KAAK,QAAQ;AAC9B,WAAO,UAAU;AAAA,EACnB;AAEA,SAAO,oBAAoB,UAAU,OAAO,KAAK,MAAM,WAAW,CAAC;AACrE;;;ACv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;AAAA,QACT;AAGA,eAAO,SAAS,QAAW;AACzB,gBAAM,cAAc,eAAe,eAAe,IAAI,IAAI;AAC1D,cAAI,aAAa;AACf,kBAAM,QAAQ,eAAe,eAAe,IAAI,WAAW;AAE3D,gBAAI,CAAC,OAAO;AACV,qBAAO,YAAY,IAAI;AACvB;AAAA,YACF;AAEA,kBAAM,EAAE,UAAU,IAAI;AAGtB,gBAAI,eAAe,SAAS,GAAG;AAC7B,qBAAO;AAAA,YACT;AAAA,UACF;AAEA,iBAAO,YAAY,IAAI;AAAA,QACzB;AAEA,eAAO;AAAA,MACT,CAAC;AAAA,IACH,CAAC;AAED,WAAO,MAAM,eAAe,IAAI,SAAS,CAAC,mBAAmB;AAC3D,qBAAe,MAAM,KAAK,IAAI,SAAS,CAAC,SAAS;AAC/C,aAAK,MAAM,OAAO,IAAI,KAAK,MAAM,CAAC,MAAM;AACtC,mBAAS;AAAA,QACX,CAAC;AACD,cAAM,UAA8B;AAAA,UAClC,iBAAiB,oBAAI,IAAI;AAAA,UACzB;AAAA,UACA;AAAA,UACA,gBAAgB,oBAAI,IAAI;AAAA,UACxB,cAAc,oBAAI,IAAI;AAAA,UACtB,gBAAgB,oBAAI,IAAI;AAAA,UACxB,mBAAmB,oBAAI,IAAI;AAAA,QAC7B;AACA,yBAAiB;AAEjB,aAAK,MAAM,SAAS,IAAI,SAAS,CAAC,aAAa;AAC7C,eAAK,cAAc,UAAU,OAAO;AAAA,QACtC,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,YAAY,iBAAwC;AAClD,SAAK,aAAa;AAAA,EACpB;AACF;","names":["NodeType","NodeType","NodeType","Builder","NodeType","NodeType","asyncTransform","Builder","NodeType","node"]}
|
package/package.json
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-ui/async-node-plugin",
|
|
9
|
-
"version": "1.1.0
|
|
9
|
+
"version": "1.1.0",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@player-ui/player": "1.1.0
|
|
12
|
+
"@player-ui/player": "1.1.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@player-ui/check-path-plugin": "workspace:^",
|