@webstudio-is/react-sdk 0.185.0 → 0.191.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 +212 -121
- package/lib/runtime.js +8 -12
- package/lib/types/components/component-meta.d.ts +1112 -449
- package/lib/types/components/components-utils.d.ts +2 -1
- package/lib/types/core-components.d.ts +298 -1
- package/lib/types/embed-template.d.ts +724 -215
- package/lib/types/hook.d.ts +9 -23
- package/lib/types/index.d.ts +0 -1
- package/package.json +10 -12
- package/lib/types/tree/create-elements-tree.d.ts +0 -26
- package/lib/types/tree/index.d.ts +0 -1
package/lib/types/hook.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Instance, Prop } from "@webstudio-is/sdk";
|
|
2
2
|
import type { IndexesWithinAncestors } from "./instance-utils";
|
|
3
|
+
export type InstanceData = {
|
|
4
|
+
id: Instance["id"];
|
|
5
|
+
instanceKey: string;
|
|
6
|
+
component: Instance["component"];
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
9
|
* Hooks are subscriptions to builder events
|
|
5
10
|
* with limited way to interact with it.
|
|
@@ -7,17 +12,15 @@ import type { IndexesWithinAncestors } from "./instance-utils";
|
|
|
7
12
|
*/
|
|
8
13
|
export type HookContext = {
|
|
9
14
|
indexesWithinAncestors: IndexesWithinAncestors;
|
|
10
|
-
getPropValue: (
|
|
11
|
-
|
|
12
|
-
setMemoryProp: (instanceId: readonly Instance["id"][], propName: Prop["name"], value: unknown) => void;
|
|
15
|
+
getPropValue: (instanceData: InstanceData, propName: Prop["name"]) => unknown;
|
|
16
|
+
setMemoryProp: (instanceData: InstanceData, propName: Prop["name"], value: unknown) => void;
|
|
13
17
|
};
|
|
14
|
-
export type InstancePath =
|
|
18
|
+
export type InstancePath = InstanceData[];
|
|
15
19
|
type NavigatorEvent = {
|
|
16
20
|
/**
|
|
17
21
|
* List of instances from selected to the root
|
|
18
22
|
*/
|
|
19
23
|
instancePath: InstancePath;
|
|
20
|
-
instanceSelector: readonly Instance["id"][];
|
|
21
24
|
};
|
|
22
25
|
export type Hook = {
|
|
23
26
|
onNavigatorSelect?: (context: HookContext, event: NavigatorEvent) => void;
|
|
@@ -27,22 +30,5 @@ export type Hook = {
|
|
|
27
30
|
* Find closest matching instance by component name
|
|
28
31
|
* by lookup in instance path
|
|
29
32
|
*/
|
|
30
|
-
export declare const getClosestInstance: (instancePath: InstancePath, currentInstance:
|
|
31
|
-
type: "instance";
|
|
32
|
-
id: string;
|
|
33
|
-
children: ({
|
|
34
|
-
value: string;
|
|
35
|
-
type: "text";
|
|
36
|
-
placeholder?: boolean | undefined;
|
|
37
|
-
} | {
|
|
38
|
-
value: string;
|
|
39
|
-
type: "id";
|
|
40
|
-
} | {
|
|
41
|
-
value: string;
|
|
42
|
-
type: "expression";
|
|
43
|
-
})[];
|
|
44
|
-
component: string;
|
|
45
|
-
label?: string | undefined;
|
|
46
|
-
} | undefined;
|
|
47
|
-
export declare const getInstanceSelectorById: (instanceSelector: readonly Instance["id"][], instanceId: Instance["id"]) => string[];
|
|
33
|
+
export declare const getClosestInstance: (instancePath: InstancePath, currentInstance: InstanceData, closestComponent: InstanceData["component"]) => InstanceData | undefined;
|
|
48
34
|
export {};
|
package/lib/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.191.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@jest/globals": "^29.7.0",
|
|
10
9
|
"@types/react": "^18.2.70",
|
|
11
10
|
"@types/react-dom": "^18.2.25",
|
|
12
11
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
13
12
|
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
14
13
|
"strip-indent": "^4.0.0",
|
|
15
|
-
"type-fest": "^4.
|
|
16
|
-
"
|
|
14
|
+
"type-fest": "^4.28.0",
|
|
15
|
+
"vitest": "^2.1.8",
|
|
17
16
|
"zod": "^3.22.4",
|
|
18
|
-
"@webstudio-is/jest-config": "1.0.7",
|
|
19
17
|
"@webstudio-is/tsconfig": "1.0.7"
|
|
20
18
|
},
|
|
21
19
|
"peerDependencies": {
|
|
@@ -26,13 +24,13 @@
|
|
|
26
24
|
"dependencies": {
|
|
27
25
|
"change-case": "^5.4.4",
|
|
28
26
|
"html-tags": "^4.0.0",
|
|
29
|
-
"nanoid": "^5.0.
|
|
27
|
+
"nanoid": "^5.0.8",
|
|
30
28
|
"title-case": "^4.3.2",
|
|
31
|
-
"@webstudio-is/css-engine": "0.
|
|
32
|
-
"@webstudio-is/icons": "^0.
|
|
33
|
-
"@webstudio-is/
|
|
34
|
-
"@webstudio-is/
|
|
35
|
-
"@webstudio-is/sdk": "0.
|
|
29
|
+
"@webstudio-is/css-engine": "0.191.0",
|
|
30
|
+
"@webstudio-is/icons": "^0.191.0",
|
|
31
|
+
"@webstudio-is/image": "0.191.0",
|
|
32
|
+
"@webstudio-is/fonts": "0.191.0",
|
|
33
|
+
"@webstudio-is/sdk": "0.191.0"
|
|
36
34
|
},
|
|
37
35
|
"exports": {
|
|
38
36
|
".": {
|
|
@@ -61,6 +59,6 @@
|
|
|
61
59
|
"build": "rm -rf lib && esbuild src/index.ts src/runtime.ts --outdir=lib --bundle --format=esm --packages=external",
|
|
62
60
|
"dts": "tsc --project tsconfig.dts.json",
|
|
63
61
|
"typecheck": "tsc",
|
|
64
|
-
"test": "
|
|
62
|
+
"test": "vitest run"
|
|
65
63
|
}
|
|
66
64
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type ForwardRefExoticComponent, type ReactNode, type RefAttributes } from "react";
|
|
2
|
-
import type { Instance, Instances } from "@webstudio-is/sdk";
|
|
3
|
-
import type { Components } from "../components/components-utils";
|
|
4
|
-
import { type Params } from "../context";
|
|
5
|
-
import type { ImageLoader } from "@webstudio-is/image";
|
|
6
|
-
type InstanceSelector = Instance["id"][];
|
|
7
|
-
export type WebstudioComponentProps = {
|
|
8
|
-
instance: Instance;
|
|
9
|
-
instanceSelector: Instance["id"][];
|
|
10
|
-
components: Components;
|
|
11
|
-
};
|
|
12
|
-
export declare const createElementsTree: ({ renderer, assetBaseUrl, imageBaseUrl, imageLoader, instances, rootInstanceId, Component, components, }: Params & {
|
|
13
|
-
instances: Instances;
|
|
14
|
-
imageLoader: ImageLoader;
|
|
15
|
-
rootInstanceId: Instance["id"];
|
|
16
|
-
Component: ForwardRefExoticComponent<WebstudioComponentProps & RefAttributes<HTMLElement>>;
|
|
17
|
-
components: Components;
|
|
18
|
-
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
-
export declare const createInstanceChildrenElements: ({ instances, instanceSelector, children, Component, components, }: {
|
|
20
|
-
instances: Instances;
|
|
21
|
-
instanceSelector: InstanceSelector;
|
|
22
|
-
children: Instance["children"];
|
|
23
|
-
Component: ForwardRefExoticComponent<WebstudioComponentProps & RefAttributes<HTMLElement>>;
|
|
24
|
-
components: Components;
|
|
25
|
-
}) => ReactNode[] | undefined;
|
|
26
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./create-elements-tree";
|