@rulecms/widget-vue 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +36 -36
- package/dist/index.d.ts +218 -10
- package/dist/index.js +1440 -1146
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,28 @@ declare type __VLS_Props = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
declare type __VLS_Props_2 = {
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Staging/production: published key (`{environmentId}---{widgetKey}`).
|
|
19
|
+
* Development (`dev.` token): the live widget key itself (`widget-...`).
|
|
20
|
+
* Omit when `rulesetPublishedKey` is set — the ruleset picks the widget.
|
|
21
|
+
*/
|
|
22
|
+
publishedKey?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Staging/production: ruleset published key (`{environmentId}---ruleset-…`).
|
|
25
|
+
* Development (`dev.` token): the `ruleset-…` key.
|
|
26
|
+
*/
|
|
27
|
+
rulesetPublishedKey?: string;
|
|
28
|
+
/** Any JSON object sent to the resolve endpoint. The server flattens nested objects. */
|
|
29
|
+
params?: WidgetSelectionParams;
|
|
30
|
+
/**
|
|
31
|
+
* `false` skips minting an anonymous id. A string is used as `params.anonId`.
|
|
32
|
+
* Omit it in the browser and the widget stores one in `localStorage`.
|
|
33
|
+
*/
|
|
34
|
+
anonymousId?: string | false;
|
|
35
|
+
/** Plain published-key GET used when the resolve request fails with a network error or 5xx. */
|
|
36
|
+
fallbackPublishedKey?: string;
|
|
37
|
+
/** Defaults to `text/plain` so the browser skips the CORS preflight. */
|
|
38
|
+
contentType?: WidgetResolveContentType;
|
|
18
39
|
token?: string;
|
|
19
40
|
endpoint?: string;
|
|
20
41
|
mode?: 'client-fetch' | 'pre-fetched';
|
|
@@ -22,6 +43,13 @@ declare type __VLS_Props_2 = {
|
|
|
22
43
|
libraries?: LibraryRegistrationMap;
|
|
23
44
|
componentProps?: ComponentPropsMap;
|
|
24
45
|
mounts?: MountsMap;
|
|
46
|
+
/**
|
|
47
|
+
* Values copied onto every Text as `placeholderValues`, unless that column's
|
|
48
|
+
* `componentProps` entry already sets the key (including `null` to opt out).
|
|
49
|
+
*/
|
|
50
|
+
placeholderValues?: unknown;
|
|
51
|
+
/** Called when a ruleset resolve returns a selection. */
|
|
52
|
+
onSelection?: (selection: WidgetSelection) => void;
|
|
25
53
|
};
|
|
26
54
|
|
|
27
55
|
declare type __VLS_Props_3 = {
|
|
@@ -36,6 +64,7 @@ declare type __VLS_Props_3 = {
|
|
|
36
64
|
plugins: RenderComponentPlugins;
|
|
37
65
|
componentProps?: ComponentPropsMap;
|
|
38
66
|
mounts?: MountsMap;
|
|
67
|
+
placeholderValues?: unknown;
|
|
39
68
|
};
|
|
40
69
|
|
|
41
70
|
declare type __VLS_Props_4 = {
|
|
@@ -51,6 +80,7 @@ declare type __VLS_Props_4 = {
|
|
|
51
80
|
plugins: RenderComponentPlugins;
|
|
52
81
|
componentProps?: ComponentPropsMap;
|
|
53
82
|
mounts?: MountsMap;
|
|
83
|
+
placeholderValues?: unknown;
|
|
54
84
|
ancestorColumnIds?: string[];
|
|
55
85
|
};
|
|
56
86
|
|
|
@@ -67,6 +97,7 @@ declare type __VLS_Props_5 = {
|
|
|
67
97
|
deviceDisplayType: keyof typeof DeviceDisplayTypes;
|
|
68
98
|
componentProps?: ComponentPropsMap;
|
|
69
99
|
mounts?: MountsMap;
|
|
100
|
+
placeholderValues?: unknown;
|
|
70
101
|
ancestorColumnIds?: string[];
|
|
71
102
|
};
|
|
72
103
|
|
|
@@ -78,6 +109,7 @@ declare type __VLS_Props_6 = {
|
|
|
78
109
|
plugins: RenderComponentPlugins;
|
|
79
110
|
componentProps?: ComponentPropsMap;
|
|
80
111
|
mounts?: MountsMap;
|
|
112
|
+
placeholderValues?: unknown;
|
|
81
113
|
scopeIdInput?: string;
|
|
82
114
|
};
|
|
83
115
|
|
|
@@ -92,6 +124,8 @@ declare type __VLS_Props_7 = {
|
|
|
92
124
|
[key: string]: any;
|
|
93
125
|
};
|
|
94
126
|
widgetInstanceProps?: WidgetInstanceProps;
|
|
127
|
+
pageViewType?: PageViewType;
|
|
128
|
+
columnPath?: string;
|
|
95
129
|
mounts?: MountsMap;
|
|
96
130
|
};
|
|
97
131
|
|
|
@@ -293,6 +327,19 @@ export declare interface BuildWidgetFetchUrlParams {
|
|
|
293
327
|
endpoint?: string;
|
|
294
328
|
}
|
|
295
329
|
|
|
330
|
+
/**
|
|
331
|
+
* Builds the ruleset resolve URL. The token, ruleset key and params travel in
|
|
332
|
+
* the POST body, so the URL carries no query string. Development tokens
|
|
333
|
+
* (`dev.…`) hit the draft resolve route; everything else uses the published one.
|
|
334
|
+
*/
|
|
335
|
+
export declare function buildWidgetResolveUrl({ token, endpoint, }: BuildWidgetResolveUrlParams): string;
|
|
336
|
+
|
|
337
|
+
export declare interface BuildWidgetResolveUrlParams {
|
|
338
|
+
token: string;
|
|
339
|
+
/** Optional override. Defaults by token: rulecms.com (dev) or widget-cache (published). */
|
|
340
|
+
endpoint?: string;
|
|
341
|
+
}
|
|
342
|
+
|
|
296
343
|
export declare interface ChildCollection {
|
|
297
344
|
publishedKey: string;
|
|
298
345
|
name: string;
|
|
@@ -304,6 +351,9 @@ export declare interface ChildCollection {
|
|
|
304
351
|
lastPublishedAt: string;
|
|
305
352
|
}
|
|
306
353
|
|
|
354
|
+
/** Drops the in-process published-widget cache. Tests call this between cases. */
|
|
355
|
+
export declare function clearPublishedWidgetFetchCache(): void;
|
|
356
|
+
|
|
307
357
|
/**
|
|
308
358
|
* A Cloudinary transformation component as an object, e.g.
|
|
309
359
|
* `{ c: 'fill', g: 'auto' }` serializes to `c_fill,g_auto`.
|
|
@@ -503,6 +553,13 @@ export declare const DEFAULT_CLOUDINARY_CLOUD_NAME = "rulecms";
|
|
|
503
553
|
*/
|
|
504
554
|
export declare const DEFAULT_LIBRARY_ID = "default";
|
|
505
555
|
|
|
556
|
+
/**
|
|
557
|
+
* How long a published-token GET stays in the in-process cache when the caller
|
|
558
|
+
* sets no cache policy. Vue has no Next.js `next.revalidate`; this is the
|
|
559
|
+
* same 60-second default `@rulecms/widget-react` applies on the server.
|
|
560
|
+
*/
|
|
561
|
+
export declare const DEFAULT_PUBLISHED_WIDGET_CACHE_MS = 60000;
|
|
562
|
+
|
|
506
563
|
export declare const DEFAULT_ROW_GAP = "var(--sl-spacing-x-small)";
|
|
507
564
|
|
|
508
565
|
export declare type DefaultAttributeValue = {
|
|
@@ -533,6 +590,9 @@ export declare const DEV_CLIENT_TOKEN_PREFIX = "dev.";
|
|
|
533
590
|
/** Live draft client API path — no cache; reads the widget table directly. */
|
|
534
591
|
export declare const DEV_WIDGET_API_PATH = "/api/v1/c/dev/widget/get";
|
|
535
592
|
|
|
593
|
+
/** Live draft ruleset resolve path (POST) — compiles the draft ruleset in-process. */
|
|
594
|
+
export declare const DEV_WIDGET_RESOLVE_API_PATH = "/api/v1/c/dev/widget/resolve";
|
|
595
|
+
|
|
536
596
|
export declare type DeviceDisplayType = 'phone' | 'tablet' | 'desktop';
|
|
537
597
|
|
|
538
598
|
export declare const DeviceDisplayTypes: {
|
|
@@ -645,27 +705,56 @@ declare interface EditPlugin {
|
|
|
645
705
|
*/
|
|
646
706
|
export declare const EMBEDDED_KEY_SEPARATOR = "___";
|
|
647
707
|
|
|
648
|
-
/**
|
|
708
|
+
/**
|
|
709
|
+
* Fetch widget JSON on the server (or at build time) and return render-ready
|
|
710
|
+
* data. Pass `publishedKey` for one widget, or `rulesetPublishedKey` + `params`
|
|
711
|
+
* to let a ruleset choose (the result then carries `selection`).
|
|
712
|
+
*/
|
|
649
713
|
export declare function fetchRuleCMSWidget(params: FetchRuleCMSWidgetParams): Promise<RuleCMSWidgetData>;
|
|
650
714
|
|
|
715
|
+
declare interface FetchRuleCMSWidgetBaseParams {
|
|
716
|
+
token: string;
|
|
717
|
+
/**
|
|
718
|
+
* Optional API origin override. Omit in apps — defaults to rulecms.com for
|
|
719
|
+
* `dev.` tokens and widget-cache for published tokens.
|
|
720
|
+
*/
|
|
721
|
+
endpoint?: string;
|
|
722
|
+
/**
|
|
723
|
+
* Pass-through to `fetch`. Published-token GETs are cached in-process for
|
|
724
|
+
* 60 seconds unless `cache` is `no-store`, `reload`, or `no-cache`. `dev.`
|
|
725
|
+
* tokens always use `cache: 'no-store'` and are never cached here. A
|
|
726
|
+
* `rulesetPublishedKey` resolve is a POST and is never cached.
|
|
727
|
+
*/
|
|
728
|
+
fetchOptions?: RequestInit;
|
|
729
|
+
}
|
|
730
|
+
|
|
651
731
|
export declare class FetchRuleCMSWidgetError extends Error {
|
|
652
732
|
readonly status?: number;
|
|
653
733
|
constructor(message: string, status?: number);
|
|
654
734
|
}
|
|
655
735
|
|
|
656
|
-
export declare
|
|
736
|
+
export declare type FetchRuleCMSWidgetParams = FetchRuleCMSWidgetPublishedKeyParams | FetchRuleCMSWidgetRulesetParams;
|
|
737
|
+
|
|
738
|
+
/** Fetch one widget by key through the plain GET path. */
|
|
739
|
+
declare interface FetchRuleCMSWidgetPublishedKeyParams extends FetchRuleCMSWidgetBaseParams {
|
|
657
740
|
/**
|
|
658
741
|
* Published key for staging/production tokens, or the live widget key when
|
|
659
742
|
* using a `dev.`-prefixed Development token.
|
|
660
743
|
*/
|
|
661
744
|
publishedKey: string;
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
745
|
+
rulesetPublishedKey?: never;
|
|
746
|
+
params?: never;
|
|
747
|
+
fallbackPublishedKey?: never;
|
|
748
|
+
contentType?: never;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Let a published ruleset pick the widget from `params` (POST resolve). The
|
|
753
|
+
* server never invents an anonymous id — pass `params.anonId` yourself when
|
|
754
|
+
* experiments should bucket a known visitor.
|
|
755
|
+
*/
|
|
756
|
+
declare interface FetchRuleCMSWidgetRulesetParams extends FetchRuleCMSWidgetBaseParams, WidgetResolveRequestOptions {
|
|
757
|
+
publishedKey?: never;
|
|
669
758
|
}
|
|
670
759
|
|
|
671
760
|
/**
|
|
@@ -933,6 +1022,15 @@ export declare const getNameFromWidgetKey: (widgetKey: string) => {
|
|
|
933
1022
|
errorMessage?: string;
|
|
934
1023
|
};
|
|
935
1024
|
|
|
1025
|
+
/**
|
|
1026
|
+
* Returns the anonymous id used as `params.anonId` for experiments, minting
|
|
1027
|
+
* and persisting one in `localStorage` on first use. Browser-only: returns
|
|
1028
|
+
* `undefined` outside a window (SSR) so the server never invents an id, and
|
|
1029
|
+
* when storage is unavailable (private mode, blocked third-party context) a
|
|
1030
|
+
* per-page-load id is returned without persisting.
|
|
1031
|
+
*/
|
|
1032
|
+
export declare function getOrCreateAnonymousId(): string | undefined;
|
|
1033
|
+
|
|
936
1034
|
/**
|
|
937
1035
|
* Where a layer sits above a base at `baseZIndex`: the first layer takes
|
|
938
1036
|
* `baseZIndex + 1`, the second `baseZIndex + 2`, and so on.
|
|
@@ -1117,6 +1215,13 @@ export declare interface LibraryCardInputs {
|
|
|
1117
1215
|
};
|
|
1118
1216
|
className?: string;
|
|
1119
1217
|
widgetInstanceProps?: WidgetInstanceProps;
|
|
1218
|
+
/**
|
|
1219
|
+
* This instance's column path — enclosing collection columns first, its own
|
|
1220
|
+
* column id last, joined with `/`. `r-button` emits it as
|
|
1221
|
+
* `data-rulecms-column-path`. Absent in the composer and from releases that
|
|
1222
|
+
* predate it.
|
|
1223
|
+
*/
|
|
1224
|
+
columnPath?: string;
|
|
1120
1225
|
/**
|
|
1121
1226
|
* Host-supplied map of mount name → Vue component. Only `r-mount`
|
|
1122
1227
|
* reads this. Absent in the composer, and absent whenever the host
|
|
@@ -1336,6 +1441,9 @@ export declare const PUBLISHED_KEY_SEPARATOR = "---";
|
|
|
1336
1441
|
/** Published (cached) client API path. */
|
|
1337
1442
|
export declare const PUBLISHED_WIDGET_API_PATH = "/api/v1/c/widget/get";
|
|
1338
1443
|
|
|
1444
|
+
/** Published ruleset resolve path (POST) — picks a widget by params, returns its payload. */
|
|
1445
|
+
export declare const PUBLISHED_WIDGET_RESOLVE_API_PATH = "/api/v1/c/widget/resolve";
|
|
1446
|
+
|
|
1339
1447
|
export declare type PublishedWidgetCollectionForKey = {
|
|
1340
1448
|
publishedKey: string;
|
|
1341
1449
|
name: string;
|
|
@@ -1483,6 +1591,9 @@ export declare interface ResolveWidgetLibrariesParams {
|
|
|
1483
1591
|
*/
|
|
1484
1592
|
export declare function rowBasedPropertiesAreAssigned(row: DisplayItemRow): boolean;
|
|
1485
1593
|
|
|
1594
|
+
/** First-party `localStorage` key holding the SDK-generated anonymous id. */
|
|
1595
|
+
export declare const RULECMS_ANONYMOUS_ID_STORAGE_KEY = "rulecms_anon_id";
|
|
1596
|
+
|
|
1486
1597
|
/** Live draft API host — RulesCMS production (never relative / local). */
|
|
1487
1598
|
export declare const RULECMS_API_ORIGIN = "https://rulecms.com";
|
|
1488
1599
|
|
|
@@ -1559,6 +1670,11 @@ export declare interface RuleCMSWidgetData {
|
|
|
1559
1670
|
* `includePositionTry` on the raw GET is `false`.
|
|
1560
1671
|
*/
|
|
1561
1672
|
positionTry?: ProjectCssPositionTryDefinitions;
|
|
1673
|
+
/**
|
|
1674
|
+
* Present when this payload came from a ruleset resolve. A plain published-key
|
|
1675
|
+
* GET never sets it.
|
|
1676
|
+
*/
|
|
1677
|
+
selection?: WidgetSelection;
|
|
1562
1678
|
}
|
|
1563
1679
|
|
|
1564
1680
|
export declare const RuleCMSWidgetProvider: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
@@ -1662,6 +1778,14 @@ export declare type SpacingSideLiteralValue = {
|
|
|
1662
1778
|
|
|
1663
1779
|
export declare type SpacingSideValue = (SpacingSideLiteralValue & CssVariableCarrier) | CssVariableValue;
|
|
1664
1780
|
|
|
1781
|
+
/**
|
|
1782
|
+
* `JSON.stringify` with object keys sorted at every depth, so two objects with
|
|
1783
|
+
* the same values serialize identically regardless of insertion order. Used as
|
|
1784
|
+
* the effect dependency for resolve `params`: a fresh `{ b, a }` on every render
|
|
1785
|
+
* must not trigger a refetch when `{ a, b }` was already sent.
|
|
1786
|
+
*/
|
|
1787
|
+
export declare function stableJsonStringify(value: unknown): string | undefined;
|
|
1788
|
+
|
|
1665
1789
|
export declare const tabletModeWidth = "820px";
|
|
1666
1790
|
|
|
1667
1791
|
export declare const textAlignAllowlist: readonly ["left", "center", "right", "justify", "start", "end"];
|
|
@@ -1706,6 +1830,14 @@ export declare const WIDGET_ATTRIBUTES_IGNORED_IN_COMPOSE_MODE: readonly ["width
|
|
|
1706
1830
|
/** Published (cached) API host. */
|
|
1707
1831
|
export declare const WIDGET_CACHE_API_ORIGIN = "https://widget-cache.rulecms.com";
|
|
1708
1832
|
|
|
1833
|
+
/**
|
|
1834
|
+
* The one key copied from `rulecms-widget`'s `placeholderValues` onto a card.
|
|
1835
|
+
* Must stay the key `r-text` reads (`PLACEHOLDER_VALUES_PROP` in
|
|
1836
|
+
* `@rulecms/source-components-vue`). The renderer copies the value and does
|
|
1837
|
+
* not look inside it.
|
|
1838
|
+
*/
|
|
1839
|
+
export declare const WIDGET_PLACEHOLDER_VALUES_KEY = "placeholderValues";
|
|
1840
|
+
|
|
1709
1841
|
/**
|
|
1710
1842
|
* True when the widget carries settings that need a real DOM element to land
|
|
1711
1843
|
* on, so the vertical container has to be emitted even where it would
|
|
@@ -1781,6 +1913,82 @@ export declare type WidgetOverlayLayers = {
|
|
|
1781
1913
|
layers: Items[];
|
|
1782
1914
|
};
|
|
1783
1915
|
|
|
1916
|
+
/**
|
|
1917
|
+
* `Content-Type` sent on the resolve POST. `text/plain` is CORS-safelisted, so
|
|
1918
|
+
* the browser skips the preflight; it is the default everywhere.
|
|
1919
|
+
* `application/json` is for server-to-server calls only.
|
|
1920
|
+
*/
|
|
1921
|
+
export declare type WidgetResolveContentType = 'application/json' | 'text/plain';
|
|
1922
|
+
|
|
1923
|
+
/** Options shared by every ruleset-driven entry point (hook, widget, server fetch). */
|
|
1924
|
+
export declare interface WidgetResolveRequestOptions {
|
|
1925
|
+
/**
|
|
1926
|
+
* Staging/production: ruleset published key (`{environmentId}---ruleset-…`).
|
|
1927
|
+
* Development (`dev.` token): the `ruleset-…` key; a published key is
|
|
1928
|
+
* accepted and stripped to its `ruleset-…` suffix.
|
|
1929
|
+
*/
|
|
1930
|
+
rulesetPublishedKey: string;
|
|
1931
|
+
/** Any JSON object. Sent as-is; the server flattens nested objects. */
|
|
1932
|
+
params?: WidgetSelectionParams;
|
|
1933
|
+
/**
|
|
1934
|
+
* Widget to GET through the plain published path when the resolve request
|
|
1935
|
+
* fails at the network level or with a 5xx. Not used on 4xx (bad token,
|
|
1936
|
+
* unknown ruleset…), and not needed for "no rule matched" — the ruleset's
|
|
1937
|
+
* own default covers that on the server.
|
|
1938
|
+
*/
|
|
1939
|
+
fallbackPublishedKey?: string;
|
|
1940
|
+
/**
|
|
1941
|
+
* Defaults to `text/plain` (no CORS preflight). Use `application/json` only
|
|
1942
|
+
* for server-to-server calls.
|
|
1943
|
+
*/
|
|
1944
|
+
contentType?: WidgetResolveContentType;
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
/** Which widget a ruleset picked and why. Returned alongside the widget payload. */
|
|
1948
|
+
export declare interface WidgetSelection {
|
|
1949
|
+
rulesetPublishedKey?: string;
|
|
1950
|
+
rulesetVersion?: string;
|
|
1951
|
+
schemaVersion?: number;
|
|
1952
|
+
outcome: WidgetSelectionOutcome;
|
|
1953
|
+
/** Matched rule id, or `null` for the default / fallback-default outcomes. */
|
|
1954
|
+
ruleId: string | null;
|
|
1955
|
+
/** Experiment variant id, or `null` when the rule was not an experiment. */
|
|
1956
|
+
variantId: string | null;
|
|
1957
|
+
widgetKey: string;
|
|
1958
|
+
widgetPublishedKey: string;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
export declare type WidgetSelectionOutcome = 'rule' | 'default' | 'fallback-default';
|
|
1962
|
+
|
|
1963
|
+
/**
|
|
1964
|
+
* Any JSON object. Sent to the resolve endpoint as-is — the server flattens
|
|
1965
|
+
* nested objects (`user.plan`) before evaluating rules. `undefined` values are
|
|
1966
|
+
* allowed for ergonomics (`{ plan: user?.plan }`) and dropped by JSON.
|
|
1967
|
+
*/
|
|
1968
|
+
export declare interface WidgetSelectionParams {
|
|
1969
|
+
[name: string]: WidgetSelectionParamValue | undefined;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
/** A JSON leaf or nested value accepted in resolve `params`. */
|
|
1973
|
+
declare type WidgetSelectionParamValue = string | number | boolean | null | WidgetSelectionParamValue[] | WidgetSelectionParams;
|
|
1974
|
+
|
|
1975
|
+
/**
|
|
1976
|
+
* Widget-wide placeholder values for one component instance.
|
|
1977
|
+
*
|
|
1978
|
+
* When the host passed `placeholderValues` on `rulecms-widget`, every instance
|
|
1979
|
+
* receives that object unless its own `componentProps` entry already has the
|
|
1980
|
+
* key. An entry that sets the key wins even when the value is `null` or
|
|
1981
|
+
* otherwise unusable: that is how one Text opts out. Other keys on the entry,
|
|
1982
|
+
* such as `onClick`, stay. The host's entry is not mutated.
|
|
1983
|
+
*
|
|
1984
|
+
* `undefined` means the widget input was omitted, which is the common case and
|
|
1985
|
+
* must not invent a bag.
|
|
1986
|
+
*/
|
|
1987
|
+
export declare function withWidgetPlaceholderValues({ widgetInstanceProps, placeholderValues, }: {
|
|
1988
|
+
widgetInstanceProps?: WidgetInstanceProps;
|
|
1989
|
+
placeholderValues?: unknown;
|
|
1990
|
+
}): WidgetInstanceProps | undefined;
|
|
1991
|
+
|
|
1784
1992
|
/**
|
|
1785
1993
|
* The base's own place in the stack. Read here rather than through
|
|
1786
1994
|
* objectStyleAttributeRegistry on purpose: the registry is shared with rows and
|