@makeswift/runtime 0.28.4 → 0.28.5

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 (79) hide show
  1. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  2. package/dist/cjs/client/index.js +3 -3
  3. package/dist/cjs/components/hooks/useMediaQuery.js +5 -29
  4. package/dist/cjs/components/hooks/useMediaQuery.js.map +1 -1
  5. package/dist/cjs/runtimes/react/hooks/use-breakpoints.js.map +1 -1
  6. package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js +39 -0
  7. package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js.map +1 -0
  8. package/dist/cjs/runtimes/react/runtime-core.js +6 -2
  9. package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
  10. package/dist/cjs/runtimes/react/testing/react-runtime.js +2 -2
  11. package/dist/cjs/runtimes/react/testing/react-runtime.js.map +1 -1
  12. package/dist/cjs/state/actions/internal/read-only-actions.js +8 -2
  13. package/dist/cjs/state/actions/internal/read-only-actions.js.map +1 -1
  14. package/dist/cjs/state/mixins/breakpoint-watch.js +72 -0
  15. package/dist/cjs/state/mixins/breakpoint-watch.js.map +1 -0
  16. package/dist/cjs/state/modules/breakpoints.js +37 -2
  17. package/dist/cjs/state/modules/breakpoints.js.map +1 -1
  18. package/dist/cjs/state/read-only-state.js +14 -1
  19. package/dist/cjs/state/read-only-state.js.map +1 -1
  20. package/dist/cjs/state/store.js +8 -0
  21. package/dist/cjs/state/store.js.map +1 -1
  22. package/dist/cjs/utils/ref-counted-map.js +20 -11
  23. package/dist/cjs/utils/ref-counted-map.js.map +1 -1
  24. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  25. package/dist/esm/client/index.js +3 -3
  26. package/dist/esm/components/hooks/useMediaQuery.js +7 -35
  27. package/dist/esm/components/hooks/useMediaQuery.js.map +1 -1
  28. package/dist/esm/runtimes/react/hooks/use-breakpoints.js.map +1 -1
  29. package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js +15 -0
  30. package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js.map +1 -0
  31. package/dist/esm/runtimes/react/runtime-core.js +6 -2
  32. package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
  33. package/dist/esm/runtimes/react/testing/react-runtime.js +2 -2
  34. package/dist/esm/runtimes/react/testing/react-runtime.js.map +1 -1
  35. package/dist/esm/state/actions/internal/read-only-actions.js +6 -1
  36. package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -1
  37. package/dist/esm/state/mixins/breakpoint-watch.js +48 -0
  38. package/dist/esm/state/mixins/breakpoint-watch.js.map +1 -0
  39. package/dist/esm/state/modules/breakpoints.js +38 -2
  40. package/dist/esm/state/modules/breakpoints.js.map +1 -1
  41. package/dist/esm/state/read-only-state.js +12 -1
  42. package/dist/esm/state/read-only-state.js.map +1 -1
  43. package/dist/esm/state/store.js +8 -0
  44. package/dist/esm/state/store.js.map +1 -1
  45. package/dist/esm/utils/ref-counted-map.js +20 -11
  46. package/dist/esm/utils/ref-counted-map.js.map +1 -1
  47. package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +6 -6
  48. package/dist/types/api-handler/handlers/webhook/types.d.ts +20 -20
  49. package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts +3 -0
  50. package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts.map +1 -0
  51. package/dist/types/components/hooks/useMediaQuery.d.ts.map +1 -1
  52. package/dist/types/runtimes/react/hooks/use-breakpoints.d.ts +1 -1
  53. package/dist/types/runtimes/react/hooks/use-breakpoints.d.ts.map +1 -1
  54. package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts +3 -0
  55. package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts.map +1 -0
  56. package/dist/types/runtimes/react/hooks/use-store.d.ts +3 -3
  57. package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
  58. package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
  59. package/dist/types/runtimes/react/testing/react-runtime.d.ts +4 -1
  60. package/dist/types/runtimes/react/testing/react-runtime.d.ts.map +1 -1
  61. package/dist/types/state/__tests__/test-store.d.ts +2 -2
  62. package/dist/types/state/actions/index.d.ts +1 -0
  63. package/dist/types/state/actions/index.d.ts.map +1 -1
  64. package/dist/types/state/actions/internal/index.d.ts +1 -0
  65. package/dist/types/state/actions/internal/index.d.ts.map +1 -1
  66. package/dist/types/state/actions/internal/read-only-actions.d.ts +6 -1
  67. package/dist/types/state/actions/internal/read-only-actions.d.ts.map +1 -1
  68. package/dist/types/state/mixins/breakpoint-watch.d.ts +11 -0
  69. package/dist/types/state/mixins/breakpoint-watch.d.ts.map +1 -0
  70. package/dist/types/state/modules/breakpoints.d.ts +11 -2
  71. package/dist/types/state/modules/breakpoints.d.ts.map +1 -1
  72. package/dist/types/state/read-only-state.d.ts +3 -1
  73. package/dist/types/state/read-only-state.d.ts.map +1 -1
  74. package/dist/types/state/read-write-state.d.ts +2 -2
  75. package/dist/types/state/store.d.ts +7 -6
  76. package/dist/types/state/store.d.ts.map +1 -1
  77. package/dist/types/utils/ref-counted-map.d.ts +8 -2
  78. package/dist/types/utils/ref-counted-map.d.ts.map +1 -1
  79. package/package.json +2 -1
@@ -1,5 +1,11 @@
1
+ import {
2
+ getBaseBreakpoint,
3
+ getBreakpointMediaQuery
4
+ } from "@makeswift/controls";
1
5
  import { isKnownAction } from "../actions";
6
+ import { InternalActionTypes } from "../actions/internal";
2
7
  import { BuilderActionTypes } from "../builder-api/actions";
8
+ import { isServer } from "../../utils/is-server";
3
9
  import {
4
10
  getBreakpoint
5
11
  } from "@makeswift/controls";
@@ -28,8 +34,26 @@ const DEFAULT_BREAKPOINTS = [
28
34
  viewportWidth: 390
29
35
  }
30
36
  ];
37
+ const getDeviceQueries = (breakpoints) => breakpoints.map((device) => ({
38
+ id: device.id,
39
+ query: getBreakpointMediaQuery(device).replace("@media", "")
40
+ }));
41
+ const getBaseBreakpointId = (breakpoints) => getBaseBreakpoint(breakpoints).id;
42
+ function getMatchingMediaBreakpointId(breakpoints) {
43
+ const baseBreakpoint = getBaseBreakpointId(breakpoints);
44
+ if (isServer())
45
+ return baseBreakpoint;
46
+ const matchingBreakpoint = getDeviceQueries(breakpoints).findLast(
47
+ ({ query }) => window.matchMedia(query).matches
48
+ );
49
+ return matchingBreakpoint?.id ?? baseBreakpoint;
50
+ }
31
51
  function getInitialState(breakpoints = DEFAULT_BREAKPOINTS) {
32
- return breakpoints;
52
+ return {
53
+ breakpoints,
54
+ baseBreakpoint: getBaseBreakpointId(breakpoints),
55
+ clientBreakpoint: getMatchingMediaBreakpointId(breakpoints)
56
+ };
33
57
  }
