@devtools-ui/console 0.0.2--canary.11.588 → 0.0.2--canary.13.662

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.
@@ -51,15 +51,7 @@ var import_react2 = __toESM(require("react"));
51
51
  var import_dsl = require("@player-tools/dsl");
52
52
  var Console2 = (props) => {
53
53
  const { exp, binding } = props;
54
- let expValue;
55
- if ((0, import_dsl.isTemplateStringInstance)(exp)) {
56
- expValue = exp.toValue();
57
- } else if (Array.isArray(exp)) {
58
- expValue = exp.map((e) => typeof e === "string" ? e : e.toValue());
59
- } else if (exp) {
60
- expValue = exp;
61
- }
62
- return /* @__PURE__ */ import_react2.default.createElement(import_dsl.Asset, { type: "console" }, exp && /* @__PURE__ */ import_react2.default.createElement("property", { name: "exp" }, expValue), binding && /* @__PURE__ */ import_react2.default.createElement("property", { name: "binding" }, binding.toValue()));
54
+ return /* @__PURE__ */ import_react2.default.createElement(import_dsl.Asset, { type: "console" }, exp && /* @__PURE__ */ import_react2.default.createElement("property", { name: "exp" }, exp.toValue()), binding && /* @__PURE__ */ import_react2.default.createElement("property", { name: "binding" }, binding.toValue()));
63
55
  };
64
56
 
65
57
  // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/transform/index.ts
@@ -71,8 +63,10 @@ var transform = (asset, options) => {
71
63
  includeInvalid: true,
72
64
  formatted: false
73
65
  }),
