@webstudio-is/react-sdk 0.5.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.
Files changed (101) hide show
  1. package/lib/components/component-type.d.ts +1 -1
  2. package/lib/components/component-type.d.ts.map +1 -1
  3. package/lib/components/component-type.js +2 -2
  4. package/lib/components/image.d.ts +3 -0
  5. package/lib/components/image.d.ts.map +1 -0
  6. package/lib/components/image.js +42 -0
  7. package/lib/components/image.props.json +2533 -0
  8. package/lib/components/image.stories.d.ts +6 -0
  9. package/lib/components/image.stories.d.ts.map +1 -0
  10. package/lib/components/image.stories.js +17 -0
  11. package/lib/components/image.ws.d.ts +5 -0
  12. package/lib/components/image.ws.d.ts.map +1 -0
  13. package/lib/components/image.ws.js +14 -0
  14. package/lib/components/index.d.ts +1 -0
  15. package/lib/components/index.d.ts.map +1 -1
  16. package/lib/components/index.js +3 -1
  17. package/lib/components/index.test.js +1 -1
  18. package/lib/components/link.d.ts +1 -1
  19. package/lib/components/link.stories.d.ts +2 -2
  20. package/lib/components/meta.d.ts +1 -0
  21. package/lib/components/meta.d.ts.map +1 -1
  22. package/lib/components/meta.js +3 -1
  23. package/lib/css/breakpoints.d.ts +1 -1
  24. package/lib/css/breakpoints.d.ts.map +1 -1
  25. package/lib/css/categories.d.ts +4 -4
  26. package/lib/css/categories.js +1 -1
  27. package/lib/css/get-browser-style.d.ts +1 -1
  28. package/lib/css/get-browser-style.d.ts.map +1 -1
  29. package/lib/css/index.d.ts +1 -1
  30. package/lib/css/index.d.ts.map +1 -1
  31. package/lib/css/index.js +1 -1
  32. package/lib/css/keyword-values.d.ts.map +1 -1
  33. package/lib/css/keyword-values.js +396 -1149
  34. package/lib/css/properties.d.ts +6 -4
  35. package/lib/css/properties.d.ts.map +1 -1
  36. package/lib/css/properties.js +3196 -3194
  37. package/lib/css/schema.d.ts +142 -10
  38. package/lib/css/schema.d.ts.map +1 -1
  39. package/lib/css/schema.js +25 -15
  40. package/lib/css/types.d.ts +0 -9
  41. package/lib/css/types.d.ts.map +1 -1
  42. package/lib/css/units.js +1 -1
  43. package/lib/db/instance.d.ts +2 -2
  44. package/lib/db/instance.d.ts.map +1 -1
  45. package/lib/db/instance.js +4 -4
  46. package/lib/index.d.ts +1 -0
  47. package/lib/index.d.ts.map +1 -1
  48. package/lib/index.js +1 -0
  49. package/lib/pubsub/create.d.ts +28 -0
  50. package/lib/pubsub/create.d.ts.map +1 -0
  51. package/lib/pubsub/create.js +58 -0
  52. package/lib/pubsub/index.d.ts +1 -2
  53. package/lib/pubsub/index.d.ts.map +1 -1
  54. package/lib/pubsub/index.js +1 -2
  55. package/lib/remix/constants.d.ts +2 -0
  56. package/lib/remix/constants.d.ts.map +1 -0
  57. package/lib/remix/constants.js +4 -0
  58. package/lib/remix/handle-request.server.d.ts +3 -0
  59. package/lib/remix/handle-request.server.d.ts.map +1 -0
  60. package/lib/remix/handle-request.server.js +16 -0
  61. package/lib/remix/index.d.ts +3 -0
  62. package/lib/remix/index.d.ts.map +1 -0
  63. package/lib/remix/index.js +18 -0
  64. package/lib/remix/insert-critical-css.d.ts +2 -0
  65. package/lib/remix/insert-critical-css.d.ts.map +1 -0
  66. package/lib/remix/insert-critical-css.js +9 -0
  67. package/lib/remix/root.d.ts +8 -0
  68. package/lib/remix/root.d.ts.map +1 -0
  69. package/lib/remix/root.js +13 -0
  70. package/lib/stitches/index.d.ts +1 -2
  71. package/lib/stitches/index.d.ts.map +1 -1
  72. package/lib/stitches/index.js +1 -2
  73. package/lib/stitches/stitches.d.ts +8 -0
  74. package/lib/stitches/stitches.d.ts.map +1 -0
  75. package/lib/stitches/{css.js → stitches.js} +12 -7
  76. package/lib/stitches/to-css.d.ts +1 -1
  77. package/lib/stitches/to-css.d.ts.map +1 -1
  78. package/lib/stitches/to-css.js +9 -0
  79. package/lib/stitches/to-css.test.js +20 -1
  80. package/lib/tree/root.d.ts +6 -2
  81. package/lib/tree/root.d.ts.map +1 -1
  82. package/lib/tree/root.js +22 -9
  83. package/lib/user-props/schema.d.ts +3 -2
  84. package/lib/user-props/schema.d.ts.map +1 -1
  85. package/lib/user-props/schema.js +3 -3
  86. package/lib/user-props/types.d.ts +1 -3
  87. package/lib/user-props/types.d.ts.map +1 -1
  88. package/lib/user-props/use-user-props.d.ts +1 -1
  89. package/lib/user-props/use-user-props.d.ts.map +1 -1
  90. package/package.json +13 -10
  91. package/lib/pubsub/publish.d.ts +0 -17
  92. package/lib/pubsub/publish.d.ts.map +0 -1
  93. package/lib/pubsub/publish.js +0 -27
  94. package/lib/pubsub/subscribe.d.ts +0 -8
  95. package/lib/pubsub/subscribe.d.ts.map +0 -1
  96. package/lib/pubsub/subscribe.js +0 -30
  97. package/lib/stitches/critical-css.d.ts +0 -4
  98. package/lib/stitches/critical-css.d.ts.map +0 -1
  99. package/lib/stitches/critical-css.js +0 -12
  100. package/lib/stitches/css.d.ts +0 -9
  101. package/lib/stitches/css.d.ts.map +0 -1
