@rippling/pebble-sdui-mobile 0.2.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 (46) hide show
  1. package/dist/core/action-utils.cjs +2 -0
  2. package/dist/core/action-utils.cjs.map +1 -0
  3. package/dist/core/action-utils.d.ts +48 -0
  4. package/dist/core/action-utils.js +8 -0
  5. package/dist/core/action-utils.js.map +1 -0
  6. package/dist/core/component-utils.cjs +2 -0
  7. package/dist/core/component-utils.cjs.map +1 -0
  8. package/dist/core/component-utils.d.ts +77 -0
  9. package/dist/core/component-utils.js +11 -0
  10. package/dist/core/component-utils.js.map +1 -0
  11. package/dist/core/conditions.cjs +2 -0
  12. package/dist/core/conditions.cjs.map +1 -0
  13. package/dist/core/conditions.d.ts +70 -0
  14. package/dist/core/conditions.js +69 -0
  15. package/dist/core/conditions.js.map +1 -0
  16. package/dist/core/elements.cjs +2 -0
  17. package/dist/core/elements.cjs.map +1 -0
  18. package/dist/core/elements.d.ts +24 -0
  19. package/dist/core/elements.js +2 -0
  20. package/dist/core/elements.js.map +1 -0
  21. package/dist/core/expressions.cjs +2 -0
  22. package/dist/core/expressions.cjs.map +1 -0
  23. package/dist/core/expressions.d.ts +81 -0
  24. package/dist/core/expressions.js +2 -0
  25. package/dist/core/expressions.js.map +1 -0
  26. package/dist/core/index.cjs +2 -0
  27. package/dist/core/index.cjs.map +1 -0
  28. package/dist/core/index.d.ts +14 -0
  29. package/dist/core/index.js +25 -0
  30. package/dist/core/index.js.map +1 -0
  31. package/dist/core/paths.cjs +2 -0
  32. package/dist/core/paths.cjs.map +1 -0
  33. package/dist/core/paths.d.ts +27 -0
  34. package/dist/core/paths.js +2 -0
  35. package/dist/core/paths.js.map +1 -0
  36. package/dist/core/spec.cjs +2 -0
  37. package/dist/core/spec.cjs.map +1 -0
  38. package/dist/core/spec.d.ts +56 -0
  39. package/dist/core/spec.js +105 -0
  40. package/dist/core/spec.js.map +1 -0
  41. package/dist/index.cjs +2 -0
  42. package/dist/index.cjs.map +1 -0
  43. package/dist/index.d.ts +7 -0
  44. package/dist/index.js +24 -0
  45. package/dist/index.js.map +1 -0
  46. package/package.json +40 -0
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(f,c,r){const e={action:f};return c&&(e.params=c),r&&(r.confirm&&(e.confirm=r.confirm),r.onSuccess&&(e.onSuccess=r.onSuccess),r.onError&&(e.onError=r.onError),r.preventDefault&&(e.preventDefault=r.preventDefault)),e}exports.buildAction=n;
2
+ //# sourceMappingURL=action-utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-utils.cjs","sources":["../../../sdui-core/src/action-utils.ts"],"sourcesContent":["/**\n * Action Binding Types\n *\n * Generic types and helpers used by generated action creators.\n * Mirrors Python SDK's actions.py.\n */\n\ndeclare const __actionBrand: unique symbol;\n\n/**\n * Opaque branded type returned by action creators.\n * Cannot be constructed manually — must go through a generated action creator.\n */\nexport interface ActionBinding {\n readonly [__actionBrand]: true;\n}\n\n/** Confirmation dialog before executing an action. */\nexport interface ActionConfirm {\n title: string;\n message: string;\n confirmLabel?: string;\n cancelLabel?: string;\n variant?: 'default' | 'danger';\n}\n\n/** Success handler after action execution. */\nexport type ActionOnSuccess =\n | { navigate: string }\n | { set: Record<string, unknown> }\n | { action: string };\n\n/** Error handler after action execution. */\nexport type ActionOnError =\n | { set: Record<string, unknown> }\n | { action: string };\n\n/** Options shared by all action bindings. */\nexport interface ActionOptions {\n confirm?: ActionConfirm;\n onSuccess?: ActionOnSuccess;\n onError?: ActionOnError;\n preventDefault?: boolean;\n}\n\n/**\n * Creates an action binding object. Used by generated action creators.\n */\nexport function buildAction(\n action: string,\n params?: Record<string, unknown>,\n options?: ActionOptions\n): ActionBinding {\n const binding: Record<string, unknown> = { action };\n if (params) binding.params = params;\n if (options) {\n if (options.confirm) binding.confirm = options.confirm;\n if (options.onSuccess) binding.onSuccess = options.onSuccess;\n if (options.onError) binding.onError = options.onError;\n if (options.preventDefault) binding.preventDefault = options.preventDefault;\n }\n return binding as unknown as ActionBinding;\n}\n"],"names":["buildAction","action","params","options","binding"],"mappings":"gFAgDO,SAASA,EACdC,EACAC,EACAC,EACe,CACf,MAAMC,EAAmC,CAAE,OAAAH,CAAA,EAC3C,OAAIC,MAAgB,OAASA,GACzBC,IACEA,EAAQ,UAASC,EAAQ,QAAUD,EAAQ,SAC3CA,EAAQ,YAAWC,EAAQ,UAAYD,EAAQ,WAC/CA,EAAQ,UAASC,EAAQ,QAAUD,EAAQ,SAC3CA,EAAQ,iBAAgBC,EAAQ,eAAiBD,EAAQ,iBAExDC,CACT"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Action Binding Types
3
+ *
4
+ * Generic types and helpers used by generated action creators.
5
+ * Mirrors Python SDK's actions.py.
6
+ */
7
+ declare const __actionBrand: unique symbol;
8
+ /**
9
+ * Opaque branded type returned by action creators.
10
+ * Cannot be constructed manually — must go through a generated action creator.
11
+ */
12
+ export interface ActionBinding {
13
+ readonly [__actionBrand]: true;
14
+ }
15
+ /** Confirmation dialog before executing an action. */
16
+ export interface ActionConfirm {
17
+ title: string;
18
+ message: string;
19
+ confirmLabel?: string;
20
+ cancelLabel?: string;
21
+ variant?: 'default' | 'danger';
22
+ }
23
+ /** Success handler after action execution. */
24
+ export type ActionOnSuccess = {
25
+ navigate: string;
26
+ } | {
27
+ set: Record<string, unknown>;
28
+ } | {
29
+ action: string;
30
+ };
31
+ /** Error handler after action execution. */
32
+ export type ActionOnError = {
33
+ set: Record<string, unknown>;
34
+ } | {
35
+ action: string;
36
+ };
37
+ /** Options shared by all action bindings. */
38
+ export interface ActionOptions {
39
+ confirm?: ActionConfirm;
40
+ onSuccess?: ActionOnSuccess;
41
+ onError?: ActionOnError;
42
+ preventDefault?: boolean;
43
+ }
44
+ /**
45
+ * Creates an action binding object. Used by generated action creators.
46
+ */
47
+ export declare function buildAction(action: string, params?: Record<string, unknown>, options?: ActionOptions): ActionBinding;
48
+ export {};
@@ -0,0 +1,8 @@
1
+ function n(c, f, r) {
2
+ const e = { action: c };
3
+ return f && (e.params = f), r && (r.confirm && (e.confirm = r.confirm), r.onSuccess && (e.onSuccess = r.onSuccess), r.onError && (e.onError = r.onError), r.preventDefault && (e.preventDefault = r.preventDefault)), e;
4
+ }
5
+ export {
6
+ n as buildAction
7
+ };
8
+ //# sourceMappingURL=action-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-utils.js","sources":["../../../sdui-core/src/action-utils.ts"],"sourcesContent":["/**\n * Action Binding Types\n *\n * Generic types and helpers used by generated action creators.\n * Mirrors Python SDK's actions.py.\n */\n\ndeclare const __actionBrand: unique symbol;\n\n/**\n * Opaque branded type returned by action creators.\n * Cannot be constructed manually — must go through a generated action creator.\n */\nexport interface ActionBinding {\n readonly [__actionBrand]: true;\n}\n\n/** Confirmation dialog before executing an action. */\nexport interface ActionConfirm {\n title: string;\n message: string;\n confirmLabel?: string;\n cancelLabel?: string;\n variant?: 'default' | 'danger';\n}\n\n/** Success handler after action execution. */\nexport type ActionOnSuccess =\n | { navigate: string }\n | { set: Record<string, unknown> }\n | { action: string };\n\n/** Error handler after action execution. */\nexport type ActionOnError =\n | { set: Record<string, unknown> }\n | { action: string };\n\n/** Options shared by all action bindings. */\nexport interface ActionOptions {\n confirm?: ActionConfirm;\n onSuccess?: ActionOnSuccess;\n onError?: ActionOnError;\n preventDefault?: boolean;\n}\n\n/**\n * Creates an action binding object. Used by generated action creators.\n */\nexport function buildAction(\n action: string,\n params?: Record<string, unknown>,\n options?: ActionOptions\n): ActionBinding {\n const binding: Record<string, unknown> = { action };\n if (params) binding.params = params;\n if (options) {\n if (options.confirm) binding.confirm = options.confirm;\n if (options.onSuccess) binding.onSuccess = options.onSuccess;\n if (options.onError) binding.onError = options.onError;\n if (options.preventDefault) binding.preventDefault = options.preventDefault;\n }\n return binding as unknown as ActionBinding;\n}\n"],"names":["buildAction","action","params","options","binding"],"mappings":"AAgDO,SAASA,EACdC,GACAC,GACAC,GACe;AACf,QAAMC,IAAmC,EAAE,QAAAH,EAAA;AAC3C,SAAIC,QAAgB,SAASA,IACzBC,MACEA,EAAQ,YAASC,EAAQ,UAAUD,EAAQ,UAC3CA,EAAQ,cAAWC,EAAQ,YAAYD,EAAQ,YAC/CA,EAAQ,YAASC,EAAQ,UAAUD,EAAQ,UAC3CA,EAAQ,mBAAgBC,EAAQ,iBAAiBD,EAAQ,kBAExDC;AACT;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(d,e){const o={type:d,props:e.props??{}};return e.id!==void 0&&(o.id=e.id),e.visible!==void 0&&(o.visible=e.visible),e.on&&(o.on=e.on),e.children&&(o.children=e.children),e.repeat&&(o.repeat=e.repeat),o}exports.buildNode=i;
2
+ //# sourceMappingURL=component-utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-utils.cjs","sources":["../../../sdui-core/src/component-utils.ts"],"sourcesContent":["/**\n * Component Utilities\n *\n * Generic types and helpers used by generated component builders.\n * Mirrors Python SDK's elements.py Element base class.\n */\n\nimport type { WrapWithPropValue } from './expressions';\nimport type { ActionBinding } from './action-utils';\nimport type { VisibilityBinding } from './conditions';\nimport type { ElementNode, RepeatBinding } from './elements';\n\n/**\n * The actual runtime shape behind the branded ElementNode.\n * Only used internally by buildNode() and render().\n */\nexport interface InternalElementNode {\n id?: string;\n type: string;\n props: Record<string, unknown>;\n children?: ElementNode[];\n visible?: unknown;\n on?: Record<string, unknown>;\n watch?: Record<string, unknown>;\n repeat?: { statePath: string; key?: string };\n}\n\n/**\n * Standard input shape for a component builder.\n *\n * - `Props`: plain prop types — automatically wrapped with PropValue\n * - `Events`: string union of supported event names (use `never` for none)\n * - `HasChildren`: whether this component accepts children\n *\n * The conditional types ensure `on` is only available when events exist,\n * and `children` is only available when HasChildren is true.\n */\nexport type ComponentInputs<\n Props,\n Events extends string = never,\n HasChildren extends boolean = false,\n> = {\n id?: string;\n props: WrapWithPropValue<Props>;\n visible?: VisibilityBinding | boolean;\n repeat?: RepeatBinding;\n} & ([Events] extends [never]\n ? { on?: never }\n : { on?: { [K in Events]?: ActionBinding } }) &\n (HasChildren extends true\n ? { children?: ElementNode[] }\n : { children?: never });\n\n/**\n * Variant where props is optional (for components with all-optional props).\n */\nexport type ComponentInputsOptionalProps<\n Props,\n Events extends string = never,\n HasChildren extends boolean = false,\n> = {\n id?: string;\n props?: WrapWithPropValue<Props>;\n visible?: VisibilityBinding | boolean;\n repeat?: RepeatBinding;\n} & ([Events] extends [never]\n ? { on?: never }\n : { on?: { [K in Events]?: ActionBinding } }) &\n (HasChildren extends true\n ? { children?: ElementNode[] }\n : { children?: never });\n\n/**\n * Creates an ElementNode from builder input. Used by generated component builders.\n */\nexport function buildNode<\n TPlatform extends string = string,\n TCatalog extends string = string,\n>(\n type: string,\n input: {\n id?: string;\n props?: unknown;\n visible?: unknown;\n on?: unknown;\n children?: unknown;\n repeat?: unknown;\n }\n): ElementNode<TPlatform, TCatalog> {\n const node: InternalElementNode = {\n type,\n props: (input.props ?? {}) as Record<string, unknown>,\n };\n if (input.id !== undefined) node.id = input.id;\n if (input.visible !== undefined) node.visible = input.visible;\n if (input.on) node.on = input.on as Record<string, unknown>;\n if (input.children) node.children = input.children as ElementNode[];\n if (input.repeat)\n node.repeat = input.repeat as unknown as {\n statePath: string;\n key?: string;\n };\n return node as unknown as ElementNode<TPlatform, TCatalog>;\n}\n"],"names":["buildNode","type","input","node"],"mappings":"gFA2EO,SAASA,EAIdC,EACAC,EAQkC,CAClC,MAAMC,EAA4B,CAChC,KAAAF,EACA,MAAQC,EAAM,OAAS,CAAA,CAAC,EAE1B,OAAIA,EAAM,KAAO,SAAWC,EAAK,GAAKD,EAAM,IACxCA,EAAM,UAAY,SAAWC,EAAK,QAAUD,EAAM,SAClDA,EAAM,KAAIC,EAAK,GAAKD,EAAM,IAC1BA,EAAM,WAAUC,EAAK,SAAWD,EAAM,UACtCA,EAAM,SACRC,EAAK,OAASD,EAAM,QAIfC,CACT"}
@@ -0,0 +1,77 @@
1
+ import { WrapWithPropValue } from './expressions';
2
+ import { ActionBinding } from './action-utils';
3
+ import { VisibilityBinding } from './conditions';
4
+ import { ElementNode, RepeatBinding } from './elements';
5
+ /**
6
+ * The actual runtime shape behind the branded ElementNode.
7
+ * Only used internally by buildNode() and render().
8
+ */
9
+ export interface InternalElementNode {
10
+ id?: string;
11
+ type: string;
12
+ props: Record<string, unknown>;
13
+ children?: ElementNode[];
14
+ visible?: unknown;
15
+ on?: Record<string, unknown>;
16
+ watch?: Record<string, unknown>;
17
+ repeat?: {
18
+ statePath: string;
19
+ key?: string;
20
+ };
21
+ }
22
+ /**
23
+ * Standard input shape for a component builder.
24
+ *
25
+ * - `Props`: plain prop types — automatically wrapped with PropValue
26
+ * - `Events`: string union of supported event names (use `never` for none)
27
+ * - `HasChildren`: whether this component accepts children
28
+ *
29
+ * The conditional types ensure `on` is only available when events exist,
30
+ * and `children` is only available when HasChildren is true.
31
+ */
32
+ export type ComponentInputs<Props, Events extends string = never, HasChildren extends boolean = false> = {
33
+ id?: string;
34
+ props: WrapWithPropValue<Props>;
35
+ visible?: VisibilityBinding | boolean;
36
+ repeat?: RepeatBinding;
37
+ } & ([Events] extends [never] ? {
38
+ on?: never;
39
+ } : {
40
+ on?: {
41
+ [K in Events]?: ActionBinding;
42
+ };
43
+ }) & (HasChildren extends true ? {
44
+ children?: ElementNode[];
45
+ } : {
46
+ children?: never;
47
+ });
48
+ /**
49
+ * Variant where props is optional (for components with all-optional props).
50
+ */
51
+ export type ComponentInputsOptionalProps<Props, Events extends string = never, HasChildren extends boolean = false> = {
52
+ id?: string;
53
+ props?: WrapWithPropValue<Props>;
54
+ visible?: VisibilityBinding | boolean;
55
+ repeat?: RepeatBinding;
56
+ } & ([Events] extends [never] ? {
57
+ on?: never;
58
+ } : {
59
+ on?: {
60
+ [K in Events]?: ActionBinding;
61
+ };
62
+ }) & (HasChildren extends true ? {
63
+ children?: ElementNode[];
64
+ } : {
65
+ children?: never;
66
+ });
67
+ /**
68
+ * Creates an ElementNode from builder input. Used by generated component builders.
69
+ */
70
+ export declare function buildNode<TPlatform extends string = string, TCatalog extends string = string>(type: string, input: {
71
+ id?: string;
72
+ props?: unknown;
73
+ visible?: unknown;
74
+ on?: unknown;
75
+ children?: unknown;
76
+ repeat?: unknown;
77
+ }): ElementNode<TPlatform, TCatalog>;
@@ -0,0 +1,11 @@
1
+ function i(d, e) {
2
+ const o = {
3
+ type: d,
4
+ props: e.props ?? {}
5
+ };
6
+ return e.id !== void 0 && (o.id = e.id), e.visible !== void 0 && (o.visible = e.visible), e.on && (o.on = e.on), e.children && (o.children = e.children), e.repeat && (o.repeat = e.repeat), o;
7
+ }
8
+ export {
9
+ i as buildNode
10
+ };
11
+ //# sourceMappingURL=component-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-utils.js","sources":["../../../sdui-core/src/component-utils.ts"],"sourcesContent":["/**\n * Component Utilities\n *\n * Generic types and helpers used by generated component builders.\n * Mirrors Python SDK's elements.py Element base class.\n */\n\nimport type { WrapWithPropValue } from './expressions';\nimport type { ActionBinding } from './action-utils';\nimport type { VisibilityBinding } from './conditions';\nimport type { ElementNode, RepeatBinding } from './elements';\n\n/**\n * The actual runtime shape behind the branded ElementNode.\n * Only used internally by buildNode() and render().\n */\nexport interface InternalElementNode {\n id?: string;\n type: string;\n props: Record<string, unknown>;\n children?: ElementNode[];\n visible?: unknown;\n on?: Record<string, unknown>;\n watch?: Record<string, unknown>;\n repeat?: { statePath: string; key?: string };\n}\n\n/**\n * Standard input shape for a component builder.\n *\n * - `Props`: plain prop types — automatically wrapped with PropValue\n * - `Events`: string union of supported event names (use `never` for none)\n * - `HasChildren`: whether this component accepts children\n *\n * The conditional types ensure `on` is only available when events exist,\n * and `children` is only available when HasChildren is true.\n */\nexport type ComponentInputs<\n Props,\n Events extends string = never,\n HasChildren extends boolean = false,\n> = {\n id?: string;\n props: WrapWithPropValue<Props>;\n visible?: VisibilityBinding | boolean;\n repeat?: RepeatBinding;\n} & ([Events] extends [never]\n ? { on?: never }\n : { on?: { [K in Events]?: ActionBinding } }) &\n (HasChildren extends true\n ? { children?: ElementNode[] }\n : { children?: never });\n\n/**\n * Variant where props is optional (for components with all-optional props).\n */\nexport type ComponentInputsOptionalProps<\n Props,\n Events extends string = never,\n HasChildren extends boolean = false,\n> = {\n id?: string;\n props?: WrapWithPropValue<Props>;\n visible?: VisibilityBinding | boolean;\n repeat?: RepeatBinding;\n} & ([Events] extends [never]\n ? { on?: never }\n : { on?: { [K in Events]?: ActionBinding } }) &\n (HasChildren extends true\n ? { children?: ElementNode[] }\n : { children?: never });\n\n/**\n * Creates an ElementNode from builder input. Used by generated component builders.\n */\nexport function buildNode<\n TPlatform extends string = string,\n TCatalog extends string = string,\n>(\n type: string,\n input: {\n id?: string;\n props?: unknown;\n visible?: unknown;\n on?: unknown;\n children?: unknown;\n repeat?: unknown;\n }\n): ElementNode<TPlatform, TCatalog> {\n const node: InternalElementNode = {\n type,\n props: (input.props ?? {}) as Record<string, unknown>,\n };\n if (input.id !== undefined) node.id = input.id;\n if (input.visible !== undefined) node.visible = input.visible;\n if (input.on) node.on = input.on as Record<string, unknown>;\n if (input.children) node.children = input.children as ElementNode[];\n if (input.repeat)\n node.repeat = input.repeat as unknown as {\n statePath: string;\n key?: string;\n };\n return node as unknown as ElementNode<TPlatform, TCatalog>;\n}\n"],"names":["buildNode","type","input","node"],"mappings":"AA2EO,SAASA,EAIdC,GACAC,GAQkC;AAClC,QAAMC,IAA4B;AAAA,IAChC,MAAAF;AAAA,IACA,OAAQC,EAAM,SAAS,CAAA;AAAA,EAAC;AAE1B,SAAIA,EAAM,OAAO,WAAWC,EAAK,KAAKD,EAAM,KACxCA,EAAM,YAAY,WAAWC,EAAK,UAAUD,EAAM,UAClDA,EAAM,OAAIC,EAAK,KAAKD,EAAM,KAC1BA,EAAM,aAAUC,EAAK,WAAWD,EAAM,WACtCA,EAAM,WACRC,EAAK,SAASD,EAAM,SAIfC;AACT;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Symbol("visibilityBrand");function r(t,n){return{...t,...n,[e]:!0}}function i(t,n){return r(t,{eq:n})}function a(t,n){return r(t,{neq:n})}function c(t,n){return r(t,{gt:n})}function l(t,n){return r(t,{gte:n})}function f(t,n){return r(t,{lt:n})}function s(t,n){return r(t,{lte:n})}function y(t){return r(t)}function d(t){return r(t,{not:!0})}function g(t){return{...t,not:!0,[e]:!0}}function u(...t){return{$and:t,[e]:!0}}function o(...t){return{$or:t,[e]:!0}}exports.$and=u;exports.$or=o;exports.$when=r;exports.__visibilityBrand=e;exports.and_=u;exports.equals=i;exports.falsy=d;exports.gt=c;exports.gte=l;exports.lt=f;exports.lte=s;exports.neq=a;exports.not_=g;exports.or_=o;exports.truthy=y;
2
+ //# sourceMappingURL=conditions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditions.cjs","sources":["../../../sdui-core/src/conditions.ts"],"sourcesContent":["/**\n * Visibility Condition Types\n *\n * Matches the Python SDK's condition system (equals, neq, gt, gte, lt, lte,\n * truthy, falsy, not_, or_, and_) while using the prototype's opaque branded\n * approach for type safety.\n */\n\nimport type { StateRef, ItemRef, IndexRef } from './expressions';\n\n/** Brand symbol for VisibilityBinding. */\nexport const __visibilityBrand: unique symbol = Symbol('visibilityBrand');\n\n/** A number value — literal or a StateRef resolving to number. */\ntype NumberValue = number | StateRef<number>;\n\n/** Comparison operators shared by all condition sources. */\nexport interface ComparisonOps {\n eq?: unknown;\n neq?: unknown;\n gt?: NumberValue;\n gte?: NumberValue;\n lt?: NumberValue;\n lte?: NumberValue;\n not?: true;\n}\n\n/**\n * Opaque branded type for visibility conditions.\n *\n * External code cannot construct these manually because they cannot assign\n * to the unique symbol property — must use condition builder functions.\n */\nexport type VisibilityBinding = { readonly [__visibilityBrand]: true } & (\n | ({ readonly $state: string } & ComparisonOps)\n | ({ readonly $item: string } & ComparisonOps)\n | ({ readonly $index: true } & ComparisonOps)\n | { readonly $and: (VisibilityBinding | boolean)[] }\n | { readonly $or: (VisibilityBinding | boolean)[] }\n);\n\n/** Source ref types accepted by condition builders. */\ntype ConditionSource = StateRef<unknown> | ItemRef<unknown> | IndexRef;\n\n/**\n * Create a visibility condition from a typed ref.\n *\n * This is the prototype's $when() — kept for backwards compatibility.\n * Matches the Python SDK's condition builder API pattern.\n *\n * Usage:\n * $when($state('/isAdmin'))\n * $when($state('/count'), { gt: 0 })\n */\nexport function $when(\n ref: ConditionSource,\n ops?: ComparisonOps\n): VisibilityBinding {\n const raw = ref as unknown as Record<string, unknown>;\n return {\n ...raw,\n ...ops,\n [__visibilityBrand]: true as const,\n } as VisibilityBinding;\n}\n\n// ---------------------------------------------------------------------------\n// Builder functions matching the Python SDK's API\n// ---------------------------------------------------------------------------\n\n/** Equality condition: visible when ref value == rhs. */\nexport function equals(\n ref: ConditionSource,\n value: unknown\n): VisibilityBinding {\n return $when(ref, { eq: value });\n}\n\n/** Not-equal condition: visible when ref value != rhs. */\nexport function neq(ref: ConditionSource, value: unknown): VisibilityBinding {\n return $when(ref, { neq: value });\n}\n\n/** Greater-than condition: visible when ref value > rhs. */\nexport function gt(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { gt: value });\n}\n\n/** Greater-than-or-equal condition: visible when ref value >= rhs. */\nexport function gte(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { gte: value });\n}\n\n/** Less-than condition: visible when ref value < rhs. */\nexport function lt(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { lt: value });\n}\n\n/** Less-than-or-equal condition: visible when ref value <= rhs. */\nexport function lte(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { lte: value });\n}\n\n/** Truthy condition: visible when ref value is truthy. */\nexport function truthy(ref: ConditionSource): VisibilityBinding {\n return $when(ref);\n}\n\n/** Falsy condition: visible when ref value is falsy. */\nexport function falsy(ref: ConditionSource): VisibilityBinding {\n return $when(ref, { not: true });\n}\n\n/** Negate a condition. */\nexport function not_(condition: VisibilityBinding): VisibilityBinding {\n const raw = condition as unknown as Record<string, unknown>;\n return {\n ...raw,\n not: true,\n [__visibilityBrand]: true as const,\n } as VisibilityBinding;\n}\n\n/** Logical AND — all conditions must be true. */\nexport function $and(\n ...conditions: (VisibilityBinding | boolean)[]\n): VisibilityBinding {\n return {\n $and: conditions,\n [__visibilityBrand]: true as const,\n } as unknown as VisibilityBinding;\n}\n\n/** Logical OR — at least one condition must be true. */\nexport function $or(\n ...conditions: (VisibilityBinding | boolean)[]\n): VisibilityBinding {\n return {\n $or: conditions,\n [__visibilityBrand]: true as const,\n } as unknown as VisibilityBinding;\n}\n\n// Aliases matching Python SDK naming\nexport { $and as and_, $or as or_ };\n"],"names":["__visibilityBrand","$when","ref","ops","equals","value","neq","gt","gte","lt","lte","truthy","falsy","not_","condition","$and","conditions","$or"],"mappings":"gFAWO,MAAMA,EAAmC,OAAO,iBAAiB,EA2CjE,SAASC,EACdC,EACAC,EACmB,CAEnB,MAAO,CACL,GAFUD,EAGV,GAAGC,EACH,CAACH,CAAiB,EAAG,EAAA,CAEzB,CAOO,SAASI,EACdF,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,GAAIG,EAAO,CACjC,CAGO,SAASC,EAAIJ,EAAsBG,EAAmC,CAC3E,OAAOJ,EAAMC,EAAK,CAAE,IAAKG,EAAO,CAClC,CAGO,SAASE,EACdL,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,GAAIG,EAAO,CACjC,CAGO,SAASG,EACdN,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,IAAKG,EAAO,CAClC,CAGO,SAASI,EACdP,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,GAAIG,EAAO,CACjC,CAGO,SAASK,EACdR,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,IAAKG,EAAO,CAClC,CAGO,SAASM,EAAOT,EAAyC,CAC9D,OAAOD,EAAMC,CAAG,CAClB,CAGO,SAASU,EAAMV,EAAyC,CAC7D,OAAOD,EAAMC,EAAK,CAAE,IAAK,GAAM,CACjC,CAGO,SAASW,EAAKC,EAAiD,CAEpE,MAAO,CACL,GAFUA,EAGV,IAAK,GACL,CAACd,CAAiB,EAAG,EAAA,CAEzB,CAGO,SAASe,KACXC,EACgB,CACnB,MAAO,CACL,KAAMA,EACN,CAAChB,CAAiB,EAAG,EAAA,CAEzB,CAGO,SAASiB,KACXD,EACgB,CACnB,MAAO,CACL,IAAKA,EACL,CAAChB,CAAiB,EAAG,EAAA,CAEzB"}
@@ -0,0 +1,70 @@
1
+ import { StateRef, ItemRef, IndexRef } from './expressions';
2
+ /** Brand symbol for VisibilityBinding. */
3
+ export declare const __visibilityBrand: unique symbol;
4
+ /** A number value — literal or a StateRef resolving to number. */
5
+ type NumberValue = number | StateRef<number>;
6
+ /** Comparison operators shared by all condition sources. */
7
+ export interface ComparisonOps {
8
+ eq?: unknown;
9
+ neq?: unknown;
10
+ gt?: NumberValue;
11
+ gte?: NumberValue;
12
+ lt?: NumberValue;
13
+ lte?: NumberValue;
14
+ not?: true;
15
+ }
16
+ /**
17
+ * Opaque branded type for visibility conditions.
18
+ *
19
+ * External code cannot construct these manually because they cannot assign
20
+ * to the unique symbol property — must use condition builder functions.
21
+ */
22
+ export type VisibilityBinding = {
23
+ readonly [__visibilityBrand]: true;
24
+ } & (({
25
+ readonly $state: string;
26
+ } & ComparisonOps) | ({
27
+ readonly $item: string;
28
+ } & ComparisonOps) | ({
29
+ readonly $index: true;
30
+ } & ComparisonOps) | {
31
+ readonly $and: (VisibilityBinding | boolean)[];
32
+ } | {
33
+ readonly $or: (VisibilityBinding | boolean)[];
34
+ });
35
+ /** Source ref types accepted by condition builders. */
36
+ type ConditionSource = StateRef<unknown> | ItemRef<unknown> | IndexRef;
37
+ /**
38
+ * Create a visibility condition from a typed ref.
39
+ *
40
+ * This is the prototype's $when() — kept for backwards compatibility.
41
+ * Matches the Python SDK's condition builder API pattern.
42
+ *
43
+ * Usage:
44
+ * $when($state('/isAdmin'))
45
+ * $when($state('/count'), { gt: 0 })
46
+ */
47
+ export declare function $when(ref: ConditionSource, ops?: ComparisonOps): VisibilityBinding;
48
+ /** Equality condition: visible when ref value == rhs. */
49
+ export declare function equals(ref: ConditionSource, value: unknown): VisibilityBinding;
50
+ /** Not-equal condition: visible when ref value != rhs. */
51
+ export declare function neq(ref: ConditionSource, value: unknown): VisibilityBinding;
52
+ /** Greater-than condition: visible when ref value > rhs. */
53
+ export declare function gt(ref: ConditionSource, value: NumberValue): VisibilityBinding;
54
+ /** Greater-than-or-equal condition: visible when ref value >= rhs. */
55
+ export declare function gte(ref: ConditionSource, value: NumberValue): VisibilityBinding;
56
+ /** Less-than condition: visible when ref value < rhs. */
57
+ export declare function lt(ref: ConditionSource, value: NumberValue): VisibilityBinding;
58
+ /** Less-than-or-equal condition: visible when ref value <= rhs. */
59
+ export declare function lte(ref: ConditionSource, value: NumberValue): VisibilityBinding;
60
+ /** Truthy condition: visible when ref value is truthy. */
61
+ export declare function truthy(ref: ConditionSource): VisibilityBinding;
62
+ /** Falsy condition: visible when ref value is falsy. */
63
+ export declare function falsy(ref: ConditionSource): VisibilityBinding;
64
+ /** Negate a condition. */
65
+ export declare function not_(condition: VisibilityBinding): VisibilityBinding;
66
+ /** Logical AND — all conditions must be true. */
67
+ export declare function $and(...conditions: (VisibilityBinding | boolean)[]): VisibilityBinding;
68
+ /** Logical OR — at least one condition must be true. */
69
+ export declare function $or(...conditions: (VisibilityBinding | boolean)[]): VisibilityBinding;
70
+ export { $and as and_, $or as or_ };
@@ -0,0 +1,69 @@
1
+ const u = Symbol("visibilityBrand");
2
+ function r(n, t) {
3
+ return {
4
+ ...n,
5
+ ...t,
6
+ [u]: !0
7
+ };
8
+ }
9
+ function o(n, t) {
10
+ return r(n, { eq: t });
11
+ }
12
+ function i(n, t) {
13
+ return r(n, { neq: t });
14
+ }
15
+ function c(n, t) {
16
+ return r(n, { gt: t });
17
+ }
18
+ function a(n, t) {
19
+ return r(n, { gte: t });
20
+ }
21
+ function f(n, t) {
22
+ return r(n, { lt: t });
23
+ }
24
+ function l(n, t) {
25
+ return r(n, { lte: t });
26
+ }
27
+ function s(n) {
28
+ return r(n);
29
+ }
30
+ function d(n) {
31
+ return r(n, { not: !0 });
32
+ }
33
+ function w(n) {
34
+ return {
35
+ ...n,
36
+ not: !0,
37
+ [u]: !0
38
+ };
39
+ }
40
+ function y(...n) {
41
+ return {
42
+ $and: n,
43
+ [u]: !0
44
+ };
45
+ }
46
+ function _(...n) {
47
+ return {
48
+ $or: n,
49
+ [u]: !0
50
+ };
51
+ }
52
+ export {
53
+ y as $and,
54
+ _ as $or,
55
+ r as $when,
56
+ u as __visibilityBrand,
57
+ y as and_,
58
+ o as equals,
59
+ d as falsy,
60
+ c as gt,
61
+ a as gte,
62
+ f as lt,
63
+ l as lte,
64
+ i as neq,
65
+ w as not_,
66
+ _ as or_,
67
+ s as truthy
68
+ };
69
+ //# sourceMappingURL=conditions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditions.js","sources":["../../../sdui-core/src/conditions.ts"],"sourcesContent":["/**\n * Visibility Condition Types\n *\n * Matches the Python SDK's condition system (equals, neq, gt, gte, lt, lte,\n * truthy, falsy, not_, or_, and_) while using the prototype's opaque branded\n * approach for type safety.\n */\n\nimport type { StateRef, ItemRef, IndexRef } from './expressions';\n\n/** Brand symbol for VisibilityBinding. */\nexport const __visibilityBrand: unique symbol = Symbol('visibilityBrand');\n\n/** A number value — literal or a StateRef resolving to number. */\ntype NumberValue = number | StateRef<number>;\n\n/** Comparison operators shared by all condition sources. */\nexport interface ComparisonOps {\n eq?: unknown;\n neq?: unknown;\n gt?: NumberValue;\n gte?: NumberValue;\n lt?: NumberValue;\n lte?: NumberValue;\n not?: true;\n}\n\n/**\n * Opaque branded type for visibility conditions.\n *\n * External code cannot construct these manually because they cannot assign\n * to the unique symbol property — must use condition builder functions.\n */\nexport type VisibilityBinding = { readonly [__visibilityBrand]: true } & (\n | ({ readonly $state: string } & ComparisonOps)\n | ({ readonly $item: string } & ComparisonOps)\n | ({ readonly $index: true } & ComparisonOps)\n | { readonly $and: (VisibilityBinding | boolean)[] }\n | { readonly $or: (VisibilityBinding | boolean)[] }\n);\n\n/** Source ref types accepted by condition builders. */\ntype ConditionSource = StateRef<unknown> | ItemRef<unknown> | IndexRef;\n\n/**\n * Create a visibility condition from a typed ref.\n *\n * This is the prototype's $when() — kept for backwards compatibility.\n * Matches the Python SDK's condition builder API pattern.\n *\n * Usage:\n * $when($state('/isAdmin'))\n * $when($state('/count'), { gt: 0 })\n */\nexport function $when(\n ref: ConditionSource,\n ops?: ComparisonOps\n): VisibilityBinding {\n const raw = ref as unknown as Record<string, unknown>;\n return {\n ...raw,\n ...ops,\n [__visibilityBrand]: true as const,\n } as VisibilityBinding;\n}\n\n// ---------------------------------------------------------------------------\n// Builder functions matching the Python SDK's API\n// ---------------------------------------------------------------------------\n\n/** Equality condition: visible when ref value == rhs. */\nexport function equals(\n ref: ConditionSource,\n value: unknown\n): VisibilityBinding {\n return $when(ref, { eq: value });\n}\n\n/** Not-equal condition: visible when ref value != rhs. */\nexport function neq(ref: ConditionSource, value: unknown): VisibilityBinding {\n return $when(ref, { neq: value });\n}\n\n/** Greater-than condition: visible when ref value > rhs. */\nexport function gt(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { gt: value });\n}\n\n/** Greater-than-or-equal condition: visible when ref value >= rhs. */\nexport function gte(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { gte: value });\n}\n\n/** Less-than condition: visible when ref value < rhs. */\nexport function lt(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { lt: value });\n}\n\n/** Less-than-or-equal condition: visible when ref value <= rhs. */\nexport function lte(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { lte: value });\n}\n\n/** Truthy condition: visible when ref value is truthy. */\nexport function truthy(ref: ConditionSource): VisibilityBinding {\n return $when(ref);\n}\n\n/** Falsy condition: visible when ref value is falsy. */\nexport function falsy(ref: ConditionSource): VisibilityBinding {\n return $when(ref, { not: true });\n}\n\n/** Negate a condition. */\nexport function not_(condition: VisibilityBinding): VisibilityBinding {\n const raw = condition as unknown as Record<string, unknown>;\n return {\n ...raw,\n not: true,\n [__visibilityBrand]: true as const,\n } as VisibilityBinding;\n}\n\n/** Logical AND — all conditions must be true. */\nexport function $and(\n ...conditions: (VisibilityBinding | boolean)[]\n): VisibilityBinding {\n return {\n $and: conditions,\n [__visibilityBrand]: true as const,\n } as unknown as VisibilityBinding;\n}\n\n/** Logical OR — at least one condition must be true. */\nexport function $or(\n ...conditions: (VisibilityBinding | boolean)[]\n): VisibilityBinding {\n return {\n $or: conditions,\n [__visibilityBrand]: true as const,\n } as unknown as VisibilityBinding;\n}\n\n// Aliases matching Python SDK naming\nexport { $and as and_, $or as or_ };\n"],"names":["__visibilityBrand","$when","ref","ops","equals","value","neq","gt","gte","lt","lte","truthy","falsy","not_","condition","$and","conditions","$or"],"mappings":"AAWO,MAAMA,IAAmC,OAAO,iBAAiB;AA2CjE,SAASC,EACdC,GACAC,GACmB;AAEnB,SAAO;AAAA,IACL,GAFUD;AAAA,IAGV,GAAGC;AAAA,IACH,CAACH,CAAiB,GAAG;AAAA,EAAA;AAEzB;AAOO,SAASI,EACdF,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,IAAIG,GAAO;AACjC;AAGO,SAASC,EAAIJ,GAAsBG,GAAmC;AAC3E,SAAOJ,EAAMC,GAAK,EAAE,KAAKG,GAAO;AAClC;AAGO,SAASE,EACdL,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,IAAIG,GAAO;AACjC;AAGO,SAASG,EACdN,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,KAAKG,GAAO;AAClC;AAGO,SAASI,EACdP,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,IAAIG,GAAO;AACjC;AAGO,SAASK,EACdR,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,KAAKG,GAAO;AAClC;AAGO,SAASM,EAAOT,GAAyC;AAC9D,SAAOD,EAAMC,CAAG;AAClB;AAGO,SAASU,EAAMV,GAAyC;AAC7D,SAAOD,EAAMC,GAAK,EAAE,KAAK,IAAM;AACjC;AAGO,SAASW,EAAKC,GAAiD;AAEpE,SAAO;AAAA,IACL,GAFUA;AAAA,IAGV,KAAK;AAAA,IACL,CAACd,CAAiB,GAAG;AAAA,EAAA;AAEzB;AAGO,SAASe,KACXC,GACgB;AACnB,SAAO;AAAA,IACL,MAAMA;AAAA,IACN,CAAChB,CAAiB,GAAG;AAAA,EAAA;AAEzB;AAGO,SAASiB,KACXD,GACgB;AACnB,SAAO;AAAA,IACL,KAAKA;AAAA,IACL,CAAChB,CAAiB,GAAG;AAAA,EAAA;AAEzB;"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=elements.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Element Node - Internal tree representation
3
+ *
4
+ * Opaque branded types for element nodes and repeat bindings.
5
+ */
6
+ declare const __elementBrand: unique symbol;
7
+ /**
8
+ * Opaque branded type returned by component builders.
9
+ * Cannot be constructed manually — must go through a generated component builder.
10
+ */
11
+ export interface ElementNode<TPlatform extends string = string, TCatalog extends string = string> {
12
+ readonly [__elementBrand]: true;
13
+ readonly __platform?: TPlatform;
14
+ readonly __catalog?: TCatalog;
15
+ }
16
+ declare const __repeatBrand: unique symbol;
17
+ /**
18
+ * Opaque branded type returned by repeat().
19
+ * Cannot be constructed manually — must go through the typed repeat() helper.
20
+ */
21
+ export interface RepeatBinding {
22
+ readonly [__repeatBrand]: true;
23
+ }
24
+ export {};
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=expressions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressions.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Phantom-Typed Expression Markers
3
+ *
4
+ * Each expression helper returns a marker object that carries the resolved
5
+ * value type as a phantom type. Builders accept PropValue<T> which
6
+ * structurally matches only when the phantom type aligns with the prop type.
7
+ *
8
+ * The __phantom symbol is used to embed type information in runtime objects
9
+ * without affecting JSON serialization. This enables compile-time type safety
10
+ * while keeping the runtime representation clean.
11
+ */
12
+ declare const __phantom: unique symbol;
13
+ /** Read-only reference to a state path. Carries resolved value type T. */
14
+ export interface StateRef<T> {
15
+ readonly $state: string;
16
+ readonly [__phantom]: T;
17
+ }
18
+ /** Two-way binding to a state path. Carries resolved value type T. */
19
+ export interface BindStateRef<T> {
20
+ readonly $bindState: string;
21
+ readonly [__phantom]: T;
22
+ }
23
+ /** Read-only reference to a repeat item path. Carries resolved value type T. */
24
+ export interface ItemRef<T> {
25
+ readonly $item: string;
26
+ readonly [__phantom]: T;
27
+ }
28
+ /** Two-way binding to a repeat item path. Carries resolved value type T. */
29
+ export interface BindItemRef<T> {
30
+ readonly $bindItem: string;
31
+ readonly [__phantom]: T;
32
+ }
33
+ /** Current repeat index. Always resolves to number. */
34
+ export interface IndexRef {
35
+ readonly $index: true;
36
+ readonly [__phantom]: number;
37
+ }
38
+ /** String template expression. Always resolves to string. */
39
+ export interface TemplateRef {
40
+ readonly $template: string;
41
+ readonly [__phantom]: string;
42
+ }
43
+ /**
44
+ * Valid interpolation value inside a $template tagged template.
45
+ * Accepts any expression ref that can be stringified at runtime.
46
+ */
47
+ export type TemplateInterpolation = StateRef<unknown> | ItemRef<unknown> | IndexRef | null | undefined;
48
+ /** Conditional expression with typed branches. Uses T directly to avoid circular PropValue recursion. */
49
+ export interface CondRef<T> {
50
+ readonly $cond: unknown;
51
+ readonly $then: T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T>;
52
+ readonly $else: T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T>;
53
+ readonly [__phantom]: T;
54
+ }
55
+ /**
56
+ * A prop value that is either a literal T or a phantom-typed expression
57
+ * that resolves to T at runtime.
58
+ */
59
+ export type PropValue<T> = T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T> | (T extends number ? IndexRef : never) | (T extends string ? TemplateRef : never) | CondRef<T>;
60
+ /**
61
+ * A value in an action param: literal T or a read-only expression.
62
+ * Narrower than PropValue — no bind refs, templates, or cond.
63
+ */
64
+ export type ActionParamValue<T> = T | StateRef<T> | ItemRef<T> | (T extends number ? IndexRef : never);
65
+ /**
66
+ * Takes a plain props type and wraps each field with PropValue<T>.
67
+ * Preserves optionality: required fields stay required, optional stay optional.
68
+ *
69
+ * Uses Extract<TProps[K], undefined> to preserve undefined in the union,
70
+ * which maintains the optional field semantics from the original type.
71
+ */
72
+ export type WrapWithPropValue<TProps> = {
73
+ [K in keyof TProps]: PropValue<NonNullable<TProps[K]>> | Extract<TProps[K], undefined>;
74
+ };
75
+ /**
76
+ * Takes a plain params type and wraps each field with ActionParamValue<T>.
77
+ */
78
+ export type WrapWithActionParamValue<TParams> = {
79
+ [K in keyof TParams]: ActionParamValue<NonNullable<TParams[K]>> | Extract<TParams[K], undefined>;
80
+ };
81
+ export {};
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=expressions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./spec.cjs"),r=require("./component-utils.cjs"),n=require("./action-utils.cjs"),e=require("./conditions.cjs");exports.createSpec=t.createSpec;exports.renderElementTree=t.renderElementTree;exports.buildNode=r.buildNode;exports.buildAction=n.buildAction;exports.$and=e.$and;exports.$or=e.$or;exports.$when=e.$when;exports.and_=e.$and;exports.equals=e.equals;exports.falsy=e.falsy;exports.gt=e.gt;exports.gte=e.gte;exports.lt=e.lt;exports.lte=e.lte;exports.neq=e.neq;exports.not_=e.not_;exports.or_=e.$or;exports.truthy=e.truthy;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared SDK implementation used by platform packages and generated catalog code.
3
+ */
4
+ export { createSpec, renderElementTree } from './spec';
5
+ export type { SpecContext, FlatSpec, FlatUIElement, ItemAccessor, } from './spec';
6
+ export { buildNode } from './component-utils';
7
+ export type { ComponentInputs, ComponentInputsOptionalProps, InternalElementNode, } from './component-utils';
8
+ export { buildAction } from './action-utils';
9
+ export type { ActionBinding, ActionConfirm, ActionOptions, ActionOnSuccess, ActionOnError, } from './action-utils';
10
+ export type { PropValue, WrapWithPropValue, StateRef, BindStateRef, ItemRef, BindItemRef, IndexRef, TemplateRef, CondRef, TemplateInterpolation, ActionParamValue, WrapWithActionParamValue, } from './expressions';
11
+ export { $when, equals, neq, gt, gte, lt, lte, truthy, falsy, not_, $and, $or, and_, or_, } from './conditions';
12
+ export type { VisibilityBinding, ComparisonOps } from './conditions';
13
+ export type { StatePaths, ValueAt, ArrayPaths, ArrayItemAt, ItemPaths, ItemValueAt, } from './paths';
14
+ export type { ElementNode, RepeatBinding } from './elements';
@@ -0,0 +1,25 @@
1
+ import { createSpec as o, renderElementTree as t } from "./spec.js";
2
+ import { buildNode as a } from "./component-utils.js";
3
+ import { buildAction as l } from "./action-utils.js";
4
+ import { $and as m, $or as p, $when as $, $and as s, equals as u, falsy as x, gt as c, gte as i, lt as _, lte as b, neq as g, not_ as h, $or as q, truthy as y } from "./conditions.js";
5
+ export {
6
+ m as $and,
7
+ p as $or,
8
+ $ as $when,
9
+ s as and_,
10
+ l as buildAction,
11
+ a as buildNode,
12
+ o as createSpec,
13
+ u as equals,
14
+ x as falsy,
15
+ c as gt,
16
+ i as gte,
17
+ _ as lt,
18
+ b as lte,
19
+ g as neq,
20
+ h as not_,
21
+ q as or_,
22
+ t as renderElementTree,
23
+ y as truthy
24
+ };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=paths.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Type-level JSON pointer path helpers for state and repeat items.
3
+ */
4
+ type Primitive = string | number | boolean | bigint | symbol | null | undefined;
5
+ type StringKeyOf<T> = Extract<keyof T, string>;
6
+ type NestedStatePaths<T> = T extends Primitive ? never : T extends readonly unknown[] ? never : {
7
+ [K in StringKeyOf<T>]: T[K] extends Primitive | readonly unknown[] ? `/${K}` : `/${K}` | `/${K}${NestedStatePaths<T[K]>}`;
8
+ }[StringKeyOf<T>];
9
+ type NestedItemPaths<T> = T extends Primitive ? never : T extends readonly unknown[] ? never : {
10
+ [K in StringKeyOf<T>]: T[K] extends Primitive | readonly unknown[] ? K : K | `${K}/${NestedItemPaths<T[K]>}`;
11
+ }[StringKeyOf<T>];
12
+ type ValueAtSegments<T, P extends string> = P extends `${infer K}/${infer Rest}` ? K extends StringKeyOf<T> ? T[K] extends readonly (infer Item)[] ? Rest extends `${number}/${infer ArrayRest}` ? ValueAtSegments<Item, ArrayRest> : never : ValueAtSegments<T[K], Rest> : never : P extends StringKeyOf<T> ? T[P] : never;
13
+ /** JSON pointer paths into a state object, such as "/user/name". */
14
+ export type StatePaths<T> = NestedStatePaths<T>;
15
+ /** Resolved value type for a state JSON pointer path. */
16
+ export type ValueAt<T, P extends string> = P extends `/${infer Rest}` ? ValueAtSegments<T, Rest> : ValueAtSegments<T, P>;
17
+ /** State paths whose resolved value is an array. */
18
+ export type ArrayPaths<T> = {
19
+ [P in StatePaths<T>]: ValueAt<T, P> extends readonly unknown[] ? P : never;
20
+ }[StatePaths<T>];
21
+ /** Array item type at an array-valued state path. */
22
+ export type ArrayItemAt<T, P extends string> = ValueAt<T, P> extends readonly (infer Item)[] ? Item : never;
23
+ /** Slash-separated paths into a repeat item, such as "title" or "owner/name". */
24
+ export type ItemPaths<T> = NestedItemPaths<T>;
25
+ /** Resolved value type for a repeat item path. */
26
+ export type ItemValueAt<T, P extends string> = ValueAtSegments<T, P>;
27
+ export {};
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function w(f,S){const $={},p=new Map,m=new WeakMap,h=new WeakSet,u=new Set;let b=0;function t(n,d=new WeakSet){var s;const c=n;if(d.has(c))return;d.add(c);const e=n;if(e.id!==void 0){const o=p.get(e.id);if(o&&o!==c)throw new Error(`Duplicate element id: ${e.id}`);p.set(e.id,c),u.add(e.id)}(s=e.children)==null||s.forEach(o=>t(o,d))}function a(){let n;do n=`element-${b}`,b+=1;while(u.has(n));return u.add(n),n}function r(n){const d=n,c=m.get(d);if(c)return c;const s=n.id??a();return m.set(d,s),s}function l(n){const d=n,c=r(n);if(h.has(d))return c;h.add(d);const e=n,s=e.children?e.children.map(g=>l(g)):void 0,o={type:e.type,props:e.props};return s&&s.length>0&&(o.children=s),e.visible!==void 0&&(o.visible=e.visible),e.on&&(o.on=e.on),e.watch&&(o.watch=e.watch),e.repeat&&(o.repeat=e.repeat),$[c]=o,c}t(f);const i=l(f);return JSON.parse(JSON.stringify({root:i,elements:$,state:S}))}function I(f){const S=f.state;function $(t){return{$state:t}}function p(t){return{$bindState:t}}function m(t,...a){let r=t[0];for(let l=0;l<a.length;l+=1){const i=a[l];!i||typeof i!="object"?r+="":"$state"in i?r+=`\${${i.$state}}`:"$item"in i?r+=`\${$item.${i.$item}}`:"$index"in i&&(r+="${$index}"),r+=t[l+1]}return{$template:r}}function h(t,a,r){return{$cond:t,$then:a,$else:r}}function u(t,a){return[{statePath:t,key:a},{$(i){return{$item:i}},$bind(i){return{$bindItem:i}},$index(){return{$index:!0}}}]}function b(t){return w(t,S)}return{$state:$,$bindState:p,$template:m,$cond:h,repeat:u,render:b}}exports.createSpec=I;exports.renderElementTree=w;
2
+ //# sourceMappingURL=spec.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.cjs","sources":["../../../sdui-core/src/spec.ts"],"sourcesContent":["/**\n * createSpec - Factory for state-bound expression helpers + render\n *\n * Mirrors Python SDK's StateHandle + render module.\n */\n\nimport type {\n StatePaths,\n ValueAt,\n ArrayPaths,\n ArrayItemAt,\n ItemPaths,\n ItemValueAt,\n} from './paths';\nimport type {\n StateRef,\n BindStateRef,\n ItemRef,\n BindItemRef,\n IndexRef,\n TemplateRef,\n TemplateInterpolation,\n CondRef,\n PropValue,\n} from './expressions';\nimport type { VisibilityBinding } from './conditions';\nimport type { ElementNode, RepeatBinding } from './elements';\nimport type { InternalElementNode } from './component-utils';\n\n/** Typed accessor for repeat item fields. */\nexport interface ItemAccessor<TItem> {\n /** Read a field from the current repeat item. */\n $<P extends ItemPaths<TItem>>(path: P): ItemRef<ItemValueAt<TItem, P>>;\n /** Two-way bind to a field on the current repeat item. */\n $bind<P extends ItemPaths<TItem>>(\n path: P\n ): BindItemRef<ItemValueAt<TItem, P>>;\n /** Current repeat index (number). */\n $index(): IndexRef;\n}\n\nexport interface FlatUIElement {\n type: string;\n props: Record<string, unknown>;\n children?: string[];\n visible?: unknown;\n on?: Record<string, unknown>;\n watch?: Record<string, unknown>;\n repeat?: { statePath: string; key?: string };\n}\n\nexport interface FlatSpec {\n root: string;\n elements: Record<string, FlatUIElement>;\n state?: Record<string, unknown>;\n}\n\n/**\n * Flatten an element tree into a flat spec format.\n * Uses JSON round-trip to strip Symbol properties and undefined values,\n * ensuring clean serialization.\n */\nexport function renderElementTree(root: ElementNode, state?: object): FlatSpec {\n const elements: Record<string, FlatUIElement> = {};\n const explicitIds = new Map<string, object>();\n const elementIds = new WeakMap<object, string>();\n const emitted = new WeakSet<object>();\n const usedIds = new Set<string>();\n let nextGeneratedId = 0;\n\n function collectExplicitIds(\n node: ElementNode,\n seen = new WeakSet<object>()\n ): void {\n const nodeObject = node as unknown as object;\n if (seen.has(nodeObject)) {\n return;\n }\n seen.add(nodeObject);\n\n const n = node as unknown as InternalElementNode;\n if (n.id !== undefined) {\n const existing = explicitIds.get(n.id);\n if (existing && existing !== nodeObject) {\n throw new Error(`Duplicate element id: ${n.id}`);\n }\n explicitIds.set(n.id, nodeObject);\n usedIds.add(n.id);\n }\n\n n.children?.forEach(child => collectExplicitIds(child, seen));\n }\n\n function allocateGeneratedId(): string {\n let id: string;\n do {\n id = `element-${nextGeneratedId}`;\n nextGeneratedId += 1;\n } while (usedIds.has(id));\n\n usedIds.add(id);\n return id;\n }\n\n function elementId(node: ElementNode): string {\n const nodeObject = node as unknown as object;\n const existing = elementIds.get(nodeObject);\n if (existing) {\n return existing;\n }\n\n const n = node as unknown as InternalElementNode;\n const id = n.id ?? allocateGeneratedId();\n elementIds.set(nodeObject, id);\n return id;\n }\n\n function flatten(node: ElementNode): string {\n const nodeObject = node as unknown as object;\n const id = elementId(node);\n if (emitted.has(nodeObject)) {\n return id;\n }\n emitted.add(nodeObject);\n\n const n = node as unknown as InternalElementNode;\n const childIds: string[] | undefined = n.children\n ? n.children.map(child => flatten(child))\n : undefined;\n\n const flatElement: FlatUIElement = {\n type: n.type,\n props: n.props,\n };\n\n if (childIds && childIds.length > 0) {\n flatElement.children = childIds;\n }\n if (n.visible !== undefined) {\n flatElement.visible = n.visible;\n }\n if (n.on) {\n flatElement.on = n.on;\n }\n if (n.watch) {\n flatElement.watch = n.watch;\n }\n if (n.repeat) {\n flatElement.repeat = n.repeat;\n }\n\n elements[id] = flatElement;\n return id;\n }\n\n collectExplicitIds(root);\n const rootId = flatten(root);\n\n return JSON.parse(\n JSON.stringify({\n root: rootId,\n elements,\n state,\n })\n ) as FlatSpec;\n}\n\nexport interface SpecContext<TState> {\n /** Read-only reference to a state path. */\n $state<P extends StatePaths<TState>>(path: P): StateRef<ValueAt<TState, P>>;\n\n /** Two-way binding to a state path. */\n $bindState<P extends StatePaths<TState>>(\n path: P\n ): BindStateRef<ValueAt<TState, P>>;\n\n /** String template expression (tagged template literal). */\n $template(\n strings: TemplateStringsArray,\n ...values: TemplateInterpolation[]\n ): TemplateRef;\n\n /** Conditional expression with typed branches. */\n $cond<T>(\n condition: VisibilityBinding | boolean,\n then: PropValue<T>,\n else_: PropValue<T>\n ): CondRef<T>;\n\n /**\n * Create a repeat binding for an array state path.\n * Returns [RepeatBinding, ItemAccessor<T>].\n */\n repeat<P extends ArrayPaths<TState>>(\n statePath: P,\n key?: string\n ): [RepeatBinding, ItemAccessor<ArrayItemAt<TState, P>>];\n\n /** Flatten an element tree into the flat spec format. */\n render(root: ElementNode): FlatSpec;\n}\n\nexport function createSpec<TState extends object>(config: {\n state: TState;\n}): SpecContext<TState> {\n const initialState = config.state;\n\n function $state(path: string): unknown {\n return { $state: path };\n }\n\n function $bindState(path: string): unknown {\n return { $bindState: path };\n }\n\n /**\n * Build a template string from a tagged template literal.\n * Converts expression refs ($state, $item, $index) into template variables.\n */\n function $template(\n strings: TemplateStringsArray,\n ...values: unknown[]\n ): unknown {\n let result = strings[0];\n for (let i = 0; i < values.length; i += 1) {\n const val = values[i];\n if (!val || typeof val !== 'object') {\n result += '';\n } else if ('$state' in val) {\n result += `\\${${val.$state}}`;\n } else if ('$item' in val) {\n result += `\\${$item.${val.$item}}`;\n } else if ('$index' in val) {\n result += '${$index}';\n }\n result += strings[i + 1];\n }\n return { $template: result };\n }\n\n function $cond(condition: unknown, then: unknown, else_: unknown): unknown {\n return { $cond: condition, $then: then, $else: else_ };\n }\n\n /**\n * Create a repeat binding for array iteration.\n * Returns [RepeatBinding, ItemAccessor] tuple.\n *\n * Type safety is enforced at the createSpec boundary through type parameters.\n * Internal implementations use `any` to work with the opaque branded types.\n */\n function repeat(\n statePath: string,\n key?: string\n ): [unknown, ItemAccessor<unknown>] {\n const repeatBinding = { statePath, key } as unknown as RepeatBinding;\n\n const itemAccessor: ItemAccessor<unknown> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n $(path: string): any {\n return { $item: path };\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n $bind(path: string): any {\n return { $bindItem: path };\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n $index(): any {\n return { $index: true };\n },\n };\n\n return [repeatBinding, itemAccessor];\n }\n\n function render(root: ElementNode): FlatSpec {\n return renderElementTree(root, initialState);\n }\n\n return {\n $state,\n $bindState,\n $template,\n $cond,\n repeat,\n render,\n } as unknown as SpecContext<TState>;\n}\n"],"names":["renderElementTree","root","state","elements","explicitIds","elementIds","emitted","usedIds","nextGeneratedId","collectExplicitIds","node","seen","nodeObject","n","existing","_a","child","allocateGeneratedId","id","elementId","flatten","childIds","flatElement","rootId","createSpec","config","initialState","$state","path","$bindState","$template","strings","values","result","i","val","$cond","condition","then","else_","repeat","statePath","key","render"],"mappings":"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"}
@@ -0,0 +1,56 @@
1
+ import { StatePaths, ValueAt, ArrayPaths, ArrayItemAt, ItemPaths, ItemValueAt } from './paths';
2
+ import { StateRef, BindStateRef, ItemRef, BindItemRef, IndexRef, TemplateRef, TemplateInterpolation, CondRef, PropValue } from './expressions';
3
+ import { VisibilityBinding } from './conditions';
4
+ import { ElementNode, RepeatBinding } from './elements';
5
+ /** Typed accessor for repeat item fields. */
6
+ export interface ItemAccessor<TItem> {
7
+ /** Read a field from the current repeat item. */
8
+ $<P extends ItemPaths<TItem>>(path: P): ItemRef<ItemValueAt<TItem, P>>;
9
+ /** Two-way bind to a field on the current repeat item. */
10
+ $bind<P extends ItemPaths<TItem>>(path: P): BindItemRef<ItemValueAt<TItem, P>>;
11
+ /** Current repeat index (number). */
12
+ $index(): IndexRef;
13
+ }
14
+ export interface FlatUIElement {
15
+ type: string;
16
+ props: Record<string, unknown>;
17
+ children?: string[];
18
+ visible?: unknown;
19
+ on?: Record<string, unknown>;
20
+ watch?: Record<string, unknown>;
21
+ repeat?: {
22
+ statePath: string;
23
+ key?: string;
24
+ };
25
+ }
26
+ export interface FlatSpec {
27
+ root: string;
28
+ elements: Record<string, FlatUIElement>;
29
+ state?: Record<string, unknown>;
30
+ }
31
+ /**
32
+ * Flatten an element tree into a flat spec format.
33
+ * Uses JSON round-trip to strip Symbol properties and undefined values,
34
+ * ensuring clean serialization.
35
+ */
36
+ export declare function renderElementTree(root: ElementNode, state?: object): FlatSpec;
37
+ export interface SpecContext<TState> {
38
+ /** Read-only reference to a state path. */
39
+ $state<P extends StatePaths<TState>>(path: P): StateRef<ValueAt<TState, P>>;
40
+ /** Two-way binding to a state path. */
41
+ $bindState<P extends StatePaths<TState>>(path: P): BindStateRef<ValueAt<TState, P>>;
42
+ /** String template expression (tagged template literal). */
43
+ $template(strings: TemplateStringsArray, ...values: TemplateInterpolation[]): TemplateRef;
44
+ /** Conditional expression with typed branches. */
45
+ $cond<T>(condition: VisibilityBinding | boolean, then: PropValue<T>, else_: PropValue<T>): CondRef<T>;
46
+ /**
47
+ * Create a repeat binding for an array state path.
48
+ * Returns [RepeatBinding, ItemAccessor<T>].
49
+ */
50
+ repeat<P extends ArrayPaths<TState>>(statePath: P, key?: string): [RepeatBinding, ItemAccessor<ArrayItemAt<TState, P>>];
51
+ /** Flatten an element tree into the flat spec format. */
52
+ render(root: ElementNode): FlatSpec;
53
+ }
54
+ export declare function createSpec<TState extends object>(config: {
55
+ state: TState;
56
+ }): SpecContext<TState>;
@@ -0,0 +1,105 @@
1
+ function I(u, w) {
2
+ const $ = {}, p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakSet(), f = /* @__PURE__ */ new Set();
3
+ let b = 0;
4
+ function t(n, d = /* @__PURE__ */ new WeakSet()) {
5
+ var s;
6
+ const c = n;
7
+ if (d.has(c))
8
+ return;
9
+ d.add(c);
10
+ const e = n;
11
+ if (e.id !== void 0) {
12
+ const o = p.get(e.id);
13
+ if (o && o !== c)
14
+ throw new Error(`Duplicate element id: ${e.id}`);
15
+ p.set(e.id, c), f.add(e.id);
16
+ }
17
+ (s = e.children) == null || s.forEach((o) => t(o, d));
18
+ }
19
+ function a() {
20
+ let n;
21
+ do
22
+ n = `element-${b}`, b += 1;
23
+ while (f.has(n));
24
+ return f.add(n), n;
25
+ }
26
+ function r(n) {
27
+ const d = n, c = m.get(d);
28
+ if (c)
29
+ return c;
30
+ const s = n.id ?? a();
31
+ return m.set(d, s), s;
32
+ }
33
+ function l(n) {
34
+ const d = n, c = r(n);
35
+ if (h.has(d))
36
+ return c;
37
+ h.add(d);
38
+ const e = n, s = e.children ? e.children.map((x) => l(x)) : void 0, o = {
39
+ type: e.type,
40
+ props: e.props
41
+ };
42
+ return s && s.length > 0 && (o.children = s), e.visible !== void 0 && (o.visible = e.visible), e.on && (o.on = e.on), e.watch && (o.watch = e.watch), e.repeat && (o.repeat = e.repeat), $[c] = o, c;
43
+ }
44
+ t(u);
45
+ const i = l(u);
46
+ return JSON.parse(
47
+ JSON.stringify({
48
+ root: i,
49
+ elements: $,
50
+ state: w
51
+ })
52
+ );
53
+ }
54
+ function S(u) {
55
+ const w = u.state;
56
+ function $(t) {
57
+ return { $state: t };
58
+ }
59
+ function p(t) {
60
+ return { $bindState: t };
61
+ }
62
+ function m(t, ...a) {
63
+ let r = t[0];
64
+ for (let l = 0; l < a.length; l += 1) {
65
+ const i = a[l];
66
+ !i || typeof i != "object" ? r += "" : "$state" in i ? r += `\${${i.$state}}` : "$item" in i ? r += `\${$item.${i.$item}}` : "$index" in i && (r += "${$index}"), r += t[l + 1];
67
+ }
68
+ return { $template: r };
69
+ }
70
+ function h(t, a, r) {
71
+ return { $cond: t, $then: a, $else: r };
72
+ }
73
+ function f(t, a) {
74
+ return [{ statePath: t, key: a }, {
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+ $(i) {
77
+ return { $item: i };
78
+ },
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ $bind(i) {
81
+ return { $bindItem: i };
82
+ },
83
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
+ $index() {
85
+ return { $index: !0 };
86
+ }
87
+ }];
88
+ }
89
+ function b(t) {
90
+ return I(t, w);
91
+ }
92
+ return {
93
+ $state: $,
94
+ $bindState: p,
95
+ $template: m,
96
+ $cond: h,
97
+ repeat: f,
98
+ render: b
99
+ };
100
+ }
101
+ export {
102
+ S as createSpec,
103
+ I as renderElementTree
104
+ };
105
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","sources":["../../../sdui-core/src/spec.ts"],"sourcesContent":["/**\n * createSpec - Factory for state-bound expression helpers + render\n *\n * Mirrors Python SDK's StateHandle + render module.\n */\n\nimport type {\n StatePaths,\n ValueAt,\n ArrayPaths,\n ArrayItemAt,\n ItemPaths,\n ItemValueAt,\n} from './paths';\nimport type {\n StateRef,\n BindStateRef,\n ItemRef,\n BindItemRef,\n IndexRef,\n TemplateRef,\n TemplateInterpolation,\n CondRef,\n PropValue,\n} from './expressions';\nimport type { VisibilityBinding } from './conditions';\nimport type { ElementNode, RepeatBinding } from './elements';\nimport type { InternalElementNode } from './component-utils';\n\n/** Typed accessor for repeat item fields. */\nexport interface ItemAccessor<TItem> {\n /** Read a field from the current repeat item. */\n $<P extends ItemPaths<TItem>>(path: P): ItemRef<ItemValueAt<TItem, P>>;\n /** Two-way bind to a field on the current repeat item. */\n $bind<P extends ItemPaths<TItem>>(\n path: P\n ): BindItemRef<ItemValueAt<TItem, P>>;\n /** Current repeat index (number). */\n $index(): IndexRef;\n}\n\nexport interface FlatUIElement {\n type: string;\n props: Record<string, unknown>;\n children?: string[];\n visible?: unknown;\n on?: Record<string, unknown>;\n watch?: Record<string, unknown>;\n repeat?: { statePath: string; key?: string };\n}\n\nexport interface FlatSpec {\n root: string;\n elements: Record<string, FlatUIElement>;\n state?: Record<string, unknown>;\n}\n\n/**\n * Flatten an element tree into a flat spec format.\n * Uses JSON round-trip to strip Symbol properties and undefined values,\n * ensuring clean serialization.\n */\nexport function renderElementTree(root: ElementNode, state?: object): FlatSpec {\n const elements: Record<string, FlatUIElement> = {};\n const explicitIds = new Map<string, object>();\n const elementIds = new WeakMap<object, string>();\n const emitted = new WeakSet<object>();\n const usedIds = new Set<string>();\n let nextGeneratedId = 0;\n\n function collectExplicitIds(\n node: ElementNode,\n seen = new WeakSet<object>()\n ): void {\n const nodeObject = node as unknown as object;\n if (seen.has(nodeObject)) {\n return;\n }\n seen.add(nodeObject);\n\n const n = node as unknown as InternalElementNode;\n if (n.id !== undefined) {\n const existing = explicitIds.get(n.id);\n if (existing && existing !== nodeObject) {\n throw new Error(`Duplicate element id: ${n.id}`);\n }\n explicitIds.set(n.id, nodeObject);\n usedIds.add(n.id);\n }\n\n n.children?.forEach(child => collectExplicitIds(child, seen));\n }\n\n function allocateGeneratedId(): string {\n let id: string;\n do {\n id = `element-${nextGeneratedId}`;\n nextGeneratedId += 1;\n } while (usedIds.has(id));\n\n usedIds.add(id);\n return id;\n }\n\n function elementId(node: ElementNode): string {\n const nodeObject = node as unknown as object;\n const existing = elementIds.get(nodeObject);\n if (existing) {\n return existing;\n }\n\n const n = node as unknown as InternalElementNode;\n const id = n.id ?? allocateGeneratedId();\n elementIds.set(nodeObject, id);\n return id;\n }\n\n function flatten(node: ElementNode): string {\n const nodeObject = node as unknown as object;\n const id = elementId(node);\n if (emitted.has(nodeObject)) {\n return id;\n }\n emitted.add(nodeObject);\n\n const n = node as unknown as InternalElementNode;\n const childIds: string[] | undefined = n.children\n ? n.children.map(child => flatten(child))\n : undefined;\n\n const flatElement: FlatUIElement = {\n type: n.type,\n props: n.props,\n };\n\n if (childIds && childIds.length > 0) {\n flatElement.children = childIds;\n }\n if (n.visible !== undefined) {\n flatElement.visible = n.visible;\n }\n if (n.on) {\n flatElement.on = n.on;\n }\n if (n.watch) {\n flatElement.watch = n.watch;\n }\n if (n.repeat) {\n flatElement.repeat = n.repeat;\n }\n\n elements[id] = flatElement;\n return id;\n }\n\n collectExplicitIds(root);\n const rootId = flatten(root);\n\n return JSON.parse(\n JSON.stringify({\n root: rootId,\n elements,\n state,\n })\n ) as FlatSpec;\n}\n\nexport interface SpecContext<TState> {\n /** Read-only reference to a state path. */\n $state<P extends StatePaths<TState>>(path: P): StateRef<ValueAt<TState, P>>;\n\n /** Two-way binding to a state path. */\n $bindState<P extends StatePaths<TState>>(\n path: P\n ): BindStateRef<ValueAt<TState, P>>;\n\n /** String template expression (tagged template literal). */\n $template(\n strings: TemplateStringsArray,\n ...values: TemplateInterpolation[]\n ): TemplateRef;\n\n /** Conditional expression with typed branches. */\n $cond<T>(\n condition: VisibilityBinding | boolean,\n then: PropValue<T>,\n else_: PropValue<T>\n ): CondRef<T>;\n\n /**\n * Create a repeat binding for an array state path.\n * Returns [RepeatBinding, ItemAccessor<T>].\n */\n repeat<P extends ArrayPaths<TState>>(\n statePath: P,\n key?: string\n ): [RepeatBinding, ItemAccessor<ArrayItemAt<TState, P>>];\n\n /** Flatten an element tree into the flat spec format. */\n render(root: ElementNode): FlatSpec;\n}\n\nexport function createSpec<TState extends object>(config: {\n state: TState;\n}): SpecContext<TState> {\n const initialState = config.state;\n\n function $state(path: string): unknown {\n return { $state: path };\n }\n\n function $bindState(path: string): unknown {\n return { $bindState: path };\n }\n\n /**\n * Build a template string from a tagged template literal.\n * Converts expression refs ($state, $item, $index) into template variables.\n */\n function $template(\n strings: TemplateStringsArray,\n ...values: unknown[]\n ): unknown {\n let result = strings[0];\n for (let i = 0; i < values.length; i += 1) {\n const val = values[i];\n if (!val || typeof val !== 'object') {\n result += '';\n } else if ('$state' in val) {\n result += `\\${${val.$state}}`;\n } else if ('$item' in val) {\n result += `\\${$item.${val.$item}}`;\n } else if ('$index' in val) {\n result += '${$index}';\n }\n result += strings[i + 1];\n }\n return { $template: result };\n }\n\n function $cond(condition: unknown, then: unknown, else_: unknown): unknown {\n return { $cond: condition, $then: then, $else: else_ };\n }\n\n /**\n * Create a repeat binding for array iteration.\n * Returns [RepeatBinding, ItemAccessor] tuple.\n *\n * Type safety is enforced at the createSpec boundary through type parameters.\n * Internal implementations use `any` to work with the opaque branded types.\n */\n function repeat(\n statePath: string,\n key?: string\n ): [unknown, ItemAccessor<unknown>] {\n const repeatBinding = { statePath, key } as unknown as RepeatBinding;\n\n const itemAccessor: ItemAccessor<unknown> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n $(path: string): any {\n return { $item: path };\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n $bind(path: string): any {\n return { $bindItem: path };\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n $index(): any {\n return { $index: true };\n },\n };\n\n return [repeatBinding, itemAccessor];\n }\n\n function render(root: ElementNode): FlatSpec {\n return renderElementTree(root, initialState);\n }\n\n return {\n $state,\n $bindState,\n $template,\n $cond,\n repeat,\n render,\n } as unknown as SpecContext<TState>;\n}\n"],"names":["renderElementTree","root","state","elements","explicitIds","elementIds","emitted","usedIds","nextGeneratedId","collectExplicitIds","node","seen","_a","nodeObject","n","existing","child","allocateGeneratedId","id","elementId","flatten","childIds","flatElement","rootId","createSpec","config","initialState","$state","path","$bindState","$template","strings","values","result","i","val","$cond","condition","then","else_","repeat","statePath","key","render"],"mappings":"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"}
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./core/spec.cjs"),o=require("./core/component-utils.cjs"),r=require("./core/action-utils.cjs"),e=require("./core/conditions.cjs");exports.createSpec=t.createSpec;exports.buildNode=o.buildNode;exports.buildAction=r.buildAction;exports.$and=e.$and;exports.$or=e.$or;exports.$when=e.$when;exports.and_=e.$and;exports.equals=e.equals;exports.falsy=e.falsy;exports.gt=e.gt;exports.gte=e.gte;exports.lt=e.lt;exports.lte=e.lte;exports.neq=e.neq;exports.not_=e.not_;exports.or_=e.$or;exports.truthy=e.truthy;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Mobile SDK authoring utilities.
3
+ *
4
+ * Mobile catalog subpaths will be added as generated mobile catalogs arrive.
5
+ */
6
+ export { createSpec, buildNode, buildAction, $when, equals, neq, gt, gte, lt, lte, truthy, falsy, not_, $and, $or, and_, or_, } from './core/index';
7
+ export type { SpecContext, FlatSpec, FlatUIElement, ItemAccessor, ComponentInputs, ComponentInputsOptionalProps, InternalElementNode, ActionBinding, ActionConfirm, ActionOptions, ActionOnSuccess, ActionOnError, PropValue, WrapWithPropValue, StateRef, BindStateRef, ItemRef, BindItemRef, IndexRef, TemplateRef, CondRef, TemplateInterpolation, ActionParamValue, WrapWithActionParamValue, VisibilityBinding, ComparisonOps, StatePaths, ValueAt, ArrayPaths, ArrayItemAt, ItemPaths, ItemValueAt, ElementNode, RepeatBinding, } from './core/index';
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ import { createSpec as r } from "./core/spec.js";
2
+ import { buildNode as a } from "./core/component-utils.js";
3
+ import { buildAction as d } from "./core/action-utils.js";
4
+ import { $and as f, $or as p, $when as $, $and as m, equals as s, falsy as u, gt as x, gte as c, lt as i, lte as _, neq as b, not_ as g, $or as h, truthy as q } from "./core/conditions.js";
5
+ export {
6
+ f as $and,
7
+ p as $or,
8
+ $ as $when,
9
+ m as and_,
10
+ d as buildAction,
11
+ a as buildNode,
12
+ r as createSpec,
13
+ s as equals,
14
+ u as falsy,
15
+ x as gt,
16
+ c as gte,
17
+ i as lt,
18
+ _ as lte,
19
+ b as neq,
20
+ g as not_,
21
+ h as or_,
22
+ q as truthy
23
+ };
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@rippling/pebble-sdui-mobile",
3
+ "version": "0.2.0",
4
+ "description": "Type-safe TypeScript mobile SDK for authoring json-render specs",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+ssh://git@github.com/Rippling/pebble-kit.git",
8
+ "directory": "packages/typescript/sdui-mobile"
9
+ },
10
+ "type": "module",
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js",
18
+ "require": "./dist/index.cjs"
19
+ }
20
+ },
21
+ "imports": {
22
+ "#core/*": {
23
+ "types": "./dist/core/*.d.ts",
24
+ "import": "./dist/core/*.js",
25
+ "require": "./dist/core/*.cjs"
26
+ }
27
+ },
28
+ "scripts": {
29
+ "build": "npm run build:self",
30
+ "build:self": "vite build",
31
+ "typecheck": "npm run typecheck:self",
32
+ "typecheck:self": "tsc --noEmit"
33
+ },
34
+ "dependencies": {
35
+ "ajv": "^8.17.0"
36
+ },
37
+ "files": [
38
+ "dist"
39
+ ]
40
+ }