74
- evaluate() {
66
+ evaluate(expression) {
75
67
  if (asset.exp) {
68
+ const referencedExpression = asset.exp.match(/{{\s*(.*?)\s*}}/);
69
+ referencedExpression && options.data.model.set([[referencedExpression[1], expression]]);
76
70
  options.evaluate(asset.exp);
77
71
  }
78
72
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/component/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/dsl/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/transform/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./component\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import React from \"react\";\nimport { Console } from \"@devtools-ds/console\";\nimport type { TransformedConsole } from \"../types\";\n\nexport const ConsoleComponent = (props: TransformedConsole) => {\n const { evaluate, history } = props;\n\n return <Console execute={evaluate} history={history} />;\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n isTemplateStringInstance,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { ConsoleAsset } from \"../types\";\n\n/**\n * Defines the component DSL representation for the Console asset,\n * a component that emulates a REPL environment that you see in browsers.\n */\nexport const Console = (\n props: Omit<AssetPropsWithChildren<ConsoleAsset>, \"binding\"> & {\n /** Binding as template string */\n binding: BindingTemplateInstance;\n }\n) => {\n const { exp, binding } = props;\n\n // Extracting the exp value from the props\n let expValue: ConsoleAsset[\"exp\"];\n\n if (isTemplateStringInstance(exp)) {\n expValue = exp.toValue();\n } else if (Array.isArray(exp)) {\n expValue = exp.map((e) => (typeof e === \"string\" ? e : e.toValue()));\n } else if (exp) {\n expValue = exp;\n }\n\n return (\n <Asset type=\"console\">\n {exp && <property name=\"exp\">{expValue}</property>}\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n </Asset>\n );\n};\n","import type {\n Asset,\n BeforeTransformFunction,\n TransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport { ConsoleAsset, TransformedConsole } from \"../types\";\n\n/**\n * Platform-agnostic transform function that takes the properties we get from the Player Content (DSL > JSON)\n * and embeds Player state and methods:\n */\nexport const transform: TransformFunction<ConsoleAsset, TransformedConsole> = (\n asset,\n options\n) => {\n return {\n ...asset,\n history:\n asset.binding === undefined\n ? undefined\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n }),\n evaluate() {\n if (asset.exp) {\n options.evaluate(asset.exp);\n }\n },\n };\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const consoleTransform = compose(\n transform,\n composeBefore(expPropTransform)\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,qBAAwB;AAGjB,IAAM,mBAAmB,CAAC,UAA8B;AAC7D,QAAM,EAAE,UAAU,QAAQ,IAAI;AAE9B,SAAO,6BAAAC,QAAA,cAAC,0BAAQ,SAAS,UAAU,SAAkB;AACvD;;;ACRA,IAAAC,gBAAkB;AAClB,iBAKO;AAOA,IAAMC,WAAU,CACrB,UAIG;AACH,QAAM,EAAE,KAAK,QAAQ,IAAI;AAGzB,MAAI;AAEJ,UAAI,qCAAyB,GAAG,GAAG;AACjC,eAAW,IAAI,QAAQ;AAAA,EACzB,WAAW,MAAM,QAAQ,GAAG,GAAG;AAC7B,eAAW,IAAI,IAAI,CAAC,MAAO,OAAO,MAAM,WAAW,IAAI,EAAE,QAAQ,CAAE;AAAA,EACrE,WAAW,KAAK;AACd,eAAW;AAAA,EACb;AAEA,SACE,8BAAAC,QAAA,cAAC,oBAAM,MAAK,aACT,OAAO,8BAAAA,QAAA,cAAC,cAAS,MAAK,SAAO,QAAS,GACtC,WAAW,8BAAAA,QAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,CAC1D;AAEJ;;;ACjCA,oCAAuC;AAOhC,IAAM,YAAiE,CAC5E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SACE,MAAM,YAAY,SACd,SACA,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,IACP,WAAW;AACT,UAAI,MAAM,KAAK;AACb,gBAAQ,SAAS,MAAM,GAAG;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,mBAAmD,CAAC,UAAU;AACzE,QAAM,YAAY,MAAM,SAAS,gBAAgB;AAEjD,MAAI,aAAa,UAAU,QAAQ,KAAK,IAAI,GAAG;AAC7C,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,MAAM;AAAA,MACT,gBAAgB;AAAA,QACd,GAAG,OAAO,SAAS;AAAA,QACnB,kBAAkB;AAAA,UAChB,GAAI,MAAM,SAAS,gBAAgB,oBAAoB,CAAC;AAAA,UACxD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,uBAAmB;AAAA,EAC9B;AAAA,MACA,6CAAc,gBAAgB;AAChC;","names":["Console","React","import_react","Console","React"]}
1
+ {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/component/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/dsl/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/transform/index.ts"],"sourcesContent":["import style from \"@devtools-ds/console/main.css\";\n\nexport * from \"./types\";\nexport * from \"./component\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import React from \"react\";\nimport { Console } from \"@devtools-ds/console\";\nimport type { TransformedConsole } from \"../types\";\n\nexport const ConsoleComponent = (props: TransformedConsole) => {\n const { evaluate, history } = props;\n\n return <Console execute={evaluate} history={history} />;\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { ConsoleAsset } from \"../types\";\n\n/**\n * Defines the component DSL representation for the Console asset,\n * a component that emulates a REPL environment that you see in browsers.\n */\nexport const Console = (\n props: Omit<AssetPropsWithChildren<ConsoleAsset>, \"binding\"> & {\n /** Binding as template string */\n binding: BindingTemplateInstance;\n /** Expression as template string */\n exp: ExpressionTemplateInstance;\n }\n) => {\n const { exp, binding } = props;\n\n return (\n <Asset type=\"console\">\n {exp && <property name=\"exp\">{exp.toValue()}</property>}\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n </Asset>\n );\n};\n","import type {\n Asset,\n BeforeTransformFunction,\n TransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport { ConsoleAsset, TransformedConsole } from \"../types\";\n\n/**\n * Platform-agnostic transform function that takes the properties we get from the Player Content (DSL > JSON)\n * and embeds Player state and methods:\n */\nexport const transform: TransformFunction<ConsoleAsset, TransformedConsole> = (\n asset,\n options\n) => {\n return {\n ...asset,\n history:\n asset.binding === undefined\n ? undefined\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n }),\n evaluate(expression: string) {\n if (asset.exp) {\n // get the referenced expression property holder from the expression\n const referencedExpression = asset.exp.match(/{{\\s*(.*?)\\s*}}/);\n // set the referenced expression property to the new expression\n // so it is available to the asset.exp\n referencedExpression &&\n options.data.model.set([[referencedExpression[1], expression]]);\n options.evaluate(asset.exp);\n }\n },\n };\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const consoleTransform = compose(\n transform,\n composeBefore(expPropTransform)\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,qBAAwB;AAGjB,IAAM,mBAAmB,CAAC,UAA8B;AAC7D,QAAM,EAAE,UAAU,QAAQ,IAAI;AAE9B,SAAO,6BAAAC,QAAA,cAAC,0BAAQ,SAAS,UAAU,SAAkB;AACvD;;;ACRA,IAAAC,gBAAkB;AAClB,iBAKO;AAOA,IAAMC,WAAU,CACrB,UAMG;AACH,QAAM,EAAE,KAAK,QAAQ,IAAI;AAEzB,SACE,8BAAAC,QAAA,cAAC,oBAAM,MAAK,aACT,OAAO,8BAAAA,QAAA,cAAC,cAAS,MAAK,SAAO,IAAI,QAAQ,CAAE,GAC3C,WAAW,8BAAAA,QAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,CAC1D;AAEJ;;;ACxBA,oCAAuC;AAOhC,IAAM,YAAiE,CAC5E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SACE,MAAM,YAAY,SACd,SACA,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,IACP,SAAS,YAAoB;AAC3B,UAAI,MAAM,KAAK;AAEb,cAAM,uBAAuB,MAAM,IAAI,MAAM,iBAAiB;AAG9D,gCACE,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,qBAAqB,CAAC,GAAG,UAAU,CAAC,CAAC;AAChE,gBAAQ,SAAS,MAAM,GAAG;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,mBAAmD,CAAC,UAAU;AACzE,QAAM,YAAY,MAAM,SAAS,gBAAgB;AAEjD,MAAI,aAAa,UAAU,QAAQ,KAAK,IAAI,GAAG;AAC7C,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,MAAM;AAAA,MACT,gBAAgB;AAAA,QACd,GAAG,OAAO,SAAS;AAAA,QACnB,kBAAkB;AAAA,UAChB,GAAI,MAAM,SAAS,gBAAgB,oBAAoB,CAAC;AAAA,UACxD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,uBAAmB;AAAA,EAC9B;AAAA,MACA,6CAAc,gBAAgB;AAChC;","names":["Console","React","import_react","Console","React"]}
@@ -9,20 +9,11 @@ var ConsoleComponent = (props) => {
9
9
  // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/dsl/index.tsx
10
10
  import React2 from "react";
11
11
  import {
12
- Asset,
13
- isTemplateStringInstance
12
+ Asset
14
13
  } from "@player-tools/dsl";
15
14
  var Console2 = (props) => {
16
15
  const { exp, binding } = props;
17
- let expValue;
18
- if (isTemplateStringInstance(exp)) {
19
- expValue = exp.toValue();
20
- } else if (Array.isArray(exp)) {
21
- expValue = exp.map((e) => typeof e === "string" ? e : e.toValue());
22
- } else if (exp) {
23
- expValue = exp;
24
- }
25
- return /* @__PURE__ */ React2.createElement(Asset, { type: "console" }, exp && /* @__PURE__ */ React2.createElement("property", { name: "exp" }, expValue), binding && /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()));
16
+ return /* @__PURE__ */ React2.createElement(Asset, { type: "console" }, exp && /* @__PURE__ */ React2.createElement("property", { name: "exp" }, exp.toValue()), binding && /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()));
26
17
  };
