@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.
- package/LICENSE +661 -0
- package/lib/__generated__/normalize.css.js +505 -0
- package/lib/core-templates.js +223 -0
- package/lib/index.js +1784 -0
- package/lib/runtime.js +101 -0
- package/lib/types/__generated__/normalize.css.d.ts +57 -0
- package/lib/types/core-metas.d.ts +748 -0
- package/lib/types/core-templates.d.ts +6 -0
- package/lib/types/expression.d.ts +58 -0
- package/lib/types/expression.test.d.ts +1 -0
- package/lib/types/form-fields.d.ts +8 -0
- package/lib/types/index.d.ts +23 -0
- package/lib/types/instances-utils.d.ts +5 -0
- package/lib/types/instances-utils.test.d.ts +1 -0
- package/lib/types/page-meta-generator.d.ts +24 -0
- package/lib/types/page-meta-generator.test.d.ts +1 -0
- package/lib/types/page-utils.d.ts +24 -0
- package/lib/types/page-utils.test.d.ts +1 -0
- package/lib/types/resource-loader.d.ts +30 -0
- package/lib/types/resource-loader.test.d.ts +1 -0
- package/lib/types/resources-generator.d.ts +22 -0
- package/lib/types/resources-generator.test.d.ts +1 -0
- package/lib/types/runtime.d.ts +3 -0
- package/lib/types/schema/assets.d.ts +527 -0
- package/lib/types/schema/breakpoints.d.ts +56 -0
- package/lib/types/schema/component-meta.d.ts +2118 -0
- package/lib/types/schema/data-sources.d.ts +303 -0
- package/lib/types/schema/deployment.d.ts +41 -0
- package/lib/types/schema/embed-template.d.ts +2250 -0
- package/lib/types/schema/instances.d.ts +417 -0
- package/lib/types/schema/pages.d.ts +675 -0
- package/lib/types/schema/prop-meta.d.ts +434 -0
- package/lib/types/schema/props.d.ts +549 -0
- package/lib/types/schema/resources.d.ts +121 -0
- package/lib/types/schema/style-source-selections.d.ts +23 -0
- package/lib/types/schema/style-sources.d.ts +62 -0
- package/lib/types/schema/styles.d.ts +2629 -0
- package/lib/types/schema/webstudio.d.ts +2374 -0
- package/lib/types/scope.d.ts +16 -0
- package/lib/types/scope.test.d.ts +1 -0
- package/lib/types/to-string.d.ts +2 -0
- package/lib/types/url-pattern.d.ts +2 -0
- package/lib/types/url-pattern.test.d.ts +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Identifier } from "acorn";
|
|
2
|
+
import type { DataSources } from "./schema/data-sources";
|
|
3
|
+
import type { Scope } from "./scope";
|
|
4
|
+
export type Diagnostic = {
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
7
|
+
severity: "error" | "hint" | "info" | "warning";
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const lintExpression: ({ expression, availableVariables, allowAssignment, }: {
|
|
11
|
+
expression: string;
|
|
12
|
+
availableVariables?: Set<Identifier["name"]>;
|
|
13
|
+
allowAssignment?: boolean;
|
|
14
|
+
}) => Diagnostic[];
|
|
15
|
+
/**
|
|
16
|
+
* check whether provided expression is a literal value
|
|
17
|
+
* like "", 0 or { param: "value" }
|
|
18
|
+
* which does not depends on any variable
|
|
19
|
+
*/
|
|
20
|
+
export declare const isLiteralExpression: (expression: string) => boolean;
|
|
21
|
+
export declare const getExpressionIdentifiers: (expression: string) => Set<string>;
|
|
22
|
+
/**
|
|
23
|
+
* transpile expression into executable one
|
|
24
|
+
*
|
|
25
|
+
* add optional chaining operator to every member expression
|
|
26
|
+
* to access any field without runtime errors
|
|
27
|
+
*
|
|
28
|
+
* replace variable names if necessary
|
|
29
|
+
*/
|
|
30
|
+
export declare const transpileExpression: ({ expression, executable, replaceVariable, }: {
|
|
31
|
+
expression: string;
|
|
32
|
+
executable?: boolean;
|
|
33
|
+
replaceVariable?: (identifier: string, assignee: boolean) => string | undefined | void;
|
|
34
|
+
}) => string;
|
|
35
|
+
/**
|
|
36
|
+
* parse object expression into key value map
|
|
37
|
+
* where each value is expression
|
|
38
|
+
*/
|
|
39
|
+
export declare const parseObjectExpression: (expression: string) => Map<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* generate key value map into object expression
|
|
42
|
+
* after updating individual value expressions
|
|
43
|
+
*/
|
|
44
|
+
export declare const generateObjectExpression: (map: Map<string, string>) => string;
|
|
45
|
+
export declare const encodeDataSourceVariable: (id: string) => string;
|
|
46
|
+
export { encodeDataSourceVariable as encodeDataVariableId };
|
|
47
|
+
export declare const decodeDataSourceVariable: (name: string) => string | undefined;
|
|
48
|
+
export { decodeDataSourceVariable as decodeDataVariableId };
|
|
49
|
+
export declare const generateExpression: ({ expression, dataSources, usedDataSources, scope, }: {
|
|
50
|
+
expression: string;
|
|
51
|
+
dataSources: DataSources;
|
|
52
|
+
usedDataSources: DataSources;
|
|
53
|
+
scope: Scope;
|
|
54
|
+
}) => string;
|
|
55
|
+
/**
|
|
56
|
+
* edge case utility for "statoc" expression without variables
|
|
57
|
+
*/
|
|
58
|
+
export declare const executeExpression: (expression: undefined | string) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from "./schema/assets";
|
|
2
|
+
export * from "./schema/pages";
|
|
3
|
+
export * from "./schema/instances";
|
|
4
|
+
export * from "./schema/data-sources";
|
|
5
|
+
export * from "./schema/resources";
|
|
6
|
+
export * from "./schema/props";
|
|
7
|
+
export * from "./schema/breakpoints";
|
|
8
|
+
export * from "./schema/style-sources";
|
|
9
|
+
export * from "./schema/style-source-selections";
|
|
10
|
+
export * from "./schema/styles";
|
|
11
|
+
export * from "./schema/deployment";
|
|
12
|
+
export * from "./schema/webstudio";
|
|
13
|
+
export * from "./schema/prop-meta";
|
|
14
|
+
export * from "./schema/embed-template";
|
|
15
|
+
export * from "./schema/component-meta";
|
|
16
|
+
export * from "./core-metas";
|
|
17
|
+
export * from "./instances-utils";
|
|
18
|
+
export * from "./page-utils";
|
|
19
|
+
export * from "./scope";
|
|
20
|
+
export * from "./expression";
|
|
21
|
+
export * from "./resources-generator";
|
|
22
|
+
export * from "./page-meta-generator";
|
|
23
|
+
export * from "./url-pattern";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Instance, Instances } from "./schema/instances";
|
|
2
|
+
export declare const ROOT_INSTANCE_ID = ":root";
|
|
3
|
+
export declare const findTreeInstanceIds: (instances: Instances, rootInstanceId: Instance["id"]) => Set<string>;
|
|
4
|
+
export declare const findTreeInstanceIdsExcludingSlotDescendants: (instances: Instances, rootInstanceId: Instance["id"]) => Set<string>;
|
|
5
|
+
export declare const parseComponentName: (componentName: string) => readonly [string | undefined, string];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Asset, Assets } from "./schema/assets";
|
|
2
|
+
import type { DataSources } from "./schema/data-sources";
|
|
3
|
+
import type { Page } from "./schema/pages";
|
|
4
|
+
import { type Scope } from "./scope";
|
|
5
|
+
export type PageMeta = {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
excludePageFromSearch?: boolean;
|
|
9
|
+
language?: string;
|
|
10
|
+
socialImageAssetName?: Asset["name"];
|
|
11
|
+
socialImageUrl?: string;
|
|
12
|
+
status?: number;
|
|
13
|
+
redirect?: string;
|
|
14
|
+
custom: Array<{
|
|
15
|
+
property: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
export declare const generatePageMeta: ({ globalScope, page, dataSources, assets, }: {
|
|
20
|
+
globalScope: Scope;
|
|
21
|
+
page: Page;
|
|
22
|
+
dataSources: DataSources;
|
|
23
|
+
assets: Assets;
|
|
24
|
+
}) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Folder, Page, Pages } from "./schema/pages";
|
|
2
|
+
export declare const ROOT_FOLDER_ID = "root";
|
|
3
|
+
/**
|
|
4
|
+
* Returns true if folder is the root folder.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isRootFolder: ({ id }: {
|
|
7
|
+
id: Folder["id"];
|
|
8
|
+
}) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Find a page by id or path.
|
|
11
|
+
*/
|
|
12
|
+
export declare const findPageByIdOrPath: (idOrPath: string, pages: Pages) => Page | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Find a folder that has has that id in the children.
|
|
15
|
+
*/
|
|
16
|
+
export declare const findParentFolderByChildId: (id: Folder["id"] | Page["id"], folders: Array<Folder>) => Folder | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get a path from all folder slugs from root to the current folder or page.
|
|
19
|
+
*/
|
|
20
|
+
export declare const getPagePath: (id: Folder["id"] | Page["id"], pages: Pages) => string;
|
|
21
|
+
export declare const getStaticSiteMapXml: (pages: Pages, updatedAt: string) => {
|
|
22
|
+
path: string;
|
|
23
|
+
lastModified: string;
|
|
24
|
+
}[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ResourceRequest } from "./schema/resources";
|
|
2
|
+
/**
|
|
3
|
+
* Prevents fetch cycles by prefixing local resources.
|
|
4
|
+
*/
|
|
5
|
+
export declare const isLocalResource: (pathname: string, resourceName?: string) => boolean;
|
|
6
|
+
export declare const sitemapResourceUrl = "/$resources/sitemap.xml";
|
|
7
|
+
export declare const loadResource: (customFetch: typeof fetch, resourceRequest: ResourceRequest) => Promise<{
|
|
8
|
+
ok: boolean;
|
|
9
|
+
data: string;
|
|
10
|
+
status: number;
|
|
11
|
+
statusText: string;
|
|
12
|
+
} | {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
data: undefined;
|
|
15
|
+
status: number;
|
|
16
|
+
statusText: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const loadResources: (customFetch: typeof fetch, requests: Map<string, ResourceRequest>) => Promise<{
|
|
19
|
+
[k: string]: {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
data: string;
|
|
22
|
+
status: number;
|
|
23
|
+
statusText: string;
|
|
24
|
+
} | {
|
|
25
|
+
ok: boolean;
|
|
26
|
+
data: undefined;
|
|
27
|
+
status: number;
|
|
28
|
+
statusText: string;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DataSources } from "./schema/data-sources";
|
|
2
|
+
import type { Page } from "./schema/pages";
|
|
3
|
+
import type { Resources } from "./schema/resources";
|
|
4
|
+
import type { Props } from "./schema/props";
|
|
5
|
+
import type { Instances } from "./schema/instances";
|
|
6
|
+
import type { Scope } from "./scope";
|
|
7
|
+
export declare const generateResources: ({ scope, page, dataSources, props, resources, }: {
|
|
8
|
+
scope: Scope;
|
|
9
|
+
page: Page;
|
|
10
|
+
dataSources: DataSources;
|
|
11
|
+
props: Props;
|
|
12
|
+
resources: Resources;
|
|
13
|
+
}) => string;
|
|
14
|
+
/**
|
|
15
|
+
* migrate webhook forms to resource action
|
|
16
|
+
* @todo move to client migrations eventually
|
|
17
|
+
*/
|
|
18
|
+
export declare const replaceFormActionsWithResources: ({ props, instances, resources, }: {
|
|
19
|
+
props: Props;
|
|
20
|
+
instances: Instances;
|
|
21
|
+
resources: Resources;
|
|
22
|
+
}) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|