featuredrop 2.7.2 → 3.0.1
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.
- package/README.md +32 -1
- package/dist/astro.cjs +333 -0
- package/dist/astro.cjs.map +1 -0
- package/dist/astro.d.cts +242 -0
- package/dist/astro.d.ts +242 -0
- package/dist/astro.js +329 -0
- package/dist/astro.js.map +1 -0
- package/dist/engine.cjs +552 -0
- package/dist/engine.cjs.map +1 -0
- package/dist/engine.d.cts +422 -0
- package/dist/engine.d.ts +422 -0
- package/dist/engine.js +545 -0
- package/dist/engine.js.map +1 -0
- package/dist/featuredrop.cjs +208 -1
- package/dist/featuredrop.cjs.map +1 -1
- package/dist/next.cjs +336 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +243 -0
- package/dist/next.d.ts +243 -0
- package/dist/next.js +332 -0
- package/dist/next.js.map +1 -0
- package/dist/nuxt.cjs +352 -0
- package/dist/nuxt.cjs.map +1 -0
- package/dist/nuxt.d.cts +282 -0
- package/dist/nuxt.d.ts +282 -0
- package/dist/nuxt.js +347 -0
- package/dist/nuxt.js.map +1 -0
- package/dist/preact.cjs +354 -0
- package/dist/preact.cjs.map +1 -1
- package/dist/preact.d.cts +170 -1
- package/dist/preact.d.ts +170 -1
- package/dist/preact.js +350 -1
- package/dist/preact.js.map +1 -1
- package/dist/react-hooks.cjs +82 -0
- package/dist/react-hooks.cjs.map +1 -1
- package/dist/react-hooks.d.cts +117 -1
- package/dist/react-hooks.d.ts +117 -1
- package/dist/react-hooks.js +80 -1
- package/dist/react-hooks.js.map +1 -1
- package/dist/react.cjs +354 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +170 -1
- package/dist/react.d.ts +170 -1
- package/dist/react.js +350 -1
- package/dist/react.js.map +1 -1
- package/dist/remix.cjs +331 -0
- package/dist/remix.cjs.map +1 -0
- package/dist/remix.d.cts +305 -0
- package/dist/remix.d.ts +305 -0
- package/dist/remix.js +327 -0
- package/dist/remix.js.map +1 -0
- package/package.json +70 -2
package/dist/next.cjs
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
// src/semver.ts
|
|
6
|
+
var SEMVER_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/;
|
|
7
|
+
function parseSemver(input) {
|
|
8
|
+
const match = input.trim().match(SEMVER_REGEX);
|
|
9
|
+
if (!match) return null;
|
|
10
|
+
return {
|
|
11
|
+
major: Number(match[1]),
|
|
12
|
+
minor: Number(match[2]),
|
|
13
|
+
patch: Number(match[3]),
|
|
14
|
+
prerelease: match[4] ? match[4].split(".") : []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function compareSemver(a, b) {
|
|
18
|
+
const pa = parseSemver(a);
|
|
19
|
+
const pb = parseSemver(b);
|
|
20
|
+
if (!pa || !pb) return 0;
|
|
21
|
+
for (const key of ["major", "minor", "patch"]) {
|
|
22
|
+
if (pa[key] !== pb[key]) return pa[key] - pb[key];
|
|
23
|
+
}
|
|
24
|
+
const aPre = pa.prerelease;
|
|
25
|
+
const bPre = pb.prerelease;
|
|
26
|
+
if (aPre.length === 0 && bPre.length === 0) return 0;
|
|
27
|
+
if (aPre.length === 0) return 1;
|
|
28
|
+
if (bPre.length === 0) return -1;
|
|
29
|
+
const len = Math.max(aPre.length, bPre.length);
|
|
30
|
+
for (let i = 0; i < len; i++) {
|
|
31
|
+
const ai = aPre[i];
|
|
32
|
+
const bi = bPre[i];
|
|
33
|
+
if (ai === void 0) return -1;
|
|
34
|
+
if (bi === void 0) return 1;
|
|
35
|
+
const aNum = Number(ai);
|
|
36
|
+
const bNum = Number(bi);
|
|
37
|
+
const aIsNum = Number.isInteger(aNum);
|
|
38
|
+
const bIsNum = Number.isInteger(bNum);
|
|
39
|
+
if (aIsNum && bIsNum && aNum !== bNum) return aNum - bNum;
|
|
40
|
+
if (aIsNum !== bIsNum) return aIsNum ? -1 : 1;
|
|
41
|
+
if (ai !== bi) return ai < bi ? -1 : 1;
|
|
42
|
+
}
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
function parseComparator(comp) {
|
|
46
|
+
const match = comp.trim().match(/^(>=|<=|>|<|=)?\\s*(.+)$/);
|
|
47
|
+
if (!match) return null;
|
|
48
|
+
const op = match[1] || ">=";
|
|
49
|
+
const version = match[2];
|
|
50
|
+
if (!parseSemver(version)) return null;
|
|
51
|
+
return { op, version };
|
|
52
|
+
}
|
|
53
|
+
function satisfiesComparator(version, comp) {
|
|
54
|
+
const diff = compareSemver(version, comp.version);
|
|
55
|
+
switch (comp.op) {
|
|
56
|
+
case ">":
|
|
57
|
+
return diff > 0;
|
|
58
|
+
case ">=":
|
|
59
|
+
return diff >= 0;
|
|
60
|
+
case "<":
|
|
61
|
+
return diff < 0;
|
|
62
|
+
case "<=":
|
|
63
|
+
return diff <= 0;
|
|
64
|
+
case "=":
|
|
65
|
+
return diff === 0;
|
|
66
|
+
default:
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function satisfiesRange(version, range) {
|
|
71
|
+
const parts = range.split(/\s+/).filter(Boolean);
|
|
72
|
+
if (parts.length === 0) return true;
|
|
73
|
+
for (const part of parts) {
|
|
74
|
+
const comp = parseComparator(part);
|
|
75
|
+
if (!comp) return false;
|
|
76
|
+
if (!satisfiesComparator(version, comp)) return false;
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/triggers.ts
|
|
82
|
+
function wildcardToRegExp(value) {
|
|
83
|
+
const escaped = value.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
84
|
+
const pattern = `^${escaped.replace(/\*/g, ".*")}$`;
|
|
85
|
+
return new RegExp(pattern);
|
|
86
|
+
}
|
|
87
|
+
function matchPath(path, pattern) {
|
|
88
|
+
if (pattern instanceof RegExp) return pattern.test(path);
|
|
89
|
+
if (!pattern) return false;
|
|
90
|
+
if (pattern.includes("*")) return wildcardToRegExp(pattern).test(path);
|
|
91
|
+
return path === pattern || path.startsWith(pattern);
|
|
92
|
+
}
|
|
93
|
+
function isTriggerMatch(trigger, context) {
|
|
94
|
+
if (!trigger) return true;
|
|
95
|
+
if (!context) return false;
|
|
96
|
+
if (trigger.type === "page") {
|
|
97
|
+
const path = context.path;
|
|
98
|
+
if (!path) return false;
|
|
99
|
+
return matchPath(path, trigger.match);
|
|
100
|
+
}
|
|
101
|
+
if (trigger.type === "usage") {
|
|
102
|
+
const usage = context.usage ?? {};
|
|
103
|
+
const count = usage[trigger.event] ?? 0;
|
|
104
|
+
return count >= (trigger.minActions ?? 1);
|
|
105
|
+
}
|
|
106
|
+
if (trigger.type === "time") {
|
|
107
|
+
const elapsedMs = context.elapsedMs ?? 0;
|
|
108
|
+
return elapsedMs >= trigger.minSeconds * 1e3;
|
|
109
|
+
}
|
|
110
|
+
if (trigger.type === "milestone") {
|
|
111
|
+
return context.milestones?.has(trigger.event) ?? false;
|
|
112
|
+
}
|
|
113
|
+
if (trigger.type === "frustration") {
|
|
114
|
+
const usage = context.usage ?? {};
|
|
115
|
+
const count = usage[trigger.pattern] ?? 0;
|
|
116
|
+
return count >= (trigger.threshold ?? 1);
|
|
117
|
+
}
|
|
118
|
+
if (trigger.type === "scroll") {
|
|
119
|
+
return (context.scrollPercent ?? 0) >= (trigger.minPercent ?? 50);
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
return trigger.evaluate(context);
|
|
123
|
+
} catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// src/core.ts
|
|
129
|
+
function matchesAudience(audience, userContext) {
|
|
130
|
+
if (audience.plan && audience.plan.length > 0) {
|
|
131
|
+
if (!userContext.plan || !audience.plan.includes(userContext.plan)) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (audience.role && audience.role.length > 0) {
|
|
136
|
+
if (!userContext.role || !audience.role.includes(userContext.role)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (audience.region && audience.region.length > 0) {
|
|
141
|
+
if (!userContext.region || !audience.region.includes(userContext.region)) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
function isAudienceMatch(feature, userContext, matchFn) {
|
|
148
|
+
if (!feature.audience) return true;
|
|
149
|
+
const { plan, role, region, custom } = feature.audience;
|
|
150
|
+
const hasRules = plan && plan.length > 0 || role && role.length > 0 || region && region.length > 0 || custom && Object.keys(custom).length > 0;
|
|
151
|
+
if (!hasRules) return true;
|
|
152
|
+
if (!userContext) return false;
|
|
153
|
+
if (matchFn) return matchFn(feature.audience, userContext);
|
|
154
|
+
return matchesAudience(feature.audience, userContext);
|
|
155
|
+
}
|
|
156
|
+
function isVersionMatch(feature, appVersion) {
|
|
157
|
+
const v = feature.version;
|
|
158
|
+
if (!v || typeof v === "string") return true;
|
|
159
|
+
if (!appVersion) return false;
|
|
160
|
+
if (!v.introduced && !v.showNewUntil && !v.deprecatedAt && !v.showIn) return true;
|
|
161
|
+
if (v.showIn && !satisfiesRange(appVersion, v.showIn)) return false;
|
|
162
|
+
if (v.introduced && compareSemver(appVersion, v.introduced) < 0) return false;
|
|
163
|
+
if (v.deprecatedAt && compareSemver(appVersion, v.deprecatedAt) >= 0) return false;
|
|
164
|
+
if (v.showNewUntil && compareSemver(appVersion, v.showNewUntil) >= 0) return false;
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
function isFlagMatch(feature, flagBridge, userContext) {
|
|
168
|
+
if (!feature.flagKey) return true;
|
|
169
|
+
if (!flagBridge) return false;
|
|
170
|
+
try {
|
|
171
|
+
return flagBridge.isEnabled(feature.flagKey, userContext);
|
|
172
|
+
} catch {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function isProductMatch(feature, product) {
|
|
177
|
+
if (!feature.product || feature.product === "*") return true;
|
|
178
|
+
if (!product) return false;
|
|
179
|
+
return feature.product === product;
|
|
180
|
+
}
|
|
181
|
+
function isDependencyMatch(feature, dismissedIds, dependencyState) {
|
|
182
|
+
const dependsOn = feature.dependsOn;
|
|
183
|
+
if (!dependsOn) return true;
|
|
184
|
+
const seenIds = dependencyState?.seenIds;
|
|
185
|
+
const clickedIds = dependencyState?.clickedIds;
|
|
186
|
+
const dismissedDependencyIds = dependencyState?.dismissedIds ?? dismissedIds;
|
|
187
|
+
if (dependsOn.seen && dependsOn.seen.length > 0) {
|
|
188
|
+
for (const id of dependsOn.seen) {
|
|
189
|
+
const seen = seenIds?.has(id) ?? false;
|
|
190
|
+
if (!seen && !dismissedDependencyIds.has(id)) return false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (dependsOn.clicked && dependsOn.clicked.length > 0) {
|
|
194
|
+
for (const id of dependsOn.clicked) {
|
|
195
|
+
if (!(clickedIds?.has(id) ?? false)) return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (dependsOn.dismissed && dependsOn.dismissed.length > 0) {
|
|
199
|
+
for (const id of dependsOn.dismissed) {
|
|
200
|
+
if (!dismissedDependencyIds.has(id)) return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
function isNew(feature, watermark, dismissedIds, now = /* @__PURE__ */ new Date(), userContext, matchAudience, appVersion, dependencyState, triggerContext, flagBridge, product) {
|
|
206
|
+
if (dismissedIds.has(feature.id)) return false;
|
|
207
|
+
if (!isAudienceMatch(feature, userContext, matchAudience)) return false;
|
|
208
|
+
if (!isDependencyMatch(feature, dismissedIds, dependencyState)) return false;
|
|
209
|
+
if (!isVersionMatch(feature, appVersion)) return false;
|
|
210
|
+
if (!isFlagMatch(feature, flagBridge, userContext)) return false;
|
|
211
|
+
if (!isProductMatch(feature, product)) return false;
|
|
212
|
+
if (!isTriggerMatch(feature.trigger, triggerContext)) return false;
|
|
213
|
+
const nowMs = now.getTime();
|
|
214
|
+
if (feature.publishAt) {
|
|
215
|
+
const publishMs = new Date(feature.publishAt).getTime();
|
|
216
|
+
if (nowMs < publishMs) return false;
|
|
217
|
+
}
|
|
218
|
+
const showUntilMs = new Date(feature.showNewUntil).getTime();
|
|
219
|
+
if (nowMs >= showUntilMs) return false;
|
|
220
|
+
if (watermark) {
|
|
221
|
+
const watermarkMs = new Date(watermark).getTime();
|
|
222
|
+
const releasedMs = new Date(feature.releasedAt).getTime();
|
|
223
|
+
if (releasedMs <= watermarkMs) return false;
|
|
224
|
+
}
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
function getNewFeatures(manifest, storage, now = /* @__PURE__ */ new Date(), userContext, matchAudience, appVersion, dependencyState, triggerContext, flagBridge, product) {
|
|
228
|
+
const watermark = storage.getWatermark();
|
|
229
|
+
const dismissedIds = storage.getDismissedIds();
|
|
230
|
+
return manifest.filter(
|
|
231
|
+
(f) => isNew(
|
|
232
|
+
f,
|
|
233
|
+
watermark,
|
|
234
|
+
dismissedIds,
|
|
235
|
+
now,
|
|
236
|
+
userContext,
|
|
237
|
+
matchAudience,
|
|
238
|
+
appVersion,
|
|
239
|
+
dependencyState,
|
|
240
|
+
triggerContext,
|
|
241
|
+
flagBridge,
|
|
242
|
+
product
|
|
243
|
+
)
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
function getNewFeatureCount(manifest, storage, now = /* @__PURE__ */ new Date(), userContext, matchAudience, appVersion, dependencyState, triggerContext, flagBridge, product) {
|
|
247
|
+
return getNewFeatures(
|
|
248
|
+
manifest,
|
|
249
|
+
storage,
|
|
250
|
+
now,
|
|
251
|
+
userContext,
|
|
252
|
+
matchAudience,
|
|
253
|
+
appVersion,
|
|
254
|
+
dependencyState,
|
|
255
|
+
triggerContext,
|
|
256
|
+
flagBridge,
|
|
257
|
+
product
|
|
258
|
+
).length;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// src/adapters/memory.ts
|
|
262
|
+
var MemoryAdapter = class {
|
|
263
|
+
watermark;
|
|
264
|
+
dismissed;
|
|
265
|
+
constructor(options = {}) {
|
|
266
|
+
this.watermark = options.watermark ?? null;
|
|
267
|
+
this.dismissed = /* @__PURE__ */ new Set();
|
|
268
|
+
}
|
|
269
|
+
getWatermark() {
|
|
270
|
+
return this.watermark;
|
|
271
|
+
}
|
|
272
|
+
getDismissedIds() {
|
|
273
|
+
return this.dismissed;
|
|
274
|
+
}
|
|
275
|
+
dismiss(id) {
|
|
276
|
+
this.dismissed.add(id);
|
|
277
|
+
}
|
|
278
|
+
async dismissAll(now) {
|
|
279
|
+
this.watermark = now.toISOString();
|
|
280
|
+
this.dismissed.clear();
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
function getNewFeaturesServer(manifest, dismissedIds, options) {
|
|
284
|
+
const storage = new MemoryAdapter();
|
|
285
|
+
if (dismissedIds) {
|
|
286
|
+
for (const id of dismissedIds) {
|
|
287
|
+
storage.dismiss(id);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return getNewFeatures(
|
|
291
|
+
manifest,
|
|
292
|
+
storage,
|
|
293
|
+
options?.now,
|
|
294
|
+
options?.userContext,
|
|
295
|
+
options?.matchAudience,
|
|
296
|
+
options?.appVersion,
|
|
297
|
+
options?.dependencyState,
|
|
298
|
+
options?.triggerContext,
|
|
299
|
+
options?.flagBridge,
|
|
300
|
+
options?.product
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
function getNewCountServer(manifest, dismissedIds, options) {
|
|
304
|
+
const storage = new MemoryAdapter();
|
|
305
|
+
if (dismissedIds) {
|
|
306
|
+
for (const id of dismissedIds) {
|
|
307
|
+
storage.dismiss(id);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return getNewFeatureCount(
|
|
311
|
+
manifest,
|
|
312
|
+
storage,
|
|
313
|
+
options?.now,
|
|
314
|
+
options?.userContext,
|
|
315
|
+
options?.matchAudience,
|
|
316
|
+
options?.appVersion,
|
|
317
|
+
options?.dependencyState,
|
|
318
|
+
options?.triggerContext,
|
|
319
|
+
options?.flagBridge,
|
|
320
|
+
options?.product
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
function FeatureDropScript({ manifest, dismissedIds }) {
|
|
324
|
+
const data = JSON.stringify({ manifest, dismissedIds: dismissedIds ?? [] });
|
|
325
|
+
return react.createElement("script", {
|
|
326
|
+
id: "__FEATUREDROP_DATA__",
|
|
327
|
+
type: "application/json",
|
|
328
|
+
dangerouslySetInnerHTML: { __html: data }
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
exports.FeatureDropScript = FeatureDropScript;
|
|
333
|
+
exports.getNewCountServer = getNewCountServer;
|
|
334
|
+
exports.getNewFeaturesServer = getNewFeaturesServer;
|
|
335
|
+
//# sourceMappingURL=next.cjs.map
|
|
336
|
+
//# sourceMappingURL=next.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/semver.ts","../src/triggers.ts","../src/core.ts","../src/adapters/memory.ts","../src/next/index.ts"],"names":["createElement"],"mappings":";;;;;AAWA,IAAM,YAAA,GAAe,4CAAA;AAEd,SAAS,YAAY,KAAA,EAAmC;AAC7D,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,IAAA,EAAK,CAAE,MAAM,YAAY,CAAA;AAC7C,EAAA,IAAI,CAAC,OAAO,OAAO,IAAA;AACnB,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA;AAAA,IACtB,KAAA,EAAO,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA;AAAA,IACtB,KAAA,EAAO,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA;AAAA,IACtB,UAAA,E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al semver comparison utilities (no build metadata sorting needed)\n\nexport type Comparator = \">=\" | \"<=\" | \">\" | \"<\" | \"=\";\n\nexport interface SemverParts {\n major: number;\n minor: number;\n patch: number;\n prerelease: string[];\n}\n\nconst SEMVER_REGEX = /^(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z.-]+))?/;\n\nexport function parseSemver(input: string): SemverParts | null {\n const match = input.trim().match(SEMVER_REGEX);\n if (!match) return null;\n return {\n major: Number(match[1]),\n minor: Number(match[2]),\n patch: Number(match[3]),\n prerelease: match[4] ? match[4].split(\".\") : [],\n };\n}\n\nexport function compareSemver(a: string, b: string): number {\n const pa = parseSemver(a);\n const pb = parseSemver(b);\n if (!pa || !pb) return 0;\n\n for (const key of [\"major\", \"minor\", \"patch\"] as const) {\n if (pa[key] !== pb[key]) return pa[key] - pb[key];\n }\n\n // Handle prerelease: absence > presence, otherwise lexicographic\n const aPre = pa.prerelease;\n const bPre = pb.prerelease;\n if (aPre.length === 0 && bPre.length === 0) return 0;\n if (aPre.length === 0) return 1;\n if (bPre.length === 0) return -1;\n\n const len = Math.max(aPre.length, bPre.length);\n for (let i = 0; i < len; i++) {\n const ai = aPre[i];\n const bi = bPre[i];\n if (ai === undefined) return -1;\n if (bi === undefined) return 1;\n const aNum = Number(ai);\n const bNum = Number(bi);\n const aIsNum = Number.isInteger(aNum);\n const bIsNum = Number.isInteger(bNum);\n if (aIsNum && bIsNum && aNum !== bNum) return aNum - bNum;\n if (aIsNum !== bIsNum) return aIsNum ? -1 : 1;\n if (ai !== bi) return ai < bi ? -1 : 1;\n }\n return 0;\n}\n\nfunction parseComparator(comp: string): { op: Comparator; version: string } | null {\n const match = comp.trim().match(/^(>=|<=|>|<|=)?\\\\s*(.+)$/);\n if (!match) return null;\n const op = (match[1] as Comparator) || \">=\";\n const version = match[2];\n if (!parseSemver(version)) return null;\n return { op, version };\n}\n\nfunction satisfiesComparator(version: string, comp: { op: Comparator; version: string }): boolean {\n const diff = compareSemver(version, comp.version);\n switch (comp.op) {\n case \">\":\n return diff > 0;\n case \">=\":\n return diff >= 0;\n case \"<\":\n return diff < 0;\n case \"<=\":\n return diff <= 0;\n case \"=\":\n return diff === 0;\n default:\n return false;\n }\n}\n\n// Space-separated comparator list (AND semantics), e.g. \">=2.5.0 <3.0.0\"\nexport function satisfiesRange(version: string, range: string): boolean {\n const parts = range.split(/\\s+/).filter(Boolean);\n if (parts.length === 0) return true;\n for (const part of parts) {\n const comp = parseComparator(part);\n if (!comp) return false;\n if (!satisfiesComparator(version, comp)) return false;\n }\n return true;\n}\n","import type { FeatureEntry, FeatureTrigger, TriggerContext } from \"./types\";\n\nfunction wildcardToRegExp(value: string): RegExp {\n const escaped = value.replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const pattern = `^${escaped.replace(/\\*/g, \".*\")}$`;\n return new RegExp(pattern);\n}\n\nfunction matchPath(path: string, pattern: string | RegExp): boolean {\n if (pattern instanceof RegExp) return pattern.test(path);\n if (!pattern) return false;\n if (pattern.includes(\"*\")) return wildcardToRegExp(pattern).test(path);\n return path === pattern || path.startsWith(pattern);\n}\n\nexport function isTriggerMatch(trigger: FeatureTrigger | undefined, context?: TriggerContext): boolean {\n if (!trigger) return true;\n if (!context) return false;\n\n if (trigger.type === \"page\") {\n const path = context.path;\n if (!path) return false;\n return matchPath(path, trigger.match);\n }\n\n if (trigger.type === \"usage\") {\n const usage = context.usage ?? {};\n const count = usage[trigger.event] ?? 0;\n return count >= (trigger.minActions ?? 1);\n }\n\n if (trigger.type === \"time\") {\n const elapsedMs = context.elapsedMs ?? 0;\n return elapsedMs >= trigger.minSeconds * 1000;\n }\n\n if (trigger.type === \"milestone\") {\n return context.milestones?.has(trigger.event) ?? false;\n }\n\n if (trigger.type === \"frustration\") {\n const usage = context.usage ?? {};\n const count = usage[trigger.pattern] ?? 0;\n return count >= (trigger.threshold ?? 1);\n }\n\n if (trigger.type === \"scroll\") {\n return (context.scrollPercent ?? 0) >= (trigger.minPercent ?? 50);\n }\n\n try {\n return trigger.evaluate(context);\n } catch {\n return false;\n }\n}\n\nexport class TriggerEngine {\n private context: TriggerContext;\n\n constructor(initial?: TriggerContext) {\n this.context = {\n path: initial?.path,\n events: new Set(initial?.events ?? []),\n milestones: new Set(initial?.milestones ?? []),\n usage: { ...(initial?.usage ?? {}) },\n elapsedMs: initial?.elapsedMs ?? 0,\n scrollPercent: initial?.scrollPercent ?? 0,\n metadata: { ...(initial?.metadata ?? {}) },\n };\n }\n\n setPath(path: string): void {\n this.context.path = path;\n }\n\n trackEvent(event: string): void {\n const next = new Set(this.context.events ?? new Set<string>());\n next.add(event);\n this.context.events = next;\n }\n\n trackUsage(event: string, delta = 1): void {\n const usage = { ...(this.context.usage ?? {}) };\n usage[event] = (usage[event] ?? 0) + Math.max(1, delta);\n this.context.usage = usage;\n }\n\n trackMilestone(event: string): void {\n const next = new Set(this.context.milestones ?? new Set<string>());\n next.add(event);\n this.context.milestones = next;\n }\n\n setElapsedMs(elapsedMs: number): void {\n this.context.elapsedMs = Math.max(0, elapsedMs);\n }\n\n setScrollPercent(scrollPercent: number): void {\n const clamped = Math.max(0, Math.min(100, scrollPercent));\n this.context.scrollPercent = clamped;\n }\n\n setMetadata(next: Record<string, unknown>): void {\n this.context.metadata = { ...next };\n }\n\n getContext(): TriggerContext {\n return {\n path: this.context.path,\n events: new Set(this.context.events ?? []),\n milestones: new Set(this.context.milestones ?? []),\n usage: { ...(this.context.usage ?? {}) },\n elapsedMs: this.context.elapsedMs,\n scrollPercent: this.context.scrollPercent,\n metadata: { ...(this.context.metadata ?? {}) },\n };\n }\n\n evaluate(trigger: FeatureTrigger | undefined): boolean {\n return isTriggerMatch(trigger, this.context);\n }\n\n evaluateFeature(feature: Pick<FeatureEntry, \"trigger\">): boolean {\n return this.evaluate(feature.trigger);\n }\n}\n","import type {\n AudienceMatchFn,\n AudienceRule,\n FeatureEntry,\n FeatureManifest,\n StorageAdapter,\n UserContext,\n FeatureDependencyState,\n FeatureFlagBridge,\n TriggerContext,\n} from \"./types\";\nimport { compareSemver, satisfiesRange } from \"./semver\";\nimport { isTriggerMatch } from \"./triggers\";\n\n/**\n * Default audience matching logic.\n *\n * For each specified field (plan, role, region), checks if the user's\n * value is included in the allowed list. Fields use AND logic between them,\n * OR logic within each field's array. The `custom` field is ignored by\n * the default matcher — use a custom `AudienceMatchFn` for that.\n */\nexport function matchesAudience(\n audience: AudienceRule,\n userContext: UserContext,\n): boolean {\n if (audience.plan && audience.plan.length > 0) {\n if (!userContext.plan || !audience.plan.includes(userContext.plan)) {\n return false;\n }\n }\n if (audience.role && audience.role.length > 0) {\n if (!userContext.role || !audience.role.includes(userContext.role)) {\n return false;\n }\n }\n if (audience.region && audience.region.length > 0) {\n if (!userContext.region || !audience.region.includes(userContext.region)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Check if a feature's audience allows the given user context.\n *\n * - No `audience` field → visible to all\n * - Empty `audience` ({}) → visible to all\n * - `audience` specified but no `userContext` → hidden (safe default)\n * - Otherwise, delegate to `matchFn` (or default `matchesAudience`)\n */\nfunction isAudienceMatch(\n feature: FeatureEntry,\n userContext?: UserContext,\n matchFn?: AudienceMatchFn,\n): boolean {\n // No audience restriction → show to everyone\n if (!feature.audience) return true;\n\n // Check if audience is empty (no fields with values)\n const { plan, role, region, custom } = feature.audience;\n const hasRules =\n (plan && plan.length > 0) ||\n (role && role.length > 0) ||\n (region && region.length > 0) ||\n (custom && Object.keys(custom).length > 0);\n if (!hasRules) return true;\n\n // Audience specified but no user context → hidden (safe default)\n if (!userContext) return false;\n\n // Use custom matcher if provided, otherwise default\n if (matchFn) return matchFn(feature.audience, userContext);\n return matchesAudience(feature.audience, userContext);\n}\n\nfunction isVersionMatch(feature: FeatureEntry, appVersion?: string): boolean {\n const v = feature.version;\n if (!v || typeof v === \"string\") return true; // string = display only\n if (!appVersion) return false; // Safe default when constraints exist\n if (!v.introduced && !v.showNewUntil && !v.deprecatedAt && !v.showIn) return true;\n\n // Range check\n if (v.showIn && !satisfiesRange(appVersion, v.showIn)) return false;\n\n if (v.introduced && compareSemver(appVersion, v.introduced) < 0) return false;\n if (v.deprecatedAt && compareSemver(appVersion, v.deprecatedAt) >= 0) return false;\n\n // showNewUntil gates \"new\" state only\n if (v.showNewUntil && compareSemver(appVersion, v.showNewUntil) >= 0) return false;\n\n return true;\n}\n\nfunction isFlagMatch(\n feature: FeatureEntry,\n flagBridge?: FeatureFlagBridge,\n userContext?: UserContext,\n): boolean {\n if (!feature.flagKey) return true;\n if (!flagBridge) return false;\n try {\n return flagBridge.isEnabled(feature.flagKey, userContext);\n } catch {\n return false;\n }\n}\n\nfunction isProductMatch(feature: FeatureEntry, product?: string): boolean {\n if (!feature.product || feature.product === \"*\") return true;\n if (!product) return false;\n return feature.product === product;\n}\n\nfunction isDependencyMatch(\n feature: FeatureEntry,\n dismissedIds: ReadonlySet<string>,\n dependencyState?: FeatureDependencyState,\n): boolean {\n const dependsOn = feature.dependsOn;\n if (!dependsOn) return true;\n\n const seenIds = dependencyState?.seenIds;\n const clickedIds = dependencyState?.clickedIds;\n const dismissedDependencyIds = dependencyState?.dismissedIds ?? dismissedIds;\n\n if (dependsOn.seen && dependsOn.seen.length > 0) {\n for (const id of dependsOn.seen) {\n const seen = seenIds?.has(id) ?? false;\n if (!seen && !dismissedDependencyIds.has(id)) return false;\n }\n }\n\n if (dependsOn.clicked && dependsOn.clicked.length > 0) {\n for (const id of dependsOn.clicked) {\n if (!(clickedIds?.has(id) ?? false)) return false;\n }\n }\n\n if (dependsOn.dismissed && dependsOn.dismissed.length > 0) {\n for (const id of dependsOn.dismissed) {\n if (!dismissedDependencyIds.has(id)) return false;\n }\n }\n\n return true;\n}\n\n/**\n * Check if a single feature should show as \"new\".\n *\n * A feature is \"new\" when ALL of these are true:\n * 1. Current time is before `showNewUntil`\n * 2. Feature was released after the watermark (or no watermark exists)\n * 3. Feature has not been individually dismissed\n * 4. If `publishAt` is set, current time must be after it (scheduled publishing)\n * 5. If `audience` is set, user must match the targeting rules\n * 6. If `flagKey` is set, the flag bridge must resolve it as enabled\n * 7. If `product` is set, it must match the current product scope\n */\nexport function isNew(\n feature: FeatureEntry,\n watermark: string | null,\n dismissedIds: ReadonlySet<string>,\n now: Date = new Date(),\n userContext?: UserContext,\n matchAudience?: AudienceMatchFn,\n appVersion?: string,\n dependencyState?: FeatureDependencyState,\n triggerContext?: TriggerContext,\n flagBridge?: FeatureFlagBridge,\n product?: string,\n): boolean {\n // Already dismissed by the user on this device\n if (dismissedIds.has(feature.id)) return false;\n\n // Audience targeting — check before time-based checks\n if (!isAudienceMatch(feature, userContext, matchAudience)) return false;\n\n // Dependency targeting — defer features until prerequisites are satisfied\n if (!isDependencyMatch(feature, dismissedIds, dependencyState)) return false;\n\n // Version targeting — requires appVersion when constraints exist\n if (!isVersionMatch(feature, appVersion)) return false;\n\n // Feature flag targeting — hide flagged entries unless enabled\n if (!isFlagMatch(feature, flagBridge, userContext)) return false;\n\n // Multi-product targeting — hide entries for other product scopes\n if (!isProductMatch(feature, product)) return false;\n\n // Contextual trigger rules — show only when trigger condition is satisfied.\n if (!isTriggerMatch(feature.trigger, triggerContext)) return false;\n\n const nowMs = now.getTime();\n\n // Scheduled publishing — hidden until publishAt\n if (feature.publishAt) {\n const publishMs = new Date(feature.publishAt).getTime();\n if (nowMs < publishMs) return false;\n }\n\n const showUntilMs = new Date(feature.showNewUntil).getTime();\n\n // Past the display window\n if (nowMs >= showUntilMs) return false;\n\n // If there's a watermark, feature must have been released after it\n if (watermark) {\n const watermarkMs = new Date(watermark).getTime();\n const releasedMs = new Date(feature.releasedAt).getTime();\n if (releasedMs <= watermarkMs) return false;\n }\n\n return true;\n}\n\n/**\n * Get all features that are currently \"new\" for this user.\n */\nexport function getNewFeatures(\n manifest: FeatureManifest,\n storage: StorageAdapter,\n now: Date = new Date(),\n userContext?: UserContext,\n matchAudience?: AudienceMatchFn,\n appVersion?: string,\n dependencyState?: FeatureDependencyState,\n triggerContext?: TriggerContext,\n flagBridge?: FeatureFlagBridge,\n product?: string,\n): FeatureEntry[] {\n const watermark = storage.getWatermark();\n const dismissedIds = storage.getDismissedIds();\n return manifest.filter((f) =>\n isNew(\n f,\n watermark,\n dismissedIds,\n now,\n userContext,\n matchAudience,\n appVersion,\n dependencyState,\n triggerContext,\n flagBridge,\n product,\n ),\n );\n}\n\n/**\n * Get the count of new features.\n */\nexport function getNewFeatureCount(\n manifest: FeatureManifest,\n storage: StorageAdapter,\n now: Date = new Date(),\n userContext?: UserContext,\n matchAudience?: AudienceMatchFn,\n appVersion?: string,\n dependencyState?: FeatureDependencyState,\n triggerContext?: TriggerContext,\n flagBridge?: FeatureFlagBridge,\n product?: string,\n): number {\n return getNewFeatures(\n manifest,\n storage,\n now,\n userContext,\n matchAudience,\n appVersion,\n dependencyState,\n triggerContext,\n flagBridge,\n product,\n ).length;\n}\n\n/**\n * Check if a specific sidebar key has a new feature.\n */\nexport function hasNewFeature(\n manifest: FeatureManifest,\n sidebarKey: string,\n storage: StorageAdapter,\n now: Date = new Date(),\n userContext?: UserContext,\n matchAudience?: AudienceMatchFn,\n appVersion?: string,\n dependencyState?: FeatureDependencyState,\n triggerContext?: TriggerContext,\n flagBridge?: FeatureFlagBridge,\n product?: string,\n): boolean {\n const watermark = storage.getWatermark();\n const dismissedIds = storage.getDismissedIds();\n return manifest.some(\n (f) =>\n f.sidebarKey === sidebarKey &&\n isNew(\n f,\n watermark,\n dismissedIds,\n now,\n userContext,\n matchAudience,\n appVersion,\n dependencyState,\n triggerContext,\n flagBridge,\n product,\n ),\n );\n}\n\n/**\n * Get all features sorted by priority (critical first) then by release date (newest first).\n */\nexport function getNewFeaturesSorted(\n manifest: FeatureManifest,\n storage: StorageAdapter,\n now: Date = new Date(),\n userContext?: UserContext,\n matchAudience?: AudienceMatchFn,\n appVersion?: string,\n dependencyState?: FeatureDependencyState,\n triggerContext?: TriggerContext,\n flagBridge?: FeatureFlagBridge,\n product?: string,\n): FeatureEntry[] {\n const priorityOrder = { critical: 0, normal: 1, low: 2 };\n return getNewFeatures(\n manifest,\n storage,\n now,\n userContext,\n matchAudience,\n appVersion,\n dependencyState,\n triggerContext,\n flagBridge,\n product,\n ).sort(\n (a, b) => {\n const pa = priorityOrder[a.priority ?? \"normal\"];\n const pb = priorityOrder[b.priority ?? \"normal\"];\n if (pa !== pb) return pa - pb;\n return (\n new Date(b.releasedAt).getTime() - new Date(a.releasedAt).getTime()\n );\n },\n );\n}\n","import type { StorageAdapter } from \"../types\";\n\n/**\n * In-memory storage adapter.\n *\n * Useful for:\n * - Testing (no side effects)\n * - Server-side rendering (no `window`/`localStorage`)\n * - Environments without persistent storage\n */\nexport class MemoryAdapter implements StorageAdapter {\n private watermark: string | null;\n private dismissed: Set<string>;\n\n constructor(options: { watermark?: string | null } = {}) {\n this.watermark = options.watermark ?? null;\n this.dismissed = new Set();\n }\n\n getWatermark(): string | null {\n return this.watermark;\n }\n\n getDismissedIds(): ReadonlySet<string> {\n return this.dismissed;\n }\n\n dismiss(id: string): void {\n this.dismissed.add(id);\n }\n\n async dismissAll(now: Date): Promise<void> {\n this.watermark = now.toISOString();\n this.dismissed.clear();\n }\n}\n","import { getNewFeatures, getNewFeatureCount } from \"../core\";\nimport { MemoryAdapter } from \"../adapters/memory\";\nimport type {\n FeatureEntry,\n FeatureManifest,\n UserContext,\n AudienceMatchFn,\n FeatureDependencyState,\n TriggerContext,\n FeatureFlagBridge,\n} from \"../types\";\nimport { createElement } from \"react\";\n\n/** Options shared by both server helpers */\nexport interface ServerOptions {\n /** Current date override (defaults to `new Date()`) */\n now?: Date;\n /** User context for audience targeting */\n userContext?: UserContext;\n /** Custom audience matcher */\n matchAudience?: AudienceMatchFn;\n /** Current app semver string for version targeting */\n appVersion?: string;\n /** Dependency state for progressive disclosure */\n dependencyState?: FeatureDependencyState;\n /** Trigger context for contextual rules */\n triggerContext?: TriggerContext;\n /** Feature flag bridge for flag-gated entries */\n flagBridge?: FeatureFlagBridge;\n /** Product scope for multi-product manifests */\n product?: string;\n}\n\n/**\n * Server-side helper: get new features without browser storage.\n *\n * Creates a temporary MemoryAdapter pre-seeded with the provided dismissed IDs\n * and calls the core `getNewFeatures` function. Safe to use in React Server\n * Components, `generateStaticParams`, or any server context.\n *\n * @param manifest The feature manifest array.\n * @param dismissedIds IDs already dismissed by this user (from your session/DB).\n * @param options Optional targeting overrides.\n */\nexport function getNewFeaturesServer(\n manifest: FeatureManifest,\n dismissedIds?: string[],\n options?: ServerOptions,\n): FeatureEntry[] {\n const storage = new MemoryAdapter();\n if (dismissedIds) {\n for (const id of dismissedIds) {\n storage.dismiss(id);\n }\n }\n return getNewFeatures(\n manifest,\n storage,\n options?.now,\n options?.userContext,\n options?.matchAudience,\n options?.appVersion,\n options?.dependencyState,\n options?.triggerContext,\n options?.flagBridge,\n options?.product,\n );\n}\n\n/**\n * Server-side helper: get new feature count.\n *\n * Same as `getNewFeaturesServer` but returns the count only.\n *\n * @param manifest The feature manifest array.\n * @param dismissedIds IDs already dismissed by this user (from your session/DB).\n * @param options Optional targeting overrides.\n */\nexport function getNewCountServer(\n manifest: FeatureManifest,\n dismissedIds?: string[],\n options?: ServerOptions,\n): number {\n const storage = new MemoryAdapter();\n if (dismissedIds) {\n for (const id of dismissedIds) {\n storage.dismiss(id);\n }\n }\n return getNewFeatureCount(\n manifest,\n storage,\n options?.now,\n options?.userContext,\n options?.matchAudience,\n options?.appVersion,\n options?.dependencyState,\n options?.triggerContext,\n options?.flagBridge,\n options?.product,\n );\n}\n\n/** Props for FeatureDropScript */\nexport interface FeatureDropScriptProps {\n manifest: FeatureEntry[];\n dismissedIds?: string[];\n}\n\n/**\n * Injects manifest + dismissed IDs into the page as a JSON script tag.\n *\n * Place this in your root layout (server component) so the client-side\n * `FeatureDropProvider` can read the data on first render without a\n * flash-of-no-content (0 new features → real count).\n *\n * Client-side usage:\n * ```ts\n * const el = document.getElementById(\"__FEATUREDROP_DATA__\");\n * const { manifest, dismissedIds } = JSON.parse(el?.textContent ?? \"{}\");\n * ```\n */\nexport function FeatureDropScript({ manifest, dismissedIds }: FeatureDropScriptProps) {\n const data = JSON.stringify({ manifest, dismissedIds: dismissedIds ?? [] });\n return createElement(\"script\", {\n id: \"__FEATUREDROP_DATA__\",\n type: \"application/json\",\n dangerouslySetInnerHTML: { __html: data },\n });\n}\n"]}
|
package/dist/next.d.cts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
/** Entry type label — determines default icon/color in UI */
|
|
4
|
+
type FeatureType = "feature" | "improvement" | "fix" | "breaking";
|
|
5
|
+
/** Priority level for announcements */
|
|
6
|
+
type FeaturePriority = "critical" | "normal" | "low";
|
|
7
|
+
/** Call-to-action for a feature entry */
|
|
8
|
+
interface FeatureCTA {
|
|
9
|
+
/** Button/link label */
|
|
10
|
+
label: string;
|
|
11
|
+
/** URL to navigate to */
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
14
|
+
/** Variant-level overrides for A/B announcement testing */
|
|
15
|
+
interface FeatureVariant {
|
|
16
|
+
/** Optional variant-specific label override */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** Optional variant-specific description override */
|
|
19
|
+
description?: string;
|
|
20
|
+
/** Optional variant-specific image override */
|
|
21
|
+
image?: string;
|
|
22
|
+
/** Optional variant-specific CTA override */
|
|
23
|
+
cta?: FeatureCTA;
|
|
24
|
+
/** Optional variant-specific metadata overrides */
|
|
25
|
+
meta?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
/** Audience targeting rule — determines which user segments see a feature */
|
|
28
|
+
interface AudienceRule {
|
|
29
|
+
/** Plans that should see this feature (e.g. ["pro", "enterprise"]) */
|
|
30
|
+
plan?: string[];
|
|
31
|
+
/** Roles that should see this feature (e.g. ["admin", "editor"]) */
|
|
32
|
+
role?: string[];
|
|
33
|
+
/** Regions that should see this feature (e.g. ["us", "eu"]) */
|
|
34
|
+
region?: string[];
|
|
35
|
+
/** Arbitrary key-value pairs for custom matching logic */
|
|
36
|
+
custom?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
/** User context for audience targeting */
|
|
39
|
+
interface UserContext {
|
|
40
|
+
/** Current user's plan (e.g. "pro", "free") */
|
|
41
|
+
plan?: string;
|
|
42
|
+
/** Current user's role (e.g. "admin", "viewer") */
|
|
43
|
+
role?: string;
|
|
44
|
+
/** Current user's region (e.g. "us", "eu") */
|
|
45
|
+
region?: string;
|
|
46
|
+
/** Arbitrary traits for custom matching logic */
|
|
47
|
+
traits?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
/** Custom audience matcher function */
|
|
50
|
+
type AudienceMatchFn = (audience: AudienceRule, userContext: UserContext) => boolean;
|
|
51
|
+
/** Feature flag resolver interface for gating announcement visibility */
|
|
52
|
+
interface FeatureFlagBridge {
|
|
53
|
+
isEnabled: (flagKey: string, userContext?: UserContext) => boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Dependency gates for progressive feature discovery */
|
|
56
|
+
interface FeatureDependencies {
|
|
57
|
+
/** Features the user must have seen before this one can surface */
|
|
58
|
+
seen?: string[];
|
|
59
|
+
/** Features the user must have clicked before this one can surface */
|
|
60
|
+
clicked?: string[];
|
|
61
|
+
/** Features the user must have dismissed before this one can surface */
|
|
62
|
+
dismissed?: string[];
|
|
63
|
+
}
|
|
64
|
+
/** Runtime interaction state used to resolve dependency chains */
|
|
65
|
+
interface FeatureDependencyState {
|
|
66
|
+
/** IDs marked as seen */
|
|
67
|
+
seenIds?: ReadonlySet<string>;
|
|
68
|
+
/** IDs marked as clicked */
|
|
69
|
+
clickedIds?: ReadonlySet<string>;
|
|
70
|
+
/** IDs marked as dismissed */
|
|
71
|
+
dismissedIds?: ReadonlySet<string>;
|
|
72
|
+
}
|
|
73
|
+
/** Runtime context used by trigger evaluation */
|
|
74
|
+
interface TriggerContext {
|
|
75
|
+
/** Current app route/path */
|
|
76
|
+
path?: string;
|
|
77
|
+
/** Named events observed in this session */
|
|
78
|
+
events?: ReadonlySet<string>;
|
|
79
|
+
/** Named milestone flags reached in this session */
|
|
80
|
+
milestones?: ReadonlySet<string>;
|
|
81
|
+
/** Usage counters keyed by event/pattern name */
|
|
82
|
+
usage?: Record<string, number>;
|
|
83
|
+
/** Session elapsed time in milliseconds */
|
|
84
|
+
elapsedMs?: number;
|
|
85
|
+
/** Scroll completion percentage (0-100) */
|
|
86
|
+
scrollPercent?: number;
|
|
87
|
+
/** Optional additional trigger context */
|
|
88
|
+
metadata?: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
type FeatureTrigger = {
|
|
91
|
+
type: "page";
|
|
92
|
+
match: string | RegExp;
|
|
93
|
+
} | {
|
|
94
|
+
type: "usage";
|
|
95
|
+
event: string;
|
|
96
|
+
minActions?: number;
|
|
97
|
+
} | {
|
|
98
|
+
type: "time";
|
|
99
|
+
minSeconds: number;
|
|
100
|
+
} | {
|
|
101
|
+
type: "milestone";
|
|
102
|
+
event: string;
|
|
103
|
+
} | {
|
|
104
|
+
type: "frustration";
|
|
105
|
+
pattern: string;
|
|
106
|
+
threshold?: number;
|
|
107
|
+
} | {
|
|
108
|
+
type: "scroll";
|
|
109
|
+
minPercent?: number;
|
|
110
|
+
} | {
|
|
111
|
+
type: "custom";
|
|
112
|
+
evaluate: (context: TriggerContext) => boolean;
|
|
113
|
+
};
|
|
114
|
+
/** A single feature entry in the manifest */
|
|
115
|
+
interface FeatureEntry {
|
|
116
|
+
/** Unique identifier for the feature */
|
|
117
|
+
id: string;
|
|
118
|
+
/** Human-readable label (e.g. "Decision Journal") */
|
|
119
|
+
label: string;
|
|
120
|
+
/** Optional longer description (supports markdown in UI components) */
|
|
121
|
+
description?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Semantic version targeting.
|
|
124
|
+
* If provided as an object, requires `appVersion` to be supplied to the provider/helpers.
|
|
125
|
+
* - introduced: earliest app version that includes this feature
|
|
126
|
+
* - showNewUntil: stop showing "new" once appVersion reaches this
|
|
127
|
+
* - deprecatedAt: hide feature for app versions at or above this (optional safety)
|
|
128
|
+
* - showIn: range string, e.g. ">=2.5.0 <3.0.0"
|
|
129
|
+
*/
|
|
130
|
+
version?: string | {
|
|
131
|
+
introduced?: string;
|
|
132
|
+
showNewUntil?: string;
|
|
133
|
+
deprecatedAt?: string;
|
|
134
|
+
showIn?: string;
|
|
135
|
+
};
|
|
136
|
+
/** ISO date when this feature was released */
|
|
137
|
+
releasedAt: string;
|
|
138
|
+
/** ISO date after which the "new" badge should stop showing */
|
|
139
|
+
showNewUntil: string;
|
|
140
|
+
/** Optional key to match navigation items (e.g. "/journal", "settings") */
|
|
141
|
+
sidebarKey?: string;
|
|
142
|
+
/** Optional grouping category (e.g. "ai", "billing", "core") */
|
|
143
|
+
category?: string;
|
|
144
|
+
/** Optional product scope (`"*"`, `"askverdict"`, etc.) for multi-product manifests */
|
|
145
|
+
product?: string;
|
|
146
|
+
/** Optional URL to link to (e.g. docs page, changelog entry) */
|
|
147
|
+
url?: string;
|
|
148
|
+
/** Optional feature flag key; requires a flag bridge to evaluate */
|
|
149
|
+
flagKey?: string;
|
|
150
|
+
/** Entry type — determines default icon/color in UI components */
|
|
151
|
+
type?: FeatureType;
|
|
152
|
+
/** Priority level — critical entries get special treatment in UI */
|
|
153
|
+
priority?: FeaturePriority;
|
|
154
|
+
/** Optional image/screenshot URL */
|
|
155
|
+
image?: string;
|
|
156
|
+
/** Optional call-to-action button */
|
|
157
|
+
cta?: FeatureCTA;
|
|
158
|
+
/** ISO date — entry is hidden until this date (scheduled publishing) */
|
|
159
|
+
publishAt?: string;
|
|
160
|
+
/** Optional arbitrary metadata */
|
|
161
|
+
meta?: Record<string, unknown>;
|
|
162
|
+
/** A/B variants keyed by variant name (e.g. control, treatment_a) */
|
|
163
|
+
variants?: Record<string, FeatureVariant>;
|
|
164
|
+
/** Percentage split per variant (same order as variants object keys) */
|
|
165
|
+
variantSplit?: number[];
|
|
166
|
+
/** Audience targeting — if set, only matching users see this feature */
|
|
167
|
+
audience?: AudienceRule;
|
|
168
|
+
/** Dependency requirements (progressive disclosure sequencing) */
|
|
169
|
+
dependsOn?: FeatureDependencies;
|
|
170
|
+
/** Contextual trigger rule */
|
|
171
|
+
trigger?: FeatureTrigger;
|
|
172
|
+
}
|
|
173
|
+
/** The full feature manifest — an array of feature entries */
|
|
174
|
+
type FeatureManifest = readonly FeatureEntry[];
|
|
175
|
+
|
|
176
|
+
/** Options shared by both server helpers */
|
|
177
|
+
interface ServerOptions {
|
|
178
|
+
/** Current date override (defaults to `new Date()`) */
|
|
179
|
+
now?: Date;
|
|
180
|
+
/** User context for audience targeting */
|
|
181
|
+
userContext?: UserContext;
|
|
182
|
+
/** Custom audience matcher */
|
|
183
|
+
matchAudience?: AudienceMatchFn;
|
|
184
|
+
/** Current app semver string for version targeting */
|
|
185
|
+
appVersion?: string;
|
|
186
|
+
/** Dependency state for progressive disclosure */
|
|
187
|
+
dependencyState?: FeatureDependencyState;
|
|
188
|
+
/** Trigger context for contextual rules */
|
|
189
|
+
triggerContext?: TriggerContext;
|
|
190
|
+
/** Feature flag bridge for flag-gated entries */
|
|
191
|
+
flagBridge?: FeatureFlagBridge;
|
|
192
|
+
/** Product scope for multi-product manifests */
|
|
193
|
+
product?: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Server-side helper: get new features without browser storage.
|
|
197
|
+
*
|
|
198
|
+
* Creates a temporary MemoryAdapter pre-seeded with the provided dismissed IDs
|
|
199
|
+
* and calls the core `getNewFeatures` function. Safe to use in React Server
|
|
200
|
+
* Components, `generateStaticParams`, or any server context.
|
|
201
|
+
*
|
|
202
|
+
* @param manifest The feature manifest array.
|
|
203
|
+
* @param dismissedIds IDs already dismissed by this user (from your session/DB).
|
|
204
|
+
* @param options Optional targeting overrides.
|
|
205
|
+
*/
|
|
206
|
+
declare function getNewFeaturesServer(manifest: FeatureManifest, dismissedIds?: string[], options?: ServerOptions): FeatureEntry[];
|
|
207
|
+
/**
|
|
208
|
+
* Server-side helper: get new feature count.
|
|
209
|
+
*
|
|
210
|
+
* Same as `getNewFeaturesServer` but returns the count only.
|
|
211
|
+
*
|
|
212
|
+
* @param manifest The feature manifest array.
|
|
213
|
+
* @param dismissedIds IDs already dismissed by this user (from your session/DB).
|
|
214
|
+
* @param options Optional targeting overrides.
|
|
215
|
+
*/
|
|
216
|
+
declare function getNewCountServer(manifest: FeatureManifest, dismissedIds?: string[], options?: ServerOptions): number;
|
|
217
|
+
/** Props for FeatureDropScript */
|
|
218
|
+
interface FeatureDropScriptProps {
|
|
219
|
+
manifest: FeatureEntry[];
|
|
220
|
+
dismissedIds?: string[];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Injects manifest + dismissed IDs into the page as a JSON script tag.
|
|
224
|
+
*
|
|
225
|
+
* Place this in your root layout (server component) so the client-side
|
|
226
|
+
* `FeatureDropProvider` can read the data on first render without a
|
|
227
|
+
* flash-of-no-content (0 new features → real count).
|
|
228
|
+
*
|
|
229
|
+
* Client-side usage:
|
|
230
|
+
* ```ts
|
|
231
|
+
* const el = document.getElementById("__FEATUREDROP_DATA__");
|
|
232
|
+
* const { manifest, dismissedIds } = JSON.parse(el?.textContent ?? "{}");
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
declare function FeatureDropScript({ manifest, dismissedIds }: FeatureDropScriptProps): react.DetailedReactHTMLElement<{
|
|
236
|
+
id: string;
|
|
237
|
+
type: string;
|
|
238
|
+
dangerouslySetInnerHTML: {
|
|
239
|
+
__html: string;
|
|
240
|
+
};
|
|
241
|
+
}, HTMLElement>;
|
|
242
|
+
|
|
243
|
+
export { FeatureDropScript, type FeatureDropScriptProps, type ServerOptions, getNewCountServer, getNewFeaturesServer };
|