solid-intlayer 9.8.1 → 9.8.2

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 (122) hide show
  1. package/dist/cjs/LoadingBoundary.cjs +1 -0
  2. package/dist/cjs/analytics/useAnalytics.cjs +1 -1
  3. package/dist/cjs/analytics/useExperiment.cjs +1 -1
  4. package/dist/cjs/client/IntlayerProvider.cjs +1 -1
  5. package/dist/cjs/client/getBrowserLocale.cjs +1 -1
  6. package/dist/cjs/client/t.cjs +1 -1
  7. package/dist/cjs/client/useDictionary.cjs +1 -1
  8. package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
  9. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
  10. package/dist/cjs/client/useLoadDynamic.cjs +1 -1
  11. package/dist/cjs/client/useLocale.cjs +1 -1
  12. package/dist/cjs/client/useLocaleStorage.cjs +1 -1
  13. package/dist/cjs/client/usePathname.cjs +1 -1
  14. package/dist/cjs/client/useRewriteURL.cjs +1 -1
  15. package/dist/cjs/client/useTraduction.cjs +1 -1
  16. package/dist/cjs/editor/useEditor.cjs +1 -1
  17. package/dist/cjs/getDictionary.cjs +1 -1
  18. package/dist/cjs/html/HTMLProvider.cjs +1 -1
  19. package/dist/cjs/html/HTMLRenderer.cjs +1 -1
  20. package/dist/cjs/markdown/MarkdownProvider.cjs +1 -1
  21. package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -1
  22. package/dist/cjs/markdown/runtime.cjs +1 -1
  23. package/dist/cjs/plugins.cjs +1 -1
  24. package/dist/cjs/server/useDictionary.cjs +1 -1
  25. package/dist/cjs/solidCompat.cjs +1 -0
  26. package/dist/cjs/solidElement/renderSolidElement.cjs +1 -1
  27. package/dist/esm/LoadingBoundary.mjs +12 -0
  28. package/dist/esm/analytics/useAnalytics.mjs +14 -11
  29. package/dist/esm/analytics/useExperiment.mjs +5 -4
  30. package/dist/esm/client/IntlayerProvider.mjs +28 -28
  31. package/dist/esm/client/getBrowserLocale.mjs +21 -21
  32. package/dist/esm/client/t.mjs +4 -4
  33. package/dist/esm/client/useDictionary.mjs +22 -14
  34. package/dist/esm/client/useDictionaryAsync.mjs +3 -3
  35. package/dist/esm/client/useDictionaryDynamic.mjs +26 -23
  36. package/dist/esm/client/useLoadDynamic.mjs +4 -5
  37. package/dist/esm/client/useLocale.mjs +15 -14
  38. package/dist/esm/client/useLocaleStorage.mjs +7 -7
  39. package/dist/esm/client/usePathname.mjs +9 -8
  40. package/dist/esm/client/useRewriteURL.mjs +6 -6
  41. package/dist/esm/client/useTraduction.mjs +5 -5
  42. package/dist/esm/editor/useEditor.mjs +11 -11
  43. package/dist/esm/getDictionary.mjs +3 -3
  44. package/dist/esm/html/HTMLProvider.mjs +5 -4
  45. package/dist/esm/html/HTMLRenderer.mjs +6 -6
  46. package/dist/esm/markdown/MarkdownProvider.mjs +20 -19
  47. package/dist/esm/markdown/MarkdownRenderer.mjs +27 -25
  48. package/dist/esm/markdown/runtime.mjs +8 -13
  49. package/dist/esm/plugins.mjs +76 -75
  50. package/dist/esm/server/useDictionary.mjs +9 -6
  51. package/dist/esm/solidCompat.mjs +48 -0
  52. package/dist/esm/solidElement/renderSolidElement.mjs +14 -16
  53. package/dist/rolldown-runtime-BocRIvOZ.js +1 -0
  54. package/dist/solid/IntlayerNode.jsx +10 -0
  55. package/dist/solid/LoadingBoundary.jsx +10 -0
  56. package/dist/solid/analytics/AnalyticsProvider.jsx +11 -0
  57. package/dist/solid/analytics/exposureSink.js +21 -0
  58. package/dist/solid/analytics/index.js +5 -0
  59. package/dist/solid/analytics/useAnalytics.jsx +58 -0
  60. package/dist/solid/analytics/useConversion.js +24 -0
  61. package/dist/solid/analytics/useExperiment.js +58 -0
  62. package/dist/solid/client/IntlayerProvider.jsx +81 -0
  63. package/dist/solid/client/getBrowserLocale.jsx +113 -0
  64. package/dist/solid/client/index.js +14 -0
  65. package/dist/solid/client/t.js +15 -0
  66. package/dist/solid/client/useContent.js +15 -0
  67. package/dist/solid/client/useDictionary.js +56 -0
  68. package/dist/solid/client/useDictionaryAsync.js +17 -0
  69. package/dist/solid/client/useDictionaryDynamic.js +105 -0
  70. package/dist/solid/client/useIntlayer.js +55 -0
  71. package/dist/solid/client/useLoadDynamic.js +134 -0
  72. package/dist/solid/client/useLocale.js +51 -0
  73. package/dist/solid/client/useLocaleBase.js +18 -0
  74. package/dist/solid/client/useLocaleStorage.js +52 -0
  75. package/dist/solid/client/usePathname.js +40 -0
  76. package/dist/solid/client/useRewriteURL.js +20 -0
  77. package/dist/solid/client/useTraduction.js +31 -0
  78. package/dist/solid/editor/ContentSelector.jsx +9 -0
  79. package/dist/solid/editor/EditorProvider.jsx +7 -0
  80. package/dist/solid/editor/useEditor.jsx +37 -0
  81. package/dist/solid/esm-BS5TZIsL.js +644 -0
  82. package/dist/solid/format/index.js +10 -0
  83. package/dist/solid/format/useCompact.js +14 -0
  84. package/dist/solid/format/useCurrency.js +15 -0
  85. package/dist/solid/format/useDate.js +24 -0
  86. package/dist/solid/format/useIntl.js +30 -0
  87. package/dist/solid/format/useList.js +14 -0
  88. package/dist/solid/format/useNumber.js +18 -0
  89. package/dist/solid/format/usePercentage.js +15 -0
  90. package/dist/solid/format/useRelativeTime.js +15 -0
  91. package/dist/solid/format/useUnit.js +14 -0
  92. package/dist/solid/getDictionary.js +16 -0
  93. package/dist/solid/getIntlayer.js +13 -0
  94. package/dist/solid/html/HTMLProvider.jsx +16 -0
  95. package/dist/solid/html/HTMLRenderer.jsx +45 -0
  96. package/dist/solid/html/index.js +3 -0
  97. package/dist/solid/html/types.js +0 -0
  98. package/dist/solid/index.js +21 -0
  99. package/dist/solid/isEnabled-C5NUhdhZ.js +100 -0
  100. package/dist/solid/markdown/MarkdownProvider.jsx +38 -0
  101. package/dist/solid/markdown/MarkdownRenderer.jsx +47 -0
  102. package/dist/solid/markdown/compiler.jsx +62 -0
  103. package/dist/solid/markdown/index.js +4 -0
  104. package/dist/solid/markdown/runtime.jsx +42 -0
  105. package/dist/solid/plugins.jsx +230 -0
  106. package/dist/solid/proxyKeys.js +13 -0
  107. package/dist/solid/server/index.js +1 -0
  108. package/dist/solid/server/useDictionary.js +29 -0
  109. package/dist/solid/solidCompat.js +155 -0
  110. package/dist/solid/solidElement/renderSolidElement.jsx +32 -0
  111. package/dist/types/LoadingBoundary.d.ts +12 -0
  112. package/dist/types/client/useDictionaryDynamic.d.ts +1 -1
  113. package/dist/types/client/useLoadDynamic.d.ts +4 -4
  114. package/dist/types/client/useLocaleStorage.d.ts +2 -2
  115. package/dist/types/format/useIntl.d.ts +1 -1
  116. package/dist/types/getDictionary.d.ts +5 -1
  117. package/dist/types/html/HTMLProvider.d.ts +1 -1
  118. package/dist/types/markdown/MarkdownProvider.d.ts +5 -1
  119. package/dist/types/server/useDictionary.d.ts +6 -6
  120. package/dist/types/solidCompat.d.ts +92 -0
  121. package/dist/types/solidElement/renderSolidElement.d.ts +1 -1
  122. package/package.json +25 -18
