@player-ui/markdown-plugin 0.5.2--canary.256.8666 → 0.6.0-next.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.
@@ -246,6 +246,8 @@ __webpack_require__.r(__webpack_exports__);
246
246
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findInArray", function() { return findInArray; });
247
247
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findNextExp", function() { return findNextExp; });
248
248
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getBindingSegments", function() { return getBindingSegments; });
249
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNodeID", function() { return getNodeID; });
250
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasAsync", function() { return hasAsync; });
249
251
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBinding", function() { return isBinding; });
250
252
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isExpressionNode", function() { return isExpressionNode; });
251
253
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isObjectExpression", function() { return isObjectExpression; });
@@ -259,11 +261,12 @@ __webpack_require__.r(__webpack_exports__);
259
261
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "severities", function() { return severities; });
260
262
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toModel", function() { return toModel; });
261
263
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toNodeResolveOptions", function() { return toNodeResolveOptions; });
264
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unpackAndPush", function() { return unpackAndPush; });
262
265
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "withParser", function() { return withParser; });
263
266
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "withoutContext", function() { return withoutContext; });
264
267
  /* harmony import */ var _player_ui_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @player-ui/types */ "./bazel-out/k8-fastbuild/bin/core/types/dist/index.esm.js");
265
268
  /* harmony import */ var _player_ui_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_player_ui_types__WEBPACK_IMPORTED_MODULE_0__);
266
- /* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _player_ui_types__WEBPACK_IMPORTED_MODULE_0__) if(["default","ApplicabilityPlugin","AssetTransformCorePlugin","BINDING_BRACKETS_REGEX","BindingInstance","BindingParser","Builder","ConsoleLogger","ConstantsController","DataController","DependencyMiddleware","DependencyModel","DependencyTracker","EMPTY_NODE","ExpNodeOpaqueIdentifier","ExpressionEvaluator","FlowController","FlowExpPlugin","FlowInstance","LocalModel","LocalStateStore","NOOPDataModel","NOOP_MODEL","NOT_STARTED_STATE","NodeType","NoopLogger","Parser","PipelinedDataModel","Player","ProxyLogger","ROOT_BINDING","Resolver","SCHEMA_VALIDATION_PROVIDER_NAME","SIMPLE_BINDING_REGEX","SchemaController","StringResolverPlugin","SwitchPlugin","TapableLogger","TemplatePlugin","VALIDATION_PROVIDER_NAME_SYMBOL","VIEW_VALIDATION_PROVIDER_NAME","ValidationBindingTrackerViewPlugin","ValidationController","ValidationMiddleware","ValidatorRegistry","ViewController","ViewInstance","caresAboutDataChanges","constructModelForPipeline","findClosestNodeAtPosition","findInArray","findNextExp","getBindingSegments","isBinding","isExpressionNode","isObjectExpression","maybeConvertToNum","parse","parseExpression","removeBindingAndChildrenFromMap","resolveDataRefs","resolveDataRefsInString","resolveExpressionsInString","severities","toModel","toNodeResolveOptions","withParser","withoutContext"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _player_ui_types__WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__));
269
+ /* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _player_ui_types__WEBPACK_IMPORTED_MODULE_0__) if(["default","ApplicabilityPlugin","AssetTransformCorePlugin","BINDING_BRACKETS_REGEX","BindingInstance","BindingParser","Builder","ConsoleLogger","ConstantsController","DataController","DependencyMiddleware","DependencyModel","DependencyTracker","EMPTY_NODE","ExpNodeOpaqueIdentifier","ExpressionEvaluator","FlowController","FlowExpPlugin","FlowInstance","LocalModel","LocalStateStore","NOOPDataModel","NOOP_MODEL","NOT_STARTED_STATE","NodeType","NoopLogger","Parser","PipelinedDataModel","Player","ProxyLogger","ROOT_BINDING","Resolver","SCHEMA_VALIDATION_PROVIDER_NAME","SIMPLE_BINDING_REGEX","SchemaController","StringResolverPlugin","SwitchPlugin","TapableLogger","TemplatePlugin","VALIDATION_PROVIDER_NAME_SYMBOL","VIEW_VALIDATION_PROVIDER_NAME","ValidationBindingTrackerViewPlugin","ValidationController","ValidationMiddleware","ValidatorRegistry","ViewController","ViewInstance","caresAboutDataChanges","constructModelForPipeline","findClosestNodeAtPosition","findInArray","findNextExp","getBindingSegments","getNodeID","hasAsync","isBinding","isExpressionNode","isObjectExpression","maybeConvertToNum","parse","parseExpression","removeBindingAndChildrenFromMap","resolveDataRefs","resolveDataRefsInString","resolveExpressionsInString","severities","toModel","toNodeResolveOptions","unpackAndPush","withParser","withoutContext"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _player_ui_types__WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__));
267
270
  /* harmony import */ var tapable_ts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tapable-ts */ "./node_modules/tapable-ts/dist/hooks.mjs");
