@turbofy-ai/app-runtime 0.0.20 → 0.0.22

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.
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Shared color painting for the editor preview and the published app.
3
+ * Color keys stay `role:solid:HEX:OPACITY` so a saved override finds the
4
+ * same computed color in both places.
5
+ */
6
+ export type IBlockColorRole = "background" | "text" | "border";
7
+ export type IBlockColorKind = "solid" | "linear";
8
+ export type IGradientStop = {
9
+ /** Position along the gradient, from 0 to 100. */
10
+ position: number;
11
+ hex: string;
12
+ opacity: number;
13
+ };
14
+ /** A linear gradient, including Tailwind `from` / `via` / `to` stops. */
15
+ export type ILinearGradient = {
16
+ /** CSS direction such as `to right`. */
17
+ direction: string;
18
+ stops: IGradientStop[];
19
+ };
20
+ export type IBlockColorOverride = {
21
+ /** Present when a solid color replaces the source color. */
22
+ hex?: string;
23
+ opacity: number;
24
+ /** Present when the color is a linear gradient. */
25
+ gradient?: ILinearGradient;
26
+ };
27
+ /** A color discovered on a block, plus the source it should match after edits. */
28
+ export type IBlockColor = {
29
+ id: string;
30
+ role: IBlockColorRole;
31
+ kind: IBlockColorKind;
32
+ /** Uppercase hex without '#'. Empty while a gradient is still a gradient. */
33
+ hex: string;
34
+ opacity: number;
35
+ /** CSS used to paint the swatch (a color or a gradient). */
36
+ swatch: string;
37
+ sourceKind: IBlockColorKind;
38
+ sourceHex: string;
39
+ sourceOpacity: number;
40
+ sourceSwatch: string;
41
+ /** Stops for the current linear gradient, when this color is one. */
42
+ gradient?: ILinearGradient;
43
+ sourceGradient?: ILinearGradient;
44
+ };
45
+ export declare const clampOpacity: (value: number) => number;
46
+ export declare const parseHex: (input: string) => string | null;
47
+ export declare const rgbToHex: (red: number, green: number, blue: number) => string;
48
+ export declare const hexToRgb: (hex: string) => {
49
+ r: number;
50
+ g: number;
51
+ b: number;
52
+ };
53
+ /**
54
+ * Parses hex and rgb()/rgba() colors.
55
+ * Transparent colors are skipped unless `allowTransparent` is set, which
56
+ * gradient stops need so a fade to transparent still has that stop.
57
+ */
58
+ export declare const parseCssColor: (value: string, allowTransparent?: boolean) => {
59
+ hex: string;
60
+ opacity: number;
61
+ } | null;
62
+ /** Resolves modern CSS colors (oklch, lab, hsl) through a canvas when needed. */
63
+ export declare const resolveCssColor: (value: string) => {
64
+ hex: string;
65
+ opacity: number;
66
+ } | null;
67
+ export declare const toCssColor: (hex: string, opacity: number) => string;
68
+ export declare const solidColorId: (role: IBlockColorRole, hex: string, opacity: number) => string;
69
+ export declare const gradientColorId: (gradient: string) => string;
70
+ export declare const normalizeGradient: (gradient: string) => string;
71
+ export declare const firstGradientColor: (gradient: string) => {
72
+ hex: string;
73
+ opacity: number;
74
+ };
75
+ export declare const fadeGradient: (gradient: string, opacity: number) => string;
76
+ export declare const overrideMatchesSource: (color: IBlockColor, override: IBlockColorOverride) => boolean;
77
+ export declare const presentColor: (color: IBlockColor, override: IBlockColorOverride) => IBlockColor;
78
+ /** Parses a CSS `linear-gradient(...)`, including Tailwind's computed stops. */
79
+ export declare const parseLinearGradient: (value: string) => ILinearGradient | null;
80
+ export declare const linearGradientToCss: (gradient: ILinearGradient) => string;
81
+ /**
82
+ * Reads `bg-gradient-to-* from-* via-* to-*` (and Tailwind v4 `bg-linear-to-*`).
83
+ * Arbitrary hex and rgb stops are supported.
84
+ */
85
+ export declare const tailwindGradientFromClassName: (className: string) => ILinearGradient | null;
86
+ /** Stable id from Tailwind gradient classes. Null when the class list has none. */
87
+ export declare const tailwindGradientId: (className: string) => string | null;
88
+ export declare const gradientsEqual: (left: ILinearGradient | undefined, right: ILinearGradient | undefined) => boolean;
89
+ export declare const readColorOverrides: (config: unknown) => Record<string, IBlockColorOverride>;
@@ -0,0 +1,3 @@
1
+ export declare const BLOCK_COLOR_HIDE_RULE = "[data-block-colors]:not([data-block-colors-ready]){visibility:hidden}";
2
+ /** Calls back when a stylesheet in `head` gains CSS the block can compute. */
3
+ export declare const watchColorStyles: (onChange: () => void) => () => void;
@@ -0,0 +1,8 @@
1
+ import { type IBlockColor, type IBlockColorOverride } from "./paint-deps";
2
+ /**
3
+ * Drops painted stamps and puts author inline styles back so the next sync
4
+ * reads the stylesheet again. Used when Tailwind replaces its generated CSS.
5
+ */
6
+ export declare const releasePaintedColors: (root: HTMLElement) => void;
7
+ /** Reads block colors and applies overrides in place. Source ids stay stable. */
8
+ export declare const syncBlockColors: (root: HTMLElement, overrides: Record<string, IBlockColorOverride>) => IBlockColor[];
@@ -8,5 +8,19 @@ interface IPageAuthConfig {
8
8
  loginPath?: string;
9
9
  defaultPath?: string;
10
10
  }