@@ -1,14 +1,15 @@
1
1
  import { reportExposure as e } from "./analytics/exposureSink.mjs";
2
2
  import { renderIntlayerNode as t } from "./IntlayerNode.mjs";
3
- import { renderSolidElement as n } from "./solidElement/renderSolidElement.mjs";
4
- import { editor as r, internationalization as i } from "@intlayer/config/built";
5
- import { Suspense as a, lazy as o } from "solid-js";
6
- import { createComponent as s, mergeProps as c } from "solid-js/web";
7
- import { bindInsertedValues as l, conditionPlugin as u, enumerationPlugin as d, fallbackPlugin as f, filePlugin as p, genderPlugin as m, isInterpolableWrapperNode as h, nestedPlugin as g, pluralPlugin as _, resolveInterpreterLocale as v, selectPlugin as y, splitInsertionTemplate as b, transformInterpolableNode as x, translationPlugin as S } from "@intlayer/core/interpreter";
3
+ import { LoadingBoundary as n } from "./LoadingBoundary.mjs";
4
+ import { lazyComponent as r } from "./solidCompat.mjs";
5
+ import { renderSolidElement as i } from "./solidElement/renderSolidElement.mjs";
6
+ import { bindInsertedValues as a, conditionPlugin as o, enumerationPlugin as s, fallbackPlugin as c, filePlugin as l, genderPlugin as u, isInterpolableWrapperNode as d, nestedPlugin as f, pluralPlugin as p, resolveInterpreterLocale as m, selectPlugin as h, splitInsertionTemplate as g, transformInterpolableNode as _, translationPlugin as v } from "@intlayer/core/interpreter";
7
+ import { createComponent as y, mergeProps as b } from "solid-js/web";
8
+ import { editor as x, internationalization as S } from "@intlayer/config/built";
8
9
  import { getMarkdownMetadata as C } from "@intlayer/core/markdown";
