@fragmentsx/client-core 0.2.2 → 0.2.4

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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fragmentsClient.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragmentsClient.test.d.ts","sourceRoot":"","sources":["../src/fragmentsClient.test.ts"],"names":[],"mappings":""}
package/dist/index.cjs.js CHANGED
@@ -232,6 +232,7 @@ const nodes = createConstants$1(
232
232
  "FragmentInstance",
233
233
  "Instance",
234
234
  "Collection",
235
+ "ArrayItem",
235
236
  "Breakpoint",
236
237
  "Frame",
237
238
  "Image",
@@ -251,6 +252,7 @@ const nodes = createConstants$1(
251
252
  "Classname",
252
253
  "GoalEvent",
253
254
  "MutateEvent",
255
+ "TextHighlight",
254
256
  "ImagePaint"
255
257
  );
256
258
  const fragmentGrowingMode = createConstants$1("auto", "fill");
@@ -1317,6 +1319,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
1317
1319
  textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
1318
1320
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
1319
1321
  link: layerField(linkValidator),
1322
+ highlight: layerField(linkValidator),
1320
1323
  ...GraphFieldSchema.entries,
1321
1324
  ...OverridesSchema.entries,
1322
1325
  ...CssOverrideSchema.entries,
@@ -1556,7 +1559,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
1556
1559
  fallback: variableType.Array
1557
1560
  }),
1558
1561
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
1559
- defaultValue: layerField(/* @__PURE__ */ array(/* @__PURE__ */ any()), { fallback: [] }),
1562
+ defaultValue: layerField(/* @__PURE__ */ array(linkValidator), { fallback: [] }),
1560
1563
  definition: layerField(linkValidator, { fallback: null }),
1561
1564
  required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
1562
1565
  ...GraphFieldSchema.entries
@@ -1667,6 +1670,23 @@ const CssOverrideSchema = /* @__PURE__ */ object({
1667
1670
  value: layerField(/* @__PURE__ */ any()),
1668
1671
  ...GraphFieldSchema.entries
1669
1672
  });
1673
+ /* @__PURE__ */ object({
1674
+ color: layerField(/* @__PURE__ */ string(), { fallback: null }),
1675
+ lineHeight: layerField(/* @__PURE__ */ number(), { fallback: null }),
1676
+ fontSize: layerField(/* @__PURE__ */ number(), { fallback: null }),
1677
+ fontWeight: layerField(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ number()]), { fallback: 400 }),
1678
+ fontFamily: layerField(/* @__PURE__ */ string(), { fallback: null }),
1679
+ textDecoration: layerField(/* @__PURE__ */ picklist(Object.keys(textDecorations)), {
1680
+ fallback: null
1681
+ }),
1682
+ parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
1683
+ ...GraphFieldSchema.entries
1684
+ });
1685
+ /* @__PURE__ */ object({
1686
+ parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
1687
+ value: layerField(/* @__PURE__ */ any(), { fallback: null }),
1688
+ ...GraphFieldSchema.entries
1689
+ });
1670
1690
  const BASE_HEADERS = {
1671
1691
  "Content-Type": "application/json"
1672
1692
  };
@@ -2331,7 +2351,7 @@ const fragmentStylesheetPlugin = (globalState) => (state) => {
2331
2351
  };
2332
2352
  return state;
2333
2353
  };
