@launchdarkly/toolbar 2.1.4 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -18
- package/dist/angular/launchdarkly-toolbar.service.d.ts +104 -0
- package/dist/angular.cjs +439 -0
- package/dist/angular.cjs.map +1 -0
- package/dist/angular.d.ts +51 -0
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/js/816.js +56 -0
- package/dist/js/816.js.map +1 -0
- package/dist/js/96.js +4 -54
- package/dist/js/96.js.map +1 -1
- package/dist/js/angular.js +353 -0
- package/dist/js/angular.js.map +1 -0
- package/dist/js/react.js +2 -1
- package/dist/js/vue.js +34 -0
- package/dist/js/vue.js.map +1 -0
- package/dist/react.cjs +3 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/vue/useLaunchDarklyToolbar.d.ts +20 -0
- package/dist/vue.cjs +122 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.ts +24 -0
- package/package.json +70 -18
- /package/dist/{react → core}/lazyLoadToolbar.d.ts +0 -0
package/dist/angular.cjs
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
LaunchDarklyToolbarService: ()=>_LaunchDarklyToolbarService
|
|
28
|
+
});
|
|
29
|
+
const core_namespaceObject = require("@angular/core");
|
|
30
|
+
function getWindow() {
|
|
31
|
+
return window;
|
|
32
|
+
}
|
|
33
|
+
async function lazyLoadToolbar(signal, url) {
|
|
34
|
+
const existing = getWindow().LaunchDarklyToolbar;
|
|
35
|
+
if (existing) return Promise.resolve(existing);
|
|
36
|
+
await lazyLoad(signal, url);
|
|
37
|
+
const toolbarModule = getWindow().LaunchDarklyToolbar;
|
|
38
|
+
if (!toolbarModule) throw new Error(`Unable to detect LaunchDarklyToolbar global from ${url}`);
|
|
39
|
+
return toolbarModule;
|
|
40
|
+
}
|
|
41
|
+
async function lazyLoad(signal, url) {
|
|
42
|
+
const existingScript = document.querySelector(`script[src="${url}"]`);
|
|
43
|
+
if (existingScript) {
|
|
44
|
+
if ('true' === existingScript.dataset.loaded) return Promise.resolve();
|
|
45
|
+
return new Promise((resolve, reject)=>{
|
|
46
|
+
existingScript.addEventListener('load', ()=>{
|
|
47
|
+
if (!signal.aborted) {
|
|
48
|
+
existingScript.dataset.loaded = 'true';
|
|
49
|
+
resolve();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
existingScript.addEventListener('error', (error)=>{
|
|
53
|
+
if (!signal.aborted) reject(error);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const script = document.createElement("script");
|
|
58
|
+
script.src = url;
|
|
59
|
+
script.crossOrigin = 'anonymous';
|
|
60
|
+
script.referrerPolicy = 'origin';
|
|
61
|
+
const waitForLoad = new Promise((resolve, reject)=>{
|
|
62
|
+
script.addEventListener('load', ()=>{
|
|
63
|
+
if (!signal.aborted) {
|
|
64
|
+
script.dataset.loaded = 'true';
|
|
65
|
+
resolve();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
script.addEventListener('error', (error)=>{
|
|
69
|
+
if (!signal.aborted) reject(error);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
document.body.appendChild(script);
|
|
73
|
+
try {
|
|
74
|
+
await waitForLoad;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.log(error);
|
|
77
|
+
throw new Error(`Could not load LaunchDarkly developer toolbar bundle from ${url}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
var package_namespaceObject = {
|
|
81
|
+
rE: "2.2.0"
|
|
82
|
+
};
|
|
83
|
+
function applyDecs2203RFactory() {
|
|
84
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
85
|
+
return function(initializer) {
|
|
86
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
87
|
+
assertCallable(initializer, "An initializer");
|
|
88
|
+
initializers.push(initializer);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
92
|
+
var kindStr;
|
|
93
|
+
switch(kind){
|
|
94
|
+
case 1:
|
|
95
|
+
kindStr = "accessor";
|
|
96
|
+
break;
|
|
97
|
+
case 2:
|
|
98
|
+
kindStr = "method";
|
|
99
|
+
break;
|
|
100
|
+
case 3:
|
|
101
|
+
kindStr = "getter";
|
|
102
|
+
break;
|
|
103
|
+
case 4:
|
|
104
|
+
kindStr = "setter";
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
kindStr = "field";
|
|
108
|
+
}
|
|
109
|
+
var ctx = {
|
|
110
|
+
kind: kindStr,
|
|
111
|
+
name: isPrivate ? "#" + name : name,
|
|
112
|
+
static: isStatic,
|
|
113
|
+
private: isPrivate,
|
|
114
|
+
metadata: metadata
|
|
115
|
+
};
|
|
116
|
+
var decoratorFinishedRef = {
|
|
117
|
+
v: false
|
|
118
|
+
};
|
|
119
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
120
|
+
var get, set;
|
|
121
|
+
if (0 === kind) if (isPrivate) {
|
|
122
|
+
get = desc.get;
|
|
123
|
+
set = desc.set;
|
|
124
|
+
} else {
|
|
125
|
+
get = function() {
|
|
126
|
+
return this[name];
|
|
127
|
+
};
|
|
128
|
+
set = function(v) {
|
|
129
|
+
this[name] = v;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
else if (2 === kind) get = function() {
|
|
133
|
+
return desc.value;
|
|
134
|
+
};
|
|
135
|
+
else {
|
|
136
|
+
if (1 === kind || 3 === kind) get = function() {
|
|
137
|
+
return desc.get.call(this);
|
|
138
|
+
};
|
|
139
|
+
if (1 === kind || 4 === kind) set = function(v) {
|
|
140
|
+
desc.set.call(this, v);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
ctx.access = get && set ? {
|
|
144
|
+
get: get,
|
|
145
|
+
set: set
|
|
146
|
+
} : get ? {
|
|
147
|
+
get: get
|
|
148
|
+
} : {
|
|
149
|
+
set: set
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
return dec(value, ctx);
|
|
153
|
+
} finally{
|
|
154
|
+
decoratorFinishedRef.v = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
158
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
159
|
+
}
|
|
160
|
+
function assertCallable(fn, hint) {
|
|
161
|
+
if ("function" != typeof fn) throw new TypeError(hint + " must be a function");
|
|
162
|
+
}
|
|
163
|
+
function assertValidReturnValue(kind, value) {
|
|
164
|
+
var type = typeof value;
|
|
165
|
+
if (1 === kind) {
|
|
166
|
+
if ("object" !== type || null === value) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
167
|
+
if (void 0 !== value.get) assertCallable(value.get, "accessor.get");
|
|
168
|
+
if (void 0 !== value.set) assertCallable(value.set, "accessor.set");
|
|
169
|
+
if (void 0 !== value.init) assertCallable(value.init, "accessor.init");
|
|
170
|
+
} else if ("function" !== type) {
|
|
171
|
+
var hint;
|
|
172
|
+
hint = 0 === kind ? "field" : 10 === kind ? "class" : "method";
|
|
173
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
177
|
+
var decs = decInfo[0];
|
|
178
|
+
var desc, init, value;
|
|
179
|
+
if (isPrivate) desc = 0 === kind || 1 === kind ? {
|
|
180
|
+
get: decInfo[3],
|
|
181
|
+
set: decInfo[4]
|
|
182
|
+
} : 3 === kind ? {
|
|
183
|
+
get: decInfo[3]
|
|
184
|
+
} : 4 === kind ? {
|
|
185
|
+
set: decInfo[3]
|
|
186
|
+
} : {
|
|
187
|
+
value: decInfo[3]
|
|
188
|
+
};
|
|
189
|
+
else if (0 !== kind) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
190
|
+
if (1 === kind) value = {
|
|
191
|
+
get: desc.get,
|
|
192
|
+
set: desc.set
|
|
193
|
+
};
|
|
194
|
+
else if (2 === kind) value = desc.value;
|
|
195
|
+
else if (3 === kind) value = desc.get;
|
|
196
|
+
else if (4 === kind) value = desc.set;
|
|
197
|
+
var newValue, get, set;
|
|
198
|
+
if ("function" == typeof decs) {
|
|
199
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
200
|
+
if (void 0 !== newValue) {
|
|
201
|
+
assertValidReturnValue(kind, newValue);
|
|
202
|
+
if (0 === kind) init = newValue;
|
|
203
|
+
else if (1 === kind) {
|
|
204
|
+
init = newValue.init;
|
|
205
|
+
get = newValue.get || value.get;
|
|
206
|
+
set = newValue.set || value.set;
|
|
207
|
+
value = {
|
|
208
|
+
get: get,
|
|
209
|
+
set: set
|
|
210
|
+
};
|
|
211
|
+
} else value = newValue;
|
|
212
|
+
}
|
|
213
|
+
} else for(var i = decs.length - 1; i >= 0; i--){
|
|
214
|
+
var dec = decs[i];
|
|
215
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
216
|
+
if (void 0 !== newValue) {
|
|
217
|
+
assertValidReturnValue(kind, newValue);
|
|
218
|
+
var newInit;
|
|
219
|
+
if (0 === kind) newInit = newValue;
|
|
220
|
+
else if (1 === kind) {
|
|
221
|
+
newInit = newValue.init;
|
|
222
|
+
get = newValue.get || value.get;
|
|
223
|
+
set = newValue.set || value.set;
|
|
224
|
+
value = {
|
|
225
|
+
get: get,
|
|
226
|
+
set: set
|
|
227
|
+
};
|
|
228
|
+
} else value = newValue;
|
|
229
|
+
if (void 0 !== newInit) if (void 0 === init) init = newInit;
|
|
230
|
+
else if ("function" == typeof init) init = [
|
|
231
|
+
init,
|
|
232
|
+
newInit
|
|
233
|
+
];
|
|
234
|
+
else init.push(newInit);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (0 === kind || 1 === kind) {
|
|
238
|
+
if (void 0 === init) init = function(instance, init) {
|
|
239
|
+
return init;
|
|
240
|
+
};
|
|
241
|
+
else if ("function" != typeof init) {
|
|
242
|
+
var ownInitializers = init;
|
|
243
|
+
init = function(instance, init) {
|
|
244
|
+
var value = init;
|
|
245
|
+
for(var i = 0; i < ownInitializers.length; i++)value = ownInitializers[i].call(instance, value);
|
|
246
|
+
return value;
|
|
247
|
+
};
|
|
248
|
+
} else {
|
|
249
|
+
var originalInitializer = init;
|
|
250
|
+
init = function(instance, init) {
|
|
251
|
+
return originalInitializer.call(instance, init);
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
ret.push(init);
|
|
255
|
+
}
|
|
256
|
+
if (0 !== kind) {
|
|
257
|
+
if (1 === kind) {
|
|
258
|
+
desc.get = value.get;
|
|
259
|
+
desc.set = value.set;
|
|
260
|
+
} else if (2 === kind) desc.value = value;
|
|
261
|
+
else if (3 === kind) desc.get = value;
|
|
262
|
+
else if (4 === kind) desc.set = value;
|
|
263
|
+
if (isPrivate) if (1 === kind) {
|
|
264
|
+
ret.push(function(instance, args) {
|
|
265
|
+
return value.get.call(instance, args);
|
|
266
|
+
});
|
|
267
|
+
ret.push(function(instance, args) {
|
|
268
|
+
return value.set.call(instance, args);
|
|
269
|
+
});
|
|
270
|
+
} else if (2 === kind) ret.push(value);
|
|
271
|
+
else ret.push(function(instance, args) {
|
|
272
|
+
return value.call(instance, args);
|
|
273
|
+
});
|
|
274
|
+
else Object.defineProperty(base, name, desc);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
278
|
+
var ret = [];
|
|
279
|
+
var protoInitializers;
|
|
280
|
+
var staticInitializers;
|
|
281
|
+
var existingProtoNonFields = new Map();
|
|
282
|
+
var existingStaticNonFields = new Map();
|
|
283
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
284
|
+
var decInfo = decInfos[i];
|
|
285
|
+
if (Array.isArray(decInfo)) {
|
|
286
|
+
var kind = decInfo[1];
|
|
287
|
+
var name = decInfo[2];
|
|
288
|
+
var isPrivate = decInfo.length > 3;
|
|
289
|
+
var isStatic = kind >= 5;
|
|
290
|
+
var base;
|
|
291
|
+
var initializers;
|
|
292
|
+
if (isStatic) {
|
|
293
|
+
base = Class;
|
|
294
|
+
kind -= 5;
|
|
295
|
+
staticInitializers = staticInitializers || [];
|
|
296
|
+
initializers = staticInitializers;
|
|
297
|
+
} else {
|
|
298
|
+
base = Class.prototype;
|
|
299
|
+
protoInitializers = protoInitializers || [];
|
|
300
|
+
initializers = protoInitializers;
|
|
301
|
+
}
|
|
302
|
+
if (0 !== kind && !isPrivate) {
|
|
303
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
304
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
305
|
+
if (true === existingKind || 3 === existingKind && 4 !== kind || 4 === existingKind && 3 !== kind) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
306
|
+
if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
307
|
+
else existingNonFields.set(name, true);
|
|
308
|
+
}
|
|
309
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
pushInitializers(ret, protoInitializers);
|
|
313
|
+
pushInitializers(ret, staticInitializers);
|
|
314
|
+
return ret;
|
|
315
|
+
}
|
|
316
|
+
function pushInitializers(ret, initializers) {
|
|
317
|
+
if (initializers) ret.push(function(instance) {
|
|
318
|
+
for(var i = 0; i < initializers.length; i++)initializers[i].call(instance);
|
|
319
|
+
return instance;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
323
|
+
if (classDecs.length > 0) {
|
|
324
|
+
var initializers = [];
|
|
325
|
+
var newClass = targetClass;
|
|
326
|
+
var name = targetClass.name;
|
|
327
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
328
|
+
var decoratorFinishedRef = {
|
|
329
|
+
v: false
|
|
330
|
+
};
|
|
331
|
+
try {
|
|
332
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
333
|
+
kind: "class",
|
|
334
|
+
name: name,
|
|
335
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
336
|
+
metadata
|
|
337
|
+
});
|
|
338
|
+
} finally{
|
|
339
|
+
decoratorFinishedRef.v = true;
|
|
340
|
+
}
|
|
341
|
+
if (void 0 !== nextNewClass) {
|
|
342
|
+
assertValidReturnValue(10, nextNewClass);
|
|
343
|
+
newClass = nextNewClass;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return [
|
|
347
|
+
defineMetadata(newClass, metadata),
|
|
348
|
+
function() {
|
|
349
|
+
for(var i = 0; i < initializers.length; i++)initializers[i].call(newClass);
|
|
350
|
+
}
|
|
351
|
+
];
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function defineMetadata(Class, metadata) {
|
|
355
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
356
|
+
configurable: true,
|
|
357
|
+
enumerable: true,
|
|
358
|
+
value: metadata
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return function(targetClass, memberDecs, classDecs, parentClass) {
|
|
362
|
+
if (void 0 !== parentClass) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
363
|
+
var metadata = Object.create(void 0 === parentMetadata ? null : parentMetadata);
|
|
364
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
365
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
366
|
+
return {
|
|
367
|
+
e: e,
|
|
368
|
+
get c () {
|
|
369
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
375
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
376
|
+
}
|
|
377
|
+
var _dec, _initClass;
|
|
378
|
+
let _LaunchDarklyToolbarService;
|
|
379
|
+
_dec = (0, core_namespaceObject.Injectable)({
|
|
380
|
+
providedIn: 'root'
|
|
381
|
+
});
|
|
382
|
+
class LaunchDarklyToolbarService {
|
|
383
|
+
static{
|
|
384
|
+
({ c: [_LaunchDarklyToolbarService, _initClass] } = _apply_decs_2203_r(this, [], [
|
|
385
|
+
_dec
|
|
386
|
+
]));
|
|
387
|
+
}
|
|
388
|
+
cleanup;
|
|
389
|
+
abortController;
|
|
390
|
+
initialized = false;
|
|
391
|
+
async initialize(config) {
|
|
392
|
+
if (this.initialized) return void console.warn('[LaunchDarkly Toolbar] Already initialized. Call destroy() first to reinitialize.');
|
|
393
|
+
const { toolbarBundleUrl, enabled, ...initConfig } = config;
|
|
394
|
+
if (false === enabled) return;
|
|
395
|
+
this.initialized = true;
|
|
396
|
+
this.abortController = new AbortController();
|
|
397
|
+
const url = toolbarBundleUrl ?? this.versionToCdn(package_namespaceObject.rE);
|
|
398
|
+
try {
|
|
399
|
+
const toolbar = await lazyLoadToolbar(this.abortController.signal, url);
|
|
400
|
+
this.cleanup = toolbar.init(initConfig);
|
|
401
|
+
} catch (err) {
|
|
402
|
+
console.error('[LaunchDarkly Toolbar] Failed to initialize:', err);
|
|
403
|
+
this.initialized = false;
|
|
404
|
+
throw err;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
ngOnDestroy() {
|
|
408
|
+
this.destroy();
|
|
409
|
+
}
|
|
410
|
+
destroy() {
|
|
411
|
+
if (this.abortController) {
|
|
412
|
+
this.abortController.abort();
|
|
413
|
+
this.abortController = void 0;
|
|
414
|
+
}
|
|
415
|
+
if (this.cleanup) {
|
|
416
|
+
this.cleanup();
|
|
417
|
+
this.cleanup = void 0;
|
|
418
|
+
}
|
|
419
|
+
this.initialized = false;
|
|
420
|
+
}
|
|
421
|
+
isInitialized() {
|
|
422
|
+
return this.initialized;
|
|
423
|
+
}
|
|
424
|
+
versionToCdn(version = 'latest') {
|
|
425
|
+
return `https://unpkg.com/@launchdarkly/toolbar@${version}/cdn/toolbar.min.js`;
|
|
426
|
+
}
|
|
427
|
+
static{
|
|
428
|
+
_initClass();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
exports.LaunchDarklyToolbarService = __webpack_exports__.LaunchDarklyToolbarService;
|
|
432
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
433
|
+
"LaunchDarklyToolbarService"
|
|
434
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
435
|
+
Object.defineProperty(exports, '__esModule', {
|
|
436
|
+
value: true
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
//# sourceMappingURL=angular.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular.cjs","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../src/core/lazyLoadToolbar.ts","../src/angular/launchdarkly-toolbar.service.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { LaunchDarklyToolbar } from '../index';\n\ninterface WindowWithMaybeToolbar extends Window {\n LaunchDarklyToolbar?: LaunchDarklyToolbar;\n}\n\nfunction getWindow(): WindowWithMaybeToolbar {\n return window;\n}\n\nexport default async function lazyLoadToolbar(signal: AbortSignal, url: string): Promise<LaunchDarklyToolbar> {\n const existing = getWindow().LaunchDarklyToolbar;\n\n if (existing) {\n return Promise.resolve(existing);\n }\n\n await lazyLoad(signal, url);\n\n const toolbarModule = getWindow().LaunchDarklyToolbar;\n if (!toolbarModule) {\n throw new Error(`Unable to detect LaunchDarklyToolbar global from ${url}`);\n }\n\n return toolbarModule;\n}\n\nasync function lazyLoad(signal: AbortSignal, url: string): Promise<void> {\n // Check if a script with this URL already exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`) as HTMLScriptElement | null;\n\n if (existingScript) {\n // If script already exists and is loaded, return immediately\n if (existingScript.dataset.loaded === 'true') {\n return Promise.resolve();\n }\n\n // If script exists but is still loading, wait for it to complete\n return new Promise<void>((resolve, reject) => {\n existingScript.addEventListener('load', () => {\n if (!signal.aborted) {\n existingScript.dataset.loaded = 'true';\n resolve();\n }\n });\n existingScript.addEventListener('error', (error) => {\n if (!signal.aborted) {\n reject(error);\n }\n });\n });\n }\n\n // Create new script element\n const script = document.createElement('script');\n script.src = url;\n script.crossOrigin = 'anonymous';\n script.referrerPolicy = 'origin';\n\n const waitForLoad = new Promise<void>((resolve, reject) => {\n script.addEventListener('load', () => {\n if (!signal.aborted) {\n script.dataset.loaded = 'true';\n resolve();\n }\n });\n script.addEventListener('error', (error) => {\n if (!signal.aborted) {\n reject(error);\n }\n });\n });\n\n document.body.appendChild(script);\n\n try {\n await waitForLoad;\n } catch (error) {\n console.log(error);\n throw new Error(`Could not load LaunchDarkly developer toolbar bundle from ${url}`);\n }\n}\n","import { Injectable, OnDestroy } from '@angular/core';\n\nimport lazyLoadToolbar from '../core/lazyLoadToolbar';\nimport type { InitializationConfig } from '../types';\nimport packageJson from '../../package.json';\n\n/**\n * Configuration options for the LaunchDarkly Toolbar service.\n * Extends the base InitializationConfig with Angular-specific options.\n */\nexport interface LaunchDarklyToolbarConfig extends InitializationConfig {\n /**\n * URL to load the toolbar bundle from.\n * Use this when developing the toolbar itself locally.\n *\n * Example: `'http://localhost:5764/toolbar.min.js'`\n *\n * Default: CDN URL based on package version\n */\n toolbarBundleUrl?: string;\n\n /**\n * Whether the toolbar should be loaded and displayed.\n *\n * Default: `true`\n */\n enabled?: boolean;\n}\n\n/**\n * Injectable service for managing the LaunchDarkly Developer Toolbar in Angular applications.\n *\n * This service handles the lifecycle of the toolbar, including initialization,\n * lazy loading, and cleanup. It can be injected into any Angular component or service.\n *\n * @example\n * ```typescript\n * import { Component, OnInit } from '@angular/core';\n * import { LaunchDarklyToolbarService } from '@launchdarkly/toolbar/angular';\n * import { FlagOverridePlugin, EventInterceptionPlugin } from '@launchdarkly/toolbar/plugins';\n *\n * @Component({\n * selector: 'app-root',\n * standalone: true,\n * providers: [LaunchDarklyToolbarService],\n * template: '<router-outlet />'\n * })\n * export class AppComponent implements OnInit {\n * private flagOverridePlugin = new FlagOverridePlugin();\n * private eventInterceptionPlugin = new EventInterceptionPlugin();\n *\n * constructor(private toolbarService: LaunchDarklyToolbarService) {}\n *\n * ngOnInit() {\n * this.toolbarService.initialize({\n * flagOverridePlugin: this.flagOverridePlugin,\n * eventInterceptionPlugin: this.eventInterceptionPlugin,\n * enabled: true,\n * position: 'bottom-right'\n * });\n * }\n * }\n * ```\n */\n@Injectable({\n providedIn: 'root', // Singleton service across the application\n})\nexport default class LaunchDarklyToolbarService implements OnDestroy {\n private cleanup?: () => void;\n private abortController?: AbortController;\n private initialized = false;\n\n /**\n * Initializes the LaunchDarkly Toolbar with the provided configuration.\n *\n * This method lazy-loads the toolbar bundle from either a custom URL or the CDN,\n * then initializes it with the provided configuration.\n *\n * @param config - Configuration options for the toolbar\n * @returns Promise that resolves when initialization is complete\n *\n * @throws {Error} If initialization fails or toolbar bundle cannot be loaded\n */\n async initialize(config: LaunchDarklyToolbarConfig): Promise<void> {\n if (this.initialized) {\n console.warn('[LaunchDarkly Toolbar] Already initialized. Call destroy() first to reinitialize.');\n return;\n }\n\n const { toolbarBundleUrl, enabled, ...initConfig } = config;\n\n if (enabled === false) {\n return;\n }\n\n this.initialized = true;\n this.abortController = new AbortController();\n const url = toolbarBundleUrl ?? this.versionToCdn(packageJson.version);\n\n try {\n const toolbar = await lazyLoadToolbar(this.abortController.signal, url);\n this.cleanup = toolbar.init(initConfig);\n } catch (err) {\n console.error('[LaunchDarkly Toolbar] Failed to initialize:', err);\n this.initialized = false;\n throw err;\n }\n }\n\n /**\n * Angular lifecycle hook called when the service is destroyed.\n * Automatically cleans up the toolbar.\n */\n ngOnDestroy(): void {\n this.destroy();\n }\n\n /**\n * Manually destroys the toolbar and cleans up resources.\n *\n * This method:\n * - Aborts any pending lazy-load requests\n * - Calls the toolbar's cleanup function\n * - Resets the initialized state\n *\n * After calling destroy(), you can call initialize() again to reinitialize.\n */\n destroy(): void {\n if (this.abortController) {\n this.abortController.abort();\n this.abortController = undefined;\n }\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = undefined;\n }\n this.initialized = false;\n }\n\n /**\n * Checks if the toolbar has been initialized.\n *\n * @returns true if the toolbar is currently initialized, false otherwise\n */\n isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Generates the CDN URL for a specific toolbar version.\n *\n * @param version - Toolbar version (defaults to 'latest')\n * @returns CDN URL for the toolbar bundle\n */\n private versionToCdn(version = 'latest'): string {\n return `https://unpkg.com/@launchdarkly/toolbar@${version}/cdn/toolbar.min.js`;\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","getWindow","window","lazyLoadToolbar","signal","url","existing","Promise","lazyLoad","toolbarModule","Error","existingScript","document","resolve","reject","error","script","waitForLoad","console","Injectable","_LaunchDarklyToolbarService","config","toolbarBundleUrl","enabled","initConfig","AbortController","packageJson","toolbar","err","undefined","version"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;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C,gDAAgDU;YAC9D,IAAI,CAAC,WAAW,GAAG;YACnB,MAAMA;QACR;IACF;IAMA,cAAoB;QAClB,IAAI,CAAC,OAAO;IACd;IAYA,UAAgB;QACd,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,KAAK;YAC1B,IAAI,CAAC,eAAe,GAAGC;QACzB;QACA,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,OAAO,GAAGA;QACjB;QACA,IAAI,CAAC,WAAW,GAAG;IACrB;IAOA,gBAAyB;QACvB,OAAO,IAAI,CAAC,WAAW;IACzB;IAQQ,aAAaC,UAAU,QAAQ,EAAU;QAC/C,OAAO,CAAC,wCAAwC,EAAEA,QAAQ,mBAAmB,CAAC;IAChF;;;;AACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular-specific exports for the LaunchDarkly Toolbar
|
|
3
|
+
*
|
|
4
|
+
* This entry point provides an Angular service for integrating
|
|
5
|
+
* the toolbar with Angular applications (14+).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Standalone Component (Angular 14+)
|
|
10
|
+
* import { Component, OnInit } from '@angular/core';
|
|
11
|
+
* import { LaunchDarklyToolbarService } from '@launchdarkly/toolbar/angular';
|
|
12
|
+
* import { FlagOverridePlugin, EventInterceptionPlugin } from '@launchdarkly/toolbar/plugins';
|
|
13
|
+
*
|
|
14
|
+
* @Component({
|
|
15
|
+
* selector: 'app-root',
|
|
16
|
+
* standalone: true,
|
|
17
|
+
* providers: [LaunchDarklyToolbarService],
|
|
18
|
+
* template: '<router-outlet />'
|
|
19
|
+
* })
|
|
20
|
+
* export class AppComponent implements OnInit {
|
|
21
|
+
* private flagOverridePlugin = new FlagOverridePlugin();
|
|
22
|
+
* private eventInterceptionPlugin = new EventInterceptionPlugin();
|
|
23
|
+
*
|
|
24
|
+
* constructor(private toolbarService: LaunchDarklyToolbarService) {}
|
|
25
|
+
*
|
|
26
|
+
* ngOnInit() {
|
|
27
|
+
* this.toolbarService.initialize({
|
|
28
|
+
* flagOverridePlugin: this.flagOverridePlugin,
|
|
29
|
+
* eventInterceptionPlugin: this.eventInterceptionPlugin,
|
|
30
|
+
* enabled: true,
|
|
31
|
+
* position: 'bottom-right'
|
|
32
|
+
* });
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Module-based Component (Traditional)
|
|
40
|
+
* import { NgModule } from '@angular/core';
|
|
41
|
+
* import { LaunchDarklyToolbarService } from '@launchdarkly/toolbar/angular';
|
|
42
|
+
*
|
|
43
|
+
* @NgModule({
|
|
44
|
+
* providers: [LaunchDarklyToolbarService],
|
|
45
|
+
* // ... other module config
|
|
46
|
+
* })
|
|
47
|
+
* export class AppModule {}
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export { default as LaunchDarklyToolbarService } from './angular/launchdarkly-toolbar.service';
|
|
51
|
+
export type { LaunchDarklyToolbarConfig } from './angular/launchdarkly-toolbar.service';
|
package/dist/index.cjs
CHANGED
|
@@ -553,7 +553,7 @@ async function lazyLoad(signal, url) {
|
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
var package_namespaceObject = {
|
|
556
|
-
rE: "2.
|
|
556
|
+
rE: "2.2.0"
|
|
557
557
|
};
|
|
558
558
|
function useLaunchDarklyToolbar(args) {
|
|
559
559
|
const { toolbarBundleUrl, enabled, ...initConfig } = args;
|
|
@@ -573,6 +573,8 @@ function useLaunchDarklyToolbar(args) {
|
|
|
573
573
|
lazyLoadToolbar(controller.signal, url).then((importedToolbar)=>{
|
|
574
574
|
if (null === configRef.current) return;
|
|
575
575
|
cleanup = importedToolbar.init(configRef.current);
|
|
576
|
+
}).catch((error)=>{
|
|
577
|
+
console.error('[LaunchDarkly Toolbar] Failed to initialize:', error);
|
|
576
578
|
});
|
|
577
579
|
return ()=>{
|
|
578
580
|
controller.abort();
|