268
271
  /* harmony import */ var ts_nested_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ts-nested-error */ "./node_modules/ts-nested-error/build/nested-error.js");
269
272
  /* harmony import */ var ts_nested_error__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ts_nested_error__WEBPACK_IMPORTED_MODULE_2__);
@@ -2626,10 +2629,24 @@ var NodeType;
2626
2629
  NodeType2["Value"] = "value";
2627
2630
  NodeType2["MultiNode"] = "multi-node";
2628
2631
  NodeType2["Switch"] = "switch";
2632
+ NodeType2["Async"] = "async";
2629
2633
  NodeType2["Unknown"] = "unknown";
2630
2634
  NodeType2["Empty"] = "empty";
2631
2635
  })(NodeType || (NodeType = {}));
2632
2636
 
2637
+ function hasAsync(obj) {
2638
+ return Object.prototype.hasOwnProperty.call(obj, "async");
2639
+ }
2640
+ function getNodeID(node) {
2641
+ var _a;
2642
+ if (!node) {
2643
+ return;
2644
+ }
2645
+ if ("value" in node && typeof node.value === "object" && typeof ((_a = node.value) == null ? void 0 : _a.id) === "string") {
2646
+ return node.value.id;
2647
+ }
2648
+ }
2649
+
2633
2650
  var __defProp$9 = Object.defineProperty;
2634
2651
  var __defProps$7 = Object.defineProperties;
2635
2652
  var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
@@ -2680,6 +2697,18 @@ class Parser {
2680
2697
  }
2681
2698
  return viewNode;
2682
2699
  }
2700
+ parseAsync(obj, type, options) {
2701
+ const parsedAsync = this.parseObject(Object(timm__WEBPACK_IMPORTED_MODULE_7__["omit"])(obj, "async"), type, options);
2702
+ const parsedNodeId = getNodeID(parsedAsync);
2703
+ if (parsedAsync !== null && parsedNodeId) {
2704
+ return this.createASTNode({
2705
+ id: parsedNodeId,
2706
+ type: NodeType.Async,
2707
+ value: parsedAsync
2708
+ }, obj);
2709
+ }
2710
+ return null;
2711
+ }
2683
2712
  createASTNode(node, value) {
2684
2713
  const tapped = this.hooks.onCreateASTNode.call(node, value);
2685
2714
  if (tapped === void 0) {
@@ -2786,6 +2815,14 @@ class Parser {
2786
2815
  ]
2787
2816
  });
2788
2817
  }
2818
+ } else if (localValue && hasAsync(localValue)) {
2819
+ const localAsync = this.parseAsync(localValue, NodeType.Value, options);
2820
+ if (localAsync) {
2821
+ children2.push({
2822
+ path: [...path, localKey],
2823
+ value: localAsync
2824
+ });
2825
+ }
2789
2826
  } else if (localValue && Array.isArray(localValue)) {
2790
2827
  const childValues = localValue.map((childVal) => this.parseObject(childVal, NodeType.Value, options)).filter((child) => !!child);
2791
2828
  if (childValues.length > 0) {
@@ -2905,6 +2942,15 @@ function toNodeResolveOptions(resolverOptions) {
2905
2942
  evaluate: (exp) => resolverOptions.evaluator.evaluate(exp, resolverOptions)
2906
2943
  });
2907
2944
  }
2945
+ function unpackAndPush(item, initial) {
2946
+ if (Array.isArray(item)) {
2947
+ item.forEach((i) => {
2948
+ unpackAndPush(i, initial);
2949
+ });
2950
+ } else {
2951
+ initial.push(item);
2952
+ }
2953
+ }
2908
2954
 
2909
2955
  var __defProp$7 = Object.defineProperty;
2910
2956
  var __defProps$5 = Object.defineProperties;
