@player-ui/computed-properties-plugin 0.14.1-next.2 → 0.14.1-next.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2581/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/computed-properties/core/dist/index.global.js","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/computed-properties/core/src/index.ts"],"names":["ComputedPropertiesPlugin","__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","src_exports","apply","player","schemaController","expressionEvaluator","getExpressionType","binding","dataType","getType","type","computedPropertyMiddleware","options","next","expType","exp","result","evaluate","context","default","set","transaction","setOperation","Error","asString","delete","hooks","dataController","tap","resolveDataStages","dataPipeline","schema","evaluator"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,2BAA2B,AAAC;IAC9B,IAAIC,YAAYC,OAAOC,cAAc;IACrC,IAAIC,mBAAmBF,OAAOG,wBAAwB;IACtD,IAAIC,oBAAoBJ,OAAOK,mBAAmB;IAClD,IAAIC,eAAeN,OAAOO,SAAS,CAACC,cAAc;IAClD,IAAIC,WAAW,SAACC,QAAQC;QACtB,IAAK,IAAIC,QAAQD,IACfZ,UAAUW,QAAQE,MAAM;YAAEC,KAAKF,GAAG,CAACC,KAAK;YAAEE,YAAY;QAAK;IAC/D;IACA,IAAIC,cAAc,SAACC,IAAIC,MAAMC,QAAQC;QACnC,IAAIF,QAAQ,CAAA,OAAOA,qCAAP,SAAOA,KAAG,MAAM,YAAY,OAAO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oBAEA5B,OAAOuB,KAAA,CAAMrB,mBAAA,CAAoBuB,GAAA,CAAI,IAAA,CAAKxC,IAAA,EAAM,SAAC4C;wBAC/C3B,sBAAsB2B;oBACxB;gBACF;;;;;IDZA,OAAOlC,aAAaG;AACtB","sourcesContent":["\"use strict\";\nvar ComputedPropertiesPlugin = (() => {\n var __defProp = 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/computed-properties/core/src/index.ts\n var src_exports = {};\n __export(src_exports, {\n ComputedPropertiesPlugin: () => ComputedPropertiesPlugin\n });\n var ComputedPropertiesPlugin = class {\n constructor() {\n this.name = \"ComputedProperties\";\n }\n apply(player) {\n let schemaController;\n let expressionEvaluator;\n const getExpressionType = (binding) => {\n const dataType = schemaController?.getType(binding);\n if (dataType?.type === \"Expression\") {\n return dataType;\n }\n };\n const computedPropertyMiddleware = {\n name: this.name,\n get(binding, options, next) {\n const expType = getExpressionType(binding);\n if (expType) {\n const { exp } = expType;\n const result = exp && expressionEvaluator?.evaluate(exp, options?.context);\n return result ?? expType.default;\n }\n return next?.get(binding, options);\n },\n set(transaction, options, next) {\n for (const setOperation of transaction) {\n if (getExpressionType(setOperation[0])) {\n throw new Error(\n `Invalid 'set' operation on computed property: ${setOperation[0].asString()}`\n );\n }\n }\n return next?.set(transaction, options) ?? [];\n },\n delete(binding, options, next) {\n if (getExpressionType(binding)) {\n throw new Error(\n `Invalid 'delete' operation on computed property: ${binding.asString()}`\n );\n }\n return next?.delete(binding, options);\n }\n };\n player.hooks.dataController.tap(this.name, (dataController) => {\n dataController.hooks.resolveDataStages.tap(this.name, (dataPipeline) => {\n return [...dataPipeline, computedPropertyMiddleware];\n });\n });\n player.hooks.schema.tap(this.name, (schema) => {\n schemaController = schema;\n });\n player.hooks.expressionEvaluator.tap(this.name, (evaluator) => {\n expressionEvaluator = evaluator;\n });\n }\n };\n return __toCommonJS(src_exports);\n})();\n","import type {\n Player,\n PlayerPlugin,\n ExpressionEvaluator,\n Schema,\n Expression,\n DataModelMiddleware,\n Updates,\n SchemaController,\n BindingInstance,\n} from \"@player-ui/player\";\n\nexport interface ExpressionDataType extends Schema.DataType<\"Expression\"> {\n /** The expression to evaluate to compute the value of this node */\n exp?: Expression;\n}\n\n/**\n * A player plugin to manage beacon events.\n * It automatically keeps track of the current user's view, and adds additional metaData to each beacon event.\n */\nexport class ComputedPropertiesPlugin implements PlayerPlugin {\n name = \"ComputedProperties\";\n\n apply(player: Player) {\n // Inject a middleware into the data-model to intercept any calls to an expression type in the schema\n // Calls to `set` throw an error. Calls to `get` compute the value and return if or default\n\n let schemaController: SchemaController | undefined;\n let expressionEvaluator: ExpressionEvaluator | undefined;\n\n /** Look up the data-type of the binding, and check for an Expression type */\n const getExpressionType = (\n binding: BindingInstance,\n ): ExpressionDataType | undefined => {\n // Check to see if the data-type of the binding is an `Expression`\n const dataType = schemaController?.getType(binding);\n\n if (dataType?.type === \"Expression\") {\n return dataType as ExpressionDataType;\n }\n };\n\n const computedPropertyMiddleware: DataModelMiddleware = {\n name: this.name,\n get(binding, options, next) {\n const expType = getExpressionType(binding);\n\n if (expType) {\n const { exp } = expType;\n const result =\n exp && expressionEvaluator?.evaluate(exp, options?.context);\n\n return result ?? expType.default;\n }\n\n return next?.get(binding, options);\n },\n set(transaction, options, next): Updates {\n for (const setOperation of transaction) {\n if (getExpressionType(setOperation[0])) {\n throw new Error(\n `Invalid 'set' operation on computed property: ${setOperation[0].asString()}`,\n );\n }\n }\n\n return next?.set(transaction, options) ?? [];\n },\n delete(binding, options, next) {\n if (getExpressionType(binding)) {\n throw new Error(\n `Invalid 'delete' operation on computed property: ${binding.asString()}`,\n );\n }\n\n return next?.delete(binding, options);\n },\n };\n\n player.hooks.dataController.tap(this.name, (dataController) => {\n dataController.hooks.resolveDataStages.tap(this.name, (dataPipeline) => {\n return [...dataPipeline, computedPropertyMiddleware];\n });\n });\n\n player.hooks.schema.tap(this.name, (schema) => {\n schemaController = schema;\n });\n\n player.hooks.expressionEvaluator.tap(this.name, (evaluator) => {\n expressionEvaluator = evaluator;\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2603/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/computed-properties/core/dist/index.global.js","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/computed-properties/core/src/index.ts"],"names":["ComputedPropertiesPlugin","__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","src_exports","apply","player","schemaController","expressionEvaluator","getExpressionType","binding","dataType","getType","type","computedPropertyMiddleware","options","next","expType","exp","result","evaluate","context","default","set","transaction","setOperation","Error","asString","delete","hooks","dataController","tap","resolveDataStages","dataPipeline","schema","evaluator"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,2BAA2B,AAAC;IAC9B,IAAIC,YAAYC,OAAOC,cAAc;IACrC,IAAIC,mBAAmBF,OAAOG,wBAAwB;IACtD,IAAIC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MC,cAAA,CAAeC,GAAA,CAAI,IAAA,CAAKxC,IAAA,EAAM,SAACuC;wBAC1CA,eAAeD,KAAA,CAAMG,iBAAA,CAAkBD,GAAA,CAAI,MAAKxC,IAAA,EAAM,SAAC0C;4BACrD,OAAO,AAAC,qBAAGA,qBAAJ;gCAAkBnB;6BAA0B;wBACrD;oBACF;oBAEAR,OAAOuB,KAAA,CAAMK,MAAA,CAAOH,GAAA,CAAI,IAAA,CAAKxC,IAAA,EAAM,SAAC2C;wBAClC3B,mBAAmB2B;oBACrB;oBAEA5B,OAAOuB,KAAA,CAAMrB,mBAAA,CAAoBuB,GAAA,CAAI,IAAA,CAAKxC,IAAA,EAAM,SAAC4C;wBAC/C3B,sBAAsB2B;oBACxB;gBACF;;;;;IDZA,OAAOlC,aAAaG;AACtB","sourcesContent":["\"use strict\";\nvar ComputedPropertiesPlugin = (() => {\n var __defProp = 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/computed-properties/core/src/index.ts\n var src_exports = {};\n __export(src_exports, {\n ComputedPropertiesPlugin: () => ComputedPropertiesPlugin\n });\n var ComputedPropertiesPlugin = class {\n constructor() {\n this.name = \"ComputedProperties\";\n }\n apply(player) {\n let schemaController;\n let expressionEvaluator;\n const getExpressionType = (binding) => {\n const dataType = schemaController?.getType(binding);\n if (dataType?.type === \"Expression\") {\n return dataType;\n }\n };\n const computedPropertyMiddleware = {\n name: this.name,\n get(binding, options, next) {\n const expType = getExpressionType(binding);\n if (expType) {\n const { exp } = expType;\n const result = exp && expressionEvaluator?.evaluate(exp, options?.context);\n return result ?? expType.default;\n }\n return next?.get(binding, options);\n },\n set(transaction, options, next) {\n for (const setOperation of transaction) {\n if (getExpressionType(setOperation[0])) {\n throw new Error(\n `Invalid 'set' operation on computed property: ${setOperation[0].asString()}`\n );\n }\n }\n return next?.set(transaction, options) ?? [];\n },\n delete(binding, options, next) {\n if (getExpressionType(binding)) {\n throw new Error(\n `Invalid 'delete' operation on computed property: ${binding.asString()}`\n );\n }\n return next?.delete(binding, options);\n }\n };\n player.hooks.dataController.tap(this.name, (dataController) => {\n dataController.hooks.resolveDataStages.tap(this.name, (dataPipeline) => {\n return [...dataPipeline, computedPropertyMiddleware];\n });\n });\n player.hooks.schema.tap(this.name, (schema) => {\n schemaController = schema;\n });\n player.hooks.expressionEvaluator.tap(this.name, (evaluator) => {\n expressionEvaluator = evaluator;\n });\n }\n };\n return __toCommonJS(src_exports);\n})();\n","import type {\n Player,\n PlayerPlugin,\n ExpressionEvaluator,\n Schema,\n Expression,\n DataModelMiddleware,\n Updates,\n SchemaController,\n BindingInstance,\n} from \"@player-ui/player\";\n\nexport interface ExpressionDataType extends Schema.DataType<\"Expression\"> {\n /** The expression to evaluate to compute the value of this node */\n exp?: Expression;\n}\n\n/**\n * A player plugin to manage beacon events.\n * It automatically keeps track of the current user's view, and adds additional metaData to each beacon event.\n */\nexport class ComputedPropertiesPlugin implements PlayerPlugin {\n name = \"ComputedProperties\";\n\n apply(player: Player) {\n // Inject a middleware into the data-model to intercept any calls to an expression type in the schema\n // Calls to `set` throw an error. Calls to `get` compute the value and return if or default\n\n let schemaController: SchemaController | undefined;\n let expressionEvaluator: ExpressionEvaluator | undefined;\n\n /** Look up the data-type of the binding, and check for an Expression type */\n const getExpressionType = (\n binding: BindingInstance,\n ): ExpressionDataType | undefined => {\n // Check to see if the data-type of the binding is an `Expression`\n const dataType = schemaController?.getType(binding);\n\n if (dataType?.type === \"Expression\") {\n return dataType as ExpressionDataType;\n }\n };\n\n const computedPropertyMiddleware: DataModelMiddleware = {\n name: this.name,\n get(binding, options, next) {\n const expType = getExpressionType(binding);\n\n if (expType) {\n const { exp } = expType;\n const result =\n exp && expressionEvaluator?.evaluate(exp, options?.context);\n\n return result ?? expType.default;\n }\n\n return next?.get(binding, options);\n },\n set(transaction, options, next): Updates {\n for (const setOperation of transaction) {\n if (getExpressionType(setOperation[0])) {\n throw new Error(\n `Invalid 'set' operation on computed property: ${setOperation[0].asString()}`,\n );\n }\n }\n\n return next?.set(transaction, options) ?? [];\n },\n delete(binding, options, next) {\n if (getExpressionType(binding)) {\n throw new Error(\n `Invalid 'delete' operation on computed property: ${binding.asString()}`,\n );\n }\n\n return next?.delete(binding, options);\n },\n };\n\n player.hooks.dataController.tap(this.name, (dataController) => {\n dataController.hooks.resolveDataStages.tap(this.name, (dataPipeline) => {\n return [...dataPipeline, computedPropertyMiddleware];\n });\n });\n\n player.hooks.schema.tap(this.name, (schema) => {\n schemaController = schema;\n });\n\n player.hooks.expressionEvaluator.tap(this.name, (evaluator) => {\n expressionEvaluator = evaluator;\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-ui/computed-properties-plugin",
|
|
9
|
-
"version": "0.14.1-next.
|
|
9
|
+
"version": "0.14.1-next.3",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@player-ui/player": "0.14.1-next.
|
|
12
|
+
"@player-ui/player": "0.14.1-next.3"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@player-ui/asset-transform-plugin": "workspace:*",
|