@webstudio-is/sdk 0.267.0 → 0.269.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/lib/index.js +370 -41
- package/lib/link-utils.js +27 -0
- package/lib/types/expression.d.ts +8 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/instances-utils.d.ts +8 -0
- package/lib/types/link-utils.d.ts +19 -0
- package/lib/types/page-meta-generator.d.ts +1 -0
- package/lib/types/page-utils.d.ts +22 -3
- package/lib/types/schema/component-meta.d.ts +49 -4
- package/lib/types/schema/pages.d.ts +824 -39
- package/lib/types/schema/prop-meta.d.ts +27 -0
- package/package.json +13 -7
package/lib/types/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./expression";
|
|
|
21
21
|
export * from "./resources-generator";
|
|
22
22
|
export * from "./page-meta-generator";
|
|
23
23
|
export * from "./url-pattern";
|
|
24
|
+
export * from "./link-utils";
|
|
24
25
|
export * from "./css";
|
|
25
26
|
export * from "./__generated__/tags";
|
|
26
27
|
export type { AnimationAction, AnimationActionScroll, AnimationActionView, AnimationKeyframe, KeyframeStyles, RangeUnit, RangeUnitValue, ScrollNamedRange, ScrollRangeValue, ViewNamedRange, ViewRangeValue, ScrollAnimation, ViewAnimation, InsetUnitValue, DurationUnitValue, IterationsUnitValue, TimeUnit, } from "./schema/animation-schema";
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { WsComponentMeta } from "./schema/component-meta";
|
|
2
2
|
import type { Instance, Instances } from "./schema/instances";
|
|
3
|
+
import type { Props } from "./schema/props";
|
|
3
4
|
export declare const ROOT_INSTANCE_ID = ":root";
|
|
4
5
|
export declare const findTreeInstanceIds: (instances: Instances, rootInstanceId: Instance["id"]) => Set<string>;
|
|
5
6
|
export declare const findTreeInstanceIdsExcludingSlotDescendants: (instances: Instances, rootInstanceId: Instance["id"]) => Set<string>;
|
|
6
7
|
export declare const parseComponentName: (componentName: string) => readonly [string | undefined, string];
|
|
8
|
+
export declare const getHtmlTagsFromProps: (props: Props) => Map<string, string>;
|
|
9
|
+
export declare const getHtmlTagFromInstance: ({ instance, metas, props, htmlTagsByInstanceId, }: {
|
|
10
|
+
instance: Instance;
|
|
11
|
+
metas: Map<Instance["component"], WsComponentMeta>;
|
|
12
|
+
props: Props;
|
|
13
|
+
htmlTagsByInstanceId?: Map<Instance["id"], string>;
|
|
14
|
+
}) => string | undefined;
|
|
7
15
|
export type IndexesWithinAncestors = Map<Instance["id"], number>;
|
|
8
16
|
export declare const getIndexesWithinAncestors: (metas: Map<Instance["component"], WsComponentMeta>, instances: Instances, rootIds: Instance["id"][]) => IndexesWithinAncestors;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type UrlParts = {
|
|
2
|
+
pathname: string;
|
|
3
|
+
search: string;
|
|
4
|
+
hash: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const isInternalHref: (href: string, assetBaseUrl: string) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* React Router resolves href="" and hash-only hrefs without preserving the
|
|
9
|
+
* concrete browser URL shape Webstudio uses for :local-link-like matching.
|
|
10
|
+
* Normalize those cases before comparing so current-link state follows anchor
|
|
11
|
+
* URL semantics instead of route-only semantics.
|
|
12
|
+
*/
|
|
13
|
+
export declare const resolveLocalLinkUrl: (href: string, location: UrlParts, resolvedPath: UrlParts) => UrlParts;
|
|
14
|
+
/**
|
|
15
|
+
* Webstudio's local link styles target the concrete URL, not just the matched
|
|
16
|
+
* route. This intentionally preserves the old NavLink end/exact behavior while
|
|
17
|
+
* also requiring query string and fragment equality.
|
|
18
|
+
*/
|
|
19
|
+
export declare const isLocalLinkActive: (current: UrlParts, target: UrlParts) => boolean;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import type { Folder, Page, Pages } from "./schema/pages";
|
|
1
|
+
import type { Folder, Page, PageTemplate, Pages } from "./schema/pages";
|
|
2
2
|
export declare const ROOT_FOLDER_ID = "root";
|
|
3
|
+
/**
|
|
4
|
+
* Narrows Page | PageTemplate to Page.
|
|
5
|
+
* Templates have no `path` field; pages always do.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isPage: (page: Page | PageTemplate | undefined) => page is Page;
|
|
8
|
+
/**
|
|
9
|
+
* Narrows Page | PageTemplate to PageTemplate.
|
|
10
|
+
*/
|
|
11
|
+
export declare const isPageTemplate: (page: Page | PageTemplate | undefined) => page is PageTemplate & {
|
|
12
|
+
path?: never;
|
|
13
|
+
};
|
|
3
14
|
/**
|
|
4
15
|
* Returns true if folder is the root folder.
|
|
5
16
|
*/
|
|
@@ -12,9 +23,17 @@ export declare const getAllPages: (pages: Pages) => Page[];
|
|
|
12
23
|
export declare const getAllFolders: (pages: Pages) => Folder[];
|
|
13
24
|
export declare const getHomePage: (pages: Pages) => Page;
|
|
14
25
|
/**
|
|
15
|
-
* Find a page by id or path.
|
|
26
|
+
* Find a page by id or path. Pass { includeTemplates: true } to also search
|
|
27
|
+
* pageTemplates (builder-only call sites: canvas awareness, selected-page
|
|
28
|
+
* computation). Without the flag the return type is `Page | undefined` so
|
|
29
|
+
* existing call sites are unaffected.
|
|
16
30
|
*/
|
|
17
|
-
export declare
|
|
31
|
+
export declare function findPageByIdOrPath(idOrPath: string, pages: Pages, options: {
|
|
32
|
+
includeTemplates: true;
|
|
33
|
+
}): Page | PageTemplate | undefined;
|
|
34
|
+
export declare function findPageByIdOrPath(idOrPath: string, pages: Pages, options?: {
|
|
35
|
+
includeTemplates?: false;
|
|
36
|
+
}): Page | undefined;
|
|
18
37
|
/**
|
|
19
38
|
* Find a folder that has has that id in the children.
|
|
20
39
|
*/
|
|
@@ -5062,7 +5062,7 @@ export type PresetStyleDecl = Simplify<Omit<z.infer<typeof PresetStyleDecl>, "pr
|
|
|
5062
5062
|
property: CssProperty;
|
|
5063
5063
|
}>;
|
|
5064
5064
|
export type PresetStyle<Tag extends HtmlTags = HtmlTags> = Partial<Record<Tag, PresetStyleDecl[]>>;
|
|
5065
|
-
export declare const componentCategories: readonly ["general", "typography", "media", "animations", "data", "forms", "localization", "radix", "xml", "other", "hidden", "internal"];
|
|
5065
|
+
export declare const componentCategories: readonly ["general", "typography", "media", "animations", "data", "forms", "localization", "radix", "xml", "text", "other", "hidden", "internal"];
|
|
5066
5066
|
export declare const ComponentState: z.ZodObject<{
|
|
5067
5067
|
selector: z.ZodString;
|
|
5068
5068
|
label: z.ZodString;
|
|
@@ -5095,7 +5095,7 @@ export declare const ContentModel: z.ZodObject<{
|
|
|
5095
5095
|
}>;
|
|
5096
5096
|
export type ContentModel = z.infer<typeof ContentModel>;
|
|
5097
5097
|
export declare const WsComponentMeta: z.ZodObject<{
|
|
5098
|
-
category: z.ZodOptional<z.ZodEnum<["general", "typography", "media", "animations", "data", "forms", "localization", "radix", "xml", "other", "hidden", "internal"]>>;
|
|
5098
|
+
category: z.ZodOptional<z.ZodEnum<["general", "typography", "media", "animations", "data", "forms", "localization", "radix", "xml", "text", "other", "hidden", "internal"]>>;
|
|
5099
5099
|
contentModel: z.ZodOptional<z.ZodObject<{
|
|
5100
5100
|
category: z.ZodUnion<[z.ZodLiteral<"instance">, z.ZodLiteral<"none">]>;
|
|
5101
5101
|
/**
|
|
@@ -10493,6 +10493,33 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
10493
10493
|
label?: string | undefined;
|
|
10494
10494
|
defaultValue?: string | undefined;
|
|
10495
10495
|
contentMode?: boolean | undefined;
|
|
10496
|
+
}>, z.ZodObject<{
|
|
10497
|
+
control: z.ZodLiteral<"timeZone">;
|
|
10498
|
+
type: z.ZodLiteral<"string">;
|
|
10499
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
10500
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
10501
|
+
label: z.ZodOptional<z.ZodString>;
|
|
10502
|
+
description: z.ZodOptional<z.ZodString>;
|
|
10503
|
+
required: z.ZodBoolean;
|
|
10504
|
+
contentMode: z.ZodOptional<z.ZodBoolean>;
|
|
10505
|
+
}, "strip", z.ZodTypeAny, {
|
|
10506
|
+
options: string[];
|
|
10507
|
+
type: "string";
|
|
10508
|
+
required: boolean;
|
|
10509
|
+
control: "timeZone";
|
|
10510
|
+
description?: string | undefined;
|
|
10511
|
+
label?: string | undefined;
|
|
10512
|
+
defaultValue?: string | undefined;
|
|
10513
|
+
contentMode?: boolean | undefined;
|
|
10514
|
+
}, {
|
|
10515
|
+
options: string[];
|
|
10516
|
+
type: "string";
|
|
10517
|
+
required: boolean;
|
|
10518
|
+
control: "timeZone";
|
|
10519
|
+
description?: string | undefined;
|
|
10520
|
+
label?: string | undefined;
|
|
10521
|
+
defaultValue?: string | undefined;
|
|
10522
|
+
contentMode?: boolean | undefined;
|
|
10496
10523
|
}>, z.ZodObject<{
|
|
10497
10524
|
control: z.ZodLiteral<"multi-select">;
|
|
10498
10525
|
type: z.ZodLiteral<"string[]">;
|
|
@@ -10748,7 +10775,7 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
10748
10775
|
}>]>>>;
|
|
10749
10776
|
}, "strip", z.ZodTypeAny, {
|
|
10750
10777
|
description?: string | undefined;
|
|
10751
|
-
category?: "xml" | "hidden" | "data" | "media" | "animations" | "general" | "typography" | "forms" | "localization" | "radix" | "other" | "internal" | undefined;
|
|
10778
|
+
category?: "xml" | "text" | "hidden" | "data" | "media" | "animations" | "general" | "typography" | "forms" | "localization" | "radix" | "other" | "internal" | undefined;
|
|
10752
10779
|
label?: string | undefined;
|
|
10753
10780
|
order?: number | undefined;
|
|
10754
10781
|
props?: Record<string, {
|
|
@@ -10853,6 +10880,15 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
10853
10880
|
label?: string | undefined;
|
|
10854
10881
|
defaultValue?: string | undefined;
|
|
10855
10882
|
contentMode?: boolean | undefined;
|
|
10883
|
+
} | {
|
|
10884
|
+
options: string[];
|
|
10885
|
+
type: "string";
|
|
10886
|
+
required: boolean;
|
|
10887
|
+
control: "timeZone";
|
|
10888
|
+
description?: string | undefined;
|
|
10889
|
+
label?: string | undefined;
|
|
10890
|
+
defaultValue?: string | undefined;
|
|
10891
|
+
contentMode?: boolean | undefined;
|
|
10856
10892
|
} | {
|
|
10857
10893
|
options: string[];
|
|
10858
10894
|
type: "string[]";
|
|
@@ -11558,7 +11594,7 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
11558
11594
|
initialProps?: string[] | undefined;
|
|
11559
11595
|
}, {
|
|
11560
11596
|
description?: string | undefined;
|
|
11561
|
-
category?: "xml" | "hidden" | "data" | "media" | "animations" | "general" | "typography" | "forms" | "localization" | "radix" | "other" | "internal" | undefined;
|
|
11597
|
+
category?: "xml" | "text" | "hidden" | "data" | "media" | "animations" | "general" | "typography" | "forms" | "localization" | "radix" | "other" | "internal" | undefined;
|
|
11562
11598
|
label?: string | undefined;
|
|
11563
11599
|
order?: number | undefined;
|
|
11564
11600
|
props?: Record<string, {
|
|
@@ -11663,6 +11699,15 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
11663
11699
|
label?: string | undefined;
|
|
11664
11700
|
defaultValue?: string | undefined;
|
|
11665
11701
|
contentMode?: boolean | undefined;
|
|
11702
|
+
} | {
|
|
11703
|
+
options: string[];
|
|
11704
|
+
type: "string";
|
|
11705
|
+
required: boolean;
|
|
11706
|
+
control: "timeZone";
|
|
11707
|
+
description?: string | undefined;
|
|
11708
|
+
label?: string | undefined;
|
|
11709
|
+
defaultValue?: string | undefined;
|
|
11710
|
+
contentMode?: boolean | undefined;
|
|
11666
11711
|
} | {
|
|
11667
11712
|
options: string[];
|
|
11668
11713
|
type: "string[]";
|