@unisim/sdk 0.229.0 → 0.230.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/phone/SwipeRow.d.ts +62 -0
- package/dist/phone/SwipeRow.d.ts.map +1 -0
- package/dist/phone/SwipeRow.js +192 -0
- package/dist/phone/SwipeRow.js.map +1 -0
- package/dist/phone/TabReorder.d.ts +125 -0
- package/dist/phone/TabReorder.d.ts.map +1 -0
- package/dist/phone/TabReorder.js +245 -0
- package/dist/phone/TabReorder.js.map +1 -0
- package/dist/phone/hold.d.ts +87 -0
- package/dist/phone/hold.d.ts.map +1 -0
- package/dist/phone/hold.js +250 -0
- package/dist/phone/hold.js.map +1 -0
- package/dist/phone/index.d.ts +12 -0
- package/dist/phone/index.d.ts.map +1 -1
- package/dist/phone/index.js +12 -0
- package/dist/phone/index.js.map +1 -1
- package/dist/phone/listCopy.d.ts +28 -0
- package/dist/phone/listCopy.d.ts.map +1 -0
- package/dist/phone/listCopy.js +115 -0
- package/dist/phone/listCopy.js.map +1 -0
- package/dist/phone/listStyles.d.ts +4 -0
- package/dist/phone/listStyles.d.ts.map +1 -0
- package/dist/phone/listStyles.js +105 -0
- package/dist/phone/listStyles.js.map +1 -0
- package/dist/phone/swipeGeometry.d.ts +62 -0
- package/dist/phone/swipeGeometry.d.ts.map +1 -0
- package/dist/phone/swipeGeometry.js +96 -0
- package/dist/phone/swipeGeometry.js.map +1 -0
- package/dist/phone/tabOrder.d.ts +19 -0
- package/dist/phone/tabOrder.d.ts.map +1 -0
- package/dist/phone/tabOrder.js +46 -0
- package/dist/phone/tabOrder.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much of the row an action takes when it is open, in px. Comfortably over
|
|
3
|
+
* the 44px touch target, because one of these deletes something.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SWIPE_ACTION_WIDTH = 96;
|
|
6
|
+
/**
|
|
7
|
+
* How far a finger travels before the gesture picks an axis. Below it nothing
|
|
8
|
+
* moves, so a tap (never perfectly still) does not nudge the row and a scroll
|
|
9
|
+
* that starts with a little sideways drift stays a scroll.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SWIPE_AXIS_SLOP = 8;
|
|
12
|
+
/**
|
|
13
|
+
* How much further a finger must travel, past an action already showing, to
|
|
14
|
+
* run it (BlackBook, owner ask 2026-11-11: "if you swipe again in that
|
|
15
|
+
* direction then do that action e.g. delete"). Only a SECOND swipe on a row
|
|
16
|
+
* already open on that side: a single long flick from closed only reveals.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SWIPE_FIRE_DISTANCE = 56;
|
|
19
|
+
/** How far past its open position the row may be dragged to show it will fire. */
|
|
20
|
+
export declare const SWIPE_FIRE_TRAVEL = 40;
|
|
21
|
+
export type SwipeAxis = 'none' | 'x' | 'y';
|
|
22
|
+
/** Which edge an action sits on, and so which one is showing. */
|
|
23
|
+
export type SwipeSide = 'left' | 'right';
|
|
24
|
+
/**
|
|
25
|
+
* How far the row may travel each way. A side with no action is 0: an absent
|
|
26
|
+
* action is a wall, not a gap that slides open onto nothing.
|
|
27
|
+
*/
|
|
28
|
+
export interface SwipeWidths {
|
|
29
|
+
left: number;
|
|
30
|
+
right: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Which way is this gesture going? Decided once per touch, at the first
|
|
34
|
+
* movement past the slop, and never revisited.
|
|
35
|
+
*/
|
|
36
|
+
export declare function decideSwipeAxis(dx: number, dy: number, slop?: number): SwipeAxis;
|
|
37
|
+
/**
|
|
38
|
+
* Where the row sits mid-drag: `base` plus the finger, clamped to the track.
|
|
39
|
+
* Positive: moved right, the LEFT action showing.
|
|
40
|
+
*/
|
|
41
|
+
export declare function swipeDragOffset(base: number, dx: number, widths?: SwipeWidths): number;
|
|
42
|
+
/**
|
|
43
|
+
* On release: which action is left showing, if any? Half the action's own
|
|
44
|
+
* width, so the same gesture opens and closes with no dead zone.
|
|
45
|
+
*/
|
|
46
|
+
export declare function swipeSettles(offset: number, widths?: SwipeWidths): SwipeSide | null;
|
|
47
|
+
/** Where a row rests for a given open side. The inverse of {@link swipeSettles}. */
|
|
48
|
+
export declare function swipeRestingOffset(open: SwipeSide | null, widths?: SwipeWidths): number;
|
|
49
|
+
/**
|
|
50
|
+
* Does this release run the action showing on `open`'s side? Only when the
|
|
51
|
+
* touch began with that side already open and the finger carried on the same
|
|
52
|
+
* way by {@link SWIPE_FIRE_DISTANCE}.
|
|
53
|
+
*/
|
|
54
|
+
export declare function swipeFiresOnRelease(open: SwipeSide | null, dx: number, widths?: SwipeWidths): SwipeSide | null;
|
|
55
|
+
/**
|
|
56
|
+
* Where the row sits mid-drag when it started open: as
|
|
57
|
+
* {@link swipeDragOffset}, but it may carry on past the open edge by up to
|
|
58
|
+
* {@link SWIPE_FIRE_TRAVEL} (at half the finger's speed), so the second swipe
|
|
59
|
+
* visibly goes somewhere.
|
|
60
|
+
*/
|
|
61
|
+
export declare function swipeDragOffsetFromOpen(open: SwipeSide | null, base: number, dx: number, widths?: SwipeWidths): number;
|
|
62
|
+
//# sourceMappingURL=swipeGeometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipeGeometry.d.ts","sourceRoot":"","sources":["../../src/phone/swipeGeometry.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC;;;;GAIG;AACH,eAAO,MAAM,eAAe,IAAI,CAAA;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAEnC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,GAAG,GAAG,GAAG,CAAA;AAE1C,iEAAiE;AACjE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,CAAA;AAExC;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,SAAkB,GAAG,SAAS,CAGzF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,GAAE,WAAwB,GAAG,MAAM,CAElG;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,WAAwB,GAAG,SAAS,GAAG,IAAI,CAI/F;AAED,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,EAAE,MAAM,GAAE,WAAwB,GAAG,MAAM,CAInG;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,GAAE,WAAwB,GAAG,SAAS,GAAG,IAAI,CAI1H;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,GAAE,WAAwB,GAAG,MAAM,CAKlI"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// The numbers behind swiping a row sideways (<SwipeRow>, BRANDING.md ▸ "A
|
|
2
|
+
// deletable row swipes: delete one way, a second action the other").
|
|
3
|
+
//
|
|
4
|
+
// Moved here in 0.230.0 from Universal BlackBook's `src/lib/swipe.ts`, the
|
|
5
|
+
// reference the rule names; Universal PDF's `SwipeRow` and Workplace Assess's
|
|
6
|
+
// `native/swipe.jsx` carried the same reveal-and-settle with the numbers
|
|
7
|
+
// inlined. Kept apart from the component because it is the part that can be
|
|
8
|
+
// wrong in a way nobody notices: the numbers decide whether a gesture people
|
|
9
|
+
// make with their thumb, without looking, does what they meant.
|
|
10
|
+
//
|
|
11
|
+
// ⚠️ Two directions, and they are named by the EDGE the button sits on, never
|
|
12
|
+
// by the way the finger moves. Swiping LEFT moves the row left and uncovers
|
|
13
|
+
// the button on the RIGHT edge; swiping RIGHT uncovers the LEFT.
|
|
14
|
+
/**
|
|
15
|
+
* How much of the row an action takes when it is open, in px. Comfortably over
|
|
16
|
+
* the 44px touch target, because one of these deletes something.
|
|
17
|
+
*/
|
|
18
|
+
export const SWIPE_ACTION_WIDTH = 96;
|
|
19
|
+
/**
|
|
20
|
+
* How far a finger travels before the gesture picks an axis. Below it nothing
|
|
21
|
+
* moves, so a tap (never perfectly still) does not nudge the row and a scroll
|
|
22
|
+
* that starts with a little sideways drift stays a scroll.
|
|
23
|
+
*/
|
|
24
|
+
export const SWIPE_AXIS_SLOP = 8;
|
|
25
|
+
/**
|
|
26
|
+
* How much further a finger must travel, past an action already showing, to
|
|
27
|
+
* run it (BlackBook, owner ask 2026-11-11: "if you swipe again in that
|
|
28
|
+
* direction then do that action e.g. delete"). Only a SECOND swipe on a row
|
|
29
|
+
* already open on that side: a single long flick from closed only reveals.
|
|
30
|
+
*/
|
|
31
|
+
export const SWIPE_FIRE_DISTANCE = 56;
|
|
32
|
+
/** How far past its open position the row may be dragged to show it will fire. */
|
|
33
|
+
export const SWIPE_FIRE_TRAVEL = 40;
|
|
34
|
+
const RIGHT_ONLY = { left: 0, right: SWIPE_ACTION_WIDTH };
|
|
35
|
+
/**
|
|
36
|
+
* Which way is this gesture going? Decided once per touch, at the first
|
|
37
|
+
* movement past the slop, and never revisited.
|
|
38
|
+
*/
|
|
39
|
+
export function decideSwipeAxis(dx, dy, slop = SWIPE_AXIS_SLOP) {
|
|
40
|
+
if (Math.abs(dx) < slop && Math.abs(dy) < slop)
|
|
41
|
+
return 'none';
|
|
42
|
+
return Math.abs(dx) > Math.abs(dy) ? 'x' : 'y';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Where the row sits mid-drag: `base` plus the finger, clamped to the track.
|
|
46
|
+
* Positive: moved right, the LEFT action showing.
|
|
47
|
+
*/
|
|
48
|
+
export function swipeDragOffset(base, dx, widths = RIGHT_ONLY) {
|
|
49
|
+
return Math.min(widths.left, Math.max(-widths.right, base + dx));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* On release: which action is left showing, if any? Half the action's own
|
|
53
|
+
* width, so the same gesture opens and closes with no dead zone.
|
|
54
|
+
*/
|
|
55
|
+
export function swipeSettles(offset, widths = RIGHT_ONLY) {
|
|
56
|
+
if (offset <= -widths.right / 2 && widths.right > 0)
|
|
57
|
+
return 'right';
|
|
58
|
+
if (offset >= widths.left / 2 && widths.left > 0)
|
|
59
|
+
return 'left';
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/** Where a row rests for a given open side. The inverse of {@link swipeSettles}. */
|
|
63
|
+
export function swipeRestingOffset(open, widths = RIGHT_ONLY) {
|
|
64
|
+
if (open === 'right')
|
|
65
|
+
return -widths.right;
|
|
66
|
+
if (open === 'left')
|
|
67
|
+
return widths.left;
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Does this release run the action showing on `open`'s side? Only when the
|
|
72
|
+
* touch began with that side already open and the finger carried on the same
|
|
73
|
+
* way by {@link SWIPE_FIRE_DISTANCE}.
|
|
74
|
+
*/
|
|
75
|
+
export function swipeFiresOnRelease(open, dx, widths = RIGHT_ONLY) {
|
|
76
|
+
if (open === 'right' && widths.right > 0 && dx <= -SWIPE_FIRE_DISTANCE)
|
|
77
|
+
return 'right';
|
|
78
|
+
if (open === 'left' && widths.left > 0 && dx >= SWIPE_FIRE_DISTANCE)
|
|
79
|
+
return 'left';
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Where the row sits mid-drag when it started open: as
|
|
84
|
+
* {@link swipeDragOffset}, but it may carry on past the open edge by up to
|
|
85
|
+
* {@link SWIPE_FIRE_TRAVEL} (at half the finger's speed), so the second swipe
|
|
86
|
+
* visibly goes somewhere.
|
|
87
|
+
*/
|
|
88
|
+
export function swipeDragOffsetFromOpen(open, base, dx, widths = RIGHT_ONLY) {
|
|
89
|
+
const raw = base + dx;
|
|
90
|
+
if (open === 'right' && raw < -widths.right)
|
|
91
|
+
return -widths.right - Math.min(SWIPE_FIRE_TRAVEL, (-widths.right - raw) / 2);
|
|
92
|
+
if (open === 'left' && raw > widths.left)
|
|
93
|
+
return widths.left + Math.min(SWIPE_FIRE_TRAVEL, (raw - widths.left) / 2);
|
|
94
|
+
return swipeDragOffset(base, dx, widths);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=swipeGeometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipeGeometry.js","sourceRoot":"","sources":["../../src/phone/swipeGeometry.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** One tab moved to a new place (`to` is its index in the result). */
|
|
2
|
+
export declare function moveTab<T>(order: readonly T[], tab: T, to: number): T[];
|
|
3
|
+
/**
|
|
4
|
+
* A stored order made whole against the app's tabs (`defaults`, in their
|
|
5
|
+
* default order): unknown names dropped, each tab once, and a tab missing from
|
|
6
|
+
* it (one added since the order was saved) put back just after its neighbour
|
|
7
|
+
* in the default order. Hidden tabs stay in the order, so a tab switched back
|
|
8
|
+
* on returns to its place.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normaliseTabOrder<T extends string>(raw: unknown, defaults: readonly T[]): T[];
|
|
11
|
+
/** Is this the default order? */
|
|
12
|
+
export declare function isDefaultTabOrder<T>(order: readonly T[], defaults: readonly T[]): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The shown tabs in a new order, written back into the whole order: hidden
|
|
15
|
+
* tabs keep their slots, the shown ones fill the rest in their new sequence.
|
|
16
|
+
* What a drag on the tab bar (which shows only the shown tabs) saves.
|
|
17
|
+
*/
|
|
18
|
+
export declare function withShownOrder<T>(full: readonly T[], shown: readonly T[]): T[];
|
|
19
|
+
//# sourceMappingURL=tabOrder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabOrder.d.ts","sourceRoot":"","sources":["../../src/phone/tabOrder.ts"],"names":[],"mappings":"AAQA,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,EAAE,CAIvE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,CAS7F;AAED,iCAAiC;AACjC,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,OAAO,CAEzF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,CAI9E"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// The tab order as data (BRANDING.md ▸ "Tabs reorder: hold and drag"): moving
|
|
2
|
+
// one tab, folding a stored order back to the tabs the app has now, and
|
|
3
|
+
// writing the shown tabs' new order back around the hidden ones.
|
|
4
|
+
//
|
|
5
|
+
// Moved here in 0.230.0 from Universal BlackBook's `src/lib/tabs.ts`, made
|
|
6
|
+
// generic over the app's tab names. Pure, so it runs anywhere (a store's
|
|
7
|
+
// migration, a sync merge, a test).
|
|
8
|
+
/** One tab moved to a new place (`to` is its index in the result). */
|
|
9
|
+
export function moveTab(order, tab, to) {
|
|
10
|
+
const rest = order.filter((t) => t !== tab);
|
|
11
|
+
rest.splice(Math.max(0, Math.min(to, rest.length)), 0, tab);
|
|
12
|
+
return rest;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A stored order made whole against the app's tabs (`defaults`, in their
|
|
16
|
+
* default order): unknown names dropped, each tab once, and a tab missing from
|
|
17
|
+
* it (one added since the order was saved) put back just after its neighbour
|
|
18
|
+
* in the default order. Hidden tabs stay in the order, so a tab switched back
|
|
19
|
+
* on returns to its place.
|
|
20
|
+
*/
|
|
21
|
+
export function normaliseTabOrder(raw, defaults) {
|
|
22
|
+
const known = Array.isArray(raw) ? raw.filter((x) => defaults.includes(x)) : [];
|
|
23
|
+
const out = [...new Set(known)];
|
|
24
|
+
defaults.forEach((t, i) => {
|
|
25
|
+
if (out.includes(t))
|
|
26
|
+
return;
|
|
27
|
+
const before = i > 0 ? out.indexOf(defaults[i - 1]) : -1;
|
|
28
|
+
out.splice(before + 1, 0, t);
|
|
29
|
+
});
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/** Is this the default order? */
|
|
33
|
+
export function isDefaultTabOrder(order, defaults) {
|
|
34
|
+
return order.length === defaults.length && order.every((t, i) => t === defaults[i]);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The shown tabs in a new order, written back into the whole order: hidden
|
|
38
|
+
* tabs keep their slots, the shown ones fill the rest in their new sequence.
|
|
39
|
+
* What a drag on the tab bar (which shows only the shown tabs) saves.
|
|
40
|
+
*/
|
|
41
|
+
export function withShownOrder(full, shown) {
|
|
42
|
+
const on = new Set(shown);
|
|
43
|
+
let k = 0;
|
|
44
|
+
return full.map((t) => (on.has(t) ? shown[k++] : t));
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=tabOrder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabOrder.js","sourceRoot":"","sources":["../../src/phone/tabOrder.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,wEAAwE;AACxE,iEAAiE;AACjE,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,oCAAoC;AAEpC,sEAAsE;AACtE,MAAM,UAAU,OAAO,CAAI,KAAmB,EAAE,GAAM,EAAE,EAAU;IAChE,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAA;IAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;IAC3D,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAmB,GAAY,EAAE,QAAsB;IACtF,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAU,EAAE,CAAE,QAA+B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/G,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/B,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACxB,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;YAAE,OAAM;QAC3B,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACzD,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,iCAAiC;AACjC,MAAM,UAAU,iBAAiB,CAAI,KAAmB,EAAE,QAAsB;IAC9E,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;AACrF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAI,IAAkB,EAAE,KAAmB;IACvE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;IACzB,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unisim/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.230.0",
|
|
4
4
|
"description": "Shared React SDK for the Universal Suite — auth, entitlements, usage telemetry, changelog, org admin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Universal Simulation Ltd",
|
|
@@ -139,6 +139,7 @@
|
|
|
139
139
|
"test:label-fit": "npm run build && node tests/label-fit.mjs",
|
|
140
140
|
"test:pull-drawer": "npm run build && node tests/pull-drawer.browser.mjs",
|
|
141
141
|
"test:phone-kit": "npm run build && node tests/phone-kit.browser.mjs",
|
|
142
|
+
"test:phone-lists": "npm run build && node tests/phone-lists.browser.mjs",
|
|
142
143
|
"test:transfer": "npm run build && node tests/transfer.mjs"
|
|
143
144
|
},
|
|
144
145
|
"dependencies": {
|