@@ -1,6 +1,66 @@
1
1
  import { z } from "zod";
2
- export declare const UnitSchema: z.ZodUnion<[z.ZodEnum<["ch", "cm", "deg", "dpcm", "dpi", "dppx", "em", "ex", "fr", "grad", "Hz", "in", "kHz", "mm", "ms", "pc", "pt", "px", "Q", "rad", "rem", "s", "turn", "vh", "vmax", "vmin", "vw", "x", "%"]>, z.ZodLiteral<"number">]>;
3
- export declare const StyleValueSchema: z.ZodUnion<[z.ZodObject<{
2
+ import { StyleProperty } from "./types";
3
+ export declare const Unit: z.ZodUnion<[z.ZodEnum<["ch", "cm", "deg", "dpcm", "dpi", "dppx", "em", "ex", "fr", "grad", "Hz", "in", "kHz", "mm", "ms", "pc", "pt", "px", "Q", "rad", "rem", "s", "turn", "vh", "vmax", "vmin", "vw", "x", "%"]>, z.ZodLiteral<"number">]>;
4
+ export declare type Unit = z.infer<typeof Unit>;
5
+ export declare const UnitValue: z.ZodObject<{
6
+ type: z.ZodLiteral<"unit">;
7
+ unit: z.ZodUnion<[z.ZodEnum<["ch", "cm", "deg", "dpcm", "dpi", "dppx", "em", "ex", "fr", "grad", "Hz", "in", "kHz", "mm", "ms", "pc", "pt", "px", "Q", "rad", "rem", "s", "turn", "vh", "vmax", "vmin", "vw", "x", "%"]>, z.ZodLiteral<"number">]>;
8
+ value: z.ZodNumber;
9
+ }, "strip", z.ZodTypeAny, {
10
+ unit: "number" | "px" | "%" | "ch" | "cm" | "deg" | "dpcm" | "dpi" | "dppx" | "em" | "ex" | "fr" | "grad" | "Hz" | "in" | "kHz" | "mm" | "ms" | "pc" | "pt" | "Q" | "rad" | "rem" | "s" | "turn" | "vh" | "vmax" | "vmin" | "vw" | "x";
11
+ value: number;
12
+ type: "unit";
13
+ }, {
14
+ unit: "number" | "px" | "%" | "ch" | "cm" | "deg" | "dpcm" | "dpi" | "dppx" | "em" | "ex" | "fr" | "grad" | "Hz" | "in" | "kHz" | "mm" | "ms" | "pc" | "pt" | "Q" | "rad" | "rem" | "s" | "turn" | "vh" | "vmax" | "vmin" | "vw" | "x";
15
+ value: number;
16
+ type: "unit";
17
+ }>;
18
+ export declare type UnitValue = z.infer<typeof UnitValue>;
19
+ export declare const KeywordValue: z.ZodObject<{
20
+ type: z.ZodLiteral<"keyword">;
21
+ value: z.ZodString;
22
+ }, "strip", z.ZodTypeAny, {
23
+ value: string;
24
+ type: "keyword";
25
+ }, {
26
+ value: string;
27
+ type: "keyword";
28
+ }>;
29
+ export declare type KeywordValue = z.infer<typeof KeywordValue>;
30
+ export declare const FontFamilyValue: z.ZodObject<{
31
+ type: z.ZodLiteral<"fontFamily">;
32
+ value: z.ZodArray<z.ZodString, "many">;
33
+ }, "strip", z.ZodTypeAny, {
34
+ value: string[];
35
+ type: "fontFamily";
36
+ }, {
37
+ value: string[];
38
+ type: "fontFamily";
39
+ }>;
40
+ export declare type FontFamilyValue = z.infer<typeof FontFamilyValue>;
41
+ export declare const InvalidValue: z.ZodObject<{
42
+ type: z.ZodLiteral<"invalid">;
43
+ value: z.ZodString;
44
+ }, "strip", z.ZodTypeAny, {
45
+ value: string;
46
+ type: "invalid";
47
+ }, {
48
+ value: string;
49
+ type: "invalid";
50
+ }>;
51
+ export declare type InvalidValue = z.infer<typeof InvalidValue>;
52
+ export declare const UnsetValue: z.ZodObject<{
53
+ type: z.ZodLiteral<"unset">;
54
+ value: z.ZodLiteral<"">;
55
+ }, "strip", z.ZodTypeAny, {
56
+ value: "";
57
+ type: "unset";
58
+ }, {
59
+ value: "";
60
+ type: "unset";
61
+ }>;
62
+ export declare type UnsetValue = z.infer<typeof UnsetValue>;
63
+ export declare const StyleValue: z.ZodUnion<[z.ZodObject<{
4
64
  type: z.ZodLiteral<"unit">;
5
65
  unit: z.ZodUnion<[z.ZodEnum<["ch", "cm", "deg", "dpcm", "dpi", "dppx", "em", "ex", "fr", "grad", "Hz", "in", "kHz", "mm", "ms", "pc", "pt", "px", "Q", "rad", "rem", "s", "turn", "vh", "vmax", "vmin", "vw", "x", "%"]>, z.ZodLiteral<"number">]>;
6
66
  value: z.ZodNumber;
@@ -30,8 +90,27 @@ export declare const StyleValueSchema: z.ZodUnion<[z.ZodObject<{
30
90
  }, {
31
91
  value: string;
32
92
  type: "invalid";
93
+ }>, z.ZodObject<{
94
+ type: z.ZodLiteral<"unset">;
95
+ value: z.ZodLiteral<"">;
96
+ }, "strip", z.ZodTypeAny, {
97
+ value: "";
98
+ type: "unset";
99
+ }, {
100
+ value: "";
101
+ type: "unset";
102
+ }>, z.ZodObject<{
103
+ type: z.ZodLiteral<"fontFamily">;
104
+ value: z.ZodArray<z.ZodString, "many">;
105
+ }, "strip", z.ZodTypeAny, {
106
+ value: string[];
107
+ type: "fontFamily";
108
+ }, {
109
+ value: string[];
110
+ type: "fontFamily";
33
111
  }>]>;
34
- export declare const StyleSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
112
+ export declare type StyleValue = z.infer<typeof StyleValue>;
113
+ export declare const Style: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
35
114
  type: z.ZodLiteral<"unit">;
36
115
  unit: z.ZodUnion<[z.ZodEnum<["ch", "cm", "deg", "dpcm", "dpi", "dppx", "em", "ex", "fr", "grad", "Hz", "in", "kHz", "mm", "ms", "pc", "pt", "px", "Q", "rad", "rem", "s", "turn", "vh", "vmax", "vmin", "vw", "x", "%"]>, z.ZodLiteral<"number">]>;
37
116
  value: z.ZodNumber;
@@ -61,8 +140,29 @@ export declare const StyleSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObje
61
140
  }, {
62
141
  value: string;
63
142
  type: "invalid";
143
+ }>, z.ZodObject<{
144
+ type: z.ZodLiteral<"unset">;
145
+ value: z.ZodLiteral<"">;
146
+ }, "strip", z.ZodTypeAny, {
147
+ value: "";
148
+ type: "unset";
149
+ }, {
150
+ value: "";
151
+ type: "unset";
152
+ }>, z.ZodObject<{
153
+ type: z.ZodLiteral<"fontFamily">;
154
+ value: z.ZodArray<z.ZodString, "many">;
155
+ }, "strip", z.ZodTypeAny, {
156
+ value: string[];
157
+ type: "fontFamily";
158
+ }, {
159
+ value: string[];
160
+ type: "fontFamily";
64
161
  }>]>>;
65
- export declare const CssRuleSchema: z.ZodObject<{
162
+ export declare type Style = {
163
+ [property in StyleProperty]?: StyleValue;
164
+ };
165
+ export declare const CssRule: z.ZodObject<{
66
166
  style: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
67
167
  type: z.ZodLiteral<"unit">;
68
168
  unit: z.ZodUnion<[z.ZodEnum<["ch", "cm", "deg", "dpcm", "dpi", "dppx", "em", "ex", "fr", "grad", "Hz", "in", "kHz", "mm", "ms", "pc", "pt", "px", "Q", "rad", "rem", "s", "turn", "vh", "vmax", "vmin", "vw", "x", "%"]>, z.ZodLiteral<"number">]>;
@@ -93,6 +193,24 @@ export declare const CssRuleSchema: z.ZodObject<{
93
193
  }, {
94
194
  value: string;
95
195
  type: "invalid";
196
+ }>, z.ZodObject<{
197
+ type: z.ZodLiteral<"unset">;
198
+ value: z.ZodLiteral<"">;
199
+ }, "strip", z.ZodTypeAny, {
200
+ value: "";
201
+ type: "unset";
202
+ }, {
203
+ value: "";
204
+ type: "unset";
205
+ }>, z.ZodObject<{
206
+ type: z.ZodLiteral<"fontFamily">;
207
+ value: z.ZodArray<z.ZodString, "many">;
208
+ }, "strip", z.ZodTypeAny, {
209
+ value: string[];
210
+ type: "fontFamily";
211
+ }, {
212
+ value: string[];
213
+ type: "fontFamily";
96
214
  }>]>>;
97
215
  breakpoint: z.ZodString;
98
216
  }, "strip", z.ZodTypeAny, {
@@ -103,9 +221,15 @@ export declare const CssRuleSchema: z.ZodObject<{
103
221
  } | {
104
222
  value: string;
105
223
  type: "keyword";
224
+ } | {
225
+ value: string[];
226
+ type: "fontFamily";
106
227
  } | {
107
228
  value: string;
108
229
  type: "invalid";
230
+ } | {
231
+ value: "";
232
+ type: "unset";
109
233
  }>;
110
234
  breakpoint: string;
111
235
  }, {
@@ -116,36 +240,44 @@ export declare const CssRuleSchema: z.ZodObject<{
116
240
  } | {
117
241
  value: string;
118
242
  type: "keyword";
243
+ } | {
244
+ value: string[];
245
+ type: "fontFamily";
119
246
  } | {
120
247
  value: string;
121
248
  type: "invalid";
249
+ } | {
250
+ value: "";
251
+ type: "unset";
122
252
  }>;
123
253
  breakpoint: string;
124
254
  }>;
125
- export declare const BreakpointSchema: z.ZodObject<{
255
+ export declare type CssRule = z.infer<typeof CssRule>;
256
+ export declare const Breakpoint: z.ZodObject<{
126
257
  id: z.ZodString;
127
258
  label: z.ZodString;
128
259
  minWidth: z.ZodNumber;
129
260
  }, "strip", z.ZodTypeAny, {
261
+ minWidth: number;
130
262
  id: string;
131
263
  label: string;
132
- minWidth: number;
133
264
  }, {
265
+ minWidth: number;
134
266
  id: string;
135
267
  label: string;
136
- minWidth: number;
137
268
  }>;
138
- export declare const BreakpointsSchema: z.ZodArray<z.ZodObject<{
269
+ export declare const Breakpoints: z.ZodArray<z.ZodObject<{
139
270
  id: z.ZodString;
140
271
  label: z.ZodString;
141
272
  minWidth: z.ZodNumber;
142
273
  }, "strip", z.ZodTypeAny, {
274
+ minWidth: number;
143
275
  id: string;
144
276
  label: string;
145
- minWidth: number;
146
277
  }, {
278
+ minWidth: number;
147
279
  id: string;
148
280
  label: string;
149
- minWidth: number;
150
281
  }>, "many">;
282
+ export declare type Breakpoint = z.infer<typeof Breakpoint>;
151
283
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/css/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,UAAU,8OAAgD,CAAC;AAqBxE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAI3B,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAAyC,CAAC;AAElE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGxB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAI3B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;WAA4B,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/css/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,IAAI,8OAAgD,CAAC;AAElE,oBAAY,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,SAAS;;;;;;;;;;;;EAIpB,CAAC;AAEH,oBAAY,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,YAAY;;;;;;;;;EAIvB,CAAC;AACH,oBAAY,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,eAAO,MAAM,eAAe;;;;;;;;;EAG1B,CAAC;AACH,oBAAY,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAI9D,eAAO,MAAM,YAAY;;;;;;;;;EAGvB,CAAC;AACH,oBAAY,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,eAAO,MAAM,UAAU;;;;;;;;;EAGrB,CAAC;AACH,oBAAY,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAMrB,CAAC;AAEH,oBAAY,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAAmC,CAAC;AAEtD,oBAAY,KAAK,GAAG;KACjB,QAAQ,IAAI,aAAa,CAAC,CAAC,EAAE,UAAU;CACzC,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGlB,CAAC;AAEH,oBAAY,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC;AAE9C,eAAO,MAAM,UAAU;;;;;;;;;;;;EAIrB,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;WAAsB,CAAC;AAE/C,oBAAY,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
package/lib/css/schema.js CHANGED
@@ -1,38 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BreakpointsSchema = exports.BreakpointSchema = exports.CssRuleSchema = exports.StyleSchema = exports.StyleValueSchema = exports.UnitSchema = void 0;
3
+ exports.Breakpoints = exports.Breakpoint = exports.CssRule = exports.Style = exports.StyleValue = exports.UnsetValue = exports.InvalidValue = exports.FontFamilyValue = exports.KeywordValue = exports.UnitValue = exports.Unit = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const units_1 = require("./units");
6
- exports.UnitSchema = zod_1.z.union([zod_1.z.enum(units_1.units), zod_1.z.literal("number")]);
7
- const UnitValueSchema = zod_1.z.object({
6
+ exports.Unit = zod_1.z.union([zod_1.z.enum(units_1.units), zod_1.z.literal("number")]);
7
+ exports.UnitValue = zod_1.z.object({
8
8
  type: zod_1.z.literal("unit"),
9
- unit: exports.UnitSchema,
9
+ unit: exports.Unit,
10
10
  value: zod_1.z.number(),
11
11
  });
12
- const KeywordValueSchema = zod_1.z.object({
12
+ exports.KeywordValue = zod_1.z.object({
13
13
  type: zod_1.z.literal("keyword"),
14
14
  // @todo use exact type
15
15
  value: zod_1.z.string(),
16
16
  });
17
+ exports.FontFamilyValue = zod_1.z.object({
18
+ type: zod_1.z.literal("fontFamily"),
19
+ value: zod_1.z.array(zod_1.z.string()),
20
+ });
17
21
  // We want to be able to render the invalid value
18
22
  // and show it is invalid visually, without saving it to the db
19
- const InvalidValueSchema = zod_1.z.object({
23
+ exports.InvalidValue = zod_1.z.object({
20
24
  type: zod_1.z.literal("invalid"),
21
25
  value: zod_1.z.string(),
22
26
  });
23
- exports.StyleValueSchema = zod_1.z.union([
24
- UnitValueSchema,
25
- KeywordValueSchema,
26
- InvalidValueSchema,
27
+ exports.UnsetValue = zod_1.z.object({
28
+ type: zod_1.z.literal("unset"),
29
+ value: zod_1.z.literal(""),
30
+ });
31
+ exports.StyleValue = zod_1.z.union([
32
+ exports.UnitValue,
33
+ exports.KeywordValue,
34
+ exports.InvalidValue,
35
+ exports.UnsetValue,
36
+ exports.FontFamilyValue,
27
37
  ]);
28
- exports.StyleSchema = zod_1.z.record(zod_1.z.string(), exports.StyleValueSchema);
29
- exports.CssRuleSchema = zod_1.z.object({
30
- style: exports.StyleSchema,
38
+ exports.Style = zod_1.z.record(zod_1.z.string(), exports.StyleValue);
39
+ exports.CssRule = zod_1.z.object({
40
+ style: exports.Style,
31
41
  breakpoint: zod_1.z.string(),
32
42
  });
33
- exports.BreakpointSchema = zod_1.z.object({
43
+ exports.Breakpoint = zod_1.z.object({
34
44
  id: zod_1.z.string(),
35
45
  label: zod_1.z.string(),
36
46
  minWidth: zod_1.z.number(),
37
47
  });
38
- exports.BreakpointsSchema = zod_1.z.array(exports.BreakpointSchema);
48
+ exports.Breakpoints = zod_1.z.array(exports.Breakpoint);
@@ -1,15 +1,6 @@
1
- import { z } from "zod";
2
1
  import { properties } from "./properties";
3
- import { BreakpointSchema, CssRuleSchema, StyleValueSchema, UnitSchema } from "./schema";
4
2
  declare type Properties = typeof properties;
5
3
  export declare type StyleProperty = keyof Properties;
6
4
  export declare type AppliesTo = Properties[StyleProperty]["appliesTo"];
7
- export declare type Style = {
8
- [property in StyleProperty]?: StyleValue;
9
- };
10
- export declare type CssRule = z.infer<typeof CssRuleSchema>;
11
- export declare type Unit = z.infer<typeof UnitSchema>;
12
- export declare type StyleValue = z.infer<typeof StyleValueSchema>;
13
- export declare type Breakpoint = z.infer<typeof BreakpointSchema>;
14
5
  export {};
15
6
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/css/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,aAAK,UAAU,GAAG,OAAO,UAAU,CAAC;AAEpC,oBAAY,aAAa,GAAG,MAAM,UAAU,CAAC;AAE7C,oBAAY,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,CAAC;AAE/D,oBAAY,KAAK,GAAG;KACjB,QAAQ,IAAI,aAAa,CAAC,CAAC,EAAE,UAAU;CACzC,CAAC;AAEF,oBAAY,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,oBAAY,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,oBAAY,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,oBAAY,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/css/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,aAAK,UAAU,GAAG,OAAO,UAAU,CAAC;AAEpC,oBAAY,aAAa,GAAG,MAAM,UAAU,CAAC;AAE7C,oBAAY,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,CAAC"}
package/lib/css/units.js CHANGED
@@ -31,5 +31,5 @@ exports.units = [
31
31
  "vmin",
32
32
  "vw",
33
33
  "x",
34
- "%"
34
+ "%",
35
35
  ];
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import * as components from "../components";
3
- import { type CssRule } from "../css";
3
+ import { CssRule } from "../css";
4
4
  export declare type BaseInstance = {
5
5
  id: string;
6
6
  component: keyof typeof components;
@@ -10,5 +10,5 @@ export declare type Instance = BaseInstance & {
10
10
  children: Array<Instance | string>;
11
11
  };
12
12
  export declare const toBaseInstance: (instance: Instance) => BaseInstance;
13
- export declare const InstanceSchema: z.ZodType<Instance, z.ZodTypeDef, Instance>;
13
+ export declare const Instance: z.ZodType<Instance, z.ZodTypeDef, Instance>;
14
14
  //# sourceMappingURL=instance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/db/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAIrD,oBAAY,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,OAAO,UAAU,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CAC1B,CAAC;AAEF,oBAAY,QAAQ,GAAG,YAAY,GAAG;IACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,KAAG,YAMnD,CAAC;AAEF,eAAO,MAAM,cAAc,6CASH,CAAC"}
1
+ {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/db/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAIjC,oBAAY,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,OAAO,UAAU,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CAC1B,CAAC;AAEF,oBAAY,QAAQ,GAAG,YAAY,GAAG;IACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,KAAG,YAMnD,CAAC;AAEF,eAAO,MAAM,QAAQ,6CASG,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InstanceSchema = exports.toBaseInstance = void 0;
3
+ exports.Instance = exports.toBaseInstance = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const css_1 = require("../css");
6
6
  const toBaseInstance = (instance) => {
@@ -11,11 +11,11 @@ const toBaseInstance = (instance) => {
11
11
  };
12
12
  };
13
13
  exports.toBaseInstance = toBaseInstance;
14
- exports.InstanceSchema = zod_1.z.lazy(() => zod_1.z.object({
14
+ exports.Instance = zod_1.z.lazy(() => zod_1.z.object({
15
15
  id: zod_1.z.string(),
16
16
  component: zod_1.z.string(),
17
- children: zod_1.z.array(zod_1.z.union([exports.InstanceSchema, zod_1.z.string()])),
18
- cssRules: zod_1.z.array(css_1.CssRuleSchema),
17
+ children: zod_1.z.array(zod_1.z.union([exports.Instance, zod_1.z.string()])),
18
+ cssRules: zod_1.z.array(css_1.CssRule),
19
19
  })
20
20
  // @todo can't figure out how to make component to be z.enum(Object.keys(components))
21
21
  );
package/lib/index.d.ts CHANGED
@@ -6,4 +6,5 @@ export * as componentsMeta from "./components/meta";
6
6
  export * from "./user-props";
7
7
  export * from "./pubsub";
8
8
  export * from "./db";
9
+ export * from "./remix";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AACpD,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AACpD,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC"}
package/lib/index.js CHANGED
@@ -35,3 +35,4 @@ exports.componentsMeta = __importStar(require("./components/meta"));
35
35
  __exportStar(require("./user-props"), exports);
36
36
  __exportStar(require("./pubsub"), exports);
37
37
  __exportStar(require("./db"), exports);
38
+ __exportStar(require("./remix"), exports);
@@ -0,0 +1,28 @@
1
+ /// <reference types="react" />
2
+ export declare const createPubsub: <PublishMap>() => {
3
+ /**
4
+ * To publish a postMessage event on the current window and parent window from the iframe.
5
+ */
6
+ publish<Type extends keyof PublishMap>(action: undefined extends PublishMap[Type] ? {
7
+ type: Type;
8
+ payload?: PublishMap[Type] | undefined;
9
+ } : {
10
+ type: Type;
11
+ payload: PublishMap[Type];
12
+ }): void;
13
+ /**
14
+ * To publish a postMessage event on the iframe and parent window from the parent window.
15
+ */
16
+ usePublish(): readonly [<Type_1 extends keyof PublishMap>(action: undefined extends PublishMap[Type_1] ? {
17
+ type: Type_1;
18
+ payload?: PublishMap[Type_1] | undefined;
19
+ } : {
20
+ type: Type_1;
21
+ payload: PublishMap[Type_1];
22
+ }) => void, import("react").MutableRefObject<HTMLIFrameElement | null>];
23
+ /**
24
+ * To subscribe a message event on the current window.
25
+ */
26
+ useSubscribe<Type_2 extends keyof PublishMap>(type: Type_2, onAction: (payload: PublishMap[Type_2]) => void): void;
27
+ };
28
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/pubsub/create.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;IA0BrB;;OAEG;;;;;;;;IAMH;;OAEG;;;;;;;;IAeH;;OAEG;2GAGwC,IAAI;CAUlD,CAAC"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createPubsub = void 0;
7
+ const mitt_1 = __importDefault(require("mitt"));
8
+ const react_1 = require("react");
9
+ const createPubsub = () => {
10
+ // `mitt` has a somewhat annoying overload for `*` type that makes it hard to wrap in a generic context
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ const emitter = (0, mitt_1.default)();
13
+ if (typeof window === "object") {
14
+ window.addEventListener("message", (event) => {
15
+ // @todo this has no type safety built in, could be anything from any source.
16
+ // we could potentially maintain a list of valid event types at runtime
17
+ // at the very least we could add a brand property or something to our events
18
+ if (typeof event.data?.type === "string") {
19
+ emitter.emit(event.data.type, event.data.payload);
20
+ }
21
+ }, false);
22
+ }
23
+ return {
24
+ /**
25
+ * To publish a postMessage event on the current window and parent window from the iframe.
26
+ */
27
+ publish(action) {
28
+ window.parent.postMessage(action, "*");
29
+ window.postMessage(action, "*");
30
+ },
31
+ /**
32
+ * To publish a postMessage event on the iframe and parent window from the parent window.
33
+ */
34
+ usePublish() {
35
+ const iframeRef = (0, react_1.useRef)(null);
36
+ const publishCallback = (0, react_1.useCallback)((action) => {
37
+ const element = iframeRef.current;
38
+ if (element?.contentWindow == null)
39
+ return;
40
+ element.contentWindow.postMessage(action, "*");
41
+ window.postMessage(action, "*");
42
+ }, [iframeRef]);
43
+ return [publishCallback, iframeRef];
44
+ },
45
+ /**
46
+ * To subscribe a message event on the current window.
47
+ */
48
+ useSubscribe(type, onAction) {
49
+ (0, react_1.useEffect)(() => {
50
+ emitter.on(type, onAction);
51
+ return () => {
52
+ emitter.off(type, onAction);
53
+ };
54
+ }, [type, onAction]);
55
+ },
56
+ };
57
+ };
58
+ exports.createPubsub = createPubsub;
@@ -1,3 +1,2 @@
1
- export * from "./publish";
2
- export * from "./subscribe";
1
+ export * from "./create";
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pubsub/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pubsub/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -14,5 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./publish"), exports);
18
- __exportStar(require("./subscribe"), exports);
17
+ __exportStar(require("./create"), exports);
@@ -0,0 +1,2 @@
1
+ export declare const CRITICAL_CSS_MARKER = "__CRITICAL_CSS__";
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/remix/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CRITICAL_CSS_MARKER = void 0;
4
+ exports.CRITICAL_CSS_MARKER = "__CRITICAL_CSS__";
@@ -0,0 +1,3 @@
1
+ import type { EntryContext } from "@remix-run/node";
2
+ export declare const handleRequest: (request: Request, responseStatusCode: number, responseHeaders: Headers, remixContext: EntryContext) => Response;
3
+ //# sourceMappingURL=handle-request.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-request.server.d.ts","sourceRoot":"","sources":["../../src/remix/handle-request.server.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,eAAO,MAAM,aAAa,YACf,OAAO,sBACI,MAAM,mBACT,OAAO,gBACV,YAAY,aAY3B,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleRequest = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const server_1 = require("react-dom/server");
6
+ const react_1 = require("@remix-run/react");
7
+ const insert_critical_css_1 = require("./insert-critical-css");
8
+ const handleRequest = (request, responseStatusCode, responseHeaders, remixContext) => {
9
+ const markup = (0, server_1.renderToString)((0, jsx_runtime_1.jsx)(react_1.RemixServer, { context: remixContext, url: request.url }));
10
+ responseHeaders.set("Content-Type", "text/html");
11
+ return new Response("<!DOCTYPE html>" + (0, insert_critical_css_1.insertCriticalCss)(markup), {
12
+ status: responseStatusCode,
13
+ headers: responseHeaders,
14
+ });
15
+ };
16
+ exports.handleRequest = handleRequest;
@@ -0,0 +1,3 @@
1
+ export * from "./root";
2
+ export * from "./handle-request.server";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/remix/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./root"), exports);
18
+ __exportStar(require("./handle-request.server"), exports);
@@ -0,0 +1,2 @@
1
+ export declare const insertCriticalCss: (markup: string) => string;
2
+ //# sourceMappingURL=insert-critical-css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-critical-css.d.ts","sourceRoot":"","sources":["../../src/remix/insert-critical-css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,WAAY,MAAM,KAAG,MAElD,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.insertCriticalCss = void 0;
4
+ const stitches_1 = require("../stitches");
5
+ const constants_1 = require("./constants");
6
+ const insertCriticalCss = (markup) => {
7
+ return markup.replace(constants_1.CRITICAL_CSS_MARKER, `<style>${(0, stitches_1.flushCss)()}</style>`);
8
+ };
9
+ exports.insertCriticalCss = insertCriticalCss;
@@ -0,0 +1,8 @@
1
+ import { Outlet as DefaultOutlet } from "@remix-run/react";
2
+ /**
3
+ * We are using Outlet prop from index layout when user renders site from a subdomain.
4
+ */
5
+ export declare const Root: ({ Outlet, }: {
6
+ Outlet: typeof DefaultOutlet;
7
+ }) => JSX.Element;
8
+ //# sourceMappingURL=root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/remix/root.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE;;GAEG;AACH,eAAO,MAAM,IAAI;YAGP,oBAAoB;iBAgB7B,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Root = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@remix-run/react");
6
+ const constants_1 = require("./constants");
7
+ /**
8
+ * We are using Outlet prop from index layout when user renders site from a subdomain.
9
+ */
10
+ const Root = ({ Outlet = react_1.Outlet, }) => {
11
+ return ((0, jsx_runtime_1.jsxs)("html", { lang: "en", children: [(0, jsx_runtime_1.jsxs)("head", { children: [(0, jsx_runtime_1.jsx)("meta", { charSet: "utf-8" }), (0, jsx_runtime_1.jsx)("meta", { name: "viewport", content: "width=device-width,initial-scale=1" }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", href: "/favicon.ico", type: "image/x-icon" }), (0, jsx_runtime_1.jsx)("link", { rel: "shortcut icon", href: "/favicon.ico", type: "image/x-icon" }), (0, jsx_runtime_1.jsx)(react_1.Meta, {}), (0, jsx_runtime_1.jsx)(react_1.Links, {}), typeof document === "undefined" ? constants_1.CRITICAL_CSS_MARKER : null] }), (0, jsx_runtime_1.jsx)(Outlet, {})] }));
12
+ };
13
+ exports.Root = Root;
@@ -1,4 +1,3 @@
1
1
  export * from "./to-css";
2
- export * from "./css";
3
- export * from "./critical-css";
2
+ export * from "./stitches";
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stitches/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stitches/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./to-css"), exports);
18
- __exportStar(require("./css"), exports);
19
- __exportStar(require("./critical-css"), exports);
18
+ __exportStar(require("./stitches"), exports);