27
18
 
28
19
  // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/transform/index.ts
@@ -34,8 +25,10 @@ var transform = (asset, options) => {
34
25
  includeInvalid: true,
35
26
  formatted: false
36
27
  }),
37
- evaluate() {
28
+ evaluate(expression) {
38
29
  if (asset.exp) {
30
+ const referencedExpression = asset.exp.match(/{{\s*(.*?)\s*}}/);
31
+ referencedExpression && options.data.model.set([[referencedExpression[1], expression]]);
39
32
  options.evaluate(asset.exp);
40
33
  }
41
34
  }
package/dist/index.mjs CHANGED
@@ -9,20 +9,11 @@ var ConsoleComponent = (props) => {
9
9
  // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/dsl/index.tsx
10
10
  import React2 from "react";
11
11
  import {
12
- Asset,
13
- isTemplateStringInstance
12
+ Asset
14
13
  } from "@player-tools/dsl";
15
14
  var Console2 = (props) => {
16
15
  const { exp, binding } = props;
17
- let expValue;
18
- if (isTemplateStringInstance(exp)) {
19
- expValue = exp.toValue();
20
- } else if (Array.isArray(exp)) {
21
- expValue = exp.map((e) => typeof e === "string" ? e : e.toValue());
22
- } else if (exp) {
23
- expValue = exp;
24
- }
25
- return /* @__PURE__ */ React2.createElement(Asset, { type: "console" }, exp && /* @__PURE__ */ React2.createElement("property", { name: "exp" }, expValue), binding && /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()));
16
+ return /* @__PURE__ */ React2.createElement(Asset, { type: "console" }, exp && /* @__PURE__ */ React2.createElement("property", { name: "exp" }, exp.toValue()), binding && /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()));
26
17
  };
