@player-ui/external-state-plugin 1.0.0--canary.865.36694
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/ExternalStatePlugin.native.js +756 -0
- package/dist/ExternalStatePlugin.native.js.map +1 -0
- package/dist/cjs/index.cjs +135 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +110 -0
- package/dist/index.mjs +110 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +30 -0
- package/src/__tests__/index.test.ts +538 -0
- package/src/index.ts +176 -0
- package/src/symbols.ts +4 -0
- package/types/index.d.ts +52 -0
- package/types/symbols.d.ts +2 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2540/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/dist/index.global.js","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/fast-sort@3.4.1/node_modules/fast-sort/dist/sort.mjs","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/index.js","../../../../../../../../../../../../execroot/execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts","../../../../../../../../../../../../execroot/execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/symbols.ts"],"names":["ExternalStatePlugin","createNewSortInstance","opts","comparer","castComparer","arrayToSort","ctx","Array","isArray","inPlaceSorting","slice","asc","sortBy","sortArray","desc","by","dlv_es_default","obj","key","def","p","undef","split","length","createObjectMatcher","partialObj","pairs","traverseObj","matchFunction","searchObj","from","entry","path","value","count","size","createBasicMatcher","seed","matcher","match","isExternal","state","state_type","isInProgress","status","__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","except","call","__toCommonJS","mod","src_exports","a","b","order","throwInvalidConfigErrorIfTrue","condition","context","Error","unpackObjectSorter","sortByObj","_a","multiPropertySorterProvider","defaultComparer","multiPropertySorter","sortByArr","depth","valA","valB","objectSorterConfig","equality","getSortStrategy","includes","multiPropSorter_1","sort","inPlaceSort","object","Map","keys","val","nestedPath","set","Registry","initialSet","logger","store","forEach","existingIndex","findIndex","splice","debug","push","query","callbackfn","clear","isRegistryEmpty","ExternalStatePluginSymbol","Symbol","for","_ExternalStatePlugin","handlers","symbol","apply","player","isFirstInstance","createRegistry","registerHandlers","hooks","flowController","tap","flow","afterTransition","flowInstance","toState","currentState","handler","transitionValue","latestState","error","getState","registry","controllers","current","transition","warn","fail","existing","findPlugin","ref","JSON","stringify","handlerFunction"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,sBAAsB,AAAC;QC2ElBC,wBAAT,SAASA,sBAAsBC,IAAA;QAC3B,IAAIC,WAAWC,aAAaF,KAAKC,QAAQ;QACzC,OAAO,SAAUE,WAAA;YACb,IAAIC,MAAMC,MAAMC,OAAA,CAAQH,gBAAgB,CAACH,KAAKO,cAAA,GACxCJ,YAAYK,KAAA,KACZL;YACN,OAAO;gBACHM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Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts\n var src_exports = {};\n __export(src_exports, {\n ExternalStatePlugin: () => ExternalStatePlugin\n });\n\n // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/fast-sort@3.4.1/node_modules/fast-sort/dist/sort.mjs\n var castComparer = function(comparer) {\n return function(a, b, order) {\n return comparer(a, b, order) * order;\n };\n };\n var throwInvalidConfigErrorIfTrue = function(condition, context) {\n if (condition)\n throw Error(\"Invalid sort config: \" + context);\n };\n var unpackObjectSorter = function(sortByObj) {\n var _a = sortByObj || {}, asc = _a.asc, desc = _a.desc;\n var order = asc ? 1 : -1;\n var sortBy = asc || desc;\n throwInvalidConfigErrorIfTrue(!sortBy, \"Expected `asc` or `desc` property\");\n throwInvalidConfigErrorIfTrue(asc && desc, \"Ambiguous object with `asc` and `desc` config properties\");\n var comparer = sortByObj.comparer && castComparer(sortByObj.comparer);\n return { order, sortBy, comparer };\n };\n var multiPropertySorterProvider = function(defaultComparer2) {\n return function multiPropertySorter(sortBy, sortByArr, depth, order, comparer, a, b) {\n var valA;\n var valB;\n if (typeof sortBy === \"string\") {\n valA = a[sortBy];\n valB = b[sortBy];\n } else if (typeof sortBy === \"function\") {\n valA = sortBy(a);\n valB = sortBy(b);\n } else {\n var objectSorterConfig = unpackObjectSorter(sortBy);\n return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer2, a, b);\n }\n var equality = comparer(valA, valB, order);\n if ((equality === 0 || valA == null && valB == null) && sortByArr.length > depth) {\n return multiPropertySorter(sortByArr[depth], sortByArr, depth + 1, order, comparer, a, b);\n }\n return equality;\n };\n };\n function getSortStrategy(sortBy, comparer, order) {\n if (sortBy === void 0 || sortBy === true) {\n return function(a, b) {\n return comparer(a, b, order);\n };\n }\n if (typeof sortBy === \"string\") {\n throwInvalidConfigErrorIfTrue(sortBy.includes(\".\"), \"String syntax not allowed for nested properties.\");\n return function(a, b) {\n return comparer(a[sortBy], b[sortBy], order);\n };\n }\n if (typeof sortBy === \"function\") {\n return function(a, b) {\n return comparer(sortBy(a), sortBy(b), order);\n };\n }\n if (Array.isArray(sortBy)) {\n var multiPropSorter_1 = multiPropertySorterProvider(comparer);\n return function(a, b) {\n return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a, b);\n };\n }\n var objectSorterConfig = unpackObjectSorter(sortBy);\n return getSortStrategy(objectSorterConfig.sortBy, objectSorterConfig.comparer || comparer, objectSorterConfig.order);\n }\n var sortArray = function(order, ctx, sortBy, comparer) {\n var _a;\n if (!Array.isArray(ctx)) {\n return ctx;\n }\n if (Array.isArray(sortBy) && sortBy.length < 2) {\n _a = sortBy, sortBy = _a[0];\n }\n return ctx.sort(getSortStrategy(sortBy, comparer, order));\n };\n function createNewSortInstance(opts) {\n var comparer = castComparer(opts.comparer);\n return function(arrayToSort) {\n var ctx = Array.isArray(arrayToSort) && !opts.inPlaceSorting ? arrayToSort.slice() : arrayToSort;\n return {\n asc: function(sortBy) {\n return sortArray(1, ctx, sortBy, comparer);\n },\n desc: function(sortBy) {\n return sortArray(-1, ctx, sortBy, comparer);\n },\n by: function(sortBy) {\n return sortArray(1, ctx, sortBy, comparer);\n }\n };\n };\n }\n var defaultComparer = function(a, b, order) {\n if (a == null)\n return order;\n if (b == null)\n return -order;\n if (typeof a !== typeof b) {\n return typeof a < typeof b ? -1 : 1;\n }\n if (a < b)\n return -1;\n if (a > b)\n return 1;\n return 0;\n };\n var sort = createNewSortInstance({\n comparer: defaultComparer\n });\n var inPlaceSort = createNewSortInstance({\n comparer: defaultComparer,\n inPlaceSorting: true\n });\n\n // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/dist/dlv.es.js\n function dlv_es_default(t, e, l, n, r) {\n for (e = e.split ? e.split(\".\") : e, n = 0; n < e.length; n++)\n t = t ? t[e[n]] : r;\n return t === r ? l : t;\n }\n\n // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+partial-match-registry@0.0.0/node_modules/@player-ui/partial-match-registry/dist/index.mjs\n function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {\n for (const key of Object.keys(object)) {\n const val = object[key];\n const nestedPath = [...path, key];\n if (typeof val === \"object\" && val !== null) {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n return pairs;\n }\n function createObjectMatcher(partialObj) {\n const pairs = traverseObj(partialObj);\n const matchFunction = (searchObj) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n if (dlv_es_default(searchObj, path) !== value) {\n return false;\n }\n }\n return true;\n };\n matchFunction.count = pairs.size;\n return matchFunction;\n }\n function createBasicMatcher(seed) {\n const matcher = (match) => seed === match;\n matcher.count = 1;\n return matcher;\n }\n var Registry = class {\n /**\n * Creates a new Registry instance\n *\n * @param initialSet - Optional array of [key, value] tuples to populate the registry\n * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)\n */\n constructor(initialSet, logger) {\n this.store = [];\n this.logger = logger;\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n /**\n * Add match -> value mapping to the registry\n *\n * If an entry with the same specificity and matching key already exists, it will be replaced\n * and a debug log will be emitted (if a logger is configured).\n *\n * @param match - The key to match against (can be a primitive or object)\n * @param value - The value to associate with this key\n */\n set(match, value) {\n const matcher = typeof match === \"object\" ? createObjectMatcher(match) : createBasicMatcher(match);\n const existingIndex = this.store.findIndex(\n (entry) => entry.matcher(match) && matcher(entry.key)\n );\n if (existingIndex !== -1) {\n this.store.splice(existingIndex, 1);\n this.logger?.debug?.(\n \"Registry: Replacing existing entry for key \",\n match\n );\n }\n this.store.push({\n key: match,\n value,\n matcher\n });\n this.store = sort(this.store).desc((entry) => entry.matcher.count);\n }\n /**\n * Fetch the best match in the registry\n *\n * Searches for the most specific entry that matches the given query.\n * The registry is sorted by specificity (matcher.count) in descending order,\n * so we iterate forward to find the highest specificity match first.\n *\n * @param query - The query object to match against registered keys\n * @returns The value associated with the best matching key, or undefined if no match found\n */\n get(query) {\n for (const entry of this.store) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n return void 0;\n }\n /** Loop over all entries and run callback */\n forEach(callbackfn) {\n for (const entry of this.store) {\n callbackfn(entry);\n }\n }\n /** Reset the items in the registry */\n clear() {\n this.store = [];\n }\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.length === 0;\n }\n };\n\n // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/symbols.ts\n var ExternalStatePluginSymbol = Symbol.for(\n \"@player-ui/ExternalStatePlugin\"\n );\n\n // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts\n function isExternal(state) {\n return state.state_type === \"EXTERNAL\";\n }\n function isInProgress(state) {\n return state.status === \"in-progress\";\n }\n var _ExternalStatePlugin = class _ExternalStatePlugin {\n /** Creates a new ExternalStatePlugin */\n constructor(handlers) {\n this.name = \"ExternalStatePlugin\";\n this.symbol = _ExternalStatePlugin.Symbol;\n this.handlers = handlers;\n }\n apply(player) {\n const isFirstInstance = this.createRegistry(player);\n this.registerHandlers(player);\n if (!isFirstInstance) {\n return;\n }\n player.hooks.flowController.tap(this.name, (flowController) => {\n flowController.hooks.flow.tap(this.name, (flow) => {\n flow.hooks.afterTransition.tap(this.name, async (flowInstance) => {\n const toState = flowInstance.currentState;\n const currentState = player.getState();\n if (toState && toState.value && isExternal(toState.value) && isInProgress(currentState)) {\n try {\n const handler = this.registry?.get(toState.value);\n const transitionValue = await handler?.(\n toState.value,\n currentState.controllers\n );\n if (transitionValue !== void 0) {\n const latestState = player.getState();\n if (isInProgress(latestState) && latestState.controllers.flow.current?.currentState?.name === toState.name) {\n latestState.controllers.flow.transition(transitionValue);\n } else {\n player.logger.warn(\n `External state resolved with [${transitionValue}], but Player already navigated away from [${toState.name}]`\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n currentState.fail(error);\n }\n }\n }\n });\n });\n });\n }\n /**\n * Create or share the registry for this plugin instance.\n *\n * Uses the Player's plugin registry to find if another instance of ExternalStatePlugin\n * has already been registered. If found, this instance will share that plugin's registry.\n * Otherwise, this instance creates a new registry.\n */\n createRegistry(player) {\n const existing = player.findPlugin(\n ExternalStatePluginSymbol\n );\n if (existing && existing !== this) {\n this.registry = existing.registry;\n return false;\n }\n this.registry = new Registry(\n void 0,\n player.logger\n );\n return true;\n }\n /**\n * Register this plugin's handlers to the shared registry.\n *\n * If a handler with the same specificity already exists, it will be replaced\n * and a debug log will be emitted (accessible via player.logger.debug).\n */\n registerHandlers(player) {\n for (const handler of this.handlers) {\n if (handler.match?.ref) {\n player.logger.warn(\n `An ExternalStateHandler contains a superfluous 'match.ref' property. 'match.ref' will be ignored. 'ref' will be used instead. Handler: ${JSON.stringify({ ref: handler.ref, match: handler.match })}`\n );\n delete handler.match?.[\"ref\"];\n continue;\n }\n this.registry?.set(\n { ref: handler.ref, ...handler.match },\n handler.handlerFunction\n );\n }\n }\n };\n /** Symbol used to identify and find existing instances of this plugin */\n _ExternalStatePlugin.Symbol = ExternalStatePluginSymbol;\n var ExternalStatePlugin = _ExternalStatePlugin;\n return __toCommonJS(src_exports);\n})();\n","// >>> INTERFACES <<<\r\n// >>> HELPERS <<<\r\nvar castComparer = function (comparer) { return function (a, b, order) { return comparer(a, b, order) * order; }; };\r\nvar throwInvalidConfigErrorIfTrue = function (condition, context) {\r\n if (condition)\r\n throw Error(\"Invalid sort config: \" + context);\r\n};\r\nvar unpackObjectSorter = function (sortByObj) {\r\n var _a = sortByObj || {}, asc = _a.asc, desc = _a.desc;\r\n var order = asc ? 1 : -1;\r\n var sortBy = (asc || desc);\r\n // Validate object config\r\n throwInvalidConfigErrorIfTrue(!sortBy, 'Expected `asc` or `desc` property');\r\n throwInvalidConfigErrorIfTrue(asc && desc, 'Ambiguous object with `asc` and `desc` config properties');\r\n var comparer = sortByObj.comparer && castComparer(sortByObj.comparer);\r\n return { order: order, sortBy: sortBy, comparer: comparer };\r\n};\r\n// >>> SORTERS <<<\r\nvar multiPropertySorterProvider = function (defaultComparer) {\r\n return function multiPropertySorter(sortBy, sortByArr, depth, order, comparer, a, b) {\r\n var valA;\r\n var valB;\r\n if (typeof sortBy === 'string') {\r\n valA = a[sortBy];\r\n valB = b[sortBy];\r\n }\r\n else if (typeof sortBy === 'function') {\r\n valA = sortBy(a);\r\n valB = sortBy(b);\r\n }\r\n else {\r\n var objectSorterConfig = unpackObjectSorter(sortBy);\r\n return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer, a, b);\r\n }\r\n var equality = comparer(valA, valB, order);\r\n if ((equality === 0 || (valA == null && valB == null)) &&\r\n sortByArr.length > depth) {\r\n return multiPropertySorter(sortByArr[depth], sortByArr, depth + 1, order, comparer, a, b);\r\n }\r\n return equality;\r\n };\r\n};\r\nfunction getSortStrategy(sortBy, comparer, order) {\r\n // Flat array sorter\r\n if (sortBy === undefined || sortBy === true) {\r\n return function (a, b) { return comparer(a, b, order); };\r\n }\r\n // Sort list of objects by single object key\r\n if (typeof sortBy === 'string') {\r\n throwInvalidConfigErrorIfTrue(sortBy.includes('.'), 'String syntax not allowed for nested properties.');\r\n return function (a, b) { return comparer(a[sortBy], b[sortBy], order); };\r\n }\r\n // Sort list of objects by single function sorter\r\n if (typeof sortBy === 'function') {\r\n return function (a, b) { return comparer(sortBy(a), sortBy(b), order); };\r\n }\r\n // Sort by multiple properties\r\n if (Array.isArray(sortBy)) {\r\n var multiPropSorter_1 = multiPropertySorterProvider(comparer);\r\n return function (a, b) { return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a, b); };\r\n }\r\n // Unpack object config to get actual sorter strategy\r\n var objectSorterConfig = unpackObjectSorter(sortBy);\r\n return getSortStrategy(objectSorterConfig.sortBy, objectSorterConfig.comparer || comparer, objectSorterConfig.order);\r\n}\r\nvar sortArray = function (order, ctx, sortBy, comparer) {\r\n var _a;\r\n if (!Array.isArray(ctx)) {\r\n return ctx;\r\n }\r\n // Unwrap sortBy if array with only 1 value to get faster sort strategy\r\n if (Array.isArray(sortBy) && sortBy.length < 2) {\r\n _a = sortBy, sortBy = _a[0];\r\n }\r\n return ctx.sort(getSortStrategy(sortBy, comparer, order));\r\n};\r\nfunction createNewSortInstance(opts) {\r\n var comparer = castComparer(opts.comparer);\r\n return function (arrayToSort) {\r\n var ctx = Array.isArray(arrayToSort) && !opts.inPlaceSorting\r\n ? arrayToSort.slice()\r\n : arrayToSort;\r\n return {\r\n asc: function (sortBy) {\r\n return sortArray(1, ctx, sortBy, comparer);\r\n },\r\n desc: function (sortBy) {\r\n return sortArray(-1, ctx, sortBy, comparer);\r\n },\r\n by: function (sortBy) {\r\n return sortArray(1, ctx, sortBy, comparer);\r\n },\r\n };\r\n };\r\n}\r\nvar defaultComparer = function (a, b, order) {\r\n if (a == null)\r\n return order;\r\n if (b == null)\r\n return -order;\r\n if (typeof a !== typeof b) {\r\n return typeof a < typeof b ? -1 : 1;\r\n }\r\n if (a < b)\r\n return -1;\r\n if (a > b)\r\n return 1;\r\n return 0;\r\n};\r\nvar sort = createNewSortInstance({\r\n comparer: defaultComparer,\r\n});\r\nvar inPlaceSort = createNewSortInstance({\r\n comparer: defaultComparer,\r\n inPlaceSorting: true,\r\n});\n\nexport { createNewSortInstance, defaultComparer, inPlaceSort, sort };\n","export default function dlv(obj, key, def, p, undef) {\n\tkey = key.split ? key.split('.') : key;\n\tfor (p = 0; p < key.length; p++) {\n\t\tobj = obj ? obj[key[p]] : undef;\n\t}\n\treturn obj === undef ? def : obj;\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n /* Explicitly avoid traversing null values.\n JavaScript's typeof null === \"object\" would otherwise cause the function to traverse null as an object\n and throw an error. \n \n Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n */\n if (typeof val === \"object\" && val !== null) {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n","import { sort } from \"fast-sort\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** Minimal logger interface for registry operations */\ninterface Logger {\n debug?: (...args: Array<any>) => void;\n}\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store: Array<RegistryIndex<V>> = [];\n private logger?: Logger;\n\n /**\n * Creates a new Registry instance\n *\n * @param initialSet - Optional array of [key, value] tuples to populate the registry\n * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)\n */\n constructor(initialSet?: Array<[any, V]>, logger?: Logger) {\n this.logger = logger;\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /**\n * Add match -> value mapping to the registry\n *\n * If an entry with the same specificity and matching key already exists, it will be replaced\n * and a debug log will be emitted (if a logger is configured).\n *\n * @param match - The key to match against (can be a primitive or object)\n * @param value - The value to associate with this key\n */\n set(match: any, value: V): void {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n // Find and remove any existing entry that matches this key\n // Use matcher to check for matching keys (handles deep equality)\n const existingIndex = this.store.findIndex(\n (entry) => entry.matcher(match) && matcher(entry.key),\n );\n if (existingIndex !== -1) {\n this.store.splice(existingIndex, 1);\n this.logger?.debug?.(\n \"Registry: Replacing existing entry for key \",\n match,\n );\n }\n\n this.store.push({\n key: match,\n value,\n matcher,\n });\n\n // Sort in descending order by matcher.count (highest specificity first)\n this.store = sort(this.store).desc((entry) => entry.matcher.count);\n }\n\n /**\n * Fetch the best match in the registry\n *\n * Searches for the most specific entry that matches the given query.\n * The registry is sorted by specificity (matcher.count) in descending order,\n * so we iterate forward to find the highest specificity match first.\n *\n * @param query - The query object to match against registered keys\n * @returns The value associated with the best matching key, or undefined if no match found\n */\n get(query: any): V | undefined {\n // Store is sorted by matcher.count (descending), so iterate forward\n for (const entry of this.store) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n return undefined;\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear(): void {\n this.store = [];\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty(): boolean {\n return this.store.length === 0;\n }\n}\n","import type {\n Player,\n PlayerPlugin,\n InProgressState,\n PlayerFlowState,\n NavigationFlowState,\n NavigationFlowExternalState,\n} from \"@player-ui/player\";\nimport { Registry } from \"@player-ui/partial-match-registry\";\nimport { ExternalStatePluginSymbol } from \"./symbols.js\";\n\nexport type ExternalStateHandlerMatch = Record<string, unknown>;\n\nexport type ExternalStateHandlerFunction = (\n state: NavigationFlowExternalState,\n options: InProgressState[\"controllers\"],\n) => string | undefined | Promise<string | undefined>;\n\nexport type ExternalStateHandler = {\n /** The name of the external state. This will appear as it's \"ref\" property in the DSL. */\n ref: string;\n /** Additional properties to match against the external state. */\n match?: ExternalStateHandlerMatch;\n /** The function to run when the external state is transitioned to. This should return the `ref` of the next state to transition to. */\n handlerFunction: ExternalStateHandlerFunction;\n};\n\nfunction isExternal(\n state: NavigationFlowState,\n): state is NavigationFlowExternalState {\n return state.state_type === \"EXTERNAL\";\n}\n\nfunction isInProgress(state: PlayerFlowState): state is InProgressState {\n return state.status === \"in-progress\";\n}\n\n/**\n * A plugin to handle external states\n *\n * This plugin uses a registry-based approach to match external states to handler functions.\n * Multiple plugins can be registered, and handlers are matched using partial object matching\n * with specificity ordering (more specific matches take precedence).\n */\nexport class ExternalStatePlugin implements PlayerPlugin {\n name = \"ExternalStatePlugin\";\n\n /** Symbol used to identify and find existing instances of this plugin */\n static Symbol: symbol = ExternalStatePluginSymbol;\n public readonly symbol: symbol = ExternalStatePlugin.Symbol;\n\n /**\n * The shared registry that maps external states to handlers.\n * All plugin instances use the same registry.\n */\n private registry?: Registry<ExternalStateHandlerFunction>;\n\n /**\n * The handlers for this plugin instance.\n */\n private readonly handlers: ExternalStateHandler[];\n\n /** Creates a new ExternalStatePlugin */\n constructor(handlers: ExternalStateHandler[]) {\n this.handlers = handlers;\n }\n\n apply(player: Player): void {\n const isFirstInstance = this.createRegistry(player);\n this.registerHandlers(player);\n\n // Only the first instance should tap the hooks to avoid redundant taps\n if (!isFirstInstance) {\n return;\n }\n\n player.hooks.flowController.tap(this.name, (flowController) => {\n flowController.hooks.flow.tap(this.name, (flow) => {\n flow.hooks.afterTransition.tap(this.name, async (flowInstance) => {\n const toState = flowInstance.currentState;\n const currentState = player.getState();\n\n if (\n toState &&\n toState.value &&\n isExternal(toState.value) &&\n isInProgress(currentState)\n ) {\n try {\n const handler = this.registry?.get(toState.value);\n const transitionValue = await handler?.(\n toState.value,\n currentState.controllers,\n );\n\n if (transitionValue !== undefined) {\n const latestState = player.getState();\n\n // Ensure the Player is still in the same state after waiting for transitionValue\n if (\n isInProgress(latestState) &&\n latestState.controllers.flow.current?.currentState?.name ===\n toState.name\n ) {\n latestState.controllers.flow.transition(transitionValue);\n } else {\n player.logger.warn(\n `External state resolved with [${transitionValue}], but Player already navigated away from [${toState.name}]`,\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n currentState.fail(error);\n }\n }\n }\n });\n });\n });\n }\n\n /**\n * Create or share the registry for this plugin instance.\n *\n * Uses the Player's plugin registry to find if another instance of ExternalStatePlugin\n * has already been registered. If found, this instance will share that plugin's registry.\n * Otherwise, this instance creates a new registry.\n */\n private createRegistry(player: Player): boolean {\n // Find the first instance of this plugin registered to the Player\n const existing = player.findPlugin<ExternalStatePlugin>(\n ExternalStatePluginSymbol,\n );\n\n // If we found a plugin and it's not ourselves, we are not the first plugin instance\n if (existing && existing !== this) {\n // Use the first plugin's registry\n this.registry = existing.registry;\n return false;\n }\n\n // We are the first plugin instance, create the registry\n this.registry = new Registry<ExternalStateHandlerFunction>(\n undefined,\n player.logger,\n );\n return true;\n }\n\n /**\n * Register this plugin's handlers to the shared registry.\n *\n * If a handler with the same specificity already exists, it will be replaced\n * and a debug log will be emitted (accessible via player.logger.debug).\n */\n private registerHandlers(player: Player): void {\n for (const handler of this.handlers) {\n // Runtime check for 'ref' property is necessary despite TypeScript constraint because\n // the Swift bridge allows improperly formatted objects to bypass TypeScript validation.\n // We log this here and not in the constructor because the Logger is not yet available in the constructor.\n if (handler.match?.ref) {\n player.logger.warn(\n `An ExternalStateHandler contains a superfluous 'match.ref' property. 'match.ref' will be ignored. 'ref' will be used instead. Handler: ${JSON.stringify({ ref: handler.ref, match: handler.match })}`,\n );\n delete handler.match?.[\"ref\"];\n continue;\n }\n // Registry will handle keeping only the last handlerFunction for each match\n this.registry?.set(\n { ref: handler.ref, ...handler.match },\n handler.handlerFunction,\n );\n }\n }\n}\n","// We prefix with \"@player-ui\" to avoid conflicts with symbols from other packages\nexport const ExternalStatePluginSymbol: symbol = Symbol.for(\n \"@player-ui/ExternalStatePlugin\",\n);\n"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
ExternalStatePlugin: () => ExternalStatePlugin
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
var import_partial_match_registry = require("@player-ui/partial-match-registry");
|
|
27
|
+
|
|
28
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/symbols.ts
|
|
29
|
+
var ExternalStatePluginSymbol = Symbol.for(
|
|
30
|
+
"@player-ui/ExternalStatePlugin"
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts
|
|
34
|
+
function isExternal(state) {
|
|
35
|
+
return state.state_type === "EXTERNAL";
|
|
36
|
+
}
|
|
37
|
+
function isInProgress(state) {
|
|
38
|
+
return state.status === "in-progress";
|
|
39
|
+
}
|
|
40
|
+
var _ExternalStatePlugin = class _ExternalStatePlugin {
|
|
41
|
+
/** Creates a new ExternalStatePlugin */
|
|
42
|
+
constructor(handlers) {
|
|
43
|
+
this.name = "ExternalStatePlugin";
|
|
44
|
+
this.symbol = _ExternalStatePlugin.Symbol;
|
|
45
|
+
this.handlers = handlers;
|
|
46
|
+
}
|
|
47
|
+
apply(player) {
|
|
48
|
+
const isFirstInstance = this.createRegistry(player);
|
|
49
|
+
this.registerHandlers(player);
|
|
50
|
+
if (!isFirstInstance) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
player.hooks.flowController.tap(this.name, (flowController) => {
|
|
54
|
+
flowController.hooks.flow.tap(this.name, (flow) => {
|
|
55
|
+
flow.hooks.afterTransition.tap(this.name, async (flowInstance) => {
|
|
56
|
+
const toState = flowInstance.currentState;
|
|
57
|
+
const currentState = player.getState();
|
|
58
|
+
if (toState && toState.value && isExternal(toState.value) && isInProgress(currentState)) {
|
|
59
|
+
try {
|
|
60
|
+
const handler = this.registry?.get(toState.value);
|
|
61
|
+
const transitionValue = await handler?.(
|
|
62
|
+
toState.value,
|
|
63
|
+
currentState.controllers
|
|
64
|
+
);
|
|
65
|
+
if (transitionValue !== void 0) {
|
|
66
|
+
const latestState = player.getState();
|
|
67
|
+
if (isInProgress(latestState) && latestState.controllers.flow.current?.currentState?.name === toState.name) {
|
|
68
|
+
latestState.controllers.flow.transition(transitionValue);
|
|
69
|
+
} else {
|
|
70
|
+
player.logger.warn(
|
|
71
|
+
`External state resolved with [${transitionValue}], but Player already navigated away from [${toState.name}]`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (error instanceof Error) {
|
|
77
|
+
currentState.fail(error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create or share the registry for this plugin instance.
|
|
87
|
+
*
|
|
88
|
+
* Uses the Player's plugin registry to find if another instance of ExternalStatePlugin
|
|
89
|
+
* has already been registered. If found, this instance will share that plugin's registry.
|
|
90
|
+
* Otherwise, this instance creates a new registry.
|
|
91
|
+
*/
|
|
92
|
+
createRegistry(player) {
|
|
93
|
+
const existing = player.findPlugin(
|
|
94
|
+
ExternalStatePluginSymbol
|
|
95
|
+
);
|
|
96
|
+
if (existing && existing !== this) {
|
|
97
|
+
this.registry = existing.registry;
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
this.registry = new import_partial_match_registry.Registry(
|
|
101
|
+
void 0,
|
|
102
|
+
player.logger
|
|
103
|
+
);
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Register this plugin's handlers to the shared registry.
|
|
108
|
+
*
|
|
109
|
+
* If a handler with the same specificity already exists, it will be replaced
|
|
110
|
+
* and a debug log will be emitted (accessible via player.logger.debug).
|
|
111
|
+
*/
|
|
112
|
+
registerHandlers(player) {
|
|
113
|
+
for (const handler of this.handlers) {
|
|
114
|
+
if (handler.match?.ref) {
|
|
115
|
+
player.logger.warn(
|
|
116
|
+
`An ExternalStateHandler contains a superfluous 'match.ref' property. 'match.ref' will be ignored. 'ref' will be used instead. Handler: ${JSON.stringify({ ref: handler.ref, match: handler.match })}`
|
|
117
|
+
);
|
|
118
|
+
delete handler.match?.["ref"];
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
this.registry?.set(
|
|
122
|
+
{ ref: handler.ref, ...handler.match },
|
|
123
|
+
handler.handlerFunction
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
/** Symbol used to identify and find existing instances of this plugin */
|
|
129
|
+
_ExternalStatePlugin.Symbol = ExternalStatePluginSymbol;
|
|
130
|
+
var ExternalStatePlugin = _ExternalStatePlugin;
|
|
131
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
+
0 && (module.exports = {
|
|
133
|
+
ExternalStatePlugin
|
|
134
|
+
});
|
|
135
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/symbols.ts"],"sourcesContent":["import type {\n Player,\n PlayerPlugin,\n InProgressState,\n PlayerFlowState,\n NavigationFlowState,\n NavigationFlowExternalState,\n} from \"@player-ui/player\";\nimport { Registry } from \"@player-ui/partial-match-registry\";\nimport { ExternalStatePluginSymbol } from \"./symbols.js\";\n\nexport type ExternalStateHandlerMatch = Record<string, unknown>;\n\nexport type ExternalStateHandlerFunction = (\n state: NavigationFlowExternalState,\n options: InProgressState[\"controllers\"],\n) => string | undefined | Promise<string | undefined>;\n\nexport type ExternalStateHandler = {\n /** The name of the external state. This will appear as it's \"ref\" property in the DSL. */\n ref: string;\n /** Additional properties to match against the external state. */\n match?: ExternalStateHandlerMatch;\n /** The function to run when the external state is transitioned to. This should return the `ref` of the next state to transition to. */\n handlerFunction: ExternalStateHandlerFunction;\n};\n\nfunction isExternal(\n state: NavigationFlowState,\n): state is NavigationFlowExternalState {\n return state.state_type === \"EXTERNAL\";\n}\n\nfunction isInProgress(state: PlayerFlowState): state is InProgressState {\n return state.status === \"in-progress\";\n}\n\n/**\n * A plugin to handle external states\n *\n * This plugin uses a registry-based approach to match external states to handler functions.\n * Multiple plugins can be registered, and handlers are matched using partial object matching\n * with specificity ordering (more specific matches take precedence).\n */\nexport class ExternalStatePlugin implements PlayerPlugin {\n name = \"ExternalStatePlugin\";\n\n /** Symbol used to identify and find existing instances of this plugin */\n static Symbol: symbol = ExternalStatePluginSymbol;\n public readonly symbol: symbol = ExternalStatePlugin.Symbol;\n\n /**\n * The shared registry that maps external states to handlers.\n * All plugin instances use the same registry.\n */\n private registry?: Registry<ExternalStateHandlerFunction>;\n\n /**\n * The handlers for this plugin instance.\n */\n private readonly handlers: ExternalStateHandler[];\n\n /** Creates a new ExternalStatePlugin */\n constructor(handlers: ExternalStateHandler[]) {\n this.handlers = handlers;\n }\n\n apply(player: Player): void {\n const isFirstInstance = this.createRegistry(player);\n this.registerHandlers(player);\n\n // Only the first instance should tap the hooks to avoid redundant taps\n if (!isFirstInstance) {\n return;\n }\n\n player.hooks.flowController.tap(this.name, (flowController) => {\n flowController.hooks.flow.tap(this.name, (flow) => {\n flow.hooks.afterTransition.tap(this.name, async (flowInstance) => {\n const toState = flowInstance.currentState;\n const currentState = player.getState();\n\n if (\n toState &&\n toState.value &&\n isExternal(toState.value) &&\n isInProgress(currentState)\n ) {\n try {\n const handler = this.registry?.get(toState.value);\n const transitionValue = await handler?.(\n toState.value,\n currentState.controllers,\n );\n\n if (transitionValue !== undefined) {\n const latestState = player.getState();\n\n // Ensure the Player is still in the same state after waiting for transitionValue\n if (\n isInProgress(latestState) &&\n latestState.controllers.flow.current?.currentState?.name ===\n toState.name\n ) {\n latestState.controllers.flow.transition(transitionValue);\n } else {\n player.logger.warn(\n `External state resolved with [${transitionValue}], but Player already navigated away from [${toState.name}]`,\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n currentState.fail(error);\n }\n }\n }\n });\n });\n });\n }\n\n /**\n * Create or share the registry for this plugin instance.\n *\n * Uses the Player's plugin registry to find if another instance of ExternalStatePlugin\n * has already been registered. If found, this instance will share that plugin's registry.\n * Otherwise, this instance creates a new registry.\n */\n private createRegistry(player: Player): boolean {\n // Find the first instance of this plugin registered to the Player\n const existing = player.findPlugin<ExternalStatePlugin>(\n ExternalStatePluginSymbol,\n );\n\n // If we found a plugin and it's not ourselves, we are not the first plugin instance\n if (existing && existing !== this) {\n // Use the first plugin's registry\n this.registry = existing.registry;\n return false;\n }\n\n // We are the first plugin instance, create the registry\n this.registry = new Registry<ExternalStateHandlerFunction>(\n undefined,\n player.logger,\n );\n return true;\n }\n\n /**\n * Register this plugin's handlers to the shared registry.\n *\n * If a handler with the same specificity already exists, it will be replaced\n * and a debug log will be emitted (accessible via player.logger.debug).\n */\n private registerHandlers(player: Player): void {\n for (const handler of this.handlers) {\n // Runtime check for 'ref' property is necessary despite TypeScript constraint because\n // the Swift bridge allows improperly formatted objects to bypass TypeScript validation.\n // We log this here and not in the constructor because the Logger is not yet available in the constructor.\n if (handler.match?.ref) {\n player.logger.warn(\n `An ExternalStateHandler contains a superfluous 'match.ref' property. 'match.ref' will be ignored. 'ref' will be used instead. Handler: ${JSON.stringify({ ref: handler.ref, match: handler.match })}`,\n );\n delete handler.match?.[\"ref\"];\n continue;\n }\n // Registry will handle keeping only the last handlerFunction for each match\n this.registry?.set(\n { ref: handler.ref, ...handler.match },\n handler.handlerFunction,\n );\n }\n }\n}\n","// We prefix with \"@player-ui\" to avoid conflicts with symbols from other packages\nexport const ExternalStatePluginSymbol: symbol = Symbol.for(\n \"@player-ui/ExternalStatePlugin\",\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,oCAAyB;;;ACPlB,IAAM,4BAAoC,OAAO;AAAA,EACtD;AACF;;;ADwBA,SAAS,WACP,OACsC;AACtC,SAAO,MAAM,eAAe;AAC9B;AAEA,SAAS,aAAa,OAAkD;AACtE,SAAO,MAAM,WAAW;AAC1B;AASO,IAAM,uBAAN,MAAM,qBAA4C;AAAA;AAAA,EAmBvD,YAAY,UAAkC;AAlB9C,gBAAO;AAIP,SAAgB,SAAiB,qBAAoB;AAenD,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,MAAM,QAAsB;AAC1B,UAAM,kBAAkB,KAAK,eAAe,MAAM;AAClD,SAAK,iBAAiB,MAAM;AAG5B,QAAI,CAAC,iBAAiB;AACpB;AAAA,IACF;AAEA,WAAO,MAAM,eAAe,IAAI,KAAK,MAAM,CAAC,mBAAmB;AAC7D,qBAAe,MAAM,KAAK,IAAI,KAAK,MAAM,CAAC,SAAS;AACjD,aAAK,MAAM,gBAAgB,IAAI,KAAK,MAAM,OAAO,iBAAiB;AAChE,gBAAM,UAAU,aAAa;AAC7B,gBAAM,eAAe,OAAO,SAAS;AAErC,cACE,WACA,QAAQ,SACR,WAAW,QAAQ,KAAK,KACxB,aAAa,YAAY,GACzB;AACA,gBAAI;AACF,oBAAM,UAAU,KAAK,UAAU,IAAI,QAAQ,KAAK;AAChD,oBAAM,kBAAkB,MAA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;AAnIa,qBAIJ,SAAiB;AAJnB,IAAM,sBAAN;","names":[]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts
|
|
2
|
+
import { Registry } from "@player-ui/partial-match-registry";
|
|
3
|
+
|
|
4
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/symbols.ts
|
|
5
|
+
var ExternalStatePluginSymbol = Symbol.for(
|
|
6
|
+
"@player-ui/ExternalStatePlugin"
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts
|
|
10
|
+
function isExternal(state) {
|
|
11
|
+
return state.state_type === "EXTERNAL";
|
|
12
|
+
}
|
|
13
|
+
function isInProgress(state) {
|
|
14
|
+
return state.status === "in-progress";
|
|
15
|
+
}
|
|
16
|
+
var _ExternalStatePlugin = class _ExternalStatePlugin {
|
|
17
|
+
/** Creates a new ExternalStatePlugin */
|
|
18
|
+
constructor(handlers) {
|
|
19
|
+
this.name = "ExternalStatePlugin";
|
|
20
|
+
this.symbol = _ExternalStatePlugin.Symbol;
|
|
21
|
+
this.handlers = handlers;
|
|
22
|
+
}
|
|
23
|
+
apply(player) {
|
|
24
|
+
const isFirstInstance = this.createRegistry(player);
|
|
25
|
+
this.registerHandlers(player);
|
|
26
|
+
if (!isFirstInstance) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
player.hooks.flowController.tap(this.name, (flowController) => {
|
|
30
|
+
flowController.hooks.flow.tap(this.name, (flow) => {
|
|
31
|
+
flow.hooks.afterTransition.tap(this.name, async (flowInstance) => {
|
|
32
|
+
const toState = flowInstance.currentState;
|
|
33
|
+
const currentState = player.getState();
|
|
34
|
+
if (toState && toState.value && isExternal(toState.value) && isInProgress(currentState)) {
|
|
35
|
+
try {
|
|
36
|
+
const handler = this.registry?.get(toState.value);
|
|
37
|
+
const transitionValue = await handler?.(
|
|
38
|
+
toState.value,
|
|
39
|
+
currentState.controllers
|
|
40
|
+
);
|
|
41
|
+
if (transitionValue !== void 0) {
|
|
42
|
+
const latestState = player.getState();
|
|
43
|
+
if (isInProgress(latestState) && latestState.controllers.flow.current?.currentState?.name === toState.name) {
|
|
44
|
+
latestState.controllers.flow.transition(transitionValue);
|
|
45
|
+
} else {
|
|
46
|
+
player.logger.warn(
|
|
47
|
+
`External state resolved with [${transitionValue}], but Player already navigated away from [${toState.name}]`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error instanceof Error) {
|
|
53
|
+
currentState.fail(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create or share the registry for this plugin instance.
|
|
63
|
+
*
|
|
64
|
+
* Uses the Player's plugin registry to find if another instance of ExternalStatePlugin
|
|
65
|
+
* has already been registered. If found, this instance will share that plugin's registry.
|
|
66
|
+
* Otherwise, this instance creates a new registry.
|
|
67
|
+
*/
|
|
68
|
+
createRegistry(player) {
|
|
69
|
+
const existing = player.findPlugin(
|
|
70
|
+
ExternalStatePluginSymbol
|
|
71
|
+
);
|
|
72
|
+
if (existing && existing !== this) {
|
|
73
|
+
this.registry = existing.registry;
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
this.registry = new Registry(
|
|
77
|
+
void 0,
|
|
78
|
+
player.logger
|
|
79
|
+
);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Register this plugin's handlers to the shared registry.
|
|
84
|
+
*
|
|
85
|
+
* If a handler with the same specificity already exists, it will be replaced
|
|
86
|
+
* and a debug log will be emitted (accessible via player.logger.debug).
|
|
87
|
+
*/
|
|
88
|
+
registerHandlers(player) {
|
|
89
|
+
for (const handler of this.handlers) {
|
|
90
|
+
if (handler.match?.ref) {
|
|
91
|
+
player.logger.warn(
|
|
92
|
+
`An ExternalStateHandler contains a superfluous 'match.ref' property. 'match.ref' will be ignored. 'ref' will be used instead. Handler: ${JSON.stringify({ ref: handler.ref, match: handler.match })}`
|
|
93
|
+
);
|
|
94
|
+
delete handler.match?.["ref"];
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
this.registry?.set(
|
|
98
|
+
{ ref: handler.ref, ...handler.match },
|
|
99
|
+
handler.handlerFunction
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/** Symbol used to identify and find existing instances of this plugin */
|
|
105
|
+
_ExternalStatePlugin.Symbol = ExternalStatePluginSymbol;
|
|
106
|
+
var ExternalStatePlugin = _ExternalStatePlugin;
|
|
107
|
+
export {
|
|
108
|
+
ExternalStatePlugin
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts
|
|
2
|
+
import { Registry } from "@player-ui/partial-match-registry";
|
|
3
|
+
|
|
4
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/symbols.ts
|
|
5
|
+
var ExternalStatePluginSymbol = Symbol.for(
|
|
6
|
+
"@player-ui/ExternalStatePlugin"
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts
|
|
10
|
+
function isExternal(state) {
|
|
11
|
+
return state.state_type === "EXTERNAL";
|
|
12
|
+
}
|
|
13
|
+
function isInProgress(state) {
|
|
14
|
+
return state.status === "in-progress";
|
|
15
|
+
}
|
|
16
|
+
var _ExternalStatePlugin = class _ExternalStatePlugin {
|
|
17
|
+
/** Creates a new ExternalStatePlugin */
|
|
18
|
+
constructor(handlers) {
|
|
19
|
+
this.name = "ExternalStatePlugin";
|
|
20
|
+
this.symbol = _ExternalStatePlugin.Symbol;
|
|
21
|
+
this.handlers = handlers;
|
|
22
|
+
}
|
|
23
|
+
apply(player) {
|
|
24
|
+
const isFirstInstance = this.createRegistry(player);
|
|
25
|
+
this.registerHandlers(player);
|
|
26
|
+
if (!isFirstInstance) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
player.hooks.flowController.tap(this.name, (flowController) => {
|
|
30
|
+
flowController.hooks.flow.tap(this.name, (flow) => {
|
|
31
|
+
flow.hooks.afterTransition.tap(this.name, async (flowInstance) => {
|
|
32
|
+
const toState = flowInstance.currentState;
|
|
33
|
+
const currentState = player.getState();
|
|
34
|
+
if (toState && toState.value && isExternal(toState.value) && isInProgress(currentState)) {
|
|
35
|
+
try {
|
|
36
|
+
const handler = this.registry?.get(toState.value);
|
|
37
|
+
const transitionValue = await handler?.(
|
|
38
|
+
toState.value,
|
|
39
|
+
currentState.controllers
|
|
40
|
+
);
|
|
41
|
+
if (transitionValue !== void 0) {
|
|
42
|
+
const latestState = player.getState();
|
|
43
|
+
if (isInProgress(latestState) && latestState.controllers.flow.current?.currentState?.name === toState.name) {
|
|
44
|
+
latestState.controllers.flow.transition(transitionValue);
|
|
45
|
+
} else {
|
|
46
|
+
player.logger.warn(
|
|
47
|
+
`External state resolved with [${transitionValue}], but Player already navigated away from [${toState.name}]`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error instanceof Error) {
|
|
53
|
+
currentState.fail(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create or share the registry for this plugin instance.
|
|
63
|
+
*
|
|
64
|
+
* Uses the Player's plugin registry to find if another instance of ExternalStatePlugin
|
|
65
|
+
* has already been registered. If found, this instance will share that plugin's registry.
|
|
66
|
+
* Otherwise, this instance creates a new registry.
|
|
67
|
+
*/
|
|
68
|
+
createRegistry(player) {
|
|
69
|
+
const existing = player.findPlugin(
|
|
70
|
+
ExternalStatePluginSymbol
|
|
71
|
+
);
|
|
72
|
+
if (existing && existing !== this) {
|
|
73
|
+
this.registry = existing.registry;
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
this.registry = new Registry(
|
|
77
|
+
void 0,
|
|
78
|
+
player.logger
|
|
79
|
+
);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Register this plugin's handlers to the shared registry.
|
|
84
|
+
*
|
|
85
|
+
* If a handler with the same specificity already exists, it will be replaced
|
|
86
|
+
* and a debug log will be emitted (accessible via player.logger.debug).
|
|
87
|
+
*/
|
|
88
|
+
registerHandlers(player) {
|
|
89
|
+
for (const handler of this.handlers) {
|
|
90
|
+
if (handler.match?.ref) {
|
|
91
|
+
player.logger.warn(
|
|
92
|
+
`An ExternalStateHandler contains a superfluous 'match.ref' property. 'match.ref' will be ignored. 'ref' will be used instead. Handler: ${JSON.stringify({ ref: handler.ref, match: handler.match })}`
|
|
93
|
+
);
|
|
94
|
+
delete handler.match?.["ref"];
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
this.registry?.set(
|
|
98
|
+
{ ref: handler.ref, ...handler.match },
|
|
99
|
+
handler.handlerFunction
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/** Symbol used to identify and find existing instances of this plugin */
|
|
105
|
+
_ExternalStatePlugin.Symbol = ExternalStatePluginSymbol;
|
|
106
|
+
var ExternalStatePlugin = _ExternalStatePlugin;
|
|
107
|
+
export {
|
|
108
|
+
ExternalStatePlugin
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/symbols.ts"],"sourcesContent":["import type {\n Player,\n PlayerPlugin,\n InProgressState,\n PlayerFlowState,\n NavigationFlowState,\n NavigationFlowExternalState,\n} from \"@player-ui/player\";\nimport { Registry } from \"@player-ui/partial-match-registry\";\nimport { ExternalStatePluginSymbol } from \"./symbols.js\";\n\nexport type ExternalStateHandlerMatch = Record<string, unknown>;\n\nexport type ExternalStateHandlerFunction = (\n state: NavigationFlowExternalState,\n options: InProgressState[\"controllers\"],\n) => string | undefined | Promise<string | undefined>;\n\nexport type ExternalStateHandler = {\n /** The name of the external state. This will appear as it's \"ref\" property in the DSL. */\n ref: string;\n /** Additional properties to match against the external state. */\n match?: ExternalStateHandlerMatch;\n /** The function to run when the external state is transitioned to. This should return the `ref` of the next state to transition to. */\n handlerFunction: ExternalStateHandlerFunction;\n};\n\nfunction isExternal(\n state: NavigationFlowState,\n): state is NavigationFlowExternalState {\n return state.state_type === \"EXTERNAL\";\n}\n\nfunction isInProgress(state: PlayerFlowState): state is InProgressState {\n return state.status === \"in-progress\";\n}\n\n/**\n * A plugin to handle external states\n *\n * This plugin uses a registry-based approach to match external states to handler functions.\n * Multiple plugins can be registered, and handlers are matched using partial object matching\n * with specificity ordering (more specific matches take precedence).\n */\nexport class ExternalStatePlugin implements PlayerPlugin {\n name = \"ExternalStatePlugin\";\n\n /** Symbol used to identify and find existing instances of this plugin */\n static Symbol: symbol = ExternalStatePluginSymbol;\n public readonly symbol: symbol = ExternalStatePlugin.Symbol;\n\n /**\n * The shared registry that maps external states to handlers.\n * All plugin instances use the same registry.\n */\n private registry?: Registry<ExternalStateHandlerFunction>;\n\n /**\n * The handlers for this plugin instance.\n */\n private readonly handlers: ExternalStateHandler[];\n\n /** Creates a new ExternalStatePlugin */\n constructor(handlers: ExternalStateHandler[]) {\n this.handlers = handlers;\n }\n\n apply(player: Player): void {\n const isFirstInstance = this.createRegistry(player);\n this.registerHandlers(player);\n\n // Only the first instance should tap the hooks to avoid redundant taps\n if (!isFirstInstance) {\n return;\n }\n\n player.hooks.flowController.tap(this.name, (flowController) => {\n flowController.hooks.flow.tap(this.name, (flow) => {\n flow.hooks.afterTransition.tap(this.name, async (flowInstance) => {\n const toState = flowInstance.currentState;\n const currentState = player.getState();\n\n if (\n toState &&\n toState.value &&\n isExternal(toState.value) &&\n isInProgress(currentState)\n ) {\n try {\n const handler = this.registry?.get(toState.value);\n const transitionValue = await handler?.(\n toState.value,\n currentState.controllers,\n );\n\n if (transitionValue !== undefined) {\n const latestState = player.getState();\n\n // Ensure the Player is still in the same state after waiting for transitionValue\n if (\n isInProgress(latestState) &&\n latestState.controllers.flow.current?.currentState?.name ===\n toState.name\n ) {\n latestState.controllers.flow.transition(transitionValue);\n } else {\n player.logger.warn(\n `External state resolved with [${transitionValue}], but Player already navigated away from [${toState.name}]`,\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n currentState.fail(error);\n }\n }\n }\n });\n });\n });\n }\n\n /**\n * Create or share the registry for this plugin instance.\n *\n * Uses the Player's plugin registry to find if another instance of ExternalStatePlugin\n * has already been registered. If found, this instance will share that plugin's registry.\n * Otherwise, this instance creates a new registry.\n */\n private createRegistry(player: Player): boolean {\n // Find the first instance of this plugin registered to the Player\n const existing = player.findPlugin<ExternalStatePlugin>(\n ExternalStatePluginSymbol,\n );\n\n // If we found a plugin and it's not ourselves, we are not the first plugin instance\n if (existing && existing !== this) {\n // Use the first plugin's registry\n this.registry = existing.registry;\n return false;\n }\n\n // We are the first plugin instance, create the registry\n this.registry = new Registry<ExternalStateHandlerFunction>(\n undefined,\n player.logger,\n );\n return true;\n }\n\n /**\n * Register this plugin's handlers to the shared registry.\n *\n * If a handler with the same specificity already exists, it will be replaced\n * and a debug log will be emitted (accessible via player.logger.debug).\n */\n private registerHandlers(player: Player): void {\n for (const handler of this.handlers) {\n // Runtime check for 'ref' property is necessary despite TypeScript constraint because\n // the Swift bridge allows improperly formatted objects to bypass TypeScript validation.\n // We log this here and not in the constructor because the Logger is not yet available in the constructor.\n if (handler.match?.ref) {\n player.logger.warn(\n `An ExternalStateHandler contains a superfluous 'match.ref' property. 'match.ref' will be ignored. 'ref' will be used instead. Handler: ${JSON.stringify({ ref: handler.ref, match: handler.match })}`,\n );\n delete handler.match?.[\"ref\"];\n continue;\n }\n // Registry will handle keeping only the last handlerFunction for each match\n this.registry?.set(\n { ref: handler.ref, ...handler.match },\n handler.handlerFunction,\n );\n }\n }\n}\n","// We prefix with \"@player-ui\" to avoid conflicts with symbols from other packages\nexport const ExternalStatePluginSymbol: symbol = Symbol.for(\n \"@player-ui/ExternalStatePlugin\",\n);\n"],"mappings":";AAQA,SAAS,gBAAgB;;;ACPlB,IAAM,4BAAoC,OAAO;AAAA,EACtD;AACF;;;ADwBA,SAAS,WACP,OACsC;AACtC,SAAO,MAAM,eAAe;AAC9B;AAEA,SAAS,aAAa,OAAkD;AACtE,SAAO,MAAM,WAAW;AAC1B;AASO,IAAM,uBAAN,MAAM,qBAA4C;AAAA;AAAA,EAmBvD,YAAY,UAAkC;AAlB9C,gBAAO;AAIP,SAAgB,SAAiB,qBAAoB;AAenD,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,MAAM,QAAsB;AAC1B,UAAM,kBAAkB,KAAK,eAAe,MAAM;AAClD,SAAK,iBAAiB,MAAM;AAG5B,QAAI,CAAC,iBAAiB;AACpB;AAAA,IACF;AAEA,WAAO,MAAM,eAAe,IAAI,KAAK,MAAM,CAAC,mBAAmB;AAC7D,qBAAe,MAAM,KAAK,IAAI,KAAK,MAAM,CAAC,SAAS;AACjD,aAAK,MAAM,gBAAgB,IAAI,KAAK,MAAM,OAAO,iBAAiB;AAChE,gBAAM,UAAU,aAAa;AAC7B,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ACA,eAAO,QAAQ,QAAQ,KAAK;AAC5B;AAAA,MACF;AAEA,WAAK,UAAU;AAAA,QACb,EAAE,KAAK,QAAQ,KAAK,GAAG,QAAQ,MAAM;AAAA,QACrC,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;AAAA;AAnIa,qBAIJ,SAAiB;AAJnB,IAAM,sBAAN;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sideEffects": false,
|
|
3
|
+
"files": [
|
|
4
|
+
"dist",
|
|
5
|
+
"src",
|
|
6
|
+
"types"
|
|
7
|
+
],
|
|
8
|
+
"name": "@player-ui/external-state-plugin",
|
|
9
|
+
"version": "1.0.0--canary.865.36694",
|
|
10
|
+
"main": "dist/cjs/index.cjs",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@player-ui/partial-match-registry": "1.0.0--canary.865.36694",
|
|
13
|
+
"tslib": "^2.6.2"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@player-ui/player": "1.0.0--canary.865.36694"
|
|
17
|
+
},
|
|
18
|
+
"module": "dist/index.legacy-esm.js",
|
|
19
|
+
"types": "types/index.d.ts",
|
|
20
|
+
"bundle": "dist/ExternalStatePlugin.native.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
"./package.json": "./package.json",
|
|
23
|
+
"./dist/index.css": "./dist/index.css",
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./types/index.d.ts",
|
|
26
|
+
"import": "./dist/index.mjs",
|
|
27
|
+
"default": "./dist/cjs/index.cjs"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|