@yaoxiu/marketing-dsl 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -737,12 +737,14 @@ function resolveCloseButton(config, layerName, closeTop) {
737
737
  return {
738
738
  key: `${layerName}-close`,
739
739
  tag: "div",
740
+ className: "dsl-close",
740
741
  style,
741
742
  onClick,
742
743
  children: [
743
744
  {
744
745
  key: `${layerName}-close-img`,
745
746
  tag: "img",
747
+ className: "dsl-close-img",
746
748
  src: image,
747
749
  style: { width: "100%", height: "100%", objectFit: "contain", display: "block" }
748
750
  }
@@ -752,12 +754,27 @@ function resolveCloseButton(config, layerName, closeTop) {
752
754
  return {
753
755
  key: `${layerName}-close`,
754
756
  tag: "div",
757
+ className: "dsl-close",
755
758
  style,
756
759
  onClick,
757
760
  text: config.icon || "\xD7"
758
761
  };
759
762
  }
760
763
  var BASE_STYLE = { boxSizing: "border-box" };
764
+ var NODE_CLASS = {
765
+ box: "dsl-box",
766
+ flex: "dsl-flex",
767
+ repeat: "dsl-flex",
768
+ tabs: "dsl-tabs",
769
+ image: "dsl-image",
770
+ text: "dsl-text",
771
+ button: "dsl-button",
772
+ countdown: "dsl-flex"
773
+ };
774
+ function nodeClass(type, clickable) {
775
+ const base = `dsl-node ${NODE_CLASS[type] || ""}`.trim();
776
+ return clickable ? `${base} is-clickable` : base;
777
+ }
761
778
  function resolveNode(node, key, layout, context, input, countdowns) {
762
779
  if (!node || typeof node !== "object") return void 0;
763
780
  if (node.visibleWhen && !evaluate(node.visibleWhen, context)) return void 0;
@@ -776,6 +793,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
776
793
  return {
777
794
  key,
778
795
  tag: "div",
796
+ className: nodeClass("box", !!onClick),
779
797
  style: Object.assign({ position: "relative" }, style),
780
798
  onClick,
781
799
  children: resolveChildren(node.children, key, "absolute", context, input, countdowns)
@@ -784,6 +802,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
784
802
  return {
785
803
  key,
786
804
  tag: "div",
805
+ className: nodeClass("flex", !!onClick),
787
806
  style: Object.assign({ display: "flex" }, style),
788
807
  onClick,
789
808
  children: resolveChildren(node.children, key, "flow", context, input, countdowns)
@@ -792,6 +811,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
792
811
  return {
793
812
  key,
794
813
  tag: "div",
814
+ className: nodeClass("repeat", !!onClick),
795
815
  style: Object.assign({ display: "flex" }, style),
796
816
  onClick,
797
817
  children: resolveRepeat(node, key, context, input, countdowns)
@@ -800,6 +820,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
800
820
  return {
801
821
  key,
802
822
  tag: "div",
823
+ className: nodeClass("tabs", false),
803
824
  style: Object.assign({ display: "flex" }, style),
804
825
  children: resolveTabs(node, key, context, input)
805
826
  };
@@ -807,6 +828,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
807
828
  return {
808
829
  key,
809
830
  tag: "img",
831
+ className: nodeClass("image", !!onClick),
810
832
  src: safeImageUrl(interpolate(node.src, context)),
811
833
  style: Object.assign({ display: "block", objectFit: "cover" }, style),
812
834
  onClick
@@ -815,6 +837,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
815
837
  return {
816
838
  key,
817
839
  tag: "div",
840
+ className: nodeClass("text", !!onClick),
818
841
  style: Object.assign({ wordBreak: "break-word" }, style),
819
842
  text: toText(interpolate(node.content, context)),
820
843
  onClick
@@ -823,6 +846,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
823
846
  return {
824
847
  key,
825
848
  tag: "div",
849
+ className: nodeClass("button", true),
826
850
  style: Object.assign(
827
851
  {
828
852
  display: "flex",
@@ -873,6 +897,7 @@ function resolveTabs(node, key, context, input) {
873
897
  return {
874
898
  key: `${key}-${index}`,
875
899
  tag: "div",
900
+ className: index === active ? "dsl-tab-item is-active" : "dsl-tab-item",
876
901
  style: Object.assign(
877
902
  {
878
903
  display: "flex",
@@ -909,6 +934,7 @@ function resolveCountdown(node, key, style, context, input, countdowns) {
909
934
  return {
910
935
  key,
911
936
  tag: "div",
937
+ className: "dsl-node dsl-text dsl-countdown",
912
938
  style: Object.assign({ wordBreak: "break-word" }, style),
913
939
  text: node.endText || "\u5DF2\u7ED3\u675F"
914
940
  };
@@ -917,6 +943,7 @@ function resolveCountdown(node, key, style, context, input, countdowns) {
917
943
  return {
918
944
  key,
919
945
  tag: "div",
946
+ className: "dsl-node dsl-text dsl-countdown",
920
947
  style: Object.assign({ wordBreak: "break-word" }, style),
921
948
  text: formatParts(parts, node.format)
922
949
  };
@@ -925,6 +952,7 @@ function resolveCountdown(node, key, style, context, input, countdowns) {
925
952
  return {
926
953
  key,
927
954
  tag: "div",
955
+ className: "dsl-node dsl-flex dsl-countdown",
928
956
  style: Object.assign({ display: "flex" }, style),
929
957
  children: resolveChildren(node.children, key, "flow", childContext, input, countdowns)
930
958
  };
package/dist/index.d.cts CHANGED
@@ -153,6 +153,12 @@ interface RenderElement {
153
153
  key: string;
154
154
  /** 画成什么。div 带 text 就是文本节点,带 children 就是容器 */
155
155
  tag: 'div' | 'img';
156
+ /**
157
+ * 类名,如 "dsl-node dsl-text is-clickable"。
158
+ * 不参与样式(样式全在 style 里),纯粹是留给调试和宿主微调的钩子。
159
+ * 由 core 统一生成,不让各框架壳各拼一套,否则 DOM 结构会慢慢跑偏。
160
+ */
161
+ className: string;
156
162
  style: CssStyle;
157
163
  text?: string;
158
164
  src?: string;
package/dist/index.d.ts CHANGED
@@ -153,6 +153,12 @@ interface RenderElement {
153
153
  key: string;
154
154
  /** 画成什么。div 带 text 就是文本节点,带 children 就是容器 */
155
155
  tag: 'div' | 'img';
156
+ /**
157
+ * 类名,如 "dsl-node dsl-text is-clickable"。
158
+ * 不参与样式(样式全在 style 里),纯粹是留给调试和宿主微调的钩子。
159
+ * 由 core 统一生成,不让各框架壳各拼一套,否则 DOM 结构会慢慢跑偏。
160
+ */
161
+ className: string;
156
162
  style: CssStyle;
157
163
  text?: string;
158
164
  src?: string;
package/dist/index.js CHANGED
@@ -735,12 +735,14 @@ function resolveCloseButton(config, layerName, closeTop) {
735
735
  return {
736
736
  key: `${layerName}-close`,
737
737
  tag: "div",
738
+ className: "dsl-close",
738
739
  style,
739
740
  onClick,
740
741
  children: [
741
742
  {
742
743
  key: `${layerName}-close-img`,
743
744
  tag: "img",
745
+ className: "dsl-close-img",
744
746
  src: image,
745
747
  style: { width: "100%", height: "100%", objectFit: "contain", display: "block" }
746
748
  }
@@ -750,12 +752,27 @@ function resolveCloseButton(config, layerName, closeTop) {
750
752
  return {
751
753
  key: `${layerName}-close`,
752
754
  tag: "div",
755
+ className: "dsl-close",
753
756
  style,
754
757
  onClick,
755
758
  text: config.icon || "\xD7"
756
759
  };
757
760
  }
758
761
  var BASE_STYLE = { boxSizing: "border-box" };
762
+ var NODE_CLASS = {
763
+ box: "dsl-box",
764
+ flex: "dsl-flex",
765
+ repeat: "dsl-flex",
766
+ tabs: "dsl-tabs",
767
+ image: "dsl-image",
768
+ text: "dsl-text",
769
+ button: "dsl-button",
770
+ countdown: "dsl-flex"
771
+ };
772
+ function nodeClass(type, clickable) {
773
+ const base = `dsl-node ${NODE_CLASS[type] || ""}`.trim();
774
+ return clickable ? `${base} is-clickable` : base;
775
+ }
759
776
  function resolveNode(node, key, layout, context, input, countdowns) {
760
777
  if (!node || typeof node !== "object") return void 0;
761
778
  if (node.visibleWhen && !evaluate(node.visibleWhen, context)) return void 0;
@@ -774,6 +791,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
774
791
  return {
775
792
  key,
776
793
  tag: "div",
794
+ className: nodeClass("box", !!onClick),
777
795
  style: Object.assign({ position: "relative" }, style),
778
796
  onClick,
779
797
  children: resolveChildren(node.children, key, "absolute", context, input, countdowns)
@@ -782,6 +800,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
782
800
  return {
783
801
  key,
784
802
  tag: "div",
803
+ className: nodeClass("flex", !!onClick),
785
804
  style: Object.assign({ display: "flex" }, style),
786
805
  onClick,
787
806
  children: resolveChildren(node.children, key, "flow", context, input, countdowns)
@@ -790,6 +809,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
790
809
  return {
791
810
  key,
792
811
  tag: "div",
812
+ className: nodeClass("repeat", !!onClick),
793
813
  style: Object.assign({ display: "flex" }, style),
794
814
  onClick,
795
815
  children: resolveRepeat(node, key, context, input, countdowns)
@@ -798,6 +818,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
798
818
  return {
799
819
  key,
800
820
  tag: "div",
821
+ className: nodeClass("tabs", false),
801
822
  style: Object.assign({ display: "flex" }, style),
802
823
  children: resolveTabs(node, key, context, input)
803
824
  };
@@ -805,6 +826,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
805
826
  return {
806
827
  key,
807
828
  tag: "img",
829
+ className: nodeClass("image", !!onClick),
808
830
  src: safeImageUrl(interpolate(node.src, context)),
809
831
  style: Object.assign({ display: "block", objectFit: "cover" }, style),
810
832
  onClick
@@ -813,6 +835,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
813
835
  return {
814
836
  key,
815
837
  tag: "div",
838
+ className: nodeClass("text", !!onClick),
816
839
  style: Object.assign({ wordBreak: "break-word" }, style),
817
840
  text: toText(interpolate(node.content, context)),
818
841
  onClick
@@ -821,6 +844,7 @@ function resolveNode(node, key, layout, context, input, countdowns) {
821
844
  return {
822
845
  key,
823
846
  tag: "div",
847
+ className: nodeClass("button", true),
824
848
  style: Object.assign(
825
849
  {
826
850
  display: "flex",
@@ -871,6 +895,7 @@ function resolveTabs(node, key, context, input) {
871
895
  return {
872
896
  key: `${key}-${index}`,
873
897
  tag: "div",
898
+ className: index === active ? "dsl-tab-item is-active" : "dsl-tab-item",
874
899
  style: Object.assign(
875
900
  {
876
901
  display: "flex",
@@ -907,6 +932,7 @@ function resolveCountdown(node, key, style, context, input, countdowns) {
907
932
  return {
908
933
  key,
909
934
  tag: "div",
935
+ className: "dsl-node dsl-text dsl-countdown",
910
936
  style: Object.assign({ wordBreak: "break-word" }, style),
911
937
  text: node.endText || "\u5DF2\u7ED3\u675F"
912
938
  };
@@ -915,6 +941,7 @@ function resolveCountdown(node, key, style, context, input, countdowns) {
915
941
  return {
916
942
  key,
917
943
  tag: "div",
944
+ className: "dsl-node dsl-text dsl-countdown",
918
945
  style: Object.assign({ wordBreak: "break-word" }, style),
919
946
  text: formatParts(parts, node.format)
920
947
  };
@@ -923,6 +950,7 @@ function resolveCountdown(node, key, style, context, input, countdowns) {
923
950
  return {
924
951
  key,
925
952
  tag: "div",
953
+ className: "dsl-node dsl-flex dsl-countdown",
926
954
  style: Object.assign({ display: "flex" }, style),
927
955
  children: resolveChildren(node.children, key, "flow", childContext, input, countdowns)
928
956
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaoxiu/marketing-dsl",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "description": "营销弹窗 DSL 解释器核心,纯逻辑无框架依赖",
6
6
  "license": "MIT",