@repobit/dex-store-elements 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.
Files changed (117) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/README.md +211 -0
  3. package/dist/src/actions/action.button.d.ts +1 -0
  4. package/dist/src/actions/action.button.js +14 -0
  5. package/dist/src/actions/action.button.js.map +1 -0
  6. package/dist/src/actions/action.input.d.ts +1 -0
  7. package/dist/src/actions/action.input.js +37 -0
  8. package/dist/src/actions/action.input.js.map +1 -0
  9. package/dist/src/actions/action.select.d.ts +1 -0
  10. package/dist/src/actions/action.select.js +12 -0
  11. package/dist/src/actions/action.select.js.map +1 -0
  12. package/dist/src/actions/index.d.ts +2 -0
  13. package/dist/src/actions/index.js +30 -0
  14. package/dist/src/actions/index.js.map +1 -0
  15. package/dist/src/actions/utilty.d.ts +9 -0
  16. package/dist/src/actions/utilty.js +88 -0
  17. package/dist/src/actions/utilty.js.map +1 -0
  18. package/dist/src/contexts/context.datalayer.d.ts +9 -0
  19. package/dist/src/contexts/context.datalayer.js +3 -0
  20. package/dist/src/contexts/context.datalayer.js.map +1 -0
  21. package/dist/src/contexts/context.derived.d.ts +12 -0
  22. package/dist/src/contexts/context.derived.js +3 -0
  23. package/dist/src/contexts/context.derived.js.map +1 -0
  24. package/dist/src/contexts/context.event.d.ts +5 -0
  25. package/dist/src/contexts/context.event.js +3 -0
  26. package/dist/src/contexts/context.event.js.map +1 -0
  27. package/dist/src/contexts/context.option.d.ts +5 -0
  28. package/dist/src/contexts/context.option.js +3 -0
  29. package/dist/src/contexts/context.option.js.map +1 -0
  30. package/dist/src/contexts/context.product.d.ts +5 -0
  31. package/dist/src/contexts/context.product.js +3 -0
  32. package/dist/src/contexts/context.product.js.map +1 -0
  33. package/dist/src/contexts/context.state.d.ts +28 -0
  34. package/dist/src/contexts/context.state.js +3 -0
  35. package/dist/src/contexts/context.state.js.map +1 -0
  36. package/dist/src/contexts/context.store.d.ts +5 -0
  37. package/dist/src/contexts/context.store.js +3 -0
  38. package/dist/src/contexts/context.store.js.map +1 -0
  39. package/dist/src/dsl/compilers/array/compiler.d.ts +1 -0
  40. package/dist/src/dsl/compilers/array/compiler.js +30 -0
  41. package/dist/src/dsl/compilers/array/compiler.js.map +1 -0
  42. package/dist/src/dsl/compilers/boolean/compiler.d.ts +7 -0
  43. package/dist/src/dsl/compilers/boolean/compiler.js +53 -0
  44. package/dist/src/dsl/compilers/boolean/compiler.js.map +1 -0
  45. package/dist/src/dsl/compilers/enum/compiler.d.ts +7 -0
  46. package/dist/src/dsl/compilers/enum/compiler.js +16 -0
  47. package/dist/src/dsl/compilers/enum/compiler.js.map +1 -0
  48. package/dist/src/dsl/compilers/index.d.ts +12 -0
  49. package/dist/src/dsl/compilers/index.js +9 -0
  50. package/dist/src/dsl/compilers/index.js.map +1 -0
  51. package/dist/src/dsl/utilty.d.ts +6 -0
  52. package/dist/src/dsl/utilty.js +32 -0
  53. package/dist/src/dsl/utilty.js.map +1 -0
  54. package/dist/src/events/events.d.ts +60 -0
  55. package/dist/src/events/events.js +56 -0
  56. package/dist/src/events/events.js.map +1 -0
  57. package/dist/src/index.d.ts +9 -0
  58. package/dist/src/index.js +10 -0
  59. package/dist/src/index.js.map +1 -0
  60. package/dist/src/nodes/node.context.d.ts +3 -0
  61. package/dist/src/nodes/node.context.js +15 -0
  62. package/dist/src/nodes/node.context.js.map +1 -0
  63. package/dist/src/nodes/node.option.d.ts +32 -0
  64. package/dist/src/nodes/node.option.js +247 -0
  65. package/dist/src/nodes/node.option.js.map +1 -0
  66. package/dist/src/nodes/node.product.d.ts +14 -0
  67. package/dist/src/nodes/node.product.js +99 -0
  68. package/dist/src/nodes/node.product.js.map +1 -0
  69. package/dist/src/nodes/node.root.d.ts +16 -0
  70. package/dist/src/nodes/node.root.js +53 -0
  71. package/dist/src/nodes/node.root.js.map +1 -0
  72. package/dist/src/nodes/node.state.d.ts +112 -0
  73. package/dist/src/nodes/node.state.js +742 -0
  74. package/dist/src/nodes/node.state.js.map +1 -0
  75. package/dist/src/renders/attributes/buyLink.d.ts +2 -0
  76. package/dist/src/renders/attributes/buyLink.js +18 -0
  77. package/dist/src/renders/attributes/buyLink.js.map +1 -0
  78. package/dist/src/renders/attributes/devices.d.ts +2 -0
  79. package/dist/src/renders/attributes/devices.js +32 -0
  80. package/dist/src/renders/attributes/devices.js.map +1 -0
  81. package/dist/src/renders/attributes/discount.d.ts +2 -0
  82. package/dist/src/renders/attributes/discount.js +96 -0
  83. package/dist/src/renders/attributes/discount.js.map +1 -0
  84. package/dist/src/renders/attributes/hide.d.ts +2 -0
  85. package/dist/src/renders/attributes/hide.js +33 -0
  86. package/dist/src/renders/attributes/hide.js.map +1 -0
  87. package/dist/src/renders/attributes/index.d.ts +3 -0
  88. package/dist/src/renders/attributes/index.js +24 -0
  89. package/dist/src/renders/attributes/index.js.map +1 -0
  90. package/dist/src/renders/attributes/price.d.ts +2 -0
  91. package/dist/src/renders/attributes/price.js +96 -0
  92. package/dist/src/renders/attributes/price.js.map +1 -0
  93. package/dist/src/renders/attributes/subscription.d.ts +2 -0
  94. package/dist/src/renders/attributes/subscription.js +34 -0
  95. package/dist/src/renders/attributes/subscription.js.map +1 -0
  96. package/dist/src/renders/attributes/trialLink.d.ts +2 -0
  97. package/dist/src/renders/attributes/trialLink.js +13 -0
  98. package/dist/src/renders/attributes/trialLink.js.map +1 -0
  99. package/dist/src/renders/context.d.ts +11 -0
  100. package/dist/src/renders/context.js +88 -0
  101. package/dist/src/renders/context.js.map +1 -0
  102. package/dist/src/renders/format.d.ts +2 -0
  103. package/dist/src/renders/format.js +21 -0
  104. package/dist/src/renders/format.js.map +1 -0
  105. package/dist/src/renders/index.d.ts +2 -0
  106. package/dist/src/renders/index.js +30 -0
  107. package/dist/src/renders/index.js.map +1 -0
  108. package/dist/src/renders/observe.d.ts +4 -0
  109. package/dist/src/renders/observe.js +30 -0
  110. package/dist/src/renders/observe.js.map +1 -0
  111. package/dist/src/renders/utility.d.ts +28 -0
  112. package/dist/src/renders/utility.js +132 -0
  113. package/dist/src/renders/utility.js.map +1 -0
  114. package/dist/src/templating/eta.d.ts +3 -0
  115. package/dist/src/templating/eta.js +9 -0
  116. package/dist/src/templating/eta.js.map +1 -0
  117. package/package.json +64 -0