9
10
  import * as w from "@intlayer/types/nodeType";
10
11
  // src/plugins.tsx
11
- var T = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : o(() => import("./editor/ContentSelector.mjs").then((e) => ({ default: e.ContentSelector }))), E = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? null : import("./markdown/MarkdownRenderer.mjs").then((e) => ({
12
+ var T = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : r(() => import("./editor/ContentSelector.mjs").then((e) => ({ default: e.ContentSelector }))), E = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? null : import("./markdown/MarkdownRenderer.mjs").then((e) => ({
12
13
  MarkdownRenderer: e.MarkdownRenderer,
13
14
  MarkdownMetadataRenderer: e.MarkdownMetadataRenderer
14
15
  })), D = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? null : import("./html/HTMLRenderer.mjs").then((e) => e.HTMLRenderer);
@@ -16,23 +17,23 @@ E?.catch(() => {}), D?.catch(() => {});
16
17
  var O = {
17
18
  id: "intlayer-node-plugin",
18
19
  canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
19
- transform: (n, i) => {
20
+ transform: (r, i) => {
20
21
  if (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
21
22
  dictionaryKey: i.dictionaryKey,
22
23
  keyPath: i.keyPath,
23
24
  locale: i.locale,
24
25
  nodeType: "text"
25
- }), process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled) {
26
- let { plugins: e, ...n } = i;
26
+ }), process.env.INTLAYER_EDITOR_ENABLED !== "false" && x.enabled) {
27
+ let { plugins: e, ...r } = i;
27
28
  return t({
28
- value: n.children,
29
- children: s(a, {
29
+ value: r.children,
30
+ children: y(n, {
30
31
  get fallback() {
31
- return n.children;
32
+ return r.children;
32
33
  },
33
34
  get children() {
34
- return s(T, c(n, { get children() {
35
- return n.children;
35
+ return y(T, b(r, { get children() {
36
+ return r.children;
36
37
  } }));
37
38
  }
38
39
  })
@@ -43,46 +44,46 @@ var O = {
43
44
  children: i.children
44
45
  });
45
46
  }
46
- }, k = process.env.INTLAYER_NODE_TYPE_SOLID_NODE === "false" ? f : {
47
+ }, k = process.env.INTLAYER_NODE_TYPE_SOLID_NODE === "false" ? c : {
47
48
  id: "solid-node-plugin",
48
49
  canHandle: (e) => typeof e == "object" && e?.props !== void 0 || typeof Node < "u" && e instanceof Node,
49
- transform: (i, { plugins: o, ...l }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
50
- dictionaryKey: l.dictionaryKey,
51
- keyPath: l.keyPath,
52
- locale: l.locale,
50
+ transform: (r, { plugins: a, ...o }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
51
+ dictionaryKey: o.dictionaryKey,
52
+ keyPath: o.keyPath,
53
+ locale: o.locale,
53
54
  nodeType: "solid-node"
54
55
  }), t({
55
- ...l,
56
+ ...o,
56
57
  value: "[[solid-element]]",
57
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled ? s(a, {
58
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && x.enabled ? y(n, {
58
59
  get fallback() {
59
- return typeof Node < "u" && i instanceof Node ? i : n(i);
60
+ return typeof Node < "u" && r instanceof Node ? r : i(r);
60
61
  },
61
62
  get children() {
62
- return s(T, c(l, { get children() {
63
- return typeof Node < "u" && i instanceof Node ? i : n(i);
63
+ return y(T, b(o, { get children() {
64
+ return typeof Node < "u" && r instanceof Node ? r : i(r);
64
65
  } }));
65
66
  }
66
- }) : typeof Node < "u" && i instanceof Node ? i : n(i)
67
+ }) : typeof Node < "u" && r instanceof Node ? r : i(r)
67
68
  }))
68
69
  }, A = (e, t) => {
69
- let n = b(e, t);
70
+ let n = g(e, t);
70
71
  return n.isSimple, n.parts;
71
- }, j = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? f : {
72
+ }, j = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? c : {
72
73
  id: "insertion-plugin",
73
74
  canHandle: (e) => typeof e == "object" && e?.nodeType === w.INSERTION,
74
75
  transform: (e, t, n) => {
75
76
  let r = [...t.keyPath, { type: w.INSERTION }], i = e[w.INSERTION];
76
77
  return (e) => {
77
- let a = {
78
+ let o = {
78
79
  id: "insertion-string-plugin",
79
- canHandle: (e) => typeof e == "string" || h(e),
80
+ canHandle: (e) => typeof e == "string" || d(e),
80
81
  transform: (n, r, i) => {
81
- if (h(n)) return x(n, e, r, t.plugins, i);
82
+ if (d(n)) return _(n, e, r, t.plugins, i);
82
83
  let a = A(i(n, {
83
84
  ...r,
84
85
  children: n,
85
- plugins: [...(t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")]
86
+ plugins: (t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")
86
87
  }), e);
87
88
  return i(a, {
88
89
  ...r,
@@ -90,36 +91,36 @@ var O = {
90
91
  children: a
91
92
  });
92
93
  }
93
- }, o = n(i, {
94
+ }, s = n(i, {
94
95
  ...t,
95
96
  children: i,
96
97
  keyPath: r,
97
- plugins: [a, ...t.plugins ?? []]
98
+ plugins: [o, ...t.plugins ?? []]
98
99
  });
99
- return l(i, o, e, !0);
100
+ return a(i, s, e, !0);
100
101
  };
101
102
  }
102
- }, M = o(() => E.then((e) => ({ default: e.MarkdownRenderer }))), N = o(() => E.then((e) => ({ default: e.MarkdownMetadataRenderer }))), P = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? f : {
103
+ }, M = r(() => E.then((e) => ({ default: e.MarkdownRenderer }))), N = r(() => E.then((e) => ({ default: e.MarkdownMetadataRenderer }))), P = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? c : {
103
104
  id: "markdown-string-plugin",
104
105
  canHandle: (e) => typeof e == "string",
105
- transform: (e, n, i) => {
106
- let { plugins: o, ...l } = n, u = i(C(e) ?? {}, {
106
+ transform: (e, r, i) => {
107
+ let { plugins: a, ...o } = r, s = i(C(e) ?? {}, {
107
108
  plugins: [{
108
109
  id: "markdown-metadata-plugin",
109
110
  canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
110
- transform: (n, i) => t({
111
+ transform: (r, i) => t({
111
112
  ...i,
112
- value: n,
113
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled ? s(a, { get children() {
114
- return s(T, c(l, { get children() {
115
- return s(N, c(l, {
113
+ value: r,
114
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && x.enabled ? y(n, { get children() {
115
+ return y(T, b(o, { get children() {
116
+ return y(N, b(o, {
116
117
  get metadataKeyPath() {
117
118
  return i.keyPath;
118
119
  },
119
120
  children: e
120
121
  }));
121
122
  } }));
122
- } }) : s(N, c(l, {
123
+ } }) : y(N, b(o, {
123
124
  get metadataKeyPath() {
124
125
  return i.keyPath;
125
126
  },
@@ -127,30 +128,30 @@ var O = {
127
128
  }))
128
129
  })
129
130
  }],
130
- dictionaryKey: l.dictionaryKey,
131
+ dictionaryKey: o.dictionaryKey,
131
132
  keyPath: []
132
- }), d = (i) => t({
133
- ...n,
133
+ }), c = (i) => t({
134
+ ...r,
134
135
  value: e,
135
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled ? s(a, { get children() {
136
- return s(T, c(l, { get children() {
137
- return s(M, c(l, {
136
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && x.enabled ? y(n, { get children() {
137
+ return y(T, b(o, { get children() {
138
+ return y(M, b(o, {
138
139
  components: i,
139
140
  children: e
140
141
  }));
141
142
  } }));
142
- } }) : s(M, c(l, {
143
+ } }) : y(M, b(o, {
143
144
  components: i,
144
145
  children: e
145
146
  })),
146
147
  additionalProps: {
147
- metadata: u,
148
- use: d
148
+ metadata: s,
149
+ use: c
149
150
  }
150
151
  });
151
- return d();
152
+ return c();
152
153
  }
153
- }, F = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? f : {
154
+ }, F = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? c : {
154
155
  id: "markdown-plugin",
155
156
  canHandle: (e) => typeof e == "object" && e?.nodeType === w.MARKDOWN,
156
157
  transform: (e, t, n) => {
@@ -162,46 +163,46 @@ var O = {
162
163
  plugins: [P, ...t.plugins ?? []]
163
164
  });
164
165
  }
165
- }, I = o(() => D.then((e) => ({ default: e }))), L = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? f : {
166
+ }, I = r(() => D.then((e) => ({ default: e }))), L = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? c : {
166
167
  id: "html-plugin",
167
168
  canHandle: (e) => typeof e == "object" && e?.nodeType === w.HTML,
168
- transform: (e, n) => {
169
- let i = e[w.HTML], { plugins: o, children: l, ...u } = n, d = (e) => t({
170
- ...u,
169
+ transform: (e, r) => {
170
+ let i = e[w.HTML], { plugins: a, children: o, ...s } = r, c = (e) => t({
171
+ ...s,
171
172
  value: i,
172
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled ? s(a, { get children() {
173
- return s(T, c(u, { get children() {
174
- return s(I, c(u, {
173
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && x.enabled ? y(n, { get children() {
174
+ return y(T, b(s, { get children() {
175
+ return y(I, b(s, {
175
176
  html: i,
176
177
  components: e
177
178
  }));
178
179
  } }));
179
- } }) : s(I, c(u, {
180
+ } }) : y(I, b(s, {
180
181
  html: i,
181
182
  components: e
182
183
  })),
183
- additionalProps: { use: d }
184
+ additionalProps: { use: c }
184
185
  });
185
- return d();
186
+ return c();
186
187
  }
187
188
  }, R = /* @__PURE__ */ new Map(), z = (e, t = !0) => {
188
- let n = v(e), r = `${n}_${t}`;
189
+ let n = m(e), r = `${n}_${t}`;
189
190
  if (R.has(r)) return R.get(r);
190
- let a = [
191
+ let i = [
191
192
  O,
192
- S(n, t ? i.defaultLocale : void 0),
193
- d,
194
- _(n),
193
+ v(n, t ? S.defaultLocale : void 0),
194
+ s,
195
+ p(n),
196
+ o,
197
+ f(n),
198
+ l,
195
199
  u,
196
- g(n),
197
- p,
198
- m,
199
- y,
200
+ h,
200
201
  k,
201
202
  j,
202
203
  F,
203
204
  L
204
- ].filter((e) => e !== f);
205
- return R.set(r, a), a;
205
+ ].filter((e) => e !== c);
206
+ return R.set(r, i), i;
206
207
  };
207
208
  export { z as getPlugins, L as htmlPlugin, j as insertionPlugin, O as intlayerNodePlugins, F as markdownPlugin, P as markdownStringPlugin, k as solidNodePlugins };
@@ -1,8 +1,11 @@
1
1
  import { useDictionary as e } from "../client/useDictionary.mjs";
2
- import { createResource as t } from "solid-js";
2
+ import { createAsyncValue as t, trackAsyncValue as n } from "../solidCompat.mjs";
3
3
  // src/server/useDictionary.ts
4
- var n = (n, r) => (t(() => n, {
5
- initialValue: n,
6
- ssrLoadFrom: "initial"
7
- }), e(n, r));
8
- export { n as useDictionary };
4
+ var r = (r, i) => {
5
+ let a = t(() => r, (e) => e, {
6
+ initialValue: r,
7
+ ssrLoadFrom: "initial"
8
+ });
9
+ return n(a), e(r, i);
10
+ };
11
+ export { r as useDictionary };
@@ -0,0 +1,48 @@
1
+ import * as e from "solid-js";
2
+ // src/solidCompat.ts
3
+ var t = typeof e.createResource != "function", n = (n, r) => {
4
+ if (t) {
5
+ e.createEffect(n, r);
6
+ return;
7
+ }
8
+ let i;
9
+ e.createEffect(() => {
10
+ let t = n(), a = e.untrack(() => r(t, i));
11
+ i = t, typeof a == "function" && e.onCleanup(a);
12
+ });
13
+ }, r = (e) => n(() => void 0, () => e()), i = (e, t) => {
14
+ let r = !0;
15
+ n(e, (e, n) => {
16
+ if (r) r = !1;
17
+ else return t(e, n);
18
+ });
19
+ }, a = (n) => {
20
+ if (t) return e.createSignal(n);
21
+ let r = 0, i, [a, o] = e.createSignal(void 0), s = e.createMemo(() => ({
22
+ value: n(i),
23
+ order: r += 1
24
+ }));
25
+ return [e.createMemo(() => {
26
+ let e = s(), t = a();
27
+ return i = t && t.order > e.order ? t.value : e.value, i;
28
+ }), (e) => {
29
+ o({
30
+ value: e,
31
+ order: r += 1
32
+ });
33
+ }];
34
+ }, o = (n) => {
35
+ t ? n() : e.startTransition(n);
36
+ }, s = (n, r, i = {}) => {
37
+ if (t) return e.createMemo(() => {
38
+ let e = n();
39
+ return e === !1 || e == null ? i.initialValue : r(e);
40
+ });
41
+ let [a] = e.createResource(n, (e) => r(e), i);
42
+ return a;
43
+ }, c = (n) => {
44
+ t || e.createRenderEffect(() => {
45
+ n();
46
+ });
47
+ }, l = (t) => e.lazy(t), u = (e) => e.Provider ?? e;
48
+ export { s as createAsyncValue, i as createChangeEffect, n as createWatchEffect, a as createWritableMemo, u as getContextProvider, t as isSolidTwo, l as lazyComponent, r as onMounted, o as runInTransition, c as trackAsyncValue };
@@ -1,17 +1,17 @@
1
- import { Dynamic as e } from "solid-js/web";
2
- // src/solidElement/renderSolidElement.ts
3
- var t = (n) => {
4
- if (typeof n == "string") return n;
5
- let { type: r, props: i } = ((e) => {
1
+ import { Dynamic as e, createComponent as t, mergeProps as n } from "solid-js/web";
2
+ // src/solidElement/renderSolidElement.tsx
3
+ var r = (i) => {
4
+ if (typeof i == "string") return i;
5
+ let { type: a, props: o } = ((e) => {
6
6
  if (e?.props && typeof e.props.children == "object") {
7
- let n = [], { children: r } = e.props;
8
- return Object.keys(r ?? {}).forEach((e) => {
9
- n.push(t(r?.[e]));
7
+ let t = [], { children: n } = e.props;
8
+ return Object.keys(n ?? {}).forEach((e) => {
9
+ t.push(r(n?.[e]));
10
10
  }), {
11
11
  ...e,
12
12
  props: {
13
13
  ...e.props,
14
- children: n
14
+ children: t
15
15
  }
16
16
  };
17
17
  }
@@ -22,11 +22,9 @@ var t = (n) => {
22
22
  children: e.props?.children ?? []
23
23
  }
24
24
  };
25
- })(n);
26
- return e({
27
- component: r ?? "span",
28
- ...i,
29
- children: i.children
30
- });
25
+ })(i);
26
+ return t(e, n({ component: a ?? "span" }, o, { get children() {
27
+ return o.children;
28
+ } }));
31
29
  };
32
- export { t as renderSolidElement };
30
+ export { r as renderSolidElement };
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
@@ -0,0 +1,10 @@
1
+ import { getIntlayerNodePrototype } from "@intlayer/core/utils";
2
+ // src/IntlayerNode.tsx
3
+ var renderIntlayerNode = ({ children, value, additionalProps }) => {
4
+ const target = [children];
5
+ target.value = value;
6
+ if (additionalProps) for (const key in additionalProps) target[key] = additionalProps[key];
7
+ Object.setPrototypeOf(target, getIntlayerNodePrototype(value, Array.prototype));
8
+ return target;
9
+ };
10
+ export { renderIntlayerNode };
@@ -0,0 +1,10 @@
1
+ import { isSolidTwo } from "./solidCompat.js";
2
+ // src/LoadingBoundary.tsx
3
+ /**
4
+ * Shows `fallback` while async reads below it are pending: `Suspense` in
5
+ * Solid 1, `Loading` in Solid 2. Both are compiler built-ins, auto-imported
6
+ * from the app's own web runtime; only the branch of the installed version is
7
+ * ever evaluated.
8
+ */
9
+ var LoadingBoundary = (props) => isSolidTwo ? <Loading fallback={props.fallback}>{props.children}</Loading> : <Suspense fallback={props.fallback}>{props.children}</Suspense>;
10
+ export { LoadingBoundary };
@@ -0,0 +1,11 @@
1
+ import { useAnalytics } from "./useAnalytics.jsx";
2
+ // src/analytics/AnalyticsProvider.tsx
3
+ /**
4
+ * Runs {@link useAnalytics} and renders its children unchanged. Mounted inside
5
+ * {@link IntlayerProvider} alongside `EditorProvider`.
6
+ */
7
+ var AnalyticsProvider = ({ children }) => {
8
+ useAnalytics();
9
+ return children;
10
+ };
11
+ export { AnalyticsProvider };
@@ -0,0 +1,21 @@
1
+ // src/analytics/exposureSink.ts
2
+ var sink = null;
3
+ /**
4
+ * Installs (or clears) the exposure sink. `useAnalytics` sets this once the
5
+ * analytics client has loaded, and clears it on unmount.
6
+ *
7
+ * @param next - The sink to install, or `null` to clear.
8
+ */
9
+ var setExposureSink = (next) => {
10
+ sink = next;
11
+ };
12
+ /**
13
+ * Forwards a content exposure to the installed sink. A cheap null-check when
14
+ * analytics is not running, so it is safe to call from every node resolution.
15
+ *
16
+ * @param input - The node metadata to report.
17
+ */
18
+ var reportExposure = (input) => {
19
+ sink?.(input);
20
+ };
21
+ export { reportExposure, setExposureSink };
@@ -0,0 +1,5 @@
1
+ import { AnalyticsProvider } from "./AnalyticsProvider.jsx";
2
+ import { useAnalytics } from "./useAnalytics.jsx";
3
+ import { useConversion } from "./useConversion.js";
4
+ import { useExperiment } from "./useExperiment.js";
5
+ export { AnalyticsProvider, useAnalytics, useConversion, useExperiment };
@@ -0,0 +1,58 @@
1
+ import { t as isEnabled } from "../isEnabled-C5NUhdhZ.js";
2
+ import { useIntlayerContext } from "../client/IntlayerProvider.jsx";
3
+ import { createWatchEffect, onMounted } from "../solidCompat.js";
4
+ import { setExposureSink } from "./exposureSink.js";
5
+ import { createSignal, onCleanup } from "solid-js";
6
+ // src/analytics/useAnalytics.tsx
7
+ /**
8
+ * Initializes the Intlayer analytics client singleton when analytics is enabled
9
+ * and keeps it aware of the current locale.
10
+ *
11
+ * Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it
12
+ * ships as its own async chunk, off the critical rendering path. Apps that
13
+ * don't opt in (`analytics.enabled !== true`) pay nothing — the whole body is
14
+ * guarded by `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build
15
+ * time.
16
+ */
17
+ var useAnalytics = () => {
18
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !isEnabled) return;
19
+ const { locale } = useIntlayerContext();
20
+ const [client, setClient] = createSignal(null);
21
+ let cancelled = false;
22
+ let initialized = false;
23
+ onMounted(() => {
24
+ import("../esm-BS5TZIsL.js").then(({ initAnalyticsClient, buildContentExposure }) => {
25
+ if (cancelled) return;
26
+ const clientInstance = initAnalyticsClient();
27
+ initialized = true;
28
+ const currentLocale = locale?.();
29
+ if (currentLocale) clientInstance.setLocale(currentLocale);
30
+ clientInstance.trackPageView({ reason: "initial" });
31
+ setExposureSink((input) => clientInstance.trackContentExposure(buildContentExposure(input)));
32
+ setClient(clientInstance);
33
+ }).catch(() => {});
34
+ });
35
+ let previousLocale;
36
+ createWatchEffect(() => ({
37
+ clientInstance: client(),
38
+ currentLocale: locale?.()
39
+ }), ({ clientInstance, currentLocale }) => {
40
+ if (!clientInstance || !currentLocale) return;
41
+ if (previousLocale === void 0) {
42
+ previousLocale = currentLocale;
43
+ return;
44
+ }
45
+ if (previousLocale === currentLocale) return;
46
+ previousLocale = currentLocale;
47
+ clientInstance.setLocale(currentLocale);
48
+ clientInstance.trackPageView({ reason: "locale_change" });
49
+ });
50
+ onCleanup(() => {
51
+ cancelled = true;
52
+ setExposureSink(null);
53
+ import("../esm-BS5TZIsL.js").then(({ stopAnalyticsClient }) => {
54
+ if (initialized) stopAnalyticsClient();
55
+ }).catch(() => {});
56
+ });
57
+ };
58
+ export { useAnalytics };
@@ -0,0 +1,24 @@
1
+ import { t as isEnabled } from "../isEnabled-C5NUhdhZ.js";
2
+ // src/analytics/useConversion.ts
3
+ /**
4
+ * Returns a `trackConversion` callback for content A/B testing. Safe to call
5
+ * from any component: it resolves to a no-op when analytics is disabled or the
6
+ * client has not been initialized yet.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * const trackConversion = useConversion();
11
+ * <button onClick={() => trackConversion({
12
+ * experimentKey: 'homepage-hero', variant: 'b', goal: 'cta_click',
13
+ * })}>Get started</button>
14
+ * ```
15
+ */
16
+ var useConversion = () => {
17
+ return (params) => {
18
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !isEnabled) return;
19
+ import("../esm-BS5TZIsL.js").then(({ getGlobalAnalyticsClient }) => {
20
+ getGlobalAnalyticsClient()?.trackConversion(params);
21
+ }).catch(() => {});
22
+ };
23
+ };
24
+ export { useConversion };
@@ -0,0 +1,58 @@
1
+ import { t as isEnabled } from "../isEnabled-C5NUhdhZ.js";
2
+ import { onMounted } from "../solidCompat.js";
3
+ import { createSignal, onCleanup } from "solid-js";
4
+ // src/analytics/useExperiment.ts
5
+ /**
6
+ * Assigns this session to a variant of an A/B experiment and records the
7
+ * exposure, scoped to `experimentKey`, so the backend can compute per-variant
8
+ * conversion rates against `useConversion` events.
9
+ *
10
+ * Assignment is deterministic per session (no server round-trip, stable across
11
+ * re-mounts). The exposure is recorded once per mount.
12
+ *
13
+ * @param experimentKey - Unique key identifying the experiment.
14
+ * @param variants - The candidate variant names; the first one is the control.
15
+ * @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).
16
+ * @returns The {@link ExperimentState} for this session.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const { variant } = useExperiment('homepage-hero', ['a', 'b']);
21
+ * const content = useIntlayer(variant() === 'b' ? 'hero-b' : 'hero');
22
+ * ```
23
+ */
24
+ var useExperiment = (experimentKey, variants, weights) => {
25
+ const [variant, setVariant] = createSignal(variants[0] ?? "");
26
+ const [isAssigned, setIsAssigned] = createSignal(false);
27
+ let cancelled = false;
28
+ let initialized = false;
29
+ onMounted(() => {
30
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !isEnabled) return;
31
+ import("../esm-BS5TZIsL.js").then(({ initAnalyticsClient }) => {
32
+ if (cancelled) return;
33
+ const client = initAnalyticsClient();
34
+ initialized = true;
35
+ const assigned = client.getVariant(experimentKey, variants, weights);
36
+ setVariant(assigned);
37
+ setIsAssigned(true);
38
+ client.trackContentExposure({
39
+ dictionaryKey: experimentKey,
40
+ keyPath: "",
41
+ nodeType: "experiment",
42
+ experimentKey,
43
+ variant: assigned
44
+ });
45
+ }).catch(() => {});
46
+ });
47
+ onCleanup(() => {
48
+ cancelled = true;
49
+ import("../esm-BS5TZIsL.js").then(({ stopAnalyticsClient }) => {
50
+ if (initialized) stopAnalyticsClient();
51
+ }).catch(() => {});
52
+ });
53
+ return {
54
+ variant,
55
+ isAssigned
56
+ };
57
+ };
58
+ export { useExperiment };