@@ -2980,22 +3026,13 @@ class Resolver {
2980
3026
  getResolveCache() {
2981
3027
  return new Map(this.resolveCache);
2982
3028
  }
2983
- getNodeID(node) {
2984
- var _a;
2985
- if (!node) {
2986
- return;
2987
- }
2988
- if ((node.type === NodeType.Asset || node.type === NodeType.View || node.type === NodeType.Value) && typeof node.value === "object" && typeof ((_a = node.value) == null ? void 0 : _a.id) === "string") {
2989
- return node.value.id;
2990
- }
2991
- }
2992
3029
  getPreviousResult(node) {
2993
3030
  var _a, _b;
2994
3031
  if (!node) {
2995
3032
  return;
2996
3033
  }
2997
3034
  const isFirstUpdate = this.resolveCache.size === 0;
2998
- const id = this.getNodeID(node);
3035
+ const id = getNodeID(node);
2999
3036
  if (id) {
3000
3037
  if (this.idCache.has(id)) {
3001
3038
  if (isFirstUpdate) {
@@ -3023,8 +3060,8 @@ class Resolver {
3023
3060
  });
3024
3061
  return clonedNode;
3025
3062
  }
3026
- computeTree(node, parent, dataChanges, cacheUpdate, options, parentNode, prevASTMap) {
3027
- var _a, _b;
3063
+ computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap) {
3064
+ var _a, _b, _c;
3028
3065
  const dependencyModel = new DependencyModel(options.data.model);
3029
3066
  dependencyModel.trackSubset("core");
3030
3067
  const depModelWithParser = withContext(withParser(dependencyModel, this.options.parseBinding));
@@ -3039,15 +3076,21 @@ class Resolver {
3039
3076
  const previousDeps = previousResult == null ? void 0 : previousResult.dependencies;
3040
3077
  const dataChanged = caresAboutDataChanges(dataChanges, previousDeps);
3041
3078
  const shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged, node, resolveOptions);
3042
- if (shouldUseLastValue && previousResult) {
3079
+ const clonedNode = __spreadProps$5(__spreadValues$7({}, this.cloneNode(node)), {
3080
+ parent: partiallyResolvedParent
3081
+ });
3082
+ const resolvedAST = (_a = this.hooks.beforeResolve.call(clonedNode, resolveOptions)) != null ? _a : {
3083
+ type: NodeType.Empty
3084
+ };
3085
+ const isNestedMultiNode = resolvedAST.type === NodeType.MultiNode && ((_b = partiallyResolvedParent == null ? void 0 : partiallyResolvedParent.parent) == null ? void 0 : _b.type) === NodeType.MultiNode && partiallyResolvedParent.type === NodeType.Value;
3086
+ if (previousResult && shouldUseLastValue) {
3043
3087
  const update2 = __spreadProps$5(__spreadValues$7({}, previousResult), {
3044
3088
  updated: false
3045
3089
  });
3046
- cacheUpdate.set(node, update2);
3047
3090
  const repopulateASTMapFromCache = (resolvedNode, AST, ASTParent) => {
3048
3091
  var _a2;
3049
- const { node: resolvedAST2 } = resolvedNode;
3050
- this.ASTMap.set(resolvedAST2, AST);
3092
+ const { node: resolvedASTLocal } = resolvedNode;
3093
+ this.ASTMap.set(resolvedASTLocal, AST);
3051
3094
  const resolvedUpdate = __spreadProps$5(__spreadValues$7({}, resolvedNode), {
3052
3095
  updated: false
3053
3096
  });
@@ -3060,24 +3103,18 @@ class Resolver {
3060
3103
  return;
3061
3104
  repopulateASTMapFromCache(previousChildResult, originalChildNode, AST);
3062
3105
  };
3063
- if ("children" in resolvedAST2) {
3064
- (_a2 = resolvedAST2.children) == null ? void 0 : _a2.forEach(({ value: childAST }) => handleChildNode(childAST));
3065
- } else if (resolvedAST2.type === NodeType.MultiNode) {
3066
- resolvedAST2.values.forEach(handleChildNode);
3106
+ if ("children" in resolvedASTLocal) {
3107
+ (_a2 = resolvedASTLocal.children) == null ? void 0 : _a2.forEach(({ value: childAST }) => handleChildNode(childAST));
3108
+ } else if (resolvedASTLocal.type === NodeType.MultiNode) {
3109
+ resolvedASTLocal.values.forEach(handleChildNode);
3067
3110
  }
3068
3111
  this.hooks.afterNodeUpdate.call(AST, ASTParent, resolvedUpdate);
3069
3112
  };
3070
- previousResult.node.parent = parentNode;
3071
- repopulateASTMapFromCache(previousResult, node, parent);
3113
+ previousResult.node.parent = partiallyResolvedParent;
3114
+ repopulateASTMapFromCache(previousResult, node, rawParent);
3072
3115
  return update2;
3073
3116
  }
3074
- const clonedNode = __spreadProps$5(__spreadValues$7({}, this.cloneNode(node)), {
3075
- parent: parentNode
3076
- });
3077
- const resolvedAST = (_a = this.hooks.beforeResolve.call(clonedNode, resolveOptions)) != null ? _a : {
3078
- type: NodeType.Empty
3079
- };
3080
- resolvedAST.parent = parentNode;
3117
+ resolvedAST.parent = partiallyResolvedParent;
3081
3118
  resolveOptions.node = resolvedAST;
3082
3119
  this.ASTMap.set(resolvedAST, node);
3083
3120
  let resolved = this.hooks.resolve.call(void 0, resolvedAST, resolveOptions);
@@ -3088,7 +3125,7 @@ class Resolver {
3088
3125
  const childDependencies = new Set();
3089
3126
  dependencyModel.trackSubset("children");
3090
3127
  if ("children" in resolvedAST) {
3091
- const newChildren = (_b = resolvedAST.children) == null ? void 0 : _b.map((child) => {
3128
+ const newChildren = (_c = resolvedAST.children) == null ? void 0 : _c.map((child) => {
3092
3129
  const computedChildTree = this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap);
3093
3130
  const {
3094
3131
  dependencies: childTreeDeps,
@@ -3111,10 +3148,18 @@ class Resolver {
3111
3148
  resolvedAST.children = newChildren;
3112
3149
  } else if (resolvedAST.type === NodeType.MultiNode) {
3113
3150
  const childValue = [];
3151
+ const rawParentToPassIn = isNestedMultiNode ? partiallyResolvedParent == null ? void 0 : partiallyResolvedParent.parent : node;
3114
3152
  const newValues = resolvedAST.values.map((mValue) => {
3115
- const mTree = this.computeTree(mValue, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap);
3153
+ var _a2;
3154
+ const mTree = this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap);
3116
3155
  if (mTree.value !== void 0 && mTree.value !== null) {
3117
- childValue.push(mTree.value);
3156
+ if (((_a2 = mTree.node.parent) == null ? void 0 : _a2.type) === NodeType.MultiNode && Array.isArray(mTree.value)) {
3157
+ mTree.value.forEach((v) => {
3158
+ unpackAndPush(v, childValue);
3159
+ });
3160
+ } else {
3161
+ childValue.push(mTree.value);
3162
+ }
3118
3163
  }
3119
3164
  mTree.dependencies.forEach((bindingDep) => childDependencies.add(bindingDep));
3120
3165
  updated = updated || mTree.updated;
@@ -3140,7 +3185,7 @@ class Resolver {
3140
3185
  ...childDependencies
3141
3186
  ])
3142
3187
  };
3143
- this.hooks.afterNodeUpdate.call(node, parent, update);
3188
+ this.hooks.afterNodeUpdate.call(node, isNestedMultiNode ? partiallyResolvedParent == null ? void 0 : partiallyResolvedParent.parent : rawParent, update);
3144
3189
  cacheUpdate.set(node, update);
3145
3190
  return update;
3146
3191
  }
@@ -3542,6 +3587,12 @@ class ViewInstance {
3542
3587
  this.templatePlugin = new TemplatePlugin(pluginOptions);
3543
3588
  this.templatePlugin.apply(this);
3544
3589
  }
3590
+ updateAsync() {
3591
+ var _a;
3592
+ const update = (_a = this.resolver) == null ? void 0 : _a.update();
3593
+ this.lastUpdate = update;
3594
+ this.hooks.onUpdate.call(update);
3595
+ }
3545
3596
  update(changes) {
3546
3597
  var _a;
3547
3598
  if (this.rootNode === void 0) {
@@ -3643,6 +3694,7 @@ var __async$2 = (__this, __arguments, generator) => {
3643
3694
  };
3644
3695
  class FlowInstance {
3645
3696
  constructor(id, flow, options) {
3697
+ this.isTransitioning = false;
3646
3698
  this.hooks = {
3647
3699
  beforeStart: new tapable_ts__WEBPACK_IMPORTED_MODULE_1__["SyncBailHook"](),
3648
3700
  onStart: new tapable_ts__WEBPACK_IMPORTED_MODULE_1__["SyncHook"](),
@@ -3685,20 +3737,23 @@ class FlowInstance {
3685
3737
  });
3686
3738
  }
3687
3739
  transition(transitionValue, options) {
3688
- var _a, _b, _c, _d, _e, _f;
3689
- if (((_a = this.currentState) == null ? void 0 : _a.value.state_type) === "END") {
3690
- (_b = this.log) == null ? void 0 : _b.warn(`Skipping transition using ${transitionValue}. Already at and END state`);
3740
+ var _a, _b, _c, _d, _e, _f, _g;
3741
+ if (this.isTransitioning) {
3742
+ throw new Error(`Transitioning while ongoing transition from ${(_a = this.currentState) == null ? void 0 : _a.name} is in progress is not supported`);
3743
+ }
3744
+ if (((_b = this.currentState) == null ? void 0 : _b.value.state_type) === "END") {
3745
+ (_c = this.log) == null ? void 0 : _c.warn(`Skipping transition using ${transitionValue}. Already at and END state`);
3691
3746
  return;
3692
3747
  }
3693
3748
  if (this.currentState === void 0) {
3694
3749
  throw new Error("Cannot transition when there's no current state");
3695
3750
  }
3696
3751
  if (options == null ? void 0 : options.force) {
3697
- (_c = this.log) == null ? void 0 : _c.debug(`Forced transition. Skipping validation checks`);
3752
+ (_d = this.log) == null ? void 0 : _d.debug(`Forced transition. Skipping validation checks`);
3698
3753
  } else {
3699
3754
  const skipTransition = this.hooks.skipTransition.call(this.currentState);
3700
3755
  if (skipTransition) {
3701
- (_d = this.log) == null ? void 0 : _d.debug(`Skipping transition from ${this.currentState.name} b/c hook told us to`);
3756
+ (_e = this.log) == null ? void 0 : _e.debug(`Skipping transition from ${this.currentState.name} b/c hook told us to`);
3702
3757
  return;
3703
3758
  }
3704
3759
  }
@@ -3709,10 +3764,10 @@ class FlowInstance {
3709
3764
  const { transitions } = state;
3710
3765
  const nextState = transitions[transitionValue] || transitions["*"];
3711
3766
  if (nextState === void 0) {
3712
- (_e = this.log) == null ? void 0 : _e.warn(`No transition from ${this.currentState.name} using ${transitionValue} or *`);
3767
+ (_f = this.log) == null ? void 0 : _f.warn(`No transition from ${this.currentState.name} using ${transitionValue} or *`);
3713
3768
  return;
3714
3769
  }
3715
- (_f = this.log) == null ? void 0 : _f.debug(`Transitioning from ${this.currentState.name} to ${nextState} using ${transitionValue} `);
3770
+ (_g = this.log) == null ? void 0 : _g.debug(`Transitioning from ${this.currentState.name} to ${nextState} using ${transitionValue} `);
3716
3771
  return this.pushHistory(nextState, options);
3717
3772
  }
3718
3773
  pushHistory(stateName, options) {
@@ -3726,6 +3781,7 @@ class FlowInstance {
3726
3781
  return;
3727
3782
  }
3728
3783
  const prevState = this.currentState;
3784
+ this.isTransitioning = true;
3729
3785
  nextState = this.hooks.resolveTransitionNode.call(nextState);
3730
3786
  const newCurrentState = {
3731
3787
  name: stateName,
@@ -3737,6 +3793,7 @@ class FlowInstance {
3737
3793
  this.hooks.onEnd.call(this.flow.onEnd);
3738
3794
  }
3739
3795
  this.hooks.transition.call(prevState, __spreadValues$5({}, newCurrentState));
3796
+ this.isTransitioning = false;
3740
3797
  this.hooks.afterTransition.call(this);
3741
3798
  }
3742
3799
  }
@@ -5094,8 +5151,8 @@ var __async = (__this, __arguments, generator) => {
5094
5151
  step((generator = generator.apply(__this, __arguments)).next());
5095
5152
  });
5096
5153
  };
5097
- const PLAYER_VERSION = "0.5.2--canary.256.8666";
5098
- const COMMIT = "f2375f827f1663275f9ff3b26108a084dcfe6c2e";
5154
+ const PLAYER_VERSION = "0.6.0-next.0";
5155
+ const COMMIT = "7c26e7b867b837ac89a482c8adbf3792336da50f";
5099
5156
  const _Player = class {
5100
5157
  constructor(config) {
5101
5158
  this.logger = new TapableLogger();