@@ -0,0 +1,5 @@
1
+ import type { Product } from '@repobit/dex-store';
2
+ export type productContextType = Product | null | undefined;
3
+ export declare const productContext: {
4
+ __context__: productContextType;
5
+ };
@@ -0,0 +1,3 @@
1
+ import { createContext } from '@lit/context';
2
+ export const productContext = createContext(Symbol('product'));
3
+ //# sourceMappingURL=context.product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.product.js","sourceRoot":"","sources":["../../../src/contexts/context.product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAqB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ export type MinMax = {
2
+ min: {
3
+ value: number;
4
+ fmt: string;
5
+ };
6
+ max: {
7
+ value: number;
8
+ fmt: string;
9
+ };
10
+ };
11
+ type Price = MinMax & {
12
+ monthly: MinMax;
13
+ };
14
+ type Discount = MinMax & {
15
+ monthly: MinMax;
16
+ percentage: MinMax & {
17
+ monthly: MinMax;
18
+ };
19
+ };
20
+ export type stateContextType = {
21
+ price: Price;
22
+ discountedPrice: Price;
23
+ discount: Discount;
24
+ };
25
+ export declare const stateContext: {
26
+ __context__: stateContextType;
27
+ };
28
+ export {};
@@ -0,0 +1,3 @@
1
+ import { createContext } from '@lit/context';
2
+ export const stateContext = createContext(Symbol('state'));
3
+ //# sourceMappingURL=context.state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.state.js","sourceRoot":"","sources":["../../../src/contexts/context.state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAuB7C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAmB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Store } from '@repobit/dex-store';
2
+ export type storeContextType = Store | undefined;
3
+ export declare const storeContext: {
4
+ __context__: storeContextType;
5
+ };
@@ -0,0 +1,3 @@
1
+ import { createContext } from '@lit/context';
2
+ export const storeContext = createContext(Symbol('store'));
3
+ //# sourceMappingURL=context.store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.store.js","sourceRoot":"","sources":["../../../src/contexts/context.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAmB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const compiler: (raw: string) => number[] | undefined;
@@ -0,0 +1,30 @@
1
+ import { split } from "../../../dsl/utilty.js";
2
+ // "2,3,4,5" -> [2,3,4,5]
3
+ // "1..4,8,10..7" -> [1,2,3,4,8,10,9,8,7]
4
+ // "" -> undefined
5
+ export const compiler = (raw) => {
6
+ const s = raw.trim();
7
+ if (s === "")
8
+ return undefined;
9
+ const out = [];
10
+ const intRe = /^-?\d+$/;
11
+ const rangeRe = /^(-?\d+)\s*\.\.\s*(-?\d+)$/;
12
+ for (const part of split(s, ",")) {
13
+ const m = part.match(rangeRe);
14
+ if (m) {
15
+ const a = parseInt(m[1], 10);
16
+ const b = parseInt(m[2], 10);
17
+ const step = a <= b ? 1 : -1;
18
+ for (let v = a; v !== b + step; v += step)
19
+ out.push(v);
20
+ continue;
21
+ }
22
+ if (intRe.test(part)) {
23
+ out.push(parseInt(part, 10));
24
+ continue;
25
+ }
26
+ throw new Error(`Invalid number token: "${part}"`);
27
+ }
28
+ return out;
29
+ };
30
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../../../src/dsl/compilers/array/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,mCAAmC;AACnC,8CAA8C;AAC9C,mCAAmC;AACnC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAwB,EAAE;IAC5D,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACrB,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IAE/B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,KAAK,GAAK,SAAS,CAAC;IAC1B,MAAM,OAAO,GAAG,4BAA4B,CAAC;IAE7C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,CAAC;YACN,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,IAAI;gBAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACvD,SAAS;QACX,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YAC7B,SAAS;QACX,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,GAAG,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Ctx } from "../../../dsl/utilty.js";
2
+ type Params = {
3
+ expr: string;
4
+ ctx: Ctx;
5
+ };
6
+ export declare const compiler: ({ expr, ctx }: Params) => boolean;
7
+ export {};
@@ -0,0 +1,53 @@
1
+ import eta from "../../../templating/eta.js";
2
+ // Very lightweight preflight checks so we can rely on Eta/JS
3
+ // for actual expression evaluation while still catching a few
4
+ // DSL-specific pitfalls we used to guard against.
5
+ function preflight(expr) {
6
+ // 1) Disallow chained comparisons like: a < b < c
7
+ // Match two comparison operators with no logical op (&&, ||) between
8
+ const chainedCmp = /(<=|>=|<|>)\s*[^&|]+(<=|>=|<|>)/;
9
+ if (chainedCmp.test(expr)) {
10
+ throw new Error("Chained comparisons are not allowed");
11
+ }
12
+ // 2) Basic parentheses balance check to surface a clearer error
13
+ let depth = 0;
14
+ for (const ch of expr) {
15
+ if (ch === "(")
16
+ depth++;
17
+ else if (ch === ")") {
18
+ depth--;
19
+ if (depth < 0) {
20
+ // extra closing paren
21
+ throw new Error("Unexpected ')'");
22
+ }
23
+ }
24
+ }
25
+ if (depth > 0) {
26
+ throw new Error("Expected ')' ");
27
+ }
28
+ }
29
+ export const compiler = ({ expr, ctx }) => {
30
+ preflight(expr);
31
+ // Normalize equality to strict semantics to match legacy DSL behavior
32
+ // - '==' -> '==='
33
+ // - '!=' -> '!=='
34
+ // Note: This is a simple text replacement and does not account for quoted strings,
35
+ // but our DSL usage does not place operators inside string literals.
36
+ const normalized = expr
37
+ .replace(/!=(?!=)/g, '!==')
38
+ .replace(/(?<![=!])==(?![=])/g, '===');
39
+ // Build a tiny Eta template that coerces the expression to boolean.
40
+ const tpl = `{{= !!(${normalized}) }}`;
41
+ try {
42
+ const fn = eta.compile(tpl);
43
+ const out = eta.render(fn, ctx);
44
+ // Eta returns a string; normalize to boolean
45
+ return String(out).trim() === "true";
46
+ }
47
+ catch (e) {
48
+ // Normalize error to a generic syntax error message used in tests
49
+ const msg = e instanceof Error ? e.message : String(e);
50
+ throw new Error(`Unexpected expression error: ${msg}`);
51
+ }
52
+ };
53
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../../../src/dsl/compilers/boolean/compiler.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAOnC,6DAA6D;AAC7D,8DAA8D;AAC9D,kDAAkD;AAClD,SAAS,SAAS,CAAC,IAAY;IAC7B,kDAAkD;IAClD,qEAAqE;IACrE,MAAM,UAAU,GAAG,iCAAiC,CAAC;IACrD,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,gEAAgE;IAChE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACtB,IAAI,EAAE,KAAK,GAAG;YAAE,KAAK,EAAE,CAAC;aACnB,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACpB,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,sBAAsB;gBACtB,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAU,EAAE,EAAE;IAChD,SAAS,CAAC,IAAI,CAAC,CAAC;IAEhB,sEAAsE;IACtE,mBAAmB;IACnB,mBAAmB;IACnB,mFAAmF;IACnF,qEAAqE;IACrE,MAAM,UAAU,GAAG,IAAI;SACpB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,OAAO,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;IAEzC,oEAAoE;IACpE,MAAM,GAAG,GAAG,UAAU,UAAU,MAAM,CAAC;IAEvC,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAChC,6CAA6C;QAC7C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC;IACvC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,kEAAkE;QAClE,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,EAAE,CAAC,CAAC;IACzD,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ type Params<Allowed extends string> = {
2
+ expr: string;
3
+ allowed: readonly Allowed[];
4
+ isAvailable: (variant: Allowed) => boolean;
5
+ };
6
+ export declare const compiler: <Allowed extends string>({ expr, allowed, isAvailable }: Params<Allowed>) => Allowed | undefined;
7
+ export {};
@@ -0,0 +1,16 @@
1
+ import { split } from "../../../dsl/utilty.js";
2
+ export const compiler = ({ expr, allowed, isAvailable }) => {
3
+ const tokens = split(expr, "||");
4
+ // validate tokens early
5
+ for (const t of tokens) {
6
+ if (!allowed.includes(t)) {
7
+ console.warn(`[store] Unknown token "${t}". Allowed: ${allowed.join(", ")}`);
8
+ }
9
+ }
10
+ for (const t of tokens) {
11
+ if (allowed.includes(t) && isAvailable(t))
12
+ return t;
13
+ }
14
+ return undefined;
15
+ };
16
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../../../src/dsl/compilers/enum/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAQrC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAyB,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAmB,EAAuB,EAAE;IACvH,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAAc,CAAC;IAC9C,wBAAwB;IACxB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,eAAe,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ export declare const Compiler: {
2
+ readonly boolean: ({ expr, ctx }: {
3
+ expr: string;
4
+ ctx: import("../utilty.js").Ctx;
5
+ }) => boolean;
6
+ readonly enum: <Allowed extends string>({ expr, allowed, isAvailable }: {
7
+ expr: string;
8
+ allowed: readonly Allowed[];
9
+ isAvailable: (variant: Allowed) => boolean;
10
+ }) => Allowed | undefined;
11
+ readonly array: (raw: string) => number[] | undefined;
12
+ };
@@ -0,0 +1,9 @@
1
+ import { compiler as array } from "./array/compiler.js";
2
+ import { compiler as boolean } from "./boolean/compiler.js";
3
+ import { compiler as enumeration } from "./enum/compiler.js";
4
+ export const Compiler = {
5
+ boolean,
6
+ enum: enumeration,
7
+ array
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dsl/compilers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE1D,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO;IACP,IAAI,EAAE,WAAW;IACjB,KAAK;CACG,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type Ctx = Record<string, unknown>;
2
+ export declare const isRecord: (v: unknown) => v is Record<string, unknown>;
3
+ export declare const getPath: <T = unknown>(ctx: unknown, path: string) => T | undefined;
4
+ export declare const isTruthy: (v: unknown) => boolean;
5
+ export declare const coerceLiteral: (s: string) => string | number | boolean | null | undefined;
6
+ export declare const split: (raw: string, sep: string) => string[];
@@ -0,0 +1,32 @@
1
+ export const isRecord = (v) => v !== null && typeof v === "object";
2
+ export const getPath = (ctx, path) => {
3
+ let acc = ctx;
4
+ for (const key of path.split(".")) {
5
+ if (!isRecord(acc) || !(key in acc))
6
+ return undefined;
7
+ acc = acc[key];
8
+ }
9
+ return acc;
10
+ };
11
+ export const isTruthy = (v) => v !== "" && v !== false && v !== null && v !== undefined;
12
+ // Parse quoted literal or pass-through
13
+ export const coerceLiteral = (s) => {
14
+ if (/^-?\d+(\.\d+)?$/.test(s))
15
+ return Number(s);
16
+ if (s === "true")
17
+ return true;
18
+ if (s === "false")
19
+ return false;
20
+ if (s === "null")
21
+ return null;
22
+ if (s === "undefined")
23
+ return undefined;
24
+ const q = s[0], end = s[s.length - 1];
25
+ if ((q === "'" && end === "'") || (q === '"' && end === '"'))
26
+ return s.slice(1, -1);
27
+ return s;
28
+ };
29
+ // Split by token, trim, drop empties
30
+ export const split = (raw, sep) => raw.split(sep).map(s => s.trim())
31
+ .filter(Boolean);
32
+ //# sourceMappingURL=utilty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilty.js","sourceRoot":"","sources":["../../../src/dsl/utilty.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAgC,EAAE,CACnE,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC;AAEtC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAc,GAAY,EAAE,IAAY,EAAiB,EAAE;IAChF,IAAI,GAAG,GAAY,GAAG,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;YAAE,OAAO,SAAS,CAAC;QACtD,GAAG,GAAG,GAAG,CAAC,GAAuB,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,GAAoB,CAAC;AAC9B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAE,EAAE,CACrC,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC;AAE3D,uCAAuC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAE,EAAE;IACzC,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IAChD,IAAI,CAAC,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAC9B,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,CAAC,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAC9B,IAAI,CAAC,KAAK,WAAW;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtC,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpF,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,qCAAqC;AACrC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE,CAChD,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;KAC9B,MAAM,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { ProductOption } from "@repobit/dex-store";
2
+ export type UpdateByDelta = {
3
+ type: "devices" | "subscription";
4
+ delta: number | "next" | "prev";
5
+ min?: number;
6
+ max?: number;
7
+ /**
8
+ * If true, treat `delta` as the new absolute value
9
+ * instead of adding/subtracting it.
10
+ */
11
+ useAsValue?: boolean;
12
+ /**
13
+ * Optional identifier of the action source element (data-store-id)
14
+ */
15
+ storeId?: string;
16
+ };
17
+ export type Action = {
18
+ id?: string;
19
+ campaign?: string;
20
+ bundle?: boolean;
21
+ devices?: number;
22
+ subscription?: number;
23
+ /**
24
+ * Optional identifier of the action source element (data-store-id)
25
+ */
26
+ storeId?: string;
27
+ };
28
+ export type CollectUpdateByDelta = {
29
+ name: symbol | string;
30
+ update: UpdateByDelta | null;
31
+ };
32
+ export type CollectAction = {
33
+ name: symbol | string;
34
+ action: Action | null;
35
+ };
36
+ export type CollectOption = {
37
+ name: symbol | string;
38
+ options: Promise<ProductOption[]> | null;
39
+ };
40
+ export declare class UpdateByDeltaEvent extends CustomEvent<UpdateByDelta> {
41
+ static readonly eventName = "store-update-delta";
42
+ constructor(detail: UpdateByDelta);
43
+ }
44
+ export declare class ActionEvent extends CustomEvent<Action> {
45
+ static readonly eventName = "store-set-action";
46
+ constructor(detail: Action);
47
+ }
48
+ export declare class CollectActionEvent extends CustomEvent<CollectAction> {
49
+ static readonly eventName = "store-collect-action";
50
+ constructor(detail: CollectAction);
51
+ }
52
+ export declare class CollectUpdateByDeltaEvent extends CustomEvent<CollectUpdateByDelta> {
53
+ static readonly eventName = "store-collect-update-by-delta";
54
+ constructor(detail: CollectUpdateByDelta);
55
+ }
56
+ export declare class CollectOptionEvent extends CustomEvent<CollectOption> {
57
+ static readonly eventName = "store-collect-option";
58
+ constructor(detail: CollectOption);
59
+ }
60
+ export type EventType = UpdateByDeltaEvent | ActionEvent;
@@ -0,0 +1,56 @@
1
+ export class UpdateByDeltaEvent extends CustomEvent {
2
+ static { this.eventName = "store-update-delta"; }
3
+ constructor(detail) {
4
+ super(UpdateByDeltaEvent.eventName, {
5
+ detail,
6
+ bubbles: true,
7
+ composed: true,
8
+ cancelable: true
9
+ });
10
+ }
11
+ }
12
+ export class ActionEvent extends CustomEvent {
13
+ static { this.eventName = "store-set-action"; }
14
+ constructor(detail) {
15
+ super(ActionEvent.eventName, {
16
+ detail,
17
+ bubbles: true,
18
+ composed: true,
19
+ cancelable: true
20
+ });
21
+ }
22
+ }
23
+ export class CollectActionEvent extends CustomEvent {
24
+ static { this.eventName = "store-collect-action"; }
25
+ constructor(detail) {
26
+ super(CollectActionEvent.eventName, {
27
+ detail,
28
+ bubbles: true,
29
+ composed: true,
30
+ cancelable: true
31
+ });
32
+ }
33
+ }
34
+ export class CollectUpdateByDeltaEvent extends CustomEvent {
35
+ static { this.eventName = "store-collect-update-by-delta"; }
36
+ constructor(detail) {
37
+ super(CollectUpdateByDeltaEvent.eventName, {
38
+ detail,
39
+ bubbles: true,
40
+ composed: true,
41
+ cancelable: true
42
+ });
43
+ }
44
+ }
45
+ export class CollectOptionEvent extends CustomEvent {
46
+ static { this.eventName = "store-collect-option"; }
47
+ constructor(detail) {
48
+ super(CollectOptionEvent.eventName, {
49
+ detail,
50
+ bubbles: true,
51
+ composed: true,
52
+ cancelable: true
53
+ });
54
+ }
55
+ }
56
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/events/events.ts"],"names":[],"mappings":"AA6CA,MAAM,OAAO,kBAAmB,SAAQ,WAA0B;aAChD,cAAS,GAAG,oBAAoB,CAAC;IAEjD,YAAY,MAAqB;QAC/B,KAAK,CAAC,kBAAkB,CAAC,SAAS,EAAE;YAClC,MAAM;YACN,OAAO,EAAK,IAAI;YAChB,QAAQ,EAAI,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;;AAGH,MAAM,OAAO,WAAY,SAAQ,WAAmB;aAClC,cAAS,GAAG,kBAAkB,CAAC;IAE/C,YAAY,MAAc;QACxB,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE;YAC3B,MAAM;YACN,OAAO,EAAK,IAAI;YAChB,QAAQ,EAAI,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;;AAGH,MAAM,OAAO,kBAAmB,SAAQ,WAA0B;aAChD,cAAS,GAAG,sBAAsB,CAAC;IAEnD,YAAY,MAAqB;QAC/B,KAAK,CAAC,kBAAkB,CAAC,SAAS,EAAE;YAClC,MAAM;YACN,OAAO,EAAK,IAAI;YAChB,QAAQ,EAAI,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;;AAGH,MAAM,OAAO,yBAA0B,SAAQ,WAAiC;aAC9D,cAAS,GAAG,+BAA+B,CAAC;IAE5D,YAAY,MAA4B;QACtC,KAAK,CAAC,yBAAyB,CAAC,SAAS,EAAE;YACzC,MAAM;YACN,OAAO,EAAK,IAAI;YAChB,QAAQ,EAAI,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;;AAGH,MAAM,OAAO,kBAAmB,SAAQ,WAA0B;aAChD,cAAS,GAAG,sBAAsB,CAAC;IAEnD,YAAY,MAAqB;QAC/B,KAAK,CAAC,kBAAkB,CAAC,SAAS,EAAE;YAClC,MAAM;YACN,OAAO,EAAK,IAAI;YAChB,QAAQ,EAAI,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { initActionNodes } from "./actions/index.js";
2
+ import { ContextNode } from "./nodes/node.context.js";
3
+ import { OptionNode } from "./nodes/node.option.js";
4
+ import { ProductNode } from "./nodes/node.product.js";
5
+ import { RootNode } from "./nodes/node.root.js";
6
+ import { StateNode } from "./nodes/node.state.js";
7
+ import './types/dom-dataset.d.ts';
8
+ import './types/global-events.d.ts';
9
+ export { ContextNode, initActionNodes, OptionNode, ProductNode, RootNode, StateNode };
@@ -0,0 +1,10 @@
1
+ import { initActionNodes } from "./actions/index.js";
2
+ import { ContextNode } from "./nodes/node.context.js";
3
+ import { OptionNode } from "./nodes/node.option.js";
4
+ import { ProductNode } from "./nodes/node.product.js";
5
+ import { RootNode } from "./nodes/node.root.js";
6
+ import { StateNode } from "./nodes/node.state.js";
7
+ import './types/dom-dataset.d.ts';
8
+ import './types/global-events.d.ts';
9
+ export { ContextNode, initActionNodes, OptionNode, ProductNode, RootNode, StateNode };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,0BAA0B,CAAC;AAClC,OAAO,4BAA4B,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { StateNode } from "./node.state.js";
2
+ export declare class ContextNode extends StateNode {
3
+ }
@@ -0,0 +1,15 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { customElement } from "lit/decorators.js";
8
+ import { StateNode } from "./node.state.js";
9
+ let ContextNode = class ContextNode extends StateNode {
10
+ };
11
+ ContextNode = __decorate([
12
+ customElement('bd-context')
13
+ ], ContextNode);
14
+ export { ContextNode };
15
+ //# sourceMappingURL=node.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.context.js","sourceRoot":"","sources":["../../../src/nodes/node.context.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGlC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,SAAS;CAAG,CAAA;AAAhC,WAAW;IADvB,aAAa,CAAC,YAAY,CAAC;GACf,WAAW,CAAqB"}
@@ -0,0 +1,32 @@
1
+ import { dataLayerContextType, dataLayerPayload } from "../contexts/context.datalayer.js";
2
+ import { optionContextType } from "../contexts/context.option.js";
3
+ import { productContextType } from "../contexts/context.product.js";
4
+ import { EventType } from "../events/events.js";
5
+ import { ProductBundleOption, ProductOption } from "@repobit/dex-store";
6
+ import { StateNode } from "./node.state.js";
7
+ export declare class OptionNode extends StateNode {
8
+ _optionContext?: optionContextType;
9
+ _dataLayer?: dataLayerContextType;
10
+ product?: productContextType;
11
+ bundle: ProductBundleOption[];
12
+ devices?: number;
13
+ subscription?: number;
14
+ dataLayerEvent?: dataLayerPayload["event"];
15
+ _option: ProductOption | null | undefined;
16
+ private _sentDataLayer;
17
+ private _pendingDevicesFromEvent;
18
+ private _pendingSubscriptionFromEvent;
19
+ get option(): ProductOption | null | undefined;
20
+ private _changeOptionEvent;
21
+ private _fireDataLayerTask;
22
+ private _loadOptionByAttributes;
23
+ private _etaOptionRenderTask;
24
+ protected shouldRunEtaStateRender(): boolean;
25
+ connectedCallback(): void;
26
+ disconnectedCallback(): void;
27
+ protected getUpdateComplete(): Promise<boolean>;
28
+ protected _eventChange(e: EventType): void;
29
+ private _applyDeltaUpdate;
30
+ private __applyAction;
31
+ private __applyBundle;
32
+ }