@webstudio-is/react-sdk 0.168.0 → 0.174.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 +194 -183
- package/lib/types/components/component-meta.d.ts +1603 -2503
- package/lib/types/components/components-utils.d.ts +0 -1
- package/lib/types/context.d.ts +0 -1
- package/lib/types/core-components.d.ts +1 -1
- package/lib/types/css/css.d.ts +3 -50
- package/lib/types/css/index.d.ts +0 -1
- package/lib/types/css/normalize.d.ts +8712 -13212
- package/lib/types/embed-template.d.ts +2013 -10395
- package/lib/types/hook.d.ts +3 -0
- package/lib/types/instance-utils.d.ts +2 -18
- package/lib/types/props.d.ts +11 -3
- package/package.json +14 -12
- package/placeholder.d.ts +61 -0
- package/lib/types/css/style-rules.d.ts +0 -21
- package/lib/types/css/style-rules.test.d.ts +0 -1
package/lib/types/hook.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type HookContext = {
|
|
|
9
9
|
indexesWithinAncestors: IndexesWithinAncestors;
|
|
10
10
|
getPropValue: (instanceId: Instance["id"], propName: Prop["name"]) => unknown;
|
|
11
11
|
setPropVariable: (instanceId: Instance["id"], propName: Prop["name"], value: unknown) => void;
|
|
12
|
+
setMemoryProp: (instanceId: readonly Instance["id"][], propName: Prop["name"], value: unknown) => void;
|
|
12
13
|
};
|
|
13
14
|
export type InstancePath = Instance[];
|
|
14
15
|
type NavigatorEvent = {
|
|
@@ -16,6 +17,7 @@ type NavigatorEvent = {
|
|
|
16
17
|
* List of instances from selected to the root
|
|
17
18
|
*/
|
|
18
19
|
instancePath: InstancePath;
|
|
20
|
+
instanceSelector: readonly Instance["id"][];
|
|
19
21
|
};
|
|
20
22
|
export type Hook = {
|
|
21
23
|
onNavigatorSelect?: (context: HookContext, event: NavigatorEvent) => void;
|
|
@@ -42,4 +44,5 @@ export declare const getClosestInstance: (instancePath: InstancePath, currentIns
|
|
|
42
44
|
component: string;
|
|
43
45
|
label?: string | undefined;
|
|
44
46
|
} | undefined;
|
|
47
|
+
export declare const getInstanceSelectorById: (instanceSelector: readonly Instance["id"][], instanceId: Instance["id"]) => string[];
|
|
45
48
|
export {};
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
import type { Instance } from "@webstudio-is/sdk";
|
|
1
|
+
import type { Instance, Instances } from "@webstudio-is/sdk";
|
|
2
2
|
import type { WsComponentMeta } from "./components/component-meta";
|
|
3
3
|
export type IndexesWithinAncestors = Map<Instance["id"], number>;
|
|
4
|
-
export declare const getIndexesWithinAncestors: (metas: Map<Instance["component"], WsComponentMeta>, instances:
|
|
5
|
-
type: "instance";
|
|
6
|
-
id: string;
|
|
7
|
-
children: ({
|
|
8
|
-
value: string;
|
|
9
|
-
type: "text";
|
|
10
|
-
placeholder?: boolean | undefined;
|
|
11
|
-
} | {
|
|
12
|
-
value: string;
|
|
13
|
-
type: "id";
|
|
14
|
-
} | {
|
|
15
|
-
value: string;
|
|
16
|
-
type: "expression";
|
|
17
|
-
})[];
|
|
18
|
-
component: string;
|
|
19
|
-
label?: string | undefined;
|
|
20
|
-
}>, rootIds: Instance["id"][]) => IndexesWithinAncestors;
|
|
4
|
+
export declare const getIndexesWithinAncestors: (metas: Map<Instance["component"], WsComponentMeta>, instances: Instances, rootIds: Instance["id"][]) => IndexesWithinAncestors;
|
package/lib/types/props.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { type Prop, type Assets, type Pages } from "@webstudio-is/sdk";
|
|
2
|
-
export declare const normalizeProps: ({ props, assetBaseUrl, assets, pages, }: {
|
|
1
|
+
import { type Prop, type Assets, type Pages, type ImageAsset } from "@webstudio-is/sdk";
|
|
2
|
+
export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingImageAssets, pages, source, }: {
|
|
3
3
|
props: Prop[];
|
|
4
4
|
assetBaseUrl: string;
|
|
5
5
|
assets: Assets;
|
|
6
|
+
uploadingImageAssets: ImageAsset[];
|
|
6
7
|
pages: Pages;
|
|
8
|
+
source: "canvas" | "prebuild";
|
|
7
9
|
}) => ({
|
|
8
10
|
value: number;
|
|
9
11
|
type: "number";
|
|
@@ -66,6 +68,13 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, pages, }: {
|
|
|
66
68
|
id: string;
|
|
67
69
|
instanceId: string;
|
|
68
70
|
required?: boolean | undefined;
|
|
71
|
+
} | {
|
|
72
|
+
value: string;
|
|
73
|
+
type: "resource";
|
|
74
|
+
name: string;
|
|
75
|
+
id: string;
|
|
76
|
+
instanceId: string;
|
|
77
|
+
required?: boolean | undefined;
|
|
69
78
|
} | {
|
|
70
79
|
value: string;
|
|
71
80
|
type: "expression";
|
|
@@ -92,5 +101,4 @@ export declare const showAttribute: "data-ws-show";
|
|
|
92
101
|
export declare const indexAttribute: "data-ws-index";
|
|
93
102
|
export declare const collapsedAttribute: "data-ws-collapsed";
|
|
94
103
|
export declare const textContentAttribute: "data-ws-text-content";
|
|
95
|
-
export declare const getInstanceIdFromComponentProps: (props: Record<string, unknown>) => string;
|
|
96
104
|
export declare const getIndexWithinAncestorFromComponentProps: (props: Record<string, unknown>) => string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.174.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
14
14
|
"strip-indent": "^4.0.0",
|
|
15
15
|
"type-fest": "^4.3.1",
|
|
16
|
-
"typescript": "5.
|
|
16
|
+
"typescript": "5.5.2",
|
|
17
17
|
"zod": "^3.22.4",
|
|
18
|
-
"@webstudio-is/
|
|
19
|
-
"@webstudio-is/
|
|
18
|
+
"@webstudio-is/tsconfig": "1.0.7",
|
|
19
|
+
"@webstudio-is/jest-config": "1.0.7"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"html-tags": "^3.3.1",
|
|
29
29
|
"nanoid": "^5.0.1",
|
|
30
30
|
"title-case": "^4.1.0",
|
|
31
|
-
"@webstudio-is/css-engine": "0.
|
|
32
|
-
"@webstudio-is/
|
|
33
|
-
"@webstudio-is/icons": "^0.
|
|
34
|
-
"@webstudio-is/
|
|
35
|
-
"@webstudio-is/
|
|
31
|
+
"@webstudio-is/css-engine": "0.174.0",
|
|
32
|
+
"@webstudio-is/fonts": "0.174.0",
|
|
33
|
+
"@webstudio-is/icons": "^0.174.0",
|
|
34
|
+
"@webstudio-is/sdk": "0.174.0",
|
|
35
|
+
"@webstudio-is/image": "0.174.0"
|
|
36
36
|
},
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
|
@@ -44,21 +44,23 @@
|
|
|
44
44
|
"webstudio": "./src/css/normalize.ts",
|
|
45
45
|
"types": "./lib/types/css/normalize.d.ts",
|
|
46
46
|
"import": "./lib/css/normalize.js"
|
|
47
|
+
},
|
|
48
|
+
"./placeholder": {
|
|
49
|
+
"types": "./placeholder.d.ts"
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
"files": [
|
|
50
53
|
"lib/*",
|
|
54
|
+
"./placeholder.d.ts",
|
|
51
55
|
"!*.{test,stories}.*"
|
|
52
56
|
],
|
|
53
57
|
"license": "AGPL-3.0-or-later",
|
|
54
58
|
"private": false,
|
|
55
59
|
"sideEffects": false,
|
|
56
60
|
"scripts": {
|
|
57
|
-
"dev": "rm -rf lib && esbuild 'src/**/*.ts' 'src/**/*.tsx' --outdir=lib --watch",
|
|
58
61
|
"build": "rm -rf lib && esbuild src/index.ts ./src/css/normalize.ts --outdir=lib --bundle --format=esm --packages=external",
|
|
59
62
|
"dts": "tsc --project tsconfig.dts.json",
|
|
60
63
|
"typecheck": "tsc",
|
|
61
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests"
|
|
62
|
-
"checks": "pnpm typecheck && pnpm test"
|
|
64
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests"
|
|
63
65
|
}
|
|
64
66
|
}
|
package/placeholder.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare module "__CONSTANTS__" {
|
|
2
|
+
import type { ImageLoader } from "@webstudio-is/image";
|
|
3
|
+
export const assetBaseUrl: string;
|
|
4
|
+
export const imageBaseUrl: string;
|
|
5
|
+
export const imageLoader: ImageLoader;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare module "__CLIENT__" {
|
|
9
|
+
import type {
|
|
10
|
+
FontAsset,
|
|
11
|
+
ImageAsset,
|
|
12
|
+
ResourceRequest,
|
|
13
|
+
System,
|
|
14
|
+
} from "@webstudio-is/sdk";
|
|
15
|
+
|
|
16
|
+
export const siteName: string;
|
|
17
|
+
|
|
18
|
+
export const favIconAsset: ImageAsset | undefined;
|
|
19
|
+
|
|
20
|
+
// Font assets on current page (can be preloaded)
|
|
21
|
+
export const pageFontAssets: FontAsset[];
|
|
22
|
+
|
|
23
|
+
export const pageBackgroundImageAssets: ImageAsset[];
|
|
24
|
+
|
|
25
|
+
export const CustomCode: () => ReactNode;
|
|
26
|
+
|
|
27
|
+
export const Page: (props: { system: System }) => ReactNode;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare module "__SERVER__" {
|
|
31
|
+
import type { PageMeta, System, ResourceRequest } from "@webstudio-is/sdk";
|
|
32
|
+
|
|
33
|
+
export const getResources: (props: { system: System }) => {
|
|
34
|
+
data: Map<string, ResourceRequest>;
|
|
35
|
+
action: Map<string, ResourceRequest>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const getPageMeta: (props: {
|
|
39
|
+
system: System;
|
|
40
|
+
resources: Record<string, any>;
|
|
41
|
+
}) => PageMeta;
|
|
42
|
+
|
|
43
|
+
type Params = Record<string, string | undefined>;
|
|
44
|
+
export const getRemixParams: ({ ...params }: Params) => Params;
|
|
45
|
+
|
|
46
|
+
export const projectId: string;
|
|
47
|
+
|
|
48
|
+
export const contactEmail: undefined | string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare module "__SITEMAP__" {
|
|
52
|
+
export const sitemap: Array<{
|
|
53
|
+
path: string;
|
|
54
|
+
lastModified: string;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare module "__REDIRECT__" {
|
|
59
|
+
export const url: string;
|
|
60
|
+
export const status: number;
|
|
61
|
+
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Style } from "@webstudio-is/css-engine";
|
|
2
|
-
import type { Styles } from "@webstudio-is/sdk";
|
|
3
|
-
import type { PresetStyle } from "../components/component-meta";
|
|
4
|
-
type StyleRule = {
|
|
5
|
-
instanceId: string;
|
|
6
|
-
breakpointId: string;
|
|
7
|
-
state: undefined | string;
|
|
8
|
-
style: Style;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Merge styles from different style sources
|
|
12
|
-
* and group by instance and breakpoint
|
|
13
|
-
*
|
|
14
|
-
* @deprecated
|
|
15
|
-
*/
|
|
16
|
-
export declare const getStyleRules: (styles: Styles, styleSourceSelections: Map<string, {
|
|
17
|
-
values: string[];
|
|
18
|
-
instanceId: string;
|
|
19
|
-
}>) => StyleRule[];
|
|
20
|
-
export declare const getPresetStyleRules: (component: string, presetStyle: PresetStyle) => Map<string, Style>;
|
|
21
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|