11
+ /**
12
+ * Drop `next` hops that point at the same path (`/de?next=/de?next=...`).
13
+ * A single hop to a different path is kept. Outer query params other than
14
+ * `next` survive a peel. Walking stops after MAX_REDIRECT_HOPS.
15
+ */
16
+ export declare const collapseRedirectPath: (value: string) => string;
17
+ /** Keep `value` when it is already a single hop, otherwise return the peeled path. */
18
+ export declare const stableRedirectPath: (value: string) => string;
19
+ export declare const isSameAppLocation: (a: string, b: string) => boolean;
20
+ /**
21
+ * Follow local `next` hops to the page that was actually requested.
22
+ * `locale` is redirect metadata and is not part of that page.
23
+ */
24
+ export declare const unwrapRedirectTarget: (value: string) => string;
11
25
  export declare const getPageRedirect: (url: URL, signedIn: boolean, config: IPageAuthConfig) => string | null | undefined;
12
26
  export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turbofy-ai/app-runtime",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -9,6 +9,11 @@
9
9
  "./api": {
10
10
  "types": "./dist/src/api.d.ts"
11
11
  },
12
+ "./cloud-function": {
13
+ "types": "./dist/src/cloud-function.d.ts",
14
+ "import": "./dist/src/cloud-function.js",
15
+ "default": "./dist/src/cloud-function.js"
16
+ },
12
17
  "./dsl": {
13
18
  "types": "./dist/src/dsl.d.ts",
14
19
  "import": "./dist/src/dsl.js",
@@ -29,11 +34,12 @@
29
34
  "dist"
30
35
  ],
31
36
  "scripts": {
32
- "build": "npm run generate && tsc && tsx scripts/bundle-dsl.ts",
37
+ "build": "npm run generate && tsc && tsx scripts/bundle-dsl.ts && tsx scripts/bundle-cloud-function.ts",
33
38
  "prepublishOnly": "npm run build",
34
39
  "generate": "tsx scripts/write-ui-reexports.ts",
35
40
  "pretypecheck": "npm run generate",
36
- "typecheck": "tsc --noEmit"
41
+ "typecheck": "tsc --noEmit",
42
+ "test": "vitest run"
37
43
  },
38
44
  "dependencies": {
39
45
  "@base-ui/react": "^1.1.0",
@@ -87,11 +93,15 @@
87
93
  "devDependencies": {
88
94
  "@graphapi-io/declarations": "*",
89
95
  "@graphapi-io/dsl-builders": "*",
96
+ "@smithy/hash-node": "^4.2.14",
97
+ "@smithy/protocol-http": "^5.3.14",
98
+ "@smithy/signature-v4": "^5.4.6",
90
99
  "@types/node": "^24.12.2",
91
100
  "dts-bundle-generator": "^9.5.1",
92
101
  "esbuild": "^0.27.2",
93
102
  "tsx": "^4.22.3",
94
- "typescript": "^5.9.3"
103
+ "typescript": "^5.9.3",
104
+ "vitest": "^4.1.4"
95
105
  },
96
106
  "publishConfig": {
97
107
  "access": "public"