34
58
  function reducer(state = getInitialState(), action) {
35
59
  if (!isKnownAction(action))
@@ -39,7 +63,17 @@ function reducer(state = getInitialState(), action) {
39
63
  const breakpoints = action.payload.breakpoints;
40
64
  if (breakpoints.length === 0)
41
65
  throw new Error("Breakpoints cannot be empty.");
42
- return breakpoints;
66
+ return {
67
+ breakpoints,
68
+ baseBreakpoint: getBaseBreakpointId(breakpoints),
69
+ clientBreakpoint: getMatchingMediaBreakpointId(breakpoints)
70
+ };
71
+ }
72
+ case InternalActionTypes.UPDATE_CLIENT_BREAKPOINT: {
73
+ const clientBreakpoint = getMatchingMediaBreakpointId(state.breakpoints);
74
+ if (clientBreakpoint === state.clientBreakpoint)
75
+ return state;
76
+ return { ...state, clientBreakpoint };
43
77
  }
44
78
  default:
45
79
  return state;
@@ -102,7 +136,9 @@ export {
102
136
  DEFAULT_BREAKPOINTS,
103
137
  DefaultBreakpointID,
104
138
  getBreakpoint,
139
+ getDeviceQueries,
105
140
  getInitialState,
141
+ getMatchingMediaBreakpointId,
106
142
  parseBreakpointsInput,
107
143
  reducer
108
144
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import { type Breakpoint, type Breakpoints } from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { BuilderActionTypes } from '../builder-api/actions'\n\nexport {\n getBreakpoint,\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n} from '@makeswift/controls'\n\nexport type State = Breakpoints\n\nexport const DefaultBreakpointID = {\n Desktop: 'desktop',\n Tablet: 'tablet',\n Mobile: 'mobile',\n} as const\n\ntype DefaultBreakpointID = (typeof DefaultBreakpointID)[keyof typeof DefaultBreakpointID]\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = [\n {\n id: DefaultBreakpointID.Desktop,\n label: 'Desktop',\n minWidth: 769,\n },\n {\n id: DefaultBreakpointID.Tablet,\n label: 'Tablet',\n minWidth: 576,\n maxWidth: 768,\n viewportWidth: 760,\n },\n {\n id: DefaultBreakpointID.Mobile,\n label: 'Mobile',\n maxWidth: 575,\n viewportWidth: 390,\n },\n]\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return breakpoints\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case BuilderActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return breakpoints\n }\n\n default:\n return state\n }\n}\n\nexport type BreakpointsInput = Record<string, { width: number; label?: string; viewport?: number }>\n\nexport function parseBreakpointsInput(input: BreakpointsInput): Breakpoints {\n validateBreakpointsInput(input)\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n const transformed = sorted.reduce(\n (prev, curr, index, array) => {\n const { width, viewport, id, label } = curr\n const next = array[index + 1]\n\n const breakpoint: Breakpoint = {\n id,\n ...(label && { label }),\n ...(next && { minWidth: next.width + 1 }),\n maxWidth: width,\n viewportWidth: viewport ?? width,\n }\n\n return [...prev, breakpoint]\n },\n [\n { id: DefaultBreakpointID.Desktop, label: 'Desktop', minWidth: sorted[0].width + 1 },\n ] as Breakpoints,\n )\n\n return transformed\n}\n\nfunction validateBreakpointsInput(input: BreakpointsInput) {\n if (DefaultBreakpointID.Desktop in input) {\n throw new Error(\n `Cannot change the base breakpoint. \"${DefaultBreakpointID.Desktop}\" is reserved as the base breakpoint.`,\n )\n }\n\n if (Object.keys(input).length === 0) {\n throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`)\n }\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n sorted.forEach(({ id, width, viewport }, index, array) => {\n // This is only valid for desktop-first. We need to check the inverse for mobile-first.\n if (viewport && viewport > width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be greater than its width.\n \"${id}\" has a viewport of ${viewport}px and a width of ${width}px.`,\n )\n }\n\n const next = array[index + 1]\n\n if (viewport && next && viewport < next.width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be smaller than the next breakpoint's width.\n \"${id}\" has a viewport of ${viewport}px and the next breakpoint \"${next.id}\" has a width of ${next.width}px.`,\n )\n }\n\n if (next && width === next.width) {\n throw new Error(\n `Breakpoints cannot have the same width. \"${id}\" and \"${next.id}\" have the same width`,\n )\n }\n })\n}\n"],"mappings":"AAEA,SAA0C,qBAAqB;AAC/D,SAAS,0BAA0B;AAEnC;AAAA,EACE;AAAA,OAIK;AAIA,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA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,oBAAoB,OAAO;AAAA,IACpE;AAAA,EACF;AAEA,MAAI,OAAO,KAAK,KAAK,EAAE,WAAW,GAAG;AACnC,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAEA,QAAM,SAAS,OAAO,QAAQ,KAAK,EAChC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,GAAG,OAAO,GAAG,EAAE,EACvC,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;AAEnC,SAAO,QAAQ,CAAC,EAAE,IAAI,OAAO,SAAS,GAAG,OAAO,UAAU;AAExD,QAAI,YAAY,WAAW,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,qBAAqB,KAAK;AAAA,MAChE;AAAA,IACF;AAEA,UAAM,OAAO,MAAM,QAAQ,CAAC;AAE5B,QAAI,YAAY,QAAQ,WAAW,KAAK,OAAO;AAC7C,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,+BAA+B,KAAK,EAAE,oBAAoB,KAAK,KAAK;AAAA,MAC1G;AAAA,IACF;AAEA,QAAI,QAAQ,UAAU,KAAK,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import {\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n getBaseBreakpoint,\n getBreakpointMediaQuery,\n} from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { InternalActionTypes } from '../actions/internal'\nimport { BuilderActionTypes } from '../builder-api/actions'\nimport { isServer } from '../../utils/is-server'\n\nexport {\n getBreakpoint,\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n} from '@makeswift/controls'\n\nexport type State = {\n breakpoints: Breakpoints\n baseBreakpoint: BreakpointId\n clientBreakpoint: BreakpointId\n}\n\nexport const DefaultBreakpointID = {\n Desktop: 'desktop',\n Tablet: 'tablet',\n Mobile: 'mobile',\n} as const\n\ntype DefaultBreakpointID = (typeof DefaultBreakpointID)[keyof typeof DefaultBreakpointID]\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = [\n {\n id: DefaultBreakpointID.Desktop,\n label: 'Desktop',\n minWidth: 769,\n },\n {\n id: DefaultBreakpointID.Tablet,\n label: 'Tablet',\n minWidth: 576,\n maxWidth: 768,\n viewportWidth: 760,\n },\n {\n id: DefaultBreakpointID.Mobile,\n label: 'Mobile',\n maxWidth: 575,\n viewportWidth: 390,\n },\n]\n\nexport const getDeviceQueries = (breakpoints: Breakpoints) =>\n breakpoints.map(device => ({\n id: device.id,\n query: getBreakpointMediaQuery(device).replace('@media', ''),\n }))\n\nconst getBaseBreakpointId = (breakpoints: Breakpoints): BreakpointId =>\n getBaseBreakpoint(breakpoints).id\n\n// Intentional impurity in the reducer buys us several practical upsides here:\n//\n// - We can keep `SET_BREAKPOINTS` atomic by recalculating the client breakpoint\n// state when we update the set of available breakpoints; if we don't do that\n// here, we'll have to do it from the outside, and the state will temporarily\n// hold a stale client breakpoint value in between\n//\n// - We can have a valid, internally consistent *initial* state for the client\n// breakpoint; if we move the client breakpoint calculation out of the reducer,\n// we'll be forced to start with a stale initial state, which will introduce\n// implicit coupling and potential timing issues between the\n// `useCurrentBreakpoint` hook and the client breakpoint synchronization code\n// in `BreakpointWatch`\n//\n// - `UPDATE_CLIENT_BREAKPOINT` can compute the client breakpoint from browser\n// state using the current breakpoint set instead of having to validate and\n// handle external payload\n\nexport function getMatchingMediaBreakpointId(breakpoints: Breakpoints): BreakpointId {\n const baseBreakpoint = getBaseBreakpointId(breakpoints)\n if (isServer()) return baseBreakpoint\n\n // using `findLast` to preserve the legacy behavior; might not be necessary\n const matchingBreakpoint = getDeviceQueries(breakpoints).findLast(\n ({ query }) => window.matchMedia(query).matches,\n )\n\n return matchingBreakpoint?.id ?? baseBreakpoint\n}\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case BuilderActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\n }\n\n case InternalActionTypes.UPDATE_CLIENT_BREAKPOINT: {\n const clientBreakpoint = getMatchingMediaBreakpointId(state.breakpoints)\n if (clientBreakpoint === state.clientBreakpoint) return state\n\n return { ...state, clientBreakpoint }\n }\n\n default:\n return state\n }\n}\n\nexport type BreakpointsInput = Record<string, { width: number; label?: string; viewport?: number }>\n\nexport function parseBreakpointsInput(input: BreakpointsInput): Breakpoints {\n validateBreakpointsInput(input)\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n const transformed = sorted.reduce(\n (prev, curr, index, array) => {\n const { width, viewport, id, label } = curr\n const next = array[index + 1]\n\n const breakpoint: Breakpoint = {\n id,\n ...(label && { label }),\n ...(next && { minWidth: next.width + 1 }),\n maxWidth: width,\n viewportWidth: viewport ?? width,\n }\n\n return [...prev, breakpoint]\n },\n [\n { id: DefaultBreakpointID.Desktop, label: 'Desktop', minWidth: sorted[0].width + 1 },\n ] as Breakpoints,\n )\n\n return transformed\n}\n\nfunction validateBreakpointsInput(input: BreakpointsInput) {\n if (DefaultBreakpointID.Desktop in input) {\n throw new Error(\n `Cannot change the base breakpoint. \"${DefaultBreakpointID.Desktop}\" is reserved as the base breakpoint.`,\n )\n }\n\n if (Object.keys(input).length === 0) {\n throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`)\n }\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n sorted.forEach(({ id, width, viewport }, index, array) => {\n // This is only valid for desktop-first. We need to check the inverse for mobile-first.\n if (viewport && viewport > width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be greater than its width.\n \"${id}\" has a viewport of ${viewport}px and a width of ${width}px.`,\n )\n }\n\n const next = array[index + 1]\n\n if (viewport && next && viewport < next.width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be smaller than the next breakpoint's width.\n \"${id}\" has a viewport of ${viewport}px and the next breakpoint \"${next.id}\" has a width of ${next.width}px.`,\n )\n }\n\n if (next && width === next.width) {\n throw new Error(\n `Breakpoints cannot have the same width. \"${id}\" and \"${next.id}\" have the same width`,\n )\n }\n })\n}\n"],"mappings":"AAAA;AAAA,EAIE;AAAA,EACA;AAAA,OACK;AAEP,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AAEzB;AAAA,EACE;AAAA,OAIK;AAQA,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAEO,MAAM,mBAAmB,CAAC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A,IACF;AAEA,UAAM,OAAO,MAAM,QAAQ,CAAC;AAE5B,QAAI,YAAY,QAAQ,WAAW,KAAK,OAAO;AAC7C,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,+BAA+B,KAAK,EAAE,oBAAoB,KAAK,KAAK;AAAA,MAC1G;AAAA,IACF;AAEA,QAAI,QAAQ,UAAU,KAAK,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -129,17 +129,28 @@ function getIsReadOnly(state) {
129
129
  function getBuilderEditMode(state) {
130
130
  return state.builderEditMode;
131
131
  }
132
- function getBreakpoints(state) {
132
+ function getBreakpointsStateSlice(state) {
133
133
  return state.breakpoints;
134
134
  }
135
+ function getBreakpoints(state) {
136
+ return getBreakpointsStateSlice(state).breakpoints;
137
+ }
138
+ function getBaseBreakpoint(state) {
139
+ return getBreakpointsStateSlice(state).baseBreakpoint;
140
+ }
141
+ function getClientBreakpoint(state) {
142
+ return getBreakpointsStateSlice(state).clientBreakpoint;
143
+ }
135
144
  function getLocale(state) {
136
145
  return state.locale;
137
146
  }
138
147
  export {
139
148
  createBaseDocument,
140
149
  createDocumentReference,
150
+ getBaseBreakpoint,
141
151
  getBreakpoints,
142
152
  getBuilderEditMode,
153
+ getClientBreakpoint,
143
154
  getComponentMeta,
144
155
  getComponentPropControllerDescriptors,
145
156
  getComponentsMeta,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state/read-only-state.ts"],"sourcesContent":["import { type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport * as SiteVersion from './modules/site-version'\nimport * as Locale from './modules/locale'\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsReadOnly from './modules/is-read-only'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { type Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nexport const reducers = {\n siteVersion: SiteVersion.reducer,\n isReadOnly: IsReadOnly.reducer,\n locale: Locale.reducer,\n documents: Documents.reducer,\n elementTrees: ElementTrees.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n builderEditMode: BuilderEditMode.reducer,\n breakpoints: Breakpoints.reducer,\n}\n\nexport type State = {\n siteVersion: SiteVersion.State\n isReadOnly: IsReadOnly.State\n locale: Locale.State\n documents: Documents.State\n elementTrees: ElementTrees.State\n reactComponents: ReactComponents.State\n componentsMeta: ComponentsMeta.State\n propControllers: PropControllers.State\n propControllerHandles: PropControllerHandles.State\n isInBuilder: IsInBuilder.State\n builderEditMode: BuilderEditMode.State\n breakpoints: Breakpoints.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllers.State {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllers.DescriptorsByProp | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nexport function getPropControllers(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropControllersHandle(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropController(\n state: State,\n {\n documentKey,\n elementKey,\n propName,\n }: { documentKey: string; elementKey: string; propName: string },\n) {\n return PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n propName,\n )\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state.isReadOnly\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nexport function getBreakpoints(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport function getLocale(state: State): string | null {\n return state.locale\n}\n"],"mappings":"AAEA,SAAS,sBAAsB;AAE/B,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,eAAe;AAC3B,YAAY,kBAAkB;AAC9B,YAAY,qBAAqB;AACjC,YAAY,oBAAoB;AAChC,YAAY,qBAAqB;AACjC,YAAY,2BAA2B;AACvC,YAAY,iBAAiB;AAC7B,YAAY,gBAAgB;AAC5B,YAAY,qBAAqB;AACjC,YAAY,iBAAiB;AAa7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKA,MAAM,WAAW;A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D,SAAO,MAAM;AACf;AAEO,SAAS,mBAAmB,OAAqC;AACtE,SAAO,MAAM;AACf;AAEO,SAAS,eAAe,OAAiC;AAC9D,SAAO,MAAM;AACf;AAEO,SAAS,UAAU,OAA6B;AACrD,SAAO,MAAM;AACf;","names":[]}
1
+ {"version":3,"sources":["../../../src/state/read-only-state.ts"],"sourcesContent":["import { type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport * as SiteVersion from './modules/site-version'\nimport * as Locale from './modules/locale'\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsReadOnly from './modules/is-read-only'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { type Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nexport const reducers = {\n siteVersion: SiteVersion.reducer,\n isReadOnly: IsReadOnly.reducer,\n locale: Locale.reducer,\n documents: Documents.reducer,\n elementTrees: ElementTrees.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n builderEditMode: BuilderEditMode.reducer,\n breakpoints: Breakpoints.reducer,\n}\n\nexport type State = {\n siteVersion: SiteVersion.State\n isReadOnly: IsReadOnly.State\n locale: Locale.State\n documents: Documents.State\n elementTrees: ElementTrees.State\n reactComponents: ReactComponents.State\n componentsMeta: ComponentsMeta.State\n propControllers: PropControllers.State\n propControllerHandles: PropControllerHandles.State\n isInBuilder: IsInBuilder.State\n builderEditMode: BuilderEditMode.State\n breakpoints: Breakpoints.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllers.State {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllers.DescriptorsByProp | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nexport function getPropControllers(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropControllersHandle(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropController(\n state: State,\n {\n documentKey,\n elementKey,\n propName,\n }: { documentKey: string; elementKey: string; propName: string },\n) {\n return PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n propName,\n )\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state.isReadOnly\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nfunction getBreakpointsStateSlice(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport function getBreakpoints(state: State): Breakpoints.Breakpoints {\n return getBreakpointsStateSlice(state).breakpoints\n}\n\nexport function getBaseBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).baseBreakpoint\n}\n\nexport function getClientBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).clientBreakpoint\n}\n\nexport function getLocale(state: State): string | null {\n return state.locale\n}\n"],"mappings":"AAEA,SAAS,sBAAsB;AAE/B,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,eAAe;AAC3B,YAAY,kBAAkB;AAC9B,YAAY,qBAAqB;AACjC,YAAY,oBAAoB;AAChC,YAAY,qBAAqB;AACjC,YAAY,2BAA2B;AACvC,YAAY,iBAAiB;AAC7B,YAAY,gBAAgB;AAC5B,YAAY,qBAAqB;AACjC,YAAY,iBAAiB;AAa7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKA,MAAM,WAAW;AAAA,EACtB,aAAa,YAAY;AAAA,EACzB,YAAY,WAAW;AAAA,EACvB,QAAQ,OAAO;AAAA,EACf,WAAW,UAAU;AAAA,EACrB,cAAc,aAAa;AAAA,EAC3B,iBAAiB,gBAAgB;AAAA,EACjC,gBAAgB,eAAe;AAAA,EAC/B,iBAAiB,gBAAgB;AAAA,EACjC,uBAAuB,sBAAsB;AAAA,EAC7C,aAAa,YAAY;AAAA,EACzB,iBAAiB,gBAAgB;AAAA,EACjC,aAAa,YAAY;AAC3B;AAmBA,SAAS,uBAAuB,OAA+B;AAC7D,SAAO,MAAM;AACf;AAEO,SAAS,YAAY,OAAc,aAAgD;AACxF,SAAO,UAAU,YAAY,uBAAuB,KAAK,GAAG,WAAW;AACzE;AAEA,SAAS,qBAAqB,OAAkC;AAC9D,SAAO,MAAM;AACf;AAEO,SAAS,YACd,OACA,aACsC;AACtC,SAAO,aAAa,YA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,EACtE,CAAC,wBAAwB,oBAAoB;AAAA,EAC7C,CAAC,WAAW,iBAAiB;AAC3B,WAAO,CAAC,GAAG,UAAU,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,MAAO,aAAa,IAAI,CAAC,GAAG,SAAS,IAAI,CAAC,IAAI,KAAK,CAAE;AAAA,EAC7F;AACF;AAEO,SAAS,WACd,OACA,aACA,YAC0B;AAC1B,SAAO,aAAa,WAAW,qBAAqB,KAAK,GAAG,aAAa,UAAU;AACrF;AAEO,SAAS,aAAa,OAAc,aAAqB,YAAmC;AACjG,SAAO,aAAa,aAAa,qBAAqB,KAAK,GAAG,aAAa,UAAU;AACvF;AAEO,SAAS,oCACd,OACA,aACA,YACiE;AACjE,QAAM,UAAU,WAAW,OAAO,aAAa,UAAU;AAEzD,MAAI,WAAW,QAAQ,UAAU,mBAAmB,OAAO;AAAG,WAAO;AAErE,SAAO,sCAAsC,OAAO,QAAQ,IAAI;AAClE;AAEO,SAAS,eAAe,OAAuB;AACpD,SAAO,MAAM;AACf;AAEO,SAAS,cAAc,OAAuB;AACnD,SAAO,MAAM;AACf;AAEO,SAAS,mBAAmB,OAAqC;AACtE,SAAO,MAAM;AACf;AAEA,SAAS,yBAAyB,OAAiC;AACjE,SAAO,MAAM;AACf;AAEO,SAAS,eAAe,OAAuC;AACpE,SAAO,yBAAyB,KAAK,EAAE;AACzC;AAEO,SAAS,kBAAkB,OAAwC;AACxE,SAAO,yBAAyB,KAAK,EAAE;AACzC;AAEO,SAAS,oBAAoB,OAAwC;AAC1E,SAAO,yBAAyB,KAAK,EAAE;AACzC;AAEO,SAAS,UAAU,OAA6B;AACrD,SAAO,MAAM;AACf;","names":[]}
@@ -10,6 +10,7 @@ import { HostActionTypes } from "./host-api";
10
10
  import * as Breakpoints from "./modules/breakpoints";
11
11
  import { readOnlyElementTreeMiddleware } from "./middleware/read-only-element-tree";
12
12
  import { makeswiftApiClientSyncMiddleware } from "./middleware/makeswift-api-client-sync";
13
+ import { breakpointWatchMixin } from "./mixins/breakpoint-watch";
13
14
  import * as ReadOnlyState from "./read-only-state";
14
15
  const configureStore = ({
15
16
  name,
@@ -141,6 +142,13 @@ function configureReadWriteStore({
141
142
  conditionalReadWriteMiddleware(readWriteMiddlewareRef)
142
143
  ],
143
144
  enhancers: () => new Tuple(
145
+ withMixin(
146
+ breakpointWatchMixin({
147
+ dispatch: (...args) => store.dispatch(...args),
148
+ getState: () => store.getState(),
149
+ subscribe: (listener) => store.subscribe(listener)
150
+ })
151
+ ),
144
152
  withMixin({
145
153
  hostApiClient,
146
154
  loadReadWriteStateIfNeeded: async () => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state/store.ts"],"sourcesContent":["import {\n type Middleware,\n type StoreEnhancer,\n type MiddlewareAPI,\n Tuple,\n configureStore as configureReduxStore,\n combineReducers,\n compose,\n} from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../api/client'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\nimport { BuilderActionTypes } from './builder-api/actions'\nimport { HostActionTypes } from './host-api'\n\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { readOnlyElementTreeMiddleware } from './middleware/read-only-element-tree'\nimport { makeswiftApiClientSyncMiddleware } from './middleware/makeswift-api-client-sync'\n\nimport { type Action } from './actions'\n\nimport { type State as ReadWriteState } from './read-write-state'\nimport * as ReadOnlyState from './read-only-state'\nimport {\n type State,\n type Dispatch,\n type ReadOnlyReducer,\n type ReadWriteDispatch,\n} from './unified-state'\n\nexport { type State } from './unified-state'\n\nconst configureStore = <Items extends readonly StoreEnhancer[] = []>({\n name,\n preloadedState,\n enhancers,\n middleware,\n}: {\n name: string\n preloadedState: Partial<State>\n enhancers: () => Tuple<Items>\n middleware?: () => Middleware[]\n}) => {\n const store = configureReduxStore({\n reducer: combineReducers(ReadOnlyState.reducers),\n preloadedState,\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat([\n readOnlyElementTreeMiddleware(),\n ...(middleware ? middleware() : []),\n ]),\n\n enhancers: getDefaultEnhancers => getDefaultEnhancers().concat(enhancers()),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n actionsDenylist: [\n HostActionTypes.BUILDER_POINTER_MOVE,\n BuilderActionTypes.HANDLE_POINTER_MOVE,\n BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n\n return store\n}\n\nexport function configureProtoStore({\n name,\n breakpoints,\n}: {\n name: string\n breakpoints: Breakpoints.State | undefined\n}) {\n return configureStore({\n name,\n preloadedState: {\n breakpoints: Breakpoints.getInitialState(breakpoints),\n },\n enhancers: () => new Tuple(),\n })\n}\n\nexport type ProtoStore = ReturnType<typeof configureProtoStore>\n\ntype ReadWriteMiddleware = ReturnType<\n typeof import('./middleware/read-write').createReadWriteMiddleware\n>\n\ntype ReadWriteMiddlewareRef = {\n current: ReadWriteMiddleware | null\n}\n\nexport function conditionalReadWriteMiddleware(\n middlewareRef: ReadWriteMiddlewareRef,\n): Middleware<Dispatch, State, Dispatch> {\n let readWriteActionBuffer: Action[] = []\n let middlewares: ReadWriteMiddleware | null = null\n let enhancedDispatch: Dispatch | null = null\n\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n const state = getState()\n\n if (middlewareRef.current == null) {\n if (!state.isReadOnly) {\n // because switching to the read-write state is an asynchronous operation,\n // we need to buffer all actions dispatched after the isReadOnly state is\n // set to false but before the read-write middleware is installed\n readWriteActionBuffer.push(action)\n }\n\n return next(action)\n }\n\n if (state.isReadOnly) {\n console.error('Read-write state mismatch', {\n isReadOnly: state.isReadOnly,\n middlewareRef: middlewareRef.current,\n siteVersion: state.siteVersion,\n })\n }\n\n // build and cache the enhanced dispatch chain when read-write middleware is installed\n if (enhancedDispatch == null || middlewares !== middlewareRef.current) {\n middlewares = middlewareRef.current\n\n const middlewareApi = { dispatch, getState } as MiddlewareAPI<\n ReadWriteDispatch,\n ReadWriteState\n >\n\n enhancedDispatch = compose<Dispatch>(...middlewares.map(mw => mw(middlewareApi)))(next)\n }\n\n // dispatch buffered actions, if any\n if (readWriteActionBuffer.length > 0) {\n const readWriteActions = [...readWriteActionBuffer]\n readWriteActionBuffer = []\n\n // Note that we're rerunning the actions through the entire middleware chain,\n // including the read-only middleware and the reducers, some of which have\n // already processed these actions once. This is safe to do because actions that\n // are run as part of page initialization are idempotent.\n for (const bufferedAction of readWriteActions) {\n enhancedDispatch(bufferedAction)\n }\n }\n\n return enhancedDispatch(action)\n }\n })\n}\n\nexport interface ReadWriteStateMixin {\n readonly hostApiClient: MakeswiftHostApiClient\n\n loadReadWriteStateIfNeeded(): Promise<() => void>\n}\n\nfunction withMixin<M extends {}>(mixin: M): StoreEnhancer<M> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n ...mixin,\n })\n}\n\nexport function configureReadWriteStore({\n name,\n appOrigin,\n hostApiClient,\n preloadedState,\n}: {\n name: string\n appOrigin: string\n hostApiClient: MakeswiftHostApiClient\n preloadedState: Partial<State>\n}) {\n const readWriteMiddlewareRef: ReadWriteMiddlewareRef = {\n current: null,\n }\n\n let refCount = 0\n let readWriteCleanup: (() => void) | null = null\n let readWriteSetupPromise: Promise<void> | null = null\n\n const loadReadWriteState = async (): Promise<void> => {\n if (readWriteCleanup != null) {\n return\n }\n\n if (readWriteSetupPromise != null) {\n await readWriteSetupPromise\n return\n }\n\n readWriteSetupPromise = (async () => {\n // import all the modules needed for read-write mode before proceeding with\n // the setup to avoid race conditions when `setup` is called concurrently\n // in two different page regions\n const { BuilderAPIProxy } = await import('./builder-api/proxy')\n const { createRootReducer, setupBuilderProxy } = await import('./read-write-state')\n const { createReadWriteMiddleware } = await import('./middleware/read-write')\n\n // IMPORTANT: only synchronous code after this point\n\n // with all modules imported, check if another concurrent setup already\n // initialized the read-write middleware\n if (readWriteMiddlewareRef.current != null) {\n return\n }\n\n store.replaceReducer(createRootReducer() as ReadOnlyReducer)\n\n const builderProxy = new BuilderAPIProxy({ appOrigin })\n readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy })\n\n const dispatch = store.dispatch as ReadWriteDispatch\n const builderProxyCleanup = dispatch(setupBuilderProxy(builderProxy))\n\n readWriteCleanup = () => {\n readWriteMiddlewareRef.current = null\n builderProxyCleanup()\n }\n })()\n\n try {\n await readWriteSetupPromise\n } finally {\n readWriteSetupPromise = null\n }\n }\n\n const store = configureStore({\n name,\n preloadedState,\n\n middleware: () => [\n makeswiftApiClientSyncMiddleware(hostApiClient),\n conditionalReadWriteMiddleware(readWriteMiddlewareRef),\n ],\n\n enhancers: () =>\n new Tuple(\n withMixin<ReadWriteStateMixin>({\n hostApiClient,\n loadReadWriteStateIfNeeded: async () => {\n const { isReadOnly } = store.getState()\n\n if (isReadOnly) {\n if (refCount > 0) {\n console.error('Read-write state mismatch', { isReadOnly, refCount })\n }\n\n return () => {}\n }\n\n await loadReadWriteState()\n refCount += 1\n\n let didCleanup = false\n return () => {\n if (didCleanup) {\n return\n }\n\n didCleanup = true\n refCount -= 1\n if (refCount === 0 && readWriteCleanup != null) {\n readWriteCleanup()\n readWriteCleanup = null\n }\n }\n },\n }),\n ),\n })\n\n return store\n}\n\nexport type Store = ReturnType<typeof configureReadWriteStore>\n"],"mappings":"AAAA;AAAA,EAIE;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,OACK;AAIP,SAAS,kBAAkB,mBAAmB,sBAAsB;AACpE,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAEhC,YAAY,iBAAiB;AAE7B,SAAS,qCAAqC;AAC9C,SAAS,wCAAwC;AAKjD,YAAY,mBAAmB;AAU/B,MAAM,iBAAiB,CAA8C;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,QAAQ,oBAAoB;AAAA,IAChC,SAAS,gBAAgB,cAAc,QAAQ;AAAA,IAC/C;AAAA,IAEA,YAAY,0BACV,qBAAqB,iBA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U;AACjC,4BAAoB;AAAA,MACtB;AAAA,IACF,GAAG;AAEH,QAAI;AACF,YAAM;AAAA,IACR,UAAE;AACA,8BAAwB;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,QAAQ,eAAe;AAAA,IAC3B;AAAA,IACA;AAAA,IAEA,YAAY,MAAM;AAAA,MAChB,iCAAiC,aAAa;AAAA,MAC9C,+BAA+B,sBAAsB;AAAA,IACvD;AAAA,IAEA,WAAW,MACT,IAAI;AAAA,MACF,UAA+B;AAAA,QAC7B;AAAA,QACA,4BAA4B,YAAY;AACtC,gBAAM,EAAE,WAAW,IAAI,MAAM,SAAS;AAEtC,cAAI,YAAY;AACd,gBAAI,WAAW,GAAG;AAChB,sBAAQ,MAAM,6BAA6B,EAAE,YAAY,SAAS,CAAC;AAAA,YACrE;AAEA,mBAAO,MAAM;AAAA,YAAC;AAAA,UAChB;AAEA,gBAAM,mBAAmB;AACzB,sBAAY;AAEZ,cAAI,aAAa;AACjB,iBAAO,MAAM;AACX,gBAAI,YAAY;AACd;AAAA,YACF;AAEA,yBAAa;AACb,wBAAY;AACZ,gBAAI,aAAa,KAAK,oBAAoB,MAAM;AAC9C,+BAAiB;AACjB,iCAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACJ,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/state/store.ts"],"sourcesContent":["import {\n type Middleware,\n type StoreEnhancer,\n type MiddlewareAPI,\n Tuple,\n configureStore as configureReduxStore,\n combineReducers,\n compose,\n} from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../api/client'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\nimport { BuilderActionTypes } from './builder-api/actions'\nimport { HostActionTypes } from './host-api'\n\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { readOnlyElementTreeMiddleware } from './middleware/read-only-element-tree'\nimport { makeswiftApiClientSyncMiddleware } from './middleware/makeswift-api-client-sync'\nimport { type BreakpointWatch, breakpointWatchMixin } from './mixins/breakpoint-watch'\n\nimport { type Action } from './actions'\n\nimport { type State as ReadWriteState } from './read-write-state'\nimport * as ReadOnlyState from './read-only-state'\nimport {\n type State,\n type Dispatch,\n type ReadOnlyReducer,\n type ReadWriteDispatch,\n} from './unified-state'\n\nexport { type State } from './unified-state'\n\nconst configureStore = <Items extends readonly StoreEnhancer[] = []>({\n name,\n preloadedState,\n enhancers,\n middleware,\n}: {\n name: string\n preloadedState: Partial<State>\n enhancers: () => Tuple<Items>\n middleware?: () => Middleware[]\n}) => {\n const store = configureReduxStore({\n reducer: combineReducers(ReadOnlyState.reducers),\n preloadedState,\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat([\n readOnlyElementTreeMiddleware(),\n ...(middleware ? middleware() : []),\n ]),\n\n enhancers: getDefaultEnhancers => getDefaultEnhancers().concat(enhancers()),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n actionsDenylist: [\n HostActionTypes.BUILDER_POINTER_MOVE,\n BuilderActionTypes.HANDLE_POINTER_MOVE,\n BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n\n return store\n}\n\nexport function configureProtoStore({\n name,\n breakpoints,\n}: {\n name: string\n breakpoints: Breakpoints.Breakpoints | undefined\n}) {\n return configureStore({\n name,\n preloadedState: {\n breakpoints: Breakpoints.getInitialState(breakpoints),\n },\n enhancers: () => new Tuple(),\n })\n}\n\nexport type ProtoStore = ReturnType<typeof configureProtoStore>\n\ntype ReadWriteMiddleware = ReturnType<\n typeof import('./middleware/read-write').createReadWriteMiddleware\n>\n\ntype ReadWriteMiddlewareRef = {\n current: ReadWriteMiddleware | null\n}\n\nexport function conditionalReadWriteMiddleware(\n middlewareRef: ReadWriteMiddlewareRef,\n): Middleware<Dispatch, State, Dispatch> {\n let readWriteActionBuffer: Action[] = []\n let middlewares: ReadWriteMiddleware | null = null\n let enhancedDispatch: Dispatch | null = null\n\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n const state = getState()\n\n if (middlewareRef.current == null) {\n if (!state.isReadOnly) {\n // because switching to the read-write state is an asynchronous operation,\n // we need to buffer all actions dispatched after the isReadOnly state is\n // set to false but before the read-write middleware is installed\n readWriteActionBuffer.push(action)\n }\n\n return next(action)\n }\n\n if (state.isReadOnly) {\n console.error('Read-write state mismatch', {\n isReadOnly: state.isReadOnly,\n middlewareRef: middlewareRef.current,\n siteVersion: state.siteVersion,\n })\n }\n\n // build and cache the enhanced dispatch chain when read-write middleware is installed\n if (enhancedDispatch == null || middlewares !== middlewareRef.current) {\n middlewares = middlewareRef.current\n\n const middlewareApi = { dispatch, getState } as MiddlewareAPI<\n ReadWriteDispatch,\n ReadWriteState\n >\n\n enhancedDispatch = compose<Dispatch>(...middlewares.map(mw => mw(middlewareApi)))(next)\n }\n\n // dispatch buffered actions, if any\n if (readWriteActionBuffer.length > 0) {\n const readWriteActions = [...readWriteActionBuffer]\n readWriteActionBuffer = []\n\n // Note that we're rerunning the actions through the entire middleware chain,\n // including the read-only middleware and the reducers, some of which have\n // already processed these actions once. This is safe to do because actions that\n // are run as part of page initialization are idempotent.\n for (const bufferedAction of readWriteActions) {\n enhancedDispatch(bufferedAction)\n }\n }\n\n return enhancedDispatch(action)\n }\n })\n}\n\nexport interface ReadWriteStateMixin {\n readonly hostApiClient: MakeswiftHostApiClient\n\n loadReadWriteStateIfNeeded(): Promise<() => void>\n}\n\nfunction withMixin<M extends {}>(mixin: M): StoreEnhancer<M> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n ...mixin,\n })\n}\n\nexport function configureReadWriteStore({\n name,\n appOrigin,\n hostApiClient,\n preloadedState,\n}: {\n name: string\n appOrigin: string\n hostApiClient: MakeswiftHostApiClient\n preloadedState: Partial<State>\n}) {\n const readWriteMiddlewareRef: ReadWriteMiddlewareRef = {\n current: null,\n }\n\n let refCount = 0\n let readWriteCleanup: (() => void) | null = null\n let readWriteSetupPromise: Promise<void> | null = null\n\n const loadReadWriteState = async (): Promise<void> => {\n if (readWriteCleanup != null) {\n return\n }\n\n if (readWriteSetupPromise != null) {\n await readWriteSetupPromise\n return\n }\n\n readWriteSetupPromise = (async () => {\n // import all the modules needed for read-write mode before proceeding with\n // the setup to avoid race conditions when `setup` is called concurrently\n // in two different page regions\n const { BuilderAPIProxy } = await import('./builder-api/proxy')\n const { createRootReducer, setupBuilderProxy } = await import('./read-write-state')\n const { createReadWriteMiddleware } = await import('./middleware/read-write')\n\n // IMPORTANT: only synchronous code after this point\n\n // with all modules imported, check if another concurrent setup already\n // initialized the read-write middleware\n if (readWriteMiddlewareRef.current != null) {\n return\n }\n\n store.replaceReducer(createRootReducer() as ReadOnlyReducer)\n\n const builderProxy = new BuilderAPIProxy({ appOrigin })\n readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy })\n\n const dispatch = store.dispatch as ReadWriteDispatch\n const builderProxyCleanup = dispatch(setupBuilderProxy(builderProxy))\n\n readWriteCleanup = () => {\n readWriteMiddlewareRef.current = null\n builderProxyCleanup()\n }\n })()\n\n try {\n await readWriteSetupPromise\n } finally {\n readWriteSetupPromise = null\n }\n }\n\n const store = configureStore({\n name,\n preloadedState,\n\n middleware: () => [\n makeswiftApiClientSyncMiddleware(hostApiClient),\n conditionalReadWriteMiddleware(readWriteMiddlewareRef),\n ],\n\n enhancers: () =>\n new Tuple(\n withMixin<BreakpointWatch>(\n breakpointWatchMixin({\n dispatch: (...args: Parameters<Dispatch>) => store.dispatch(...args),\n getState: (): State => store.getState(),\n subscribe: (listener): VoidFunction => store.subscribe(listener),\n }),\n ),\n\n withMixin<ReadWriteStateMixin>({\n hostApiClient,\n loadReadWriteStateIfNeeded: async () => {\n const { isReadOnly } = store.getState()\n\n if (isReadOnly) {\n if (refCount > 0) {\n console.error('Read-write state mismatch', { isReadOnly, refCount })\n }\n\n return () => {}\n }\n\n await loadReadWriteState()\n refCount += 1\n\n let didCleanup = false\n return () => {\n if (didCleanup) {\n return\n }\n\n didCleanup = true\n refCount -= 1\n if (refCount === 0 && readWriteCleanup != null) {\n readWriteCleanup()\n readWriteCleanup = null\n }\n }\n },\n }),\n ),\n })\n\n return store\n}\n\nexport type Store = ReturnType<typeof configureReadWriteStore>\n"],"mappings":"AAAA;AAAA,EAIE;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,OACK;AAIP,SAAS,kBAAkB,mBAAmB,sBAAsB;AACpE,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAEhC,YAAY,iBAAiB;AAE7B,SAAS,qCAAqC;AAC9C,SAAS,wCAAwC;AACjD,SAA+B,4BAA4B;AAK3D,YAAY,mBAAmB;AAU/B,MAAM,iBAAiB,CAA8C;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,QAAQ,oBAAoB;AAAA,IAChC,SAAS,gBAAgB,cAAc,QAAQ;AAAA,IAC/C;AAAA,IAEA,YAAY,0BACV,qBAAqB,iBAAiB,EAAE,OAAO;AAAA,MAC7C,8BAA8B;AAAA,MAC9B,GAAI,aAAa,WAAW,IAAI,CAAC;AAAA,IACnC,CAAC;AAAA,IAEH,WAAW,yBAAuB,oBAAoB,EAAE,OAAO,UAAU,CAAC;AAAA,IAE1E,UAAU,eAAe;AAAA,MACvB,MAAM,GAAG,IAAI,MAAK,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MAC1C,iBAAiB;AAAA,QACf,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,mBAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;AAEO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AACF,GAGG;AACD,SAAO,eAAe;AAAA,IACpB;AAAA,IACA,gBAAgB;AAAA,MACd,aAAa,YAAY,gBAAgB,WAAW;AAAA,IACtD;AAAA,IACA,W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gBAAM,EAAE,WAAW,IAAI,MAAM,SAAS;AAEtC,cAAI,YAAY;AACd,gBAAI,WAAW,GAAG;AAChB,sBAAQ,MAAM,6BAA6B,EAAE,YAAY,SAAS,CAAC;AAAA,YACrE;AAEA,mBAAO,MAAM;AAAA,YAAC;AAAA,UAChB;AAEA,gBAAM,mBAAmB;AACzB,sBAAY;AAEZ,cAAI,aAAa;AACjB,iBAAO,MAAM;AACX,gBAAI,YAAY;AACd;AAAA,YACF;AAEA,yBAAa;AACb,wBAAY;AACZ,gBAAI,aAAa,KAAK,oBAAoB,MAAM;AAC9C,+BAAiB;AACjB,iCAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACJ,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -37,35 +37,44 @@ class RefCountedMap {
37
37
  this.removeExpired();
38
38
  }
39
39
  }
40
+ /**
41
+ * Returns true on transition from unowned to owned
42
+ */
40
43
  retain(key, value) {
41
44
  try {
42
45
  const existing = this.map.get(key);
43
- if (existing != null) {
44
- if (existing.value !== value)
45
- return;
46
- existing.count = (existing.count ?? 0) + 1;
47
- } else {
46
+ if (existing == null) {
48
47
  this.map.set(key, { value, count: 1 });
48
+ return true;
49
+ }
50
+ if (existing.value === value) {
51
+ existing.count = (existing.count ?? 0) + 1;
52
+ return existing.count === 1;
49
53
  }
54
+ return false;
50
55
  } finally {
51
56
  if (this.ttlCheck & TTLCheck.ON_RETAIN)
52
57
  this.removeExpired();
53
58
  }
54
59
  }
60
+ /**
61
+ * Returns true on transition from owned to unowned
62
+ */
55
63
  release(key, value) {
56
64
  try {
57
65
  const existing = this.map.get(key);
58
66
  if (existing == null)
59
- return;
67
+ return false;
60
68
  if (isUnowned(existing))
61
- return;
69
+ return false;
62
70
  if (existing.value !== value)
63
- return;
64
- if (existing.count > 1) {
65
- existing.count -= 1;
66
- } else {
71
+ return false;
72
+ if (existing.count === 1) {
67
73
  this.map.delete(key);
74
+ return true;
68
75
  }
76
+ existing.count -= 1;
77
+ return false;
69
78
  } finally {
70
79
  if (this.ttlCheck & TTLCheck.ON_RELEASE)
71
80
  this.removeExpired();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/ref-counted-map.ts"],"sourcesContent":["type RefCountedMapEntry<V> = {\n value: V\n count: number\n}\n\ntype UnownedMapEntry<V> = {\n value: V\n count: undefined\n accessedAt: number\n}\n\ntype MapEntry<V> = RefCountedMapEntry<V> | UnownedMapEntry<V>\n\nconst TTLCheck = {\n ON_GET: 1 << 0,\n ON_RETAIN: 1 << 1,\n ON_RELEASE: 1 << 2,\n} as const\n\n/**\n * Ref-counted map with explicit retention semantics. Entries are unowned by default and may be evicted after their\n * TTL unless explicitly retained. This provides TTL-based caching for unowned entries, while allowing consumers to\n * opt into stronger lifetime control via explicit retention.\n */\nexport class RefCountedMap<K, V> {\n private readonly map = new Map<K, MapEntry<V>>()\n private readonly unownedEntryTtlMs: number\n private readonly ttlCheck: number\n\n static readonly TTLCheck = TTLCheck\n\n constructor({\n unownedEntryTtlMs,\n ttlCheck = TTLCheck.ON_GET | TTLCheck.ON_RETAIN | TTLCheck.ON_RELEASE,\n }: {\n unownedEntryTtlMs: number\n ttlCheck?: number\n }) {\n this.unownedEntryTtlMs = unownedEntryTtlMs\n this.ttlCheck = ttlCheck\n }\n\n get size(): number {\n return this.map.size\n }\n\n get(key: K): V | undefined {\n return this.map.get(key)?.value\n }\n\n getOrCreate(key: K, init: () => V): V {\n try {\n const existing = this.map.get(key)\n\n if (existing) {\n if (isUnowned(existing)) existing.accessedAt = Date.now()\n return existing.value\n }\n\n const value = init()\n this.map.set(key, { value, count: undefined, accessedAt: Date.now() })\n return value\n } finally {\n if (this.ttlCheck & TTLCheck.ON_GET) this.removeExpired()\n }\n }\n\n retain(key: K, value: V): void {\n try {\n const existing = this.map.get(key)\n\n // `retain` might be called on a unowned entry that has already been evicted from the map due to TTL expiration\n // *and* possibly replaced by a new unowned entry with the same key; handle this gracefully\n if (existing != null) {\n if (existing.value !== value) return\n existing.count = (existing.count ?? 0) + 1\n } else {\n this.map.set(key, { value, count: 1 })\n }\n } finally {\n if (this.ttlCheck & TTLCheck.ON_RETAIN) this.removeExpired()\n }\n }\n\n release(key: K, value: V): void {\n try {\n const existing = this.map.get(key)\n\n // `release` might be called on an entry that remained unowned due being superseded by a new entry with the same\n // key after TTL expiration of the original entry; handle this gracefully\n if (existing == null) return\n if (isUnowned(existing)) return\n if (existing.value !== value) return\n\n if (existing.count > 1) {\n existing.count -= 1\n } else {\n this.map.delete(key)\n }\n } finally {\n if (this.ttlCheck & TTLCheck.ON_RELEASE) this.removeExpired()\n }\n }\n\n private removeExpired(): void {\n const now = Date.now()\n const isExpired = (entry: MapEntry<V>): boolean =>\n isUnowned(entry) && now - entry.accessedAt > this.unownedEntryTtlMs\n\n this.map.forEach((entry, key) => {\n if (isExpired(entry)) this.map.delete(key)\n })\n }\n}\n\nconst isUnowned = <V>(entry: MapEntry<V>): entry is UnownedMapEntry<V> => entry.count === undefined\n"],"mappings":"AAaA,MAAM,WAAW;AAAA,EACf,QAAQ,KAAK;AAAA,EACb,WAAW,KAAK;AAAA,EAChB,YAAY,KAAK;AACnB;AAOO,MAAM,cAAoB;AAAA,EACd,MAAM,oBAAI,IAAoB;AAAA,EAC9B;AAAA,EACA;AAAA,EAEjB,OAAgB,WAAW;AAAA,EAE3B,YAAY;AAAA,IACV;AAAA,IACA,WAAW,SAAS,SAAS,SAAS,YAAY,SAAS;AAAA,EAC7D,GAGG;AACD,SAAK,oBAAoB;AACzB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,KAAK,IAAI;AAAA,EAClB;AAAA,EAEA,IAAI,KAAuB;AACzB,WAAO,KAAK,IAAI,IAAI,GAAG,GAAG;AAAA,EAC5B;AAAA,EAEA,YAAY,KAAQ,MAAkB;AACpC,QAAI;AACF,YAAM,WAAW,KAAK,IAAI,IAAI,GAAG;AAEjC,UAAI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AAAG,aAAK,IAAI,OAAO,GAAG;AAAA,IAC3C,CAAC;AAAA,EACH;AACF;AAEA,MAAM,YAAY,CAAI,UAAoD,MAAM,UAAU;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/ref-counted-map.ts"],"sourcesContent":["type RefCountedMapEntry<V> = {\n value: V\n count: number\n}\n\ntype UnownedMapEntry<V> = {\n value: V\n count: undefined\n accessedAt: number\n}\n\ntype MapEntry<V> = RefCountedMapEntry<V> | UnownedMapEntry<V>\n\nconst TTLCheck = {\n ON_GET: 1 << 0,\n ON_RETAIN: 1 << 1,\n ON_RELEASE: 1 << 2,\n} as const\n\n/**\n * Ref-counted map with explicit retention semantics. Entries are unowned by default and may be evicted after their\n * TTL unless explicitly retained. This provides TTL-based caching for unowned entries, while allowing consumers to\n * opt into stronger lifetime control via explicit retention.\n */\nexport class RefCountedMap<K, V> {\n private readonly map = new Map<K, MapEntry<V>>()\n private readonly unownedEntryTtlMs: number\n private readonly ttlCheck: number\n\n static readonly TTLCheck = TTLCheck\n\n constructor({\n unownedEntryTtlMs,\n ttlCheck = TTLCheck.ON_GET | TTLCheck.ON_RETAIN | TTLCheck.ON_RELEASE,\n }: {\n unownedEntryTtlMs: number\n ttlCheck?: number\n }) {\n this.unownedEntryTtlMs = unownedEntryTtlMs\n this.ttlCheck = ttlCheck\n }\n\n get size(): number {\n return this.map.size\n }\n\n get(key: K): V | undefined {\n return this.map.get(key)?.value\n }\n\n getOrCreate(key: K, init: () => V): V {\n try {\n const existing = this.map.get(key)\n\n if (existing) {\n if (isUnowned(existing)) existing.accessedAt = Date.now()\n return existing.value\n }\n\n const value = init()\n this.map.set(key, { value, count: undefined, accessedAt: Date.now() })\n return value\n } finally {\n if (this.ttlCheck & TTLCheck.ON_GET) this.removeExpired()\n }\n }\n\n /**\n * Returns true on transition from unowned to owned\n */\n retain(key: K, value: V): boolean {\n try {\n const existing = this.map.get(key)\n\n if (existing == null) {\n this.map.set(key, { value, count: 1 })\n return true\n }\n\n // `retain` might be called on a unowned entry that has already been evicted from the map due to TTL expiration\n // *and* possibly replaced by a new unowned entry with the same key; handle this gracefully\n if (existing.value === value) {\n existing.count = (existing.count ?? 0) + 1\n return existing.count === 1\n }\n\n return false\n } finally {\n if (this.ttlCheck & TTLCheck.ON_RETAIN) this.removeExpired()\n }\n }\n\n /**\n * Returns true on transition from owned to unowned\n */\n release(key: K, value: V): boolean {\n try {\n const existing = this.map.get(key)\n\n // `release` might be called on an entry that remained unowned due being superseded by a new entry with the same\n // key after TTL expiration of the original entry; handle this gracefully\n if (existing == null) return false\n if (isUnowned(existing)) return false\n if (existing.value !== value) return false\n\n if (existing.count === 1) {\n this.map.delete(key)\n return true\n }\n\n existing.count -= 1\n return false\n } finally {\n if (this.ttlCheck & TTLCheck.ON_RELEASE) this.removeExpired()\n }\n }\n\n private removeExpired(): void {\n const now = Date.now()\n const isExpired = (entry: MapEntry<V>): boolean =>\n isUnowned(entry) && now - entry.accessedAt > this.unownedEntryTtlMs\n\n this.map.forEach((entry, key) => {\n if (isExpired(entry)) this.map.delete(key)\n })\n }\n}\n\nconst isUnowned = <V>(entry: MapEntry<V>): entry is UnownedMapEntry<V> => entry.count === undefined\n"],"mappings":"AAaA,MAAM,WAAW;AAAA,EACf,QAAQ,KAAK;AAAA,EACb,WAAW,KAAK;AAAA,EAChB,YAAY,KAAK;AACnB;AAOO,MAAM,cAAoB;AAAA,EACd,MAAM,oBAAI,IAAoB;AAAA,EAC9B;AAAA,EACA;AAAA,EAEjB,OAAgB,WAAW;AAAA,EAE3B,YAAY;AAAA,IACV;AAAA,IACA,WAAW,SAAS,SAAS,SAAS,YAAY,SAAS;AAAA,EAC7D,GAGG;AACD,SAAK,oBAAoB;AACzB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,KAAK,IAAI;AAAA,EAClB;AAAA,EAEA,IAAI,KAAuB;AACzB,WAAO,KAAK,IAAI,IAAI,GAAG,GAAG;AAAA,EAC5B;AAA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,EAEQ,gBAAsB;AAC5B,UAAM,MAAM,KAAK,IAAI;AACrB,UAAM,YAAY,CAAC,UACjB,UAAU,KAAK,KAAK,MAAM,MAAM,aAAa,KAAK;AAEpD,SAAK,IAAI,QAAQ,CAAC,OAAO,QAAQ;AAC/B,UAAI,UAAU,KAAK;AAAG,aAAK,IAAI,OAAO,GAAG;AAAA,IAC3C,CAAC;AAAA,EACH;AACF;AAEA,MAAM,YAAY,CAAI,UAAoD,MAAM,UAAU;","names":[]}
@@ -20,15 +20,15 @@ export declare const diffProjectionSchema: z.ZodObject<{
20
20
  pathname: z.ZodString;
21
21
  previousPathname: z.ZodOptional<z.ZodString>;
22
22
  }, "strip", z.ZodTypeAny, {
23
- pageId: string;
24
23
  pathname: string;
25
24
  locale: string | null;
25
+ pageId: string;
26
26
  changeType: "deleted" | "created" | "updated";
27
27
  previousPathname?: string | undefined;
28
28
  }, {
29
- pageId: string;
30
29
  pathname: string;
31
30
  locale: string | null;
31
+ pageId: string;
32
32
  changeType: "deleted" | "created" | "updated";
33
33
  previousPathname?: string | undefined;
34
34
  }>, "many">;
@@ -86,15 +86,15 @@ export declare const diffProjectionSchema: z.ZodObject<{
86
86
  pathname: z.ZodString;
87
87
  previousPathname: z.ZodOptional<z.ZodString>;
88
88
  }, "strip", z.ZodTypeAny, {
89
- pageId: string;
90
89
  pathname: string;
91
90
  locale: string | null;
91
+ pageId: string;
92
92
  changeType: "deleted" | "created" | "updated";
93
93
  previousPathname?: string | undefined;
94
94
  }, {
95
- pageId: string;
96
95
  pathname: string;
97
96
  locale: string | null;
97
+ pageId: string;
98
98
  changeType: "deleted" | "created" | "updated";
99
99
  previousPathname?: string | undefined;
100
100
  }>, "many">;
@@ -152,15 +152,15 @@ export declare const diffProjectionSchema: z.ZodObject<{
152
152
  pathname: z.ZodString;
153
153
  previousPathname: z.ZodOptional<z.ZodString>;
154
154
  }, "strip", z.ZodTypeAny, {
155
- pageId: string;
156
155
  pathname: string;
157
156
  locale: string | null;
157
+ pageId: string;
158
158
  changeType: "deleted" | "created" | "updated";
159
159
  previousPathname?: string | undefined;
160
160
  }, {
161
- pageId: string;
162
161
  pathname: string;
163
162
  locale: string | null;
163
+ pageId: string;
164
164
  changeType: "deleted" | "created" | "updated";
165
165
  previousPathname?: string | undefined;
166
166
  }>, "many">;
@@ -39,15 +39,15 @@ export declare const sitePublishedWebhookPayloadSchema: z.ZodObject<{
39
39
  pathname: z.ZodString;
40
40
  previousPathname: z.ZodOptional<z.ZodString>;
41
41
  }, "strip", z.ZodTypeAny, {
42
- pageId: string;
43
42
  pathname: string;
44
43
  locale: string | null;
44
+ pageId: string;
45
45
  changeType: "deleted" | "created" | "updated";
46
46
  previousPathname?: string | undefined;
47
47
  }, {
48
- pageId: string;
49
48
  pathname: string;
50
49
  locale: string | null;
50
+ pageId: string;
51
51
  changeType: "deleted" | "created" | "updated";
52
52
  previousPathname?: string | undefined;
53
53
  }>, "many">;
@@ -105,15 +105,15 @@ export declare const sitePublishedWebhookPayloadSchema: z.ZodObject<{
105
105
  pathname: z.ZodString;
106
106
  previousPathname: z.ZodOptional<z.ZodString>;
107
107
  }, "strip", z.ZodTypeAny, {
108
- pageId: string;
109
108
  pathname: string;
110
109
  locale: string | null;
110
+ pageId: string;
111
111
  changeType: "deleted" | "created" | "updated";
112
112
  previousPathname?: string | undefined;
113
113
  }, {
114
- pageId: string;
115
114
  pathname: string;
116
115
  locale: string | null;
116
+ pageId: string;
117
117
  changeType: "deleted" | "created" | "updated";
118
118
  previousPathname?: string | undefined;
119
119
  }>, "many">;
@@ -171,15 +171,15 @@ export declare const sitePublishedWebhookPayloadSchema: z.ZodObject<{
171
171
  pathname: z.ZodString;
172
172
  previousPathname: z.ZodOptional<z.ZodString>;
173
173
  }, "strip", z.ZodTypeAny, {
174
- pageId: string;
175
174
  pathname: string;
176
175
  locale: string | null;
176
+ pageId: string;
177
177
  changeType: "deleted" | "created" | "updated";
178
178
  previousPathname?: string | undefined;
179
179
  }, {
180
- pageId: string;
181
180
  pathname: string;
182
181
  locale: string | null;
182
+ pageId: string;
183
183
  changeType: "deleted" | "created" | "updated";
184
184
  previousPathname?: string | undefined;
185
185
  }>, "many">;
@@ -246,15 +246,15 @@ export declare const sitePublishedWebhookPayloadSchema: z.ZodObject<{
246
246
  pathname: z.ZodString;
247
247
  previousPathname: z.ZodOptional<z.ZodString>;
248
248
  }, "strip", z.ZodTypeAny, {
249
- pageId: string;
250
249
  pathname: string;
251
250
  locale: string | null;
251
+ pageId: string;
252
252
  changeType: "deleted" | "created" | "updated";
253
253
  previousPathname?: string | undefined;
254
254
  }, {
255
- pageId: string;
256
255
  pathname: string;
257
256
  locale: string | null;
257
+ pageId: string;
258
258
  changeType: "deleted" | "created" | "updated";
259
259
  previousPathname?: string | undefined;
260
260
  }>, "many">;
@@ -332,15 +332,15 @@ export declare const sitePublishedWebhookPayloadSchema: z.ZodObject<{
332
332
  pathname: z.ZodString;
333
333
  previousPathname: z.ZodOptional<z.ZodString>;
334
334
  }, "strip", z.ZodTypeAny, {
335
- pageId: string;
336
335
  pathname: string;
337
336
  locale: string | null;
337
+ pageId: string;
338
338
  changeType: "deleted" | "created" | "updated";
339
339
  previousPathname?: string | undefined;
340
340
  }, {
341
- pageId: string;
342
341
  pathname: string;
343
342
  locale: string | null;
343
+ pageId: string;
344
344
  changeType: "deleted" | "created" | "updated";
345
345
  previousPathname?: string | undefined;
346
346
  }>, "many">;
@@ -432,15 +432,15 @@ declare const webhookPayloadSchema: z.ZodObject<{
432
432
  pathname: z.ZodString;
433
433
  previousPathname: z.ZodOptional<z.ZodString>;
434
434
  }, "strip", z.ZodTypeAny, {
435
- pageId: string;
436
435
  pathname: string;
437
436
  locale: string | null;
437
+ pageId: string;
438
438
  changeType: "deleted" | "created" | "updated";
439
439
  previousPathname?: string | undefined;
440
440
  }, {
441
- pageId: string;
442
441
  pathname: string;
443
442
  locale: string | null;
443
+ pageId: string;
444
444
  changeType: "deleted" | "created" | "updated";
445
445
  previousPathname?: string | undefined;
446
446
  }>, "many">;
@@ -498,15 +498,15 @@ declare const webhookPayloadSchema: z.ZodObject<{
498
498
  pathname: z.ZodString;
499
499
  previousPathname: z.ZodOptional<z.ZodString>;
500
500
  }, "strip", z.ZodTypeAny, {
501
- pageId: string;
502
501
  pathname: string;
503
502
  locale: string | null;
503
+ pageId: string;
504
504
  changeType: "deleted" | "created" | "updated";
505
505
  previousPathname?: string | undefined;
506
506
  }, {
507
- pageId: string;
508
507
  pathname: string;
509
508
  locale: string | null;
509
+ pageId: string;
510
510
  changeType: "deleted" | "created" | "updated";
511
511
  previousPathname?: string | undefined;
512
512
  }>, "many">;
@@ -564,15 +564,15 @@ declare const webhookPayloadSchema: z.ZodObject<{
564
564
  pathname: z.ZodString;
565
565
  previousPathname: z.ZodOptional<z.ZodString>;
566
566
  }, "strip", z.ZodTypeAny, {
567
- pageId: string;
568
567
  pathname: string;
569
568
  locale: string | null;
569
+ pageId: string;
570
570
  changeType: "deleted" | "created" | "updated";
571
571
  previousPathname?: string | undefined;
572
572
  }, {
573
- pageId: string;
574
573
  pathname: string;
575
574
  locale: string | null;
575
+ pageId: string;
576
576
  changeType: "deleted" | "created" | "updated";
577
577
  previousPathname?: string | undefined;
578
578
  }>, "many">;
@@ -639,15 +639,15 @@ declare const webhookPayloadSchema: z.ZodObject<{
639
639
  pathname: z.ZodString;
640
640
  previousPathname: z.ZodOptional<z.ZodString>;
641
641
  }, "strip", z.ZodTypeAny, {
642
- pageId: string;
643
642
  pathname: string;
644
643
  locale: string | null;
644
+ pageId: string;
645
645
  changeType: "deleted" | "created" | "updated";
646
646
  previousPathname?: string | undefined;
647
647
  }, {
648
- pageId: string;
649
648
  pathname: string;
650
649
  locale: string | null;
650
+ pageId: string;
651
651
  changeType: "deleted" | "created" | "updated";
652
652
  previousPathname?: string | undefined;
653
653
  }>, "many">;
@@ -725,15 +725,15 @@ declare const webhookPayloadSchema: z.ZodObject<{
725
725
  pathname: z.ZodString;
726
726
  previousPathname: z.ZodOptional<z.ZodString>;
727
727
  }, "strip", z.ZodTypeAny, {
728
- pageId: string;
729
728
  pathname: string;
730
729
  locale: string | null;
730
+ pageId: string;
731
731
  changeType: "deleted" | "created" | "updated";
732
732
  previousPathname?: string | undefined;
733
733
  }, {
734
- pageId: string;
735
734
  pathname: string;
736
735
  locale: string | null;
736
+ pageId: string;
737
737
  changeType: "deleted" | "created" | "updated";
738
738
  previousPathname?: string | undefined;
739
739
  }>, "many">;
@@ -0,0 +1,3 @@
1
+ /** @jest-environment jsdom */
2
+ export {};
3
+ //# sourceMappingURL=useMediaQuery.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMediaQuery.test.d.ts","sourceRoot":"","sources":["../../../../../src/components/hooks/__tests__/useMediaQuery.test.tsx"],"names":[],"mappings":"AAAA,8BAA8B"}
@@ -1 +1 @@
1
- {"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../../src/components/hooks/useMediaQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,cAAc,EAIpB,MAAM,qBAAqB,CAAA;AAU5B,wBAAgB,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CA+B1F"}
1
+ {"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../../src/components/hooks/useMediaQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,qBAAqB,CAAA;AAKjF,wBAAgB,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAO1F"}
@@ -1,3 +1,3 @@
1
- import { Breakpoints } from '../../../state/modules/breakpoints';
1
+ import { type Breakpoints } from '../../../state/modules/breakpoints';
2
2
  export declare function useBreakpoints(): Breakpoints;
3
3
  //# sourceMappingURL=use-breakpoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-breakpoints.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAIhE,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
1
+ {"version":3,"file":"use-breakpoints.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAKrE,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
@@ -0,0 +1,3 @@
1
+ import { type BreakpointId } from '../../../state/modules/breakpoints';
2
+ export declare function useCurrentBreakpoint(): BreakpointId;
3
+ //# sourceMappingURL=use-current-breakpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-current-breakpoint.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-current-breakpoint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAKtE,wBAAgB,oBAAoB,IAAI,YAAY,CAQnD"}