2334
- const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n }\n }\n\n ul, ol {\n padding: 0;\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
2354
+ const globalCss = '[data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n\n * {\n font-family: inherit;\n }\n }\n\n /*overflow-wrap: break-word;*/\n}\n\n[data-key^="Fragment"] {\n\n ul, ol {\n padding: 0;\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
2335
2355
  const globalStylesheetPlugin = (state) => {
2336
2356
  if (!("$fragments" in state)) {
2337
2357
  throw new Error("GlobalStylesheetPlugin need $fragments plugin");
@@ -2773,5 +2793,22 @@ const ssrPlugin = (state) => {
2773
2793
  };
2774
2794
  return state;
2775
2795
  };
2796
+ function createTestFragmentsClient(options) {
2797
+ const client = createFragmentsClient({
2798
+ apiToken: (options == null ? void 0 : options.apiToken) ?? "test-token"
2799
+ });
2800
+ if ((options == null ? void 0 : options.fragments) && Object.keys(options.fragments).length > 0) {
2801
+ Object.entries(options.fragments).forEach(([fragmentId, document2]) => {
2802
+ client.$fetch.cacheDocuments.set(Number(fragmentId), document2);
2803
+ });
2804
+ }
2805
+ if ((options == null ? void 0 : options.areas) && Object.keys(options.areas).length > 0) {
2806
+ Object.entries(options.areas).forEach(([areaCode, entity]) => {
2807
+ client.$fetch.cacheAreaDocuments.set(areaCode, entity);
2808
+ });
2809
+ }
2810
+ return client;
2811
+ }
2776
2812
  exports.createFragmentsClient = createFragmentsClient;
2813
+ exports.createTestFragmentsClient = createTestFragmentsClient;
2777
2814
  exports.ssrPlugin = ssrPlugin;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { createFragmentsClient } from './fragmentsClient';
2
2
  export { ssrPlugin } from './plugins/ssr';
3
+ export { createTestFragmentsClient, type TestFragmentsClientOptions, type FragmentDocument, type AreaCacheEntity, } from './testing/createTestFragmentsClient';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EACL,yBAAyB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,qCAAqC,CAAC"}
package/dist/index.es.js CHANGED
@@ -230,6 +230,7 @@ const nodes = createConstants$1(
230
230
  "FragmentInstance",
231
231
  "Instance",
232
232
  "Collection",
233
+ "ArrayItem",
233
234
  "Breakpoint",
234
235
  "Frame",
235
236
  "Image",
@@ -249,6 +250,7 @@ const nodes = createConstants$1(
249
250
  "Classname",
250
251
  "GoalEvent",
251
252
  "MutateEvent",
253
+ "TextHighlight",
252
254
  "ImagePaint"
253
255
  );
254
256
  const fragmentGrowingMode = createConstants$1("auto", "fill");
@@ -1315,6 +1317,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
1315
1317
  textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
1316
1318
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
1317
1319
  link: layerField(linkValidator),
1320
+ highlight: layerField(linkValidator),
1318
1321
  ...GraphFieldSchema.entries,
1319
1322
  ...OverridesSchema.entries,
1320
1323
  ...CssOverrideSchema.entries,
@@ -1554,7 +1557,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
1554
1557
  fallback: variableType.Array
1555
1558
  }),
1556
1559
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
1557
- defaultValue: layerField(/* @__PURE__ */ array(/* @__PURE__ */ any()), { fallback: [] }),
1560
+ defaultValue: layerField(/* @__PURE__ */ array(linkValidator), { fallback: [] }),
1558
1561
  definition: layerField(linkValidator, { fallback: null }),
1559
1562
  required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
1560
1563
  ...GraphFieldSchema.entries
@@ -1665,6 +1668,23 @@ const CssOverrideSchema = /* @__PURE__ */ object({
1665
1668
  value: layerField(/* @__PURE__ */ any()),
1666
1669
  ...GraphFieldSchema.entries
1667
1670
  });
1671
+ /* @__PURE__ */ object({
1672
+ color: layerField(/* @__PURE__ */ string(), { fallback: null }),
1673
+ lineHeight: layerField(/* @__PURE__ */ number(), { fallback: null }),
1674
+ fontSize: layerField(/* @__PURE__ */ number(), { fallback: null }),
1675
+ fontWeight: layerField(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ number()]), { fallback: 400 }),
1676
+ fontFamily: layerField(/* @__PURE__ */ string(), { fallback: null }),
1677
+ textDecoration: layerField(/* @__PURE__ */ picklist(Object.keys(textDecorations)), {
1678
+ fallback: null
1679
+ }),
1680
+ parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
1681
+ ...GraphFieldSchema.entries
1682
+ });
1683
+ /* @__PURE__ */ object({
1684
+ parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
1685
+ value: layerField(/* @__PURE__ */ any(), { fallback: null }),
1686
+ ...GraphFieldSchema.entries
1687
+ });
1668
1688
  const BASE_HEADERS = {
1669
1689
  "Content-Type": "application/json"
1670
1690
  };
@@ -2329,7 +2349,7 @@ const fragmentStylesheetPlugin = (globalState) => (state) => {
2329
2349
  };
2330
2350
  return state;
2331
2351
  };
