@webstudio-is/react-sdk 0.6.1 → 0.7.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/components/component-type.d.ts +1 -1
- package/lib/components/component-type.d.ts.map +1 -1
- package/lib/components/component-type.js +2 -2
- package/lib/components/image.d.ts +3 -0
- package/lib/components/image.d.ts.map +1 -0
- package/lib/components/image.js +42 -0
- package/lib/components/image.props.json +2533 -0
- package/lib/components/image.stories.d.ts +6 -0
- package/lib/components/image.stories.d.ts.map +1 -0
- package/lib/components/image.stories.js +17 -0
- package/lib/components/image.ws.d.ts +5 -0
- package/lib/components/image.ws.d.ts.map +1 -0
- package/lib/components/image.ws.js +14 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +3 -1
- package/lib/components/index.test.js +1 -1
- package/lib/components/link.d.ts +1 -1
- package/lib/components/link.stories.d.ts +2 -2
- package/lib/components/meta.d.ts +1 -0
- package/lib/components/meta.d.ts.map +1 -1
- package/lib/components/meta.js +3 -1
- package/lib/css/breakpoints.d.ts +1 -1
- package/lib/css/breakpoints.d.ts.map +1 -1
- package/lib/css/categories.d.ts +3 -3
- package/lib/css/get-browser-style.d.ts +1 -1
- package/lib/css/get-browser-style.d.ts.map +1 -1
- package/lib/css/index.d.ts +1 -1
- package/lib/css/index.d.ts.map +1 -1
- package/lib/css/index.js +1 -1
- package/lib/css/keyword-values.d.ts.map +1 -1
- package/lib/css/keyword-values.js +396 -1149
- package/lib/css/properties.d.ts.map +1 -1
- package/lib/css/properties.js +3196 -3196
- package/lib/css/schema.d.ts +142 -10
- package/lib/css/schema.d.ts.map +1 -1
- package/lib/css/schema.js +25 -15
- package/lib/css/types.d.ts +0 -9
- package/lib/css/types.d.ts.map +1 -1
- package/lib/css/units.js +1 -1
- package/lib/db/instance.d.ts +2 -2
- package/lib/db/instance.d.ts.map +1 -1
- package/lib/db/instance.js +4 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/remix/constants.d.ts +2 -0
- package/lib/remix/constants.d.ts.map +1 -0
- package/lib/remix/constants.js +4 -0
- package/lib/remix/handle-request.server.d.ts +3 -0
- package/lib/remix/handle-request.server.d.ts.map +1 -0
- package/lib/remix/handle-request.server.js +16 -0
- package/lib/remix/index.d.ts +3 -0
- package/lib/remix/index.d.ts.map +1 -0
- package/lib/{canvas → remix}/index.js +2 -1
- package/lib/remix/insert-critical-css.d.ts +2 -0
- package/lib/remix/insert-critical-css.d.ts.map +1 -0
- package/lib/remix/insert-critical-css.js +9 -0
- package/lib/{canvas/canvas.d.ts → remix/root.d.ts} +1 -1
- package/lib/remix/root.d.ts.map +1 -0
- package/lib/{canvas/canvas.js → remix/root.js} +2 -2
- package/lib/stitches/index.d.ts +1 -2
- package/lib/stitches/index.d.ts.map +1 -1
- package/lib/stitches/index.js +1 -2
- package/lib/stitches/stitches.d.ts +8 -0
- package/lib/stitches/stitches.d.ts.map +1 -0
- package/lib/stitches/{css.js → stitches.js} +12 -7
- package/lib/stitches/to-css.d.ts +1 -1
- package/lib/stitches/to-css.d.ts.map +1 -1
- package/lib/stitches/to-css.js +9 -0
- package/lib/stitches/to-css.test.js +20 -1
- package/lib/tree/root.d.ts +5 -1
- package/lib/tree/root.d.ts.map +1 -1
- package/lib/tree/root.js +20 -7
- package/lib/user-props/schema.d.ts +3 -2
- package/lib/user-props/schema.d.ts.map +1 -1
- package/lib/user-props/schema.js +3 -3
- package/lib/user-props/types.d.ts +1 -3
- package/lib/user-props/types.d.ts.map +1 -1
- package/lib/user-props/use-user-props.d.ts +1 -1
- package/lib/user-props/use-user-props.d.ts.map +1 -1
- package/package.json +5 -3
- package/lib/canvas/canvas.d.ts.map +0 -1
- package/lib/canvas/index.d.ts +0 -2
- package/lib/canvas/index.d.ts.map +0 -1
- package/lib/stitches/critical-css.d.ts +0 -4
- package/lib/stitches/critical-css.d.ts.map +0 -1
- package/lib/stitches/critical-css.js +0 -12
- package/lib/stitches/css.d.ts +0 -9
- package/lib/stitches/css.d.ts.map +0 -1
package/lib/tree/root.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { Tree, InstanceProps } from "../db";
|
|
2
2
|
import type { Breakpoint } from "../css";
|
|
3
3
|
import { type WrapperComponentProps } from "./wrapper-component";
|
|
4
|
+
import type { Asset } from "@webstudio-is/asset-uploader";
|
|
4
5
|
export declare type Data = {
|
|
5
6
|
tree: Tree | null;
|
|
6
7
|
breakpoints: Array<Breakpoint>;
|
|
7
8
|
props: Array<InstanceProps>;
|
|
9
|
+
assets: Array<Asset>;
|
|
8
10
|
};
|
|
9
|
-
export declare const
|
|
11
|
+
export declare const useGlobalStyles: ({ assets }: {
|
|
12
|
+
assets: Array<Asset>;
|
|
13
|
+
}) => void;
|
|
10
14
|
declare type RootProps = {
|
|
11
15
|
data: Data;
|
|
12
16
|
Component?: (props: WrapperComponentProps) => JSX.Element;
|
package/lib/tree/root.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/tree/root.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/tree/root.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,8BAA8B,CAAC;AAGrE,oBAAY,IAAI,GAAG;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC5B,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,eAAe;YAA0B,MAAM,KAAK,CAAC;UAmBjE,CAAC;AAEF,aAAK,SAAS,GAAG;IACf,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,GAAG,CAAC,OAAO,CAAC;CAC3D,CAAC;AAEF,eAAO,MAAM,YAAY,yBAGtB,SAAS,KAAG,WAAW,GAAG,IAY5B,CAAC"}
|
package/lib/tree/root.js
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InstanceRoot = exports.
|
|
3
|
+
exports.InstanceRoot = exports.useGlobalStyles = void 0;
|
|
4
4
|
const user_props_1 = require("../user-props/");
|
|
5
5
|
const stitches_1 = require("../stitches");
|
|
6
6
|
const create_elements_tree_1 = require("./create-elements-tree");
|
|
7
7
|
const wrapper_component_1 = require("./wrapper-component");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const fonts_1 = require("@webstudio-is/fonts");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const useGlobalStyles = ({ assets }) => {
|
|
11
|
+
const ref = (0, react_1.useRef)();
|
|
12
|
+
// This may look weird, but globalCss API doesn't allow us creating global styles with data,
|
|
13
|
+
// so we have to manually ensure calling it only once
|
|
14
|
+
if (ref.current === assets)
|
|
15
|
+
return;
|
|
16
|
+
const fontAssets = assets.filter((asset) => fonts_1.FONT_FORMATS.has(asset.format));
|
|
17
|
+
(0, stitches_1.globalCss)({
|
|
18
|
+
"@font-face": (0, fonts_1.getFontFaces)(fontAssets),
|
|
19
|
+
html: {
|
|
20
|
+
height: "100%",
|
|
21
|
+
},
|
|
22
|
+
})();
|
|
23
|
+
ref.current = assets;
|
|
24
|
+
};
|
|
25
|
+
exports.useGlobalStyles = useGlobalStyles;
|
|
13
26
|
const InstanceRoot = ({ data, Component, }) => {
|
|
14
27
|
if (data.tree === null) {
|
|
15
28
|
throw new Error("Tree is null");
|
|
16
29
|
}
|
|
17
30
|
(0, stitches_1.setBreakpoints)(data.breakpoints);
|
|
18
|
-
(0, exports.
|
|
31
|
+
(0, exports.useGlobalStyles)({ assets: data.assets });
|
|
19
32
|
(0, user_props_1.useAllUserProps)(data.props);
|
|
20
33
|
return (0, create_elements_tree_1.createElementsTree)({
|
|
21
34
|
instance: data.tree.root,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UserProp: z.ZodObject<{
|
|
3
3
|
id: z.ZodString;
|
|
4
4
|
prop: z.ZodString;
|
|
5
5
|
value: z.ZodUnion<[z.ZodString, z.ZodBoolean]>;
|
|
@@ -15,7 +15,8 @@ export declare const UserPropSchema: z.ZodObject<{
|
|
|
15
15
|
id: string;
|
|
16
16
|
prop: string;
|
|
17
17
|
}>;
|
|
18
|
-
export declare
|
|
18
|
+
export declare type UserProp = z.infer<typeof UserProp>;
|
|
19
|
+
export declare const UserProps: z.ZodArray<z.ZodObject<{
|
|
19
20
|
id: z.ZodString;
|
|
20
21
|
prop: z.ZodString;
|
|
21
22
|
value: z.ZodUnion<[z.ZodString, z.ZodBoolean]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/user-props/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/user-props/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;EAKnB,CAAC;AAEH,oBAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;WAAoB,CAAC"}
|
package/lib/user-props/schema.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.UserProps = exports.UserProp = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.
|
|
5
|
+
exports.UserProp = zod_1.z.object({
|
|
6
6
|
id: zod_1.z.string(),
|
|
7
7
|
prop: zod_1.z.string(),
|
|
8
8
|
value: zod_1.z.union([zod_1.z.string(), zod_1.z.boolean()]),
|
|
9
9
|
required: zod_1.z.optional(zod_1.z.boolean()),
|
|
10
10
|
});
|
|
11
|
-
exports.
|
|
11
|
+
exports.UserProps = zod_1.z.array(exports.UserProp);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
1
|
import type { InstanceProps, Instance } from "../db";
|
|
3
|
-
import {
|
|
4
|
-
export declare type UserProp = z.infer<typeof UserPropSchema>;
|
|
2
|
+
import { UserProp } from "./schema";
|
|
5
3
|
export declare type UserPropsUpdates = {
|
|
6
4
|
treeId: InstanceProps["treeId"];
|
|
7
5
|
propsId: InstanceProps["id"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/user-props/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/user-props/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC1B,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-user-props.d.ts","sourceRoot":"","sources":["../../src/user-props/use-user-props.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"use-user-props.d.ts","sourceRoot":"","sources":["../../src/user-props/use-user-props.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,aAAK,SAAS,GAAG;IAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,YAAY,eAAgB,QAAQ,CAAC,IAAI,CAAC,cAuBtD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "tsup src/index.ts --format esm,cjs --watch --out-dir=lib",
|
|
9
|
-
"build": "yarn build:
|
|
9
|
+
"build": "yarn build:lib",
|
|
10
10
|
"build:mdn-data": "tsx ./bin/mdn-data.ts ./src/css",
|
|
11
11
|
"build:args": "tsx ./bin/generate-arg-types.ts './src/components/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx'",
|
|
12
12
|
"typecheck": "tsc --noEmit",
|
|
13
|
-
"build:lib": "rm -fr lib && tsc",
|
|
13
|
+
"build:lib": "rm -fr lib tsconfig.tsbuildinfo && tsc",
|
|
14
14
|
"test": "jest",
|
|
15
15
|
"lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",
|
|
16
16
|
"checks": "yarn typecheck && yarn lint && yarn test",
|
|
@@ -58,8 +58,10 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@stitches/core": "^1.2.7",
|
|
61
|
+
"@webstudio-is/asset-uploader": "^*",
|
|
61
62
|
"@webstudio-is/icons": "*",
|
|
62
63
|
"@webstudio-is/jest-config": "*",
|
|
64
|
+
"@webstudio-is/fonts": "*",
|
|
63
65
|
"immer": "^9.0.12",
|
|
64
66
|
"mitt": "^3.0.0",
|
|
65
67
|
"react-nano-state": "^0.4.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../../src/canvas/canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE;;GAEG;AACH,eAAO,MAAM,IAAI;YAGP,oBAAoB;iBAgB7B,CAAC"}
|
package/lib/canvas/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"critical-css.d.ts","sourceRoot":"","sources":["../../src/stitches/critical-css.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAIxD,eAAO,MAAM,WAAW,QAAO,WAAW,GAAG,IACsB,CAAC;AAEpE,eAAO,MAAM,iBAAiB,WACpB,MAAM,eACF,wBAAwB,KACnC,MAEF,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.insertCriticalCss = exports.CriticalCss = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const css_1 = require("./css");
|
|
6
|
-
const criticalCssMarker = "__critical-css__";
|
|
7
|
-
const CriticalCss = () => typeof document === "undefined" ? (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: criticalCssMarker }) : null;
|
|
8
|
-
exports.CriticalCss = CriticalCss;
|
|
9
|
-
const insertCriticalCss = (markup, getCssText = css_1.getCssText) => {
|
|
10
|
-
return markup.replace(criticalCssMarker, `<style>${getCssText()}</style>`);
|
|
11
|
-
};
|
|
12
|
-
exports.insertCriticalCss = insertCriticalCss;
|
package/lib/stitches/css.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { globalCss, type CSS, css as createCss } from "@stitches/core";
|
|
2
|
-
import type { Breakpoint } from "../css";
|
|
3
|
-
export declare const getCachedConfig: () => any;
|
|
4
|
-
export declare const css: typeof createCss;
|
|
5
|
-
export { globalCss };
|
|
6
|
-
export { type CSS };
|
|
7
|
-
export declare const getCssText: () => string;
|
|
8
|
-
export declare const setBreakpoints: (breakpoints: Array<Breakpoint>) => void;
|
|
9
|
-
//# sourceMappingURL=css.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/stitches/css.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,KAAK,GAAG,EACR,GAAG,IAAI,SAAS,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQzC,eAAO,MAAM,eAAe,WAK3B,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,OAAO,SAExB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAE,KAAK,GAAG,EAAE,CAAC;AAEpB,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAC;AAEF,eAAO,MAAM,cAAc,gBAAiB,MAAM,UAAU,CAAC,SAO5D,CAAC"}
|