@webstudio-is/sdk 0.0.0-021f2d4

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.
Files changed (44) hide show
  1. package/LICENSE +661 -0
  2. package/lib/__generated__/normalize.css.js +505 -0
  3. package/lib/core-templates.js +223 -0
  4. package/lib/index.js +1784 -0
  5. package/lib/runtime.js +101 -0
  6. package/lib/types/__generated__/normalize.css.d.ts +57 -0
  7. package/lib/types/core-metas.d.ts +748 -0
  8. package/lib/types/core-templates.d.ts +6 -0
  9. package/lib/types/expression.d.ts +58 -0
  10. package/lib/types/expression.test.d.ts +1 -0
  11. package/lib/types/form-fields.d.ts +8 -0
  12. package/lib/types/index.d.ts +23 -0
  13. package/lib/types/instances-utils.d.ts +5 -0
  14. package/lib/types/instances-utils.test.d.ts +1 -0
  15. package/lib/types/page-meta-generator.d.ts +24 -0
  16. package/lib/types/page-meta-generator.test.d.ts +1 -0
  17. package/lib/types/page-utils.d.ts +24 -0
  18. package/lib/types/page-utils.test.d.ts +1 -0
  19. package/lib/types/resource-loader.d.ts +30 -0
  20. package/lib/types/resource-loader.test.d.ts +1 -0
  21. package/lib/types/resources-generator.d.ts +22 -0
  22. package/lib/types/resources-generator.test.d.ts +1 -0
  23. package/lib/types/runtime.d.ts +3 -0
  24. package/lib/types/schema/assets.d.ts +527 -0
  25. package/lib/types/schema/breakpoints.d.ts +56 -0
  26. package/lib/types/schema/component-meta.d.ts +2118 -0
  27. package/lib/types/schema/data-sources.d.ts +303 -0
  28. package/lib/types/schema/deployment.d.ts +41 -0
  29. package/lib/types/schema/embed-template.d.ts +2250 -0
  30. package/lib/types/schema/instances.d.ts +417 -0
  31. package/lib/types/schema/pages.d.ts +675 -0
  32. package/lib/types/schema/prop-meta.d.ts +434 -0
  33. package/lib/types/schema/props.d.ts +549 -0
  34. package/lib/types/schema/resources.d.ts +121 -0
  35. package/lib/types/schema/style-source-selections.d.ts +23 -0
  36. package/lib/types/schema/style-sources.d.ts +62 -0
  37. package/lib/types/schema/styles.d.ts +2629 -0
  38. package/lib/types/schema/webstudio.d.ts +2374 -0
  39. package/lib/types/scope.d.ts +16 -0
  40. package/lib/types/scope.test.d.ts +1 -0
  41. package/lib/types/to-string.d.ts +2 -0
  42. package/lib/types/url-pattern.d.ts +2 -0
  43. package/lib/types/url-pattern.test.d.ts +1 -0
  44. package/package.json +60 -0
