@webstudio-is/react-sdk 0.189.0 → 0.191.4
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/package.json +10 -12
- package/lib/index.js +0 -1528
- package/lib/runtime.js +0 -65
- package/lib/types/component-generator.d.ts +0 -37
- package/lib/types/component-generator.test.d.ts +0 -1
- package/lib/types/components/component-meta.d.ts +0 -3615
- package/lib/types/components/components-utils.d.ts +0 -7
- package/lib/types/context.d.ts +0 -37
- package/lib/types/core-components.d.ts +0 -451
- package/lib/types/css/css.d.ts +0 -21
- package/lib/types/css/css.test.d.ts +0 -1
- package/lib/types/css/global-rules.d.ts +0 -6
- package/lib/types/css/index.d.ts +0 -2
- package/lib/types/embed-template.d.ts +0 -2560
- package/lib/types/embed-template.test.d.ts +0 -1
- package/lib/types/hook.d.ts +0 -48
- package/lib/types/hook.test.d.ts +0 -1
- package/lib/types/index.d.ts +0 -12
- package/lib/types/instance-utils.d.ts +0 -4
- package/lib/types/instance-utils.test.d.ts +0 -1
- package/lib/types/prop-meta.d.ts +0 -434
- package/lib/types/props.d.ts +0 -104
- package/lib/types/props.test.d.ts +0 -1
- package/lib/types/remix.d.ts +0 -20
- package/lib/types/remix.test.d.ts +0 -1
- package/lib/types/runtime.d.ts +0 -4
- package/lib/types/variable-state.d.ts +0 -2
package/lib/runtime.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// src/context.tsx
|
|
2
|
-
import { createContext, useContext, useMemo } from "react";
|
|
3
|
-
import { createJsonStringifyProxy, isPlainObject } from "@webstudio-is/sdk";
|
|
4
|
-
var ReactSdkContext = createContext({
|
|
5
|
-
assetBaseUrl: "/",
|
|
6
|
-
imageBaseUrl: "/",
|
|
7
|
-
imageLoader: ({ src }) => src,
|
|
8
|
-
resources: {}
|
|
9
|
-
});
|
|
10
|
-
var useResource = (name) => {
|
|
11
|
-
const { resources } = useContext(ReactSdkContext);
|
|
12
|
-
const resource = resources[name];
|
|
13
|
-
const resourceMemozied = useMemo(
|
|
14
|
-
() => isPlainObject(resource) ? createJsonStringifyProxy(resource) : resource,
|
|
15
|
-
[resource]
|
|
16
|
-
);
|
|
17
|
-
return resourceMemozied;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// src/hook.ts
|
|
21
|
-
var getClosestInstance = (instancePath, currentInstance, closestComponent) => {
|
|
22
|
-
let matched = false;
|
|
23
|
-
for (const instance of instancePath) {
|
|
24
|
-
if (currentInstance === instance) {
|
|
25
|
-
matched = true;
|
|
26
|
-
}
|
|
27
|
-
if (matched && instance.component === closestComponent) {
|
|
28
|
-
return instance;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var getInstanceSelectorById = (instanceSelector, instanceId) => {
|
|
33
|
-
const index = instanceSelector.findIndex(
|
|
34
|
-
(selector) => selector === instanceId
|
|
35
|
-
);
|
|
36
|
-
if (index === -1) {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
return instanceSelector.slice(index);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/variable-state.tsx
|
|
43
|
-
import { createJsonStringifyProxy as createJsonStringifyProxy2, isPlainObject as isPlainObject2 } from "@webstudio-is/sdk";
|
|
44
|
-
import { useState, useMemo as useMemo2 } from "react";
|
|
45
|
-
var useVariableState = (initialState) => {
|
|
46
|
-
const [state, setState] = useState(initialState);
|
|
47
|
-
const value = useMemo2(
|
|
48
|
-
() => isPlainObject2(state) ? createJsonStringifyProxy2(state) : state,
|
|
49
|
-
[state]
|
|
50
|
-
);
|
|
51
|
-
return [value, setState];
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// src/runtime.ts
|
|
55
|
-
var getIndexWithinAncestorFromComponentProps = (props) => {
|
|
56
|
-
return props["data-ws-index"];
|
|
57
|
-
};
|
|
58
|
-
export {
|
|
59
|
-
ReactSdkContext,
|
|
60
|
-
getClosestInstance,
|
|
61
|
-
getIndexWithinAncestorFromComponentProps,
|
|
62
|
-
getInstanceSelectorById,
|
|
63
|
-
useResource,
|
|
64
|
-
useVariableState
|
|
65
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Instances, Instance, Props, Scope, DataSources, Prop } from "@webstudio-is/sdk";
|
|
2
|
-
import type { IndexesWithinAncestors } from "./instance-utils";
|
|
3
|
-
export declare const generateJsxElement: ({ context, scope, instance, props, dataSources, usedDataSources, indexesWithinAncestors, children, classesMap, }: {
|
|
4
|
-
context?: "expression" | "jsx";
|
|
5
|
-
scope: Scope;
|
|
6
|
-
instance: Instance;
|
|
7
|
-
props: Props;
|
|
8
|
-
dataSources: DataSources;
|
|
9
|
-
usedDataSources: DataSources;
|
|
10
|
-
indexesWithinAncestors: IndexesWithinAncestors;
|
|
11
|
-
children: string;
|
|
12
|
-
classesMap?: Map<string, Array<string>>;
|
|
13
|
-
}) => string;
|
|
14
|
-
export declare const generateJsxChildren: ({ scope, children, instances, props, dataSources, usedDataSources, indexesWithinAncestors, classesMap, excludePlaceholders, }: {
|
|
15
|
-
scope: Scope;
|
|
16
|
-
children: Instance["children"];
|
|
17
|
-
instances: Instances;
|
|
18
|
-
props: Props;
|
|
19
|
-
dataSources: DataSources;
|
|
20
|
-
usedDataSources: DataSources;
|
|
21
|
-
indexesWithinAncestors: IndexesWithinAncestors;
|
|
22
|
-
classesMap?: Map<string, Array<string>>;
|
|
23
|
-
excludePlaceholders?: boolean;
|
|
24
|
-
}) => string;
|
|
25
|
-
export declare const generateWebstudioComponent: ({ scope, name, rootInstanceId, parameters, instances, props, dataSources, indexesWithinAncestors, classesMap, }: {
|
|
26
|
-
scope: Scope;
|
|
27
|
-
name: string;
|
|
28
|
-
rootInstanceId: Instance["id"];
|
|
29
|
-
parameters: Extract<Prop, {
|
|
30
|
-
type: "parameter";
|
|
31
|
-
}>[];
|
|
32
|
-
instances: Instances;
|
|
33
|
-
props: Props;
|
|
34
|
-
dataSources: DataSources;
|
|
35
|
-
indexesWithinAncestors: IndexesWithinAncestors;
|
|
36
|
-
classesMap: Map<string, Array<string>>;
|
|
37
|
-
}) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|