@webstudio-is/sdk 0.93.0 → 0.95.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.
@@ -31,3 +31,14 @@ export const findTreeInstanceIdsExcludingSlotDescendants = (instances, rootInsta
31
31
  });
32
32
  return ids;
33
33
  };
34
+ export const parseComponentName = (componentName) => {
35
+ const parts = componentName.split(":");
36
+ let namespace;
37
+ let name;
38
+ if (parts.length === 1) {
39
+ [name] = parts;
40
+ } else {
41
+ [namespace, name] = parts;
42
+ }
43
+ return [namespace, name];
44
+ };
@@ -2,7 +2,8 @@
2
2
  import { expect, test } from "@jest/globals";
3
3
  import {
4
4
  findTreeInstanceIds,
5
- findTreeInstanceIdsExcludingSlotDescendants
5
+ findTreeInstanceIdsExcludingSlotDescendants,
6
+ parseComponentName
6
7
  } from "./instances-utils";
7
8
  const createInstance = (id, component, children) => {
8
9
  return {
@@ -56,3 +57,7 @@ test("find all tree instances excluding slot descendants", () => {
56
57
  findTreeInstanceIdsExcludingSlotDescendants(instances, "box1")
57
58
  ).toEqual(/* @__PURE__ */ new Set(["box1", "box12", "slot11"]));
58
59
  });
60
+ test("extract short name and namespace from component name", () => {
61
+ expect(parseComponentName("Box")).toEqual([void 0, "Box"]);
62
+ expect(parseComponentName("radix:Box")).toEqual(["radix", "Box"]);
63
+ });
@@ -25,3 +25,4 @@ export declare const findTreeInstanceIdsExcludingSlotDescendants: (instances: Ma
25
25
  })[];
26
26
  label?: string | undefined;
27
27
  }>, rootInstanceId: Instance["id"]) => Set<string>;
28
+ export declare const parseComponentName: (componentName: string) => readonly [string | undefined, string];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk",
3
- "version": "0.93.0",
3
+ "version": "0.95.0",
4
4
  "description": "Webstudio site data schema",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -9,7 +9,8 @@
9
9
  "exports": {
10
10
  "source": "./src/index.ts",
11
11
  "types": "./lib/types/index.d.ts",
12
- "import": "./lib/index.js"
12
+ "import": "./lib/index.js",
13
+ "require": "./lib/index.js"
13
14
  },
14
15
  "files": [
15
16
  "lib/*",
@@ -18,8 +19,8 @@
18
19
  "sideEffects": false,
19
20
  "dependencies": {
20
21
  "zod": "^3.21.4",
21
- "@webstudio-is/fonts": "^0.93.0",
22
- "@webstudio-is/css-engine": "^0.93.0"
22
+ "@webstudio-is/fonts": "^0.95.0",
23
+ "@webstudio-is/css-engine": "^0.95.0"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@jest/globals": "^29.6.4",