27
18
 
28
19
  // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/transform/index.ts
@@ -34,8 +25,10 @@ var transform = (asset, options) => {
34
25
  includeInvalid: true,
35
26
  formatted: false
36
27
  }),
37
- evaluate() {
28
+ evaluate(expression) {
38
29
  if (asset.exp) {
30
+ const referencedExpression = asset.exp.match(/{{\s*(.*?)\s*}}/);
31
+ referencedExpression && options.data.model.set([[referencedExpression[1], expression]]);
39
32
  options.evaluate(asset.exp);
40
33
  }
41
34
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/component/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/dsl/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/transform/index.ts"],"sourcesContent":["import React from \"react\";\nimport { Console } from \"@devtools-ds/console\";\nimport type { TransformedConsole } from \"../types\";\n\nexport const ConsoleComponent = (props: TransformedConsole) => {\n const { evaluate, history } = props;\n\n return <Console execute={evaluate} history={history} />;\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n isTemplateStringInstance,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { ConsoleAsset } from \"../types\";\n\n/**\n * Defines the component DSL representation for the Console asset,\n * a component that emulates a REPL environment that you see in browsers.\n */\nexport const Console = (\n props: Omit<AssetPropsWithChildren<ConsoleAsset>, \"binding\"> & {\n /** Binding as template string */\n binding: BindingTemplateInstance;\n }\n) => {\n const { exp, binding } = props;\n\n // Extracting the exp value from the props\n let expValue: ConsoleAsset[\"exp\"];\n\n if (isTemplateStringInstance(exp)) {\n expValue = exp.toValue();\n } else if (Array.isArray(exp)) {\n expValue = exp.map((e) => (typeof e === \"string\" ? e : e.toValue()));\n } else if (exp) {\n expValue = exp;\n }\n\n return (\n <Asset type=\"console\">\n {exp && <property name=\"exp\">{expValue}</property>}\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n </Asset>\n );\n};\n","import type {\n Asset,\n BeforeTransformFunction,\n TransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport { ConsoleAsset, TransformedConsole } from \"../types\";\n\n/**\n * Platform-agnostic transform function that takes the properties we get from the Player Content (DSL > JSON)\n * and embeds Player state and methods:\n */\nexport const transform: TransformFunction<ConsoleAsset, TransformedConsole> = (\n asset,\n options\n) => {\n return {\n ...asset,\n history:\n asset.binding === undefined\n ? undefined\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n }),\n evaluate() {\n if (asset.exp) {\n options.evaluate(asset.exp);\n }\n },\n };\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const consoleTransform = compose(\n transform,\n composeBefore(expPropTransform)\n);\n"],"mappings":";AAAA,OAAO,WAAW;AAClB,SAAS,eAAe;AAGjB,IAAM,mBAAmB,CAAC,UAA8B;AAC7D,QAAM,EAAE,UAAU,QAAQ,IAAI;AAE9B,SAAO,oCAAC,WAAQ,SAAS,UAAU,SAAkB;AACvD;;;ACRA,OAAOA,YAAW;AAClB;AAAA,EAEE;AAAA,EACA;AAAA,OAEK;AAOA,IAAMC,WAAU,CACrB,UAIG;AACH,QAAM,EAAE,KAAK,QAAQ,IAAI;AAGzB,MAAI;AAEJ,MAAI,yBAAyB,GAAG,GAAG;AACjC,eAAW,IAAI,QAAQ;AAAA,EACzB,WAAW,MAAM,QAAQ,GAAG,GAAG;AAC7B,eAAW,IAAI,IAAI,CAAC,MAAO,OAAO,MAAM,WAAW,IAAI,EAAE,QAAQ,CAAE;AAAA,EACrE,WAAW,KAAK;AACd,eAAW;AAAA,EACb;AAEA,SACE,gBAAAD,OAAA,cAAC,SAAM,MAAK,aACT,OAAO,gBAAAA,OAAA,cAAC,cAAS,MAAK,SAAO,QAAS,GACtC,WAAW,gBAAAA,OAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,CAC1D;AAEJ;;;ACjCA,SAAS,SAAS,qBAAqB;AAOhC,IAAM,YAAiE,CAC5E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SACE,MAAM,YAAY,SACd,SACA,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,IACP,WAAW;AACT,UAAI,MAAM,KAAK;AACb,gBAAQ,SAAS,MAAM,GAAG;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,mBAAmD,CAAC,UAAU;AACzE,QAAM,YAAY,MAAM,SAAS,gBAAgB;AAEjD,MAAI,aAAa,UAAU,QAAQ,KAAK,IAAI,GAAG;AAC7C,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,MAAM;AAAA,MACT,gBAAgB;AAAA,QACd,GAAG,OAAO,SAAS;AAAA,QACnB,kBAAkB;AAAA,UAChB,GAAI,MAAM,SAAS,gBAAgB,oBAAoB,CAAC;AAAA,UACxD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA,cAAc,gBAAgB;AAChC;","names":["React","Console"]}
1
+ {"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/component/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/dsl/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/console/src/transform/index.ts"],"sourcesContent":["import React from \"react\";\nimport { Console } from \"@devtools-ds/console\";\nimport type { TransformedConsole } from \"../types\";\n\nexport const ConsoleComponent = (props: TransformedConsole) => {\n const { evaluate, history } = props;\n\n return <Console execute={evaluate} history={history} />;\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { ConsoleAsset } from \"../types\";\n\n/**\n * Defines the component DSL representation for the Console asset,\n * a component that emulates a REPL environment that you see in browsers.\n */\nexport const Console = (\n props: Omit<AssetPropsWithChildren<ConsoleAsset>, \"binding\"> & {\n /** Binding as template string */\n binding: BindingTemplateInstance;\n /** Expression as template string */\n exp: ExpressionTemplateInstance;\n }\n) => {\n const { exp, binding } = props;\n\n return (\n <Asset type=\"console\">\n {exp && <property name=\"exp\">{exp.toValue()}</property>}\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n </Asset>\n );\n};\n","import type {\n Asset,\n BeforeTransformFunction,\n TransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport { ConsoleAsset, TransformedConsole } from \"../types\";\n\n/**\n * Platform-agnostic transform function that takes the properties we get from the Player Content (DSL > JSON)\n * and embeds Player state and methods:\n */\nexport const transform: TransformFunction<ConsoleAsset, TransformedConsole> = (\n asset,\n options\n) => {\n return {\n ...asset,\n history:\n asset.binding === undefined\n ? undefined\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n }),\n evaluate(expression: string) {\n if (asset.exp) {\n // get the referenced expression property holder from the expression\n const referencedExpression = asset.exp.match(/{{\\s*(.*?)\\s*}}/);\n // set the referenced expression property to the new expression\n // so it is available to the asset.exp\n referencedExpression &&\n options.data.model.set([[referencedExpression[1], expression]]);\n options.evaluate(asset.exp);\n }\n },\n };\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const consoleTransform = compose(\n transform,\n composeBefore(expPropTransform)\n);\n"],"mappings":";AAAA,OAAO,WAAW;AAClB,SAAS,eAAe;AAGjB,IAAM,mBAAmB,CAAC,UAA8B;AAC7D,QAAM,EAAE,UAAU,QAAQ,IAAI;AAE9B,SAAO,oCAAC,WAAQ,SAAS,UAAU,SAAkB;AACvD;;;ACRA,OAAOA,YAAW;AAClB;AAAA,EAEE;AAAA,OAGK;AAOA,IAAMC,WAAU,CACrB,UAMG;AACH,QAAM,EAAE,KAAK,QAAQ,IAAI;AAEzB,SACE,gBAAAD,OAAA,cAAC,SAAM,MAAK,aACT,OAAO,gBAAAA,OAAA,cAAC,cAAS,MAAK,SAAO,IAAI,QAAQ,CAAE,GAC3C,WAAW,gBAAAA,OAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,CAC1D;AAEJ;;;ACxBA,SAAS,SAAS,qBAAqB;AAOhC,IAAM,YAAiE,CAC5E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SACE,MAAM,YAAY,SACd,SACA,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,IACP,SAAS,YAAoB;AAC3B,UAAI,MAAM,KAAK;AAEb,cAAM,uBAAuB,MAAM,IAAI,MAAM,iBAAiB;AAG9D,gCACE,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,qBAAqB,CAAC,GAAG,UAAU,CAAC,CAAC;AAChE,gBAAQ,SAAS,MAAM,GAAG;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,mBAAmD,CAAC,UAAU;AACzE,QAAM,YAAY,MAAM,SAAS,gBAAgB;AAEjD,MAAI,aAAa,UAAU,QAAQ,KAAK,IAAI,GAAG;AAC7C,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,MAAM;AAAA,MACT,gBAAgB;AAAA,QACd,GAAG,OAAO,SAAS;AAAA,QACnB,kBAAkB;AAAA,UAChB,GAAI,MAAM,SAAS,gBAAgB,oBAAoB,CAAC;AAAA,UACxD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA,cAAc,gBAAgB;AAChC;","names":["React","Console"]}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@devtools-ui/console",
3
- "version": "0.0.2--canary.11.588",
3
+ "version": "0.0.2--canary.13.662",
4
4
  "main": "dist/cjs/index.cjs",