package/lib/runtime.js ADDED
@@ -0,0 +1,101 @@
1
+ // src/resource-loader.ts
2
+ var LOCAL_RESOURCE_PREFIX = "$resources";
3
+ var isLocalResource = (pathname, resourceName) => {
4
+ const segments = pathname.split("/").filter(Boolean);
5
+ if (resourceName === void 0) {
6
+ return segments[0] === LOCAL_RESOURCE_PREFIX;
7
+ }
8
+ return segments.join("/") === `${LOCAL_RESOURCE_PREFIX}/${resourceName}`;
9
+ };
10
+ var sitemapResourceUrl = `/${LOCAL_RESOURCE_PREFIX}/sitemap.xml`;
11
+ var loadResource = async (customFetch, resourceRequest) => {
12
+ const { url, method, headers, body } = resourceRequest;
13
+ const requestHeaders = new Headers(
14
+ headers.map(({ name, value }) => [name, value])
15
+ );
16
+ const requestInit = {
17
+ method,
18
+ headers: requestHeaders
19
+ };
20
+ if (method !== "get" && body !== void 0) {
21
+ if (typeof body === "string") {
22
+ requestInit.body = body;
23
+ }
24
+ if (typeof body === "object") {
25
+ requestInit.body = JSON.stringify(body);
26
+ }
27
+ }
28
+ try {
29
+ const response = await customFetch(url.trim(), requestInit);
30
+ let data = await response.text();
31
+ try {
32
+ data = JSON.parse(data);
33
+ } catch {
34
+ }
35
+ if (!response.ok) {
36
+ console.error(
37
+ `Failed to load resource: ${url} - ${response.status}: ${JSON.stringify(data).slice(0, 300)}`
38
+ );
39
+ }
40
+ return {
41
+ ok: response.ok,
42
+ data,
43
+ status: response.status,
44
+ statusText: response.statusText
45
+ };
46
+ } catch (error) {
47
+ console.error(error);
48
+ const message = error.message;
49
+ return {
50
+ ok: false,
51
+ data: void 0,
52
+ status: 500,
53
+ statusText: message
54
+ };
55
+ }
56
+ };
57
+ var loadResources = async (customFetch, requests) => {
58
+ return Object.fromEntries(
59
+ await Promise.all(
60
+ Array.from(
61
+ requests,
62
+ async ([name, request]) => [name, await loadResource(customFetch, request)]
63
+ )
64
+ )
65
+ );
66
+ };
67
+
68
+ // src/to-string.ts
69
+ var createJsonStringifyProxy = (target) => {
70
+ return new Proxy(target, {
71
+ get(target2, prop, receiver) {
72
+ if (prop === "toString") {
73
+ return function() {
74
+ return JSON.stringify(target2);
75
+ };
76
+ }
77
+ const value = Reflect.get(target2, prop, receiver);
78
+ if (typeof value === "object" && value !== null) {
79
+ return createJsonStringifyProxy(value);
80
+ }
81
+ return value;
82
+ }
83
+ });
84
+ };
85
+ var isPlainObject = (value) => {
86
+ return Object.prototype.toString.call(value) === "[object Object]" && (Object.getPrototypeOf(value) === null || Object.getPrototypeOf(value) === Object.prototype);
87
+ };
88
+
89
+ // src/form-fields.ts
90
+ var formIdFieldName = `ws--form-id`;
91
+ var formBotFieldName = `ws--form-bot`;
92
+ export {
93
+ createJsonStringifyProxy,
94
+ formBotFieldName,
95
+ formIdFieldName,
96
+ isLocalResource,
97
+ isPlainObject,
98
+ loadResource,
99
+ loadResources,
100
+ sitemapResourceUrl
101
+ };
@@ -0,0 +1,57 @@
1
+ import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";
2
+ type StyleDecl = {
3
+ state?: string;
4
+ property: StyleProperty;
5
+ value: StyleValue;
6
+ };
7
+ export declare const div: StyleDecl[];
8
+ export declare const address: StyleDecl[];
9
+ export declare const article: StyleDecl[];
10
+ export declare const aside: StyleDecl[];
11
+ export declare const figure: StyleDecl[];
12
+ export declare const footer: StyleDecl[];
13
+ export declare const header: StyleDecl[];
14
+ export declare const main: StyleDecl[];
15
+ export declare const nav: StyleDecl[];
16
+ export declare const section: StyleDecl[];
17
+ export declare const form: StyleDecl[];
18
+ export declare const label: StyleDecl[];
19
+ export declare const time: StyleDecl[];
20
+ export declare const h1: StyleDecl[];
21
+ export declare const h2: StyleDecl[];
22
+ export declare const h3: StyleDecl[];
23
+ export declare const h4: StyleDecl[];
24
+ export declare const h5: StyleDecl[];
25
+ export declare const h6: StyleDecl[];
26
+ export declare const i: StyleDecl[];
27
+ export declare const img: StyleDecl[];
28
+ export declare const a: StyleDecl[];
29
+ export declare const li: StyleDecl[];
30
+ export declare const ul: StyleDecl[];
31
+ export declare const ol: StyleDecl[];
32
+ export declare const p: StyleDecl[];
33
+ export declare const span: StyleDecl[];
34
+ export declare const html: StyleDecl[];
35
+ export declare const body: StyleDecl[];
36
+ export declare const hr: StyleDecl[];
37
+ export declare const b: StyleDecl[];
38
+ export declare const strong: StyleDecl[];
39
+ export declare const code: StyleDecl[];
40
+ export declare const kbd: StyleDecl[];
41
+ export declare const samp: StyleDecl[];
42
+ export declare const pre: StyleDecl[];
43
+ export declare const small: StyleDecl[];
44
+ export declare const sub: StyleDecl[];
45
+ export declare const sup: StyleDecl[];
46
+ export declare const table: StyleDecl[];
47
+ export declare const input: StyleDecl[];
48
+ export declare const textarea: StyleDecl[];
49
+ export declare const optgroup: StyleDecl[];
50
+ export declare const radio: StyleDecl[];
51
+ export declare const checkbox: StyleDecl[];
52
+ export declare const button: StyleDecl[];
53
+ export declare const select: StyleDecl[];
54
+ export declare const legend: StyleDecl[];
55
+ export declare const progress: StyleDecl[];
56
+ export declare const summary: StyleDecl[];
57
+ export {};