2332
- const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n }\n }\n\n ul, ol {\n padding: 0;\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
2352
+ const globalCss = '[data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n\n * {\n font-family: inherit;\n }\n }\n\n /*overflow-wrap: break-word;*/\n}\n\n[data-key^="Fragment"] {\n\n ul, ol {\n padding: 0;\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
2333
2353
  const globalStylesheetPlugin = (state) => {
2334
2354
  if (!("$fragments" in state)) {
2335
2355
  throw new Error("GlobalStylesheetPlugin need $fragments plugin");
@@ -2771,7 +2791,24 @@ const ssrPlugin = (state) => {
2771
2791
  };
2772
2792
  return state;
2773
2793
  };
2794
+ function createTestFragmentsClient(options) {
2795
+ const client = createFragmentsClient({
2796
+ apiToken: (options == null ? void 0 : options.apiToken) ?? "test-token"
2797
+ });
2798
+ if ((options == null ? void 0 : options.fragments) && Object.keys(options.fragments).length > 0) {
2799
+ Object.entries(options.fragments).forEach(([fragmentId, document2]) => {
2800
+ client.$fetch.cacheDocuments.set(Number(fragmentId), document2);
2801
+ });
2802
+ }
2803
+ if ((options == null ? void 0 : options.areas) && Object.keys(options.areas).length > 0) {
2804
+ Object.entries(options.areas).forEach(([areaCode, entity]) => {
2805
+ client.$fetch.cacheAreaDocuments.set(areaCode, entity);
2806
+ });
2807
+ }
2808
+ return client;
2809
+ }
2774
2810
  export {
2775
2811
  createFragmentsClient,
2812
+ createTestFragmentsClient,
2776
2813
  ssrPlugin
2777
2814
  };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fetcher.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcher.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch/fetcher.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/load/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/ssr/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=buildCssBlock.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildCssBlock.test.d.ts","sourceRoot":"","sources":["../../../../src/plugins/styleSheet/utils/buildCssBlock.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=compareRules.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compareRules.test.d.ts","sourceRoot":"","sources":["../../../../src/plugins/styleSheet/utils/compareRules.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getAllChildren.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllChildren.test.d.ts","sourceRoot":"","sources":["../../../../src/plugins/styleSheet/utils/getAllChildren.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=toCSS.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toCSS.test.d.ts","sourceRoot":"","sources":["../../../../src/plugins/styleSheet/utils/toCSS.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import { GraphState } from '@graph-state/core';
2
+ /**
3
+ * Document object for a fragment. Must have _type: "Fragment" and _id.
4
+ * Structure matches save.json / API response.
5
+ */
6
+ export type FragmentDocument = {
7
+ _type: string;
8
+ _id: string;
9
+ children?: unknown[];
10
+ [key: string]: unknown;
11
+ };
12
+ /**
13
+ * Area cache entity as stored by fetch plugin.
14
+ */
15
+ export interface AreaCacheEntity {
16
+ fragmentId: number;
17
+ props: Record<string, unknown>;
18
+ }
19
+ export interface TestFragmentsClientOptions {
20
+ apiToken?: string;
21
+ /** Pre-seeded fragment documents: fragmentId -> document */
22
+ fragments?: Record<number, FragmentDocument>;
23
+ /** Pre-seeded area cache: areaCode -> entity */
24
+ areas?: Record<string, AreaCacheEntity>;
25
+ }
26
+ /**
27
+ * Creates a fragments client for testing with pre-seeded cache.
28
+ * loadFragment/loadArea will use cached data—no network requests.
29
+ */
30
+ export declare function createTestFragmentsClient(options?: TestFragmentsClientOptions): GraphState;
31
+ //# sourceMappingURL=createTestFragmentsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTestFragmentsClient.d.ts","sourceRoot":"","sources":["../../src/testing/createTestFragmentsClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC7C,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,CAAC,EAAE,0BAA0B,GACnC,UAAU,CAkBZ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=createTestFragmentsClient.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTestFragmentsClient.test.d.ts","sourceRoot":"","sources":["../../src/testing/createTestFragmentsClient.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fragmentsx/client-core",
3
3
  "private": false,
4
- "version": "0.2.2",
4
+ "version": "0.2.4",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -21,8 +21,8 @@
21
21
  "dependencies": {
22
22
  "@graph-state/checkers": "^0.1.3",
23
23
  "@graph-state/core": "^0.13.2",
24
- "@fragmentsx/utils": "0.2.0",
25
- "@fragmentsx/definition": "0.2.0"
24
+ "@fragmentsx/definition": "0.2.2",
25
+ "@fragmentsx/utils": "0.2.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@graph-state/plugin-logger": "^0.3.0",