5
5
  "dependencies": {
6
- "@devtools-ui/text": "0.0.2--canary.11.588",
7
- "@devtools-ui/collection": "0.0.2--canary.11.588",
6
+ "@devtools-ui/text": "0.0.2--canary.13.662",
7
+ "@devtools-ui/collection": "0.0.2--canary.13.662",
8
8
  "@chakra-ui/react": "^2.8.2",
9
9
  "@emotion/react": "^11.11.4",
10
10
  "@emotion/styled": "^11.11.0",
@@ -26,6 +26,7 @@
26
26
  "sideEffects": false,
27
27
  "exports": {
28
28
  "./package.json": "./package.json",
29
+ "./dist/index.css": "./dist/index.css",
29
30
  ".": {
30
31
  "types": "./types/index.d.ts",
31
32
  "import": "./dist/index.mjs",
package/src/dsl/index.tsx CHANGED
@@ -2,8 +2,8 @@ import React from "react";
2
2
  import {
3
3
  AssetPropsWithChildren,
4
4
  Asset,
5
- isTemplateStringInstance,
6
5
  BindingTemplateInstance,
6
+ ExpressionTemplateInstance,
7
7
  } from "@player-tools/dsl";
8
8
  import type { ConsoleAsset } from "../types";
9
9
 
@@ -15,24 +15,15 @@ export const Console = (
15
15
  props: Omit<AssetPropsWithChildren<ConsoleAsset>, "binding"> & {
16
16
  /** Binding as template string */
17
17
  binding: BindingTemplateInstance;
18
+ /** Expression as template string */
19
+ exp: ExpressionTemplateInstance;
18
20
  }
19
21
  ) => {
20
22
  const { exp, binding } = props;
21
23
 
22
- // Extracting the exp value from the props
23
- let expValue: ConsoleAsset["exp"];
24
-
25
- if (isTemplateStringInstance(exp)) {
26
- expValue = exp.toValue();
27
- } else if (Array.isArray(exp)) {
28
- expValue = exp.map((e) => (typeof e === "string" ? e : e.toValue()));
29
- } else if (exp) {
30
- expValue = exp;
31
- }
32
-
33
24
  return (
34
25
  <Asset type="console">
35
- {exp && <property name="exp">{expValue}</property>}
26
+ {exp && <property name="exp">{exp.toValue()}</property>}
36
27
  {binding && <property name="binding">{binding.toValue()}</property>}
37
28
  </Asset>
38
29
  );
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import style from "@devtools-ds/console/main.css";
2
+
1
3
  export * from "./types";
2
4
  export * from "./component";
3
5
  export * from "./dsl";
@@ -23,8 +23,14 @@ export const transform: TransformFunction<ConsoleAsset, TransformedConsole> = (
23
23
  includeInvalid: true,
24
24
  formatted: false,
25
25
  }),
26
- evaluate() {
26
+ evaluate(expression: string) {
27
27
  if (asset.exp) {
28
+ // get the referenced expression property holder from the expression
29
+ const referencedExpression = asset.exp.match(/{{\s*(.*?)\s*}}/);
30
+ // set the referenced expression property to the new expression
31
+ // so it is available to the asset.exp
32
+ referencedExpression &&
33
+ options.data.model.set([[referencedExpression[1], expression]]);
28
34
  options.evaluate(asset.exp);
29
35
  }
30
36
  },
@@ -1,4 +1,4 @@
1
- import type { Asset, Expression } from "@player-ui/types";
1
+ import type { Asset } from "@player-ui/types";
2
2
 
3
3
  export interface Evaluation {
4
4
  /** A unique key for this expression */
@@ -16,7 +16,7 @@ export interface Evaluation {
16
16
 
17
17
  export interface ConsoleAsset extends Asset<"console"> {
18
18
  /** Evaluate expression */
19
- exp?: Expression;
19
+ exp?: string;
20
20
  /** History binding */
21
21
  binding?: string;
22
22
  }
@@ -26,5 +26,5 @@ export interface TransformedConsole extends ConsoleAsset {
26
26
  /** A stateful instance of an action */
27
27
  history: Evaluation[];
28
28
  /** A method to evaluate the expression */
29
- evaluate: () => void;
29
+ evaluate: (expression: string) => void;
30
30
  }
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { AssetPropsWithChildren, BindingTemplateInstance } from "@player-tools/dsl";
2
+ import { AssetPropsWithChildren, BindingTemplateInstance, ExpressionTemplateInstance } from "@player-tools/dsl";
3
3
  import type { ConsoleAsset } from "../types";
4
4
  /**
5
5
  * Defines the component DSL representation for the Console asset,
@@ -8,5 +8,7 @@ import type { ConsoleAsset } from "../types";
8
8
  export declare const Console: (props: Omit<AssetPropsWithChildren<ConsoleAsset>, "binding"> & {
9
9
  /** Binding as template string */
10
10
  binding: BindingTemplateInstance;
11
+ /** Expression as template string */
12
+ exp: ExpressionTemplateInstance;
11
13
  }) => React.JSX.Element;
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { Asset, Expression } from "@player-ui/types";
1
+ import type { Asset } from "@player-ui/types";
2
2
  export interface Evaluation {
3
3
  /** A unique key for this expression */
4
4
  id: string;
@@ -11,7 +11,7 @@ export interface Evaluation {
11
11
  }
12
12
  export interface ConsoleAsset extends Asset<"console"> {
13
13
  /** Evaluate expression */
14
- exp?: Expression;
14
+ exp?: string;
15
15
  /** History binding */
16
16
  binding?: string;
17
17
  }
@@ -20,6 +20,6 @@ export interface TransformedConsole extends ConsoleAsset {
20
20
  /** A stateful instance of an action */
21
21
  history: Evaluation[];
22
22
  /** A method to evaluate the expression */
23
- evaluate: () => void;
23
+ evaluate: (expression: string) => void;
24
24
  }
25
25
  //# sourceMappingURL=index.d.ts.map