@unseenco/theatre-gsap 0.4.1 → 0.4.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.
- package/dist/index.js +2410 -29
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +2403 -28
- package/dist/index.mjs.map +4 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -22,34 +22,2385 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
attachGsapSequenceBridge: () => attachGsapSequenceBridge,
|
|
24
24
|
configureTheatreGsap: () => configureTheatreGsap,
|
|
25
|
-
getAnimationEntry: () =>
|
|
25
|
+
getAnimationEntry: () => getAnimationEntry2,
|
|
26
26
|
getAnimationEntryById: () => getAnimationEntryById,
|
|
27
|
-
getAnimationEntryForSheetObject: () =>
|
|
27
|
+
getAnimationEntryForSheetObject: () => getAnimationEntryForSheetObject2,
|
|
28
28
|
getTheatreGsapConfig: () => getTheatreGsapConfig,
|
|
29
|
-
listAnimationEntries: () =>
|
|
29
|
+
listAnimationEntries: () => listAnimationEntries2,
|
|
30
30
|
registerGsapAnimation: () => registerGsapAnimation
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(src_exports);
|
|
33
33
|
|
|
34
34
|
// src/registerGsapAnimation.ts
|
|
35
35
|
var import_privateAPIs = require("@unseenco/theatre-core/privateAPIs");
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
// ../../theatre/shared/src/utils/errors.ts
|
|
38
|
+
var TheatreError = class extends Error {
|
|
39
|
+
};
|
|
40
|
+
var InvalidArgumentError = class extends TheatreError {
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// ../../theatre/shared/src/_logger/logger.ts
|
|
44
|
+
function lazy(f) {
|
|
45
|
+
return function lazyLogIncluded(m, lazyArg) {
|
|
46
|
+
return f(m, lazyArg());
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
var LEVELS = {
|
|
50
|
+
_hmm: getLogMeta(524 /* _HMM */),
|
|
51
|
+
_todo: getLogMeta(522 /* _TODO */),
|
|
52
|
+
_error: getLogMeta(521 /* _ERROR */),
|
|
53
|
+
errorDev: getLogMeta(529 /* ERROR_DEV */),
|
|
54
|
+
errorPublic: getLogMeta(545 /* ERROR_PUBLIC */),
|
|
55
|
+
_kapow: getLogMeta(268 /* _KAPOW */),
|
|
56
|
+
_warn: getLogMeta(265 /* _WARN */),
|
|
57
|
+
warnDev: getLogMeta(273 /* WARN_DEV */),
|
|
58
|
+
warnPublic: getLogMeta(289 /* WARN_PUBLIC */),
|
|
59
|
+
_debug: getLogMeta(137 /* _DEBUG */),
|
|
60
|
+
debugDev: getLogMeta(145 /* DEBUG_DEV */),
|
|
61
|
+
_trace: getLogMeta(73 /* _TRACE */),
|
|
62
|
+
traceDev: getLogMeta(81 /* TRACE_DEV */)
|
|
63
|
+
};
|
|
64
|
+
function getLogMeta(level) {
|
|
65
|
+
return Object.freeze({
|
|
66
|
+
audience: hasFlag(level, 8 /* INTERNAL */) ? "internal" : hasFlag(level, 16 /* DEV */) ? "dev" : "public",
|
|
67
|
+
category: hasFlag(level, 4 /* TROUBLESHOOTING */) ? "troubleshooting" : hasFlag(level, 2 /* TODO */) ? "todo" : "general",
|
|
68
|
+
level: (
|
|
69
|
+
// I think this is equivalent... but I'm not using it until we have tests.
|
|
70
|
+
// this code won't really impact performance much anyway, since it's just computed once
|
|
71
|
+
// up front.
|
|
72
|
+
// level &
|
|
73
|
+
// (TheatreLoggerLevel.TRACE |
|
|
74
|
+
// TheatreLoggerLevel.DEBUG |
|
|
75
|
+
// TheatreLoggerLevel.WARN |
|
|
76
|
+
// TheatreLoggerLevel.ERROR),
|
|
77
|
+
hasFlag(level, 512 /* ERROR */) ? 512 /* ERROR */ : hasFlag(level, 256 /* WARN */) ? 256 /* WARN */ : hasFlag(level, 128 /* DEBUG */) ? 128 /* DEBUG */ : (
|
|
78
|
+
// no other option
|
|
79
|
+
64 /* TRACE */
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function hasFlag(level, flag) {
|
|
85
|
+
return (level & flag) === flag;
|
|
86
|
+
}
|
|
87
|
+
function shouldLog(includes, level) {
|
|
88
|
+
return ((level & 32 /* PUBLIC */) === 32 /* PUBLIC */ ? true : (level & 16 /* DEV */) === 16 /* DEV */ ? includes.dev : (level & 8 /* INTERNAL */) === 8 /* INTERNAL */ ? includes.internal : false) && includes.min <= level;
|
|
89
|
+
}
|
|
90
|
+
var DEFAULTS = {
|
|
91
|
+
loggingConsoleStyle: true,
|
|
92
|
+
loggerConsoleStyle: true,
|
|
93
|
+
includes: Object.freeze({
|
|
94
|
+
internal: false,
|
|
95
|
+
dev: false,
|
|
96
|
+
min: 256 /* WARN */
|
|
97
|
+
}),
|
|
98
|
+
filtered: function defaultFiltered() {
|
|
99
|
+
},
|
|
100
|
+
include: function defaultInclude() {
|
|
101
|
+
return {};
|
|
102
|
+
},
|
|
103
|
+
create: null,
|
|
104
|
+
creatExt: null,
|
|
105
|
+
named(parent, name, key) {
|
|
106
|
+
return this.create({
|
|
107
|
+
names: [...parent.names, { name, key }]
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
style: {
|
|
111
|
+
bold: void 0,
|
|
112
|
+
// /Service$/
|
|
113
|
+
italic: void 0,
|
|
114
|
+
// /Model$/
|
|
115
|
+
cssMemo: /* @__PURE__ */ new Map([
|
|
116
|
+
// handle empty names so we don't have to check for
|
|
117
|
+
// name.length > 0 during this.css('')
|
|
118
|
+
["", ""]
|
|
119
|
+
// bring a specific override
|
|
120
|
+
// ["Marker", "color:#aea9ff;font-size:0.75em;text-transform:uppercase"]
|
|
121
|
+
]),
|
|
122
|
+
collapseOnRE: /[a-z- ]+/g,
|
|
123
|
+
color: void 0,
|
|
124
|
+
// create collapsed name
|
|
125
|
+
// insert collapsed name into cssMemo with original's style
|
|
126
|
+
collapsed(name) {
|
|
127
|
+
if (name.length < 5)
|
|
128
|
+
return name;
|
|
129
|
+
const collapsed = name.replace(this.collapseOnRE, "");
|
|
130
|
+
if (!this.cssMemo.has(collapsed)) {
|
|
131
|
+
this.cssMemo.set(collapsed, this.css(name));
|
|
132
|
+
}
|
|
133
|
+
return collapsed;
|
|
134
|
+
},
|
|
135
|
+
css(name) {
|
|
136
|
+
const found = this.cssMemo.get(name);
|
|
137
|
+
if (found)
|
|
138
|
+
return found;
|
|
139
|
+
let css = `color:${this.color?.(name) ?? `hsl(${(name.charCodeAt(0) + name.charCodeAt(name.length - 1)) % 360}, 100%, 60%)`}`;
|
|
140
|
+
if (this.bold?.test(name)) {
|
|
141
|
+
css += ";font-weight:600";
|
|
142
|
+
}
|
|
143
|
+
if (this.italic?.test(name)) {
|
|
144
|
+
css += ";font-style:italic";
|
|
145
|
+
}
|
|
146
|
+
this.cssMemo.set(name, css);
|
|
147
|
+
return css;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
function createTheatreInternalLogger(useConsole = console, _options = {}) {
|
|
152
|
+
const ref2 = { ...DEFAULTS, includes: { ...DEFAULTS.includes } };
|
|
153
|
+
const createConsole = {
|
|
154
|
+
styled: createConsoleLoggerStyled.bind(ref2, useConsole),
|
|
155
|
+
noStyle: createConsoleLoggerNoStyle.bind(ref2, useConsole)
|
|
156
|
+
};
|
|
157
|
+
const createExtBound = createExtLogger.bind(ref2);
|
|
158
|
+
function getConCreate() {
|
|
159
|
+
return ref2.loggingConsoleStyle && ref2.loggerConsoleStyle ? createConsole.styled : createConsole.noStyle;
|
|
160
|
+
}
|
|
161
|
+
ref2.create = getConCreate();
|
|
162
|
+
return {
|
|
163
|
+
configureLogger(config) {
|
|
164
|
+
if (config === "console") {
|
|
165
|
+
ref2.loggerConsoleStyle = DEFAULTS.loggerConsoleStyle;
|
|
166
|
+
ref2.create = getConCreate();
|
|
167
|
+
} else if (config.type === "console") {
|
|
168
|
+
ref2.loggerConsoleStyle = config.style ?? DEFAULTS.loggerConsoleStyle;
|
|
169
|
+
ref2.create = getConCreate();
|
|
170
|
+
} else if (config.type === "keyed") {
|
|
171
|
+
ref2.creatExt = (source2) => config.keyed(source2.names);
|
|
172
|
+
ref2.create = createExtBound;
|
|
173
|
+
} else if (config.type === "named") {
|
|
174
|
+
ref2.creatExt = configNamedToKeyed.bind(null, config.named);
|
|
175
|
+
ref2.create = createExtBound;
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
configureLogging(config) {
|
|
179
|
+
ref2.includes.dev = config.dev ?? DEFAULTS.includes.dev;
|
|
180
|
+
ref2.includes.internal = config.internal ?? DEFAULTS.includes.internal;
|
|
181
|
+
ref2.includes.min = config.min ?? DEFAULTS.includes.min;
|
|
182
|
+
ref2.include = config.include ?? DEFAULTS.include;
|
|
183
|
+
ref2.loggingConsoleStyle = config.consoleStyle ?? DEFAULTS.loggingConsoleStyle;
|
|
184
|
+
ref2.create = getConCreate();
|
|
185
|
+
},
|
|
186
|
+
getLogger() {
|
|
187
|
+
return ref2.create({ names: [] });
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function configNamedToKeyed(namedFn, source2) {
|
|
192
|
+
const names = [];
|
|
193
|
+
for (let { name, key } of source2.names) {
|
|
194
|
+
names.push(key == null ? name : `${name} (${key})`);
|
|
195
|
+
}
|
|
196
|
+
return namedFn(names);
|
|
197
|
+
}
|
|
198
|
+
function createExtLogger(source2) {
|
|
199
|
+
const includes = { ...this.includes, ...this.include(source2) };
|
|
200
|
+
const f = this.filtered;
|
|
201
|
+
const named = this.named.bind(this, source2);
|
|
202
|
+
const ext = this.creatExt(source2);
|
|
203
|
+
const _HMM = shouldLog(includes, 524 /* _HMM */);
|
|
204
|
+
const _TODO = shouldLog(includes, 522 /* _TODO */);
|
|
205
|
+
const _ERROR = shouldLog(includes, 521 /* _ERROR */);
|
|
206
|
+
const ERROR_DEV = shouldLog(includes, 529 /* ERROR_DEV */);
|
|
207
|
+
const ERROR_PUBLIC = shouldLog(includes, 545 /* ERROR_PUBLIC */);
|
|
208
|
+
const _WARN = shouldLog(includes, 265 /* _WARN */);
|
|
209
|
+
const _KAPOW = shouldLog(includes, 268 /* _KAPOW */);
|
|
210
|
+
const WARN_DEV = shouldLog(includes, 273 /* WARN_DEV */);
|
|
211
|
+
const WARN_PUBLIC = shouldLog(includes, 289 /* WARN_PUBLIC */);
|
|
212
|
+
const _DEBUG = shouldLog(includes, 137 /* _DEBUG */);
|
|
213
|
+
const DEBUG_DEV = shouldLog(includes, 145 /* DEBUG_DEV */);
|
|
214
|
+
const _TRACE = shouldLog(includes, 73 /* _TRACE */);
|
|
215
|
+
const TRACE_DEV = shouldLog(includes, 81 /* TRACE_DEV */);
|
|
216
|
+
const _hmm = _HMM ? ext.error.bind(ext, LEVELS._hmm) : f.bind(source2, 524 /* _HMM */);
|
|
217
|
+
const _todo = _TODO ? ext.error.bind(ext, LEVELS._todo) : f.bind(source2, 522 /* _TODO */);
|
|
218
|
+
const _error = _ERROR ? ext.error.bind(ext, LEVELS._error) : f.bind(source2, 521 /* _ERROR */);
|
|
219
|
+
const errorDev = ERROR_DEV ? ext.error.bind(ext, LEVELS.errorDev) : f.bind(source2, 529 /* ERROR_DEV */);
|
|
220
|
+
const errorPublic = ERROR_PUBLIC ? ext.error.bind(ext, LEVELS.errorPublic) : f.bind(source2, 545 /* ERROR_PUBLIC */);
|
|
221
|
+
const _kapow = _KAPOW ? ext.warn.bind(ext, LEVELS._kapow) : f.bind(source2, 268 /* _KAPOW */);
|
|
222
|
+
const _warn = _WARN ? ext.warn.bind(ext, LEVELS._warn) : f.bind(source2, 265 /* _WARN */);
|
|
223
|
+
const warnDev = WARN_DEV ? ext.warn.bind(ext, LEVELS.warnDev) : f.bind(source2, 273 /* WARN_DEV */);
|
|
224
|
+
const warnPublic = WARN_PUBLIC ? ext.warn.bind(ext, LEVELS.warnPublic) : f.bind(source2, 273 /* WARN_DEV */);
|
|
225
|
+
const _debug = _DEBUG ? ext.debug.bind(ext, LEVELS._debug) : f.bind(source2, 137 /* _DEBUG */);
|
|
226
|
+
const debugDev = DEBUG_DEV ? ext.debug.bind(ext, LEVELS.debugDev) : f.bind(source2, 145 /* DEBUG_DEV */);
|
|
227
|
+
const _trace = _TRACE ? ext.trace.bind(ext, LEVELS._trace) : f.bind(source2, 73 /* _TRACE */);
|
|
228
|
+
const traceDev = TRACE_DEV ? ext.trace.bind(ext, LEVELS.traceDev) : f.bind(source2, 81 /* TRACE_DEV */);
|
|
229
|
+
const logger = {
|
|
230
|
+
_hmm,
|
|
231
|
+
_todo,
|
|
232
|
+
_error,
|
|
233
|
+
errorDev,
|
|
234
|
+
errorPublic,
|
|
235
|
+
_kapow,
|
|
236
|
+
_warn,
|
|
237
|
+
warnDev,
|
|
238
|
+
warnPublic,
|
|
239
|
+
_debug,
|
|
240
|
+
debugDev,
|
|
241
|
+
_trace,
|
|
242
|
+
traceDev,
|
|
243
|
+
lazy: {
|
|
244
|
+
_hmm: _HMM ? lazy(_hmm) : _hmm,
|
|
245
|
+
_todo: _TODO ? lazy(_todo) : _todo,
|
|
246
|
+
_error: _ERROR ? lazy(_error) : _error,
|
|
247
|
+
errorDev: ERROR_DEV ? lazy(errorDev) : errorDev,
|
|
248
|
+
errorPublic: ERROR_PUBLIC ? lazy(errorPublic) : errorPublic,
|
|
249
|
+
_kapow: _KAPOW ? lazy(_kapow) : _kapow,
|
|
250
|
+
_warn: _WARN ? lazy(_warn) : _warn,
|
|
251
|
+
warnDev: WARN_DEV ? lazy(warnDev) : warnDev,
|
|
252
|
+
warnPublic: WARN_PUBLIC ? lazy(warnPublic) : warnPublic,
|
|
253
|
+
_debug: _DEBUG ? lazy(_debug) : _debug,
|
|
254
|
+
debugDev: DEBUG_DEV ? lazy(debugDev) : debugDev,
|
|
255
|
+
_trace: _TRACE ? lazy(_trace) : _trace,
|
|
256
|
+
traceDev: TRACE_DEV ? lazy(traceDev) : traceDev
|
|
257
|
+
},
|
|
258
|
+
//
|
|
259
|
+
named,
|
|
260
|
+
utilFor: {
|
|
261
|
+
internal() {
|
|
262
|
+
return {
|
|
263
|
+
debug: logger._debug,
|
|
264
|
+
error: logger._error,
|
|
265
|
+
warn: logger._warn,
|
|
266
|
+
trace: logger._trace,
|
|
267
|
+
named(name, key) {
|
|
268
|
+
return logger.named(name, key).utilFor.internal();
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
},
|
|
272
|
+
dev() {
|
|
273
|
+
return {
|
|
274
|
+
debug: logger.debugDev,
|
|
275
|
+
error: logger.errorDev,
|
|
276
|
+
warn: logger.warnDev,
|
|
277
|
+
trace: logger.traceDev,
|
|
278
|
+
named(name, key) {
|
|
279
|
+
return logger.named(name, key).utilFor.dev();
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
},
|
|
283
|
+
public() {
|
|
284
|
+
return {
|
|
285
|
+
error: logger.errorPublic,
|
|
286
|
+
warn: logger.warnPublic,
|
|
287
|
+
debug(message, obj) {
|
|
288
|
+
logger._warn(`(public "debug" filtered out) ${message}`, obj);
|
|
289
|
+
},
|
|
290
|
+
trace(message, obj) {
|
|
291
|
+
logger._warn(`(public "trace" filtered out) ${message}`, obj);
|
|
292
|
+
},
|
|
293
|
+
named(name, key) {
|
|
294
|
+
return logger.named(name, key).utilFor.public();
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
return logger;
|
|
301
|
+
}
|
|
302
|
+
function createConsoleLoggerStyled(con, source2) {
|
|
303
|
+
const includes = { ...this.includes, ...this.include(source2) };
|
|
304
|
+
const styleArgs = [];
|
|
305
|
+
let prefix = "";
|
|
306
|
+
for (let i = 0; i < source2.names.length; i++) {
|
|
307
|
+
const { name, key } = source2.names[i];
|
|
308
|
+
prefix += ` %c${name}`;
|
|
309
|
+
styleArgs.push(this.style.css(name));
|
|
310
|
+
if (key != null) {
|
|
311
|
+
const keyStr = `%c#${key}`;
|
|
312
|
+
prefix += keyStr;
|
|
313
|
+
styleArgs.push(this.style.css(keyStr));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const f = this.filtered;
|
|
317
|
+
const named = this.named.bind(this, source2);
|
|
318
|
+
const prefixArr = [prefix, ...styleArgs];
|
|
319
|
+
return _createConsoleLogger(
|
|
320
|
+
f,
|
|
321
|
+
source2,
|
|
322
|
+
includes,
|
|
323
|
+
con,
|
|
324
|
+
prefixArr,
|
|
325
|
+
styledKapowPrefix(prefixArr),
|
|
326
|
+
named
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
function styledKapowPrefix(args) {
|
|
330
|
+
const start = args.slice(0);
|
|
331
|
+
for (let i = 1; i < start.length; i++)
|
|
332
|
+
start[i] += ";background-color:#e0005a;padding:2px;color:white";
|
|
333
|
+
return start;
|
|
334
|
+
}
|
|
335
|
+
function createConsoleLoggerNoStyle(con, source2) {
|
|
336
|
+
const includes = { ...this.includes, ...this.include(source2) };
|
|
337
|
+
let prefix = "";
|
|
338
|
+
for (let i = 0; i < source2.names.length; i++) {
|
|
339
|
+
const { name, key } = source2.names[i];
|
|
340
|
+
prefix += ` ${name}`;
|
|
341
|
+
if (key != null) {
|
|
342
|
+
prefix += `#${key}`;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const f = this.filtered;
|
|
346
|
+
const named = this.named.bind(this, source2);
|
|
347
|
+
const prefixArr = [prefix];
|
|
348
|
+
return _createConsoleLogger(
|
|
349
|
+
f,
|
|
350
|
+
source2,
|
|
351
|
+
includes,
|
|
352
|
+
con,
|
|
353
|
+
prefixArr,
|
|
354
|
+
prefixArr,
|
|
355
|
+
named
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
function _createConsoleLogger(f, source2, includes, con, prefix, kapowPrefix, named) {
|
|
359
|
+
const _HMM = shouldLog(includes, 524 /* _HMM */);
|
|
360
|
+
const _TODO = shouldLog(includes, 522 /* _TODO */);
|
|
361
|
+
const _ERROR = shouldLog(includes, 521 /* _ERROR */);
|
|
362
|
+
const ERROR_DEV = shouldLog(includes, 529 /* ERROR_DEV */);
|
|
363
|
+
const ERROR_PUBLIC = shouldLog(includes, 545 /* ERROR_PUBLIC */);
|
|
364
|
+
const _WARN = shouldLog(includes, 265 /* _WARN */);
|
|
365
|
+
const _KAPOW = shouldLog(includes, 268 /* _KAPOW */);
|
|
366
|
+
const WARN_DEV = shouldLog(includes, 273 /* WARN_DEV */);
|
|
367
|
+
const WARN_PUBLIC = shouldLog(includes, 289 /* WARN_PUBLIC */);
|
|
368
|
+
const _DEBUG = shouldLog(includes, 137 /* _DEBUG */);
|
|
369
|
+
const DEBUG_DEV = shouldLog(includes, 145 /* DEBUG_DEV */);
|
|
370
|
+
const _TRACE = shouldLog(includes, 73 /* _TRACE */);
|
|
371
|
+
const TRACE_DEV = shouldLog(includes, 81 /* TRACE_DEV */);
|
|
372
|
+
const _hmm = _HMM ? con.error.bind(con, ...prefix) : f.bind(source2, 524 /* _HMM */);
|
|
373
|
+
const _todo = _TODO ? con.error.bind(con, ...prefix) : f.bind(source2, 522 /* _TODO */);
|
|
374
|
+
const _error = _ERROR ? con.error.bind(con, ...prefix) : f.bind(source2, 521 /* _ERROR */);
|
|
375
|
+
const errorDev = ERROR_DEV ? con.error.bind(con, ...prefix) : f.bind(source2, 529 /* ERROR_DEV */);
|
|
376
|
+
const errorPublic = ERROR_PUBLIC ? con.error.bind(con, ...prefix) : f.bind(source2, 545 /* ERROR_PUBLIC */);
|
|
377
|
+
const _kapow = _KAPOW ? con.warn.bind(con, ...kapowPrefix) : f.bind(source2, 268 /* _KAPOW */);
|
|
378
|
+
const _warn = _WARN ? con.warn.bind(con, ...prefix) : f.bind(source2, 265 /* _WARN */);
|
|
379
|
+
const warnDev = WARN_DEV ? con.warn.bind(con, ...prefix) : f.bind(source2, 273 /* WARN_DEV */);
|
|
380
|
+
const warnPublic = WARN_PUBLIC ? con.warn.bind(con, ...prefix) : f.bind(source2, 273 /* WARN_DEV */);
|
|
381
|
+
const _debug = _DEBUG ? con.info.bind(con, ...prefix) : f.bind(source2, 137 /* _DEBUG */);
|
|
382
|
+
const debugDev = DEBUG_DEV ? con.info.bind(con, ...prefix) : f.bind(source2, 145 /* DEBUG_DEV */);
|
|
383
|
+
const _trace = _TRACE ? con.debug.bind(con, ...prefix) : f.bind(source2, 73 /* _TRACE */);
|
|
384
|
+
const traceDev = TRACE_DEV ? con.debug.bind(con, ...prefix) : f.bind(source2, 81 /* TRACE_DEV */);
|
|
385
|
+
const logger = {
|
|
386
|
+
_hmm,
|
|
387
|
+
_todo,
|
|
388
|
+
_error,
|
|
389
|
+
errorDev,
|
|
390
|
+
errorPublic,
|
|
391
|
+
_kapow,
|
|
392
|
+
_warn,
|
|
393
|
+
warnDev,
|
|
394
|
+
warnPublic,
|
|
395
|
+
_debug,
|
|
396
|
+
debugDev,
|
|
397
|
+
_trace,
|
|
398
|
+
traceDev,
|
|
399
|
+
lazy: {
|
|
400
|
+
_hmm: _HMM ? lazy(_hmm) : _hmm,
|
|
401
|
+
_todo: _TODO ? lazy(_todo) : _todo,
|
|
402
|
+
_error: _ERROR ? lazy(_error) : _error,
|
|
403
|
+
errorDev: ERROR_DEV ? lazy(errorDev) : errorDev,
|
|
404
|
+
errorPublic: ERROR_PUBLIC ? lazy(errorPublic) : errorPublic,
|
|
405
|
+
_kapow: _KAPOW ? lazy(_kapow) : _kapow,
|
|
406
|
+
_warn: _WARN ? lazy(_warn) : _warn,
|
|
407
|
+
warnDev: WARN_DEV ? lazy(warnDev) : warnDev,
|
|
408
|
+
warnPublic: WARN_PUBLIC ? lazy(warnPublic) : warnPublic,
|
|
409
|
+
_debug: _DEBUG ? lazy(_debug) : _debug,
|
|
410
|
+
debugDev: DEBUG_DEV ? lazy(debugDev) : debugDev,
|
|
411
|
+
_trace: _TRACE ? lazy(_trace) : _trace,
|
|
412
|
+
traceDev: TRACE_DEV ? lazy(traceDev) : traceDev
|
|
413
|
+
},
|
|
414
|
+
//
|
|
415
|
+
named,
|
|
416
|
+
utilFor: {
|
|
417
|
+
internal() {
|
|
418
|
+
return {
|
|
419
|
+
debug: logger._debug,
|
|
420
|
+
error: logger._error,
|
|
421
|
+
warn: logger._warn,
|
|
422
|
+
trace: logger._trace,
|
|
423
|
+
named(name, key) {
|
|
424
|
+
return logger.named(name, key).utilFor.internal();
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
},
|
|
428
|
+
dev() {
|
|
429
|
+
return {
|
|
430
|
+
debug: logger.debugDev,
|
|
431
|
+
error: logger.errorDev,
|
|
432
|
+
warn: logger.warnDev,
|
|
433
|
+
trace: logger.traceDev,
|
|
434
|
+
named(name, key) {
|
|
435
|
+
return logger.named(name, key).utilFor.dev();
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
},
|
|
439
|
+
public() {
|
|
440
|
+
return {
|
|
441
|
+
error: logger.errorPublic,
|
|
442
|
+
warn: logger.warnPublic,
|
|
443
|
+
debug(message, obj) {
|
|
444
|
+
logger._warn(`(public "debug" filtered out) ${message}`, obj);
|
|
445
|
+
},
|
|
446
|
+
trace(message, obj) {
|
|
447
|
+
logger._warn(`(public "trace" filtered out) ${message}`, obj);
|
|
448
|
+
},
|
|
449
|
+
named(name, key) {
|
|
450
|
+
return logger.named(name, key).utilFor.public();
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
return logger;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// ../../theatre/shared/src/logger.ts
|
|
460
|
+
var internal = createTheatreInternalLogger(console, {
|
|
461
|
+
_debug: function() {
|
|
462
|
+
},
|
|
463
|
+
_error: function() {
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
internal.configureLogging({
|
|
467
|
+
dev: true,
|
|
468
|
+
min: 64 /* TRACE */
|
|
469
|
+
});
|
|
470
|
+
var logger_default = internal.getLogger().named("Theatre.js (default logger)").utilFor.dev();
|
|
471
|
+
|
|
472
|
+
// ../../theatre/shared/src/globalVariableNames.ts
|
|
473
|
+
var notifications = "__TheatreJS_Notifications";
|
|
474
|
+
|
|
475
|
+
// ../../theatre/shared/src/notify.ts
|
|
476
|
+
var createHandler = (type) => (...args) => {
|
|
477
|
+
switch (type) {
|
|
478
|
+
case "success": {
|
|
479
|
+
logger_default.debug(args.slice(0, 2).join("\n"));
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
case "info": {
|
|
483
|
+
logger_default.debug(args.slice(0, 2).join("\n"));
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
case "warning": {
|
|
487
|
+
logger_default.warn(args.slice(0, 2).join("\n"));
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
case "error": {
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return typeof window !== "undefined" ? (
|
|
494
|
+
// @ts-ignore
|
|
495
|
+
window[notifications]?.notify[type](...args)
|
|
496
|
+
) : void 0;
|
|
497
|
+
};
|
|
498
|
+
var notify = {
|
|
499
|
+
warning: createHandler("warning"),
|
|
500
|
+
success: createHandler("success"),
|
|
501
|
+
info: createHandler("info"),
|
|
502
|
+
error: createHandler("error")
|
|
503
|
+
};
|
|
504
|
+
if (typeof window !== "undefined") {
|
|
505
|
+
window.addEventListener("error", (e) => {
|
|
506
|
+
notify.error(
|
|
507
|
+
`An error occurred`,
|
|
508
|
+
`<pre>${e.message}</pre>
|
|
509
|
+
|
|
510
|
+
See **console** for details.`
|
|
511
|
+
);
|
|
512
|
+
});
|
|
513
|
+
window.addEventListener("unhandledrejection", (e) => {
|
|
514
|
+
notify.error(
|
|
515
|
+
`An error occurred`,
|
|
516
|
+
`<pre>${e.reason}</pre>
|
|
517
|
+
|
|
518
|
+
See **console** for details.`
|
|
519
|
+
);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// ../../theatre/shared/src/utils/slashedPaths.ts
|
|
524
|
+
var normalizeSlashedPath = (p) => p.replace(/^[\s\/]*/, "").replace(/[\s\/]*$/, "").replace(/\s*\/\s*/g, " / ");
|
|
525
|
+
var getValidationErrorsOfSlashedPath = (p) => {
|
|
526
|
+
if (typeof p !== "string")
|
|
527
|
+
return `it is not a string. (it is a ${typeof p})`;
|
|
528
|
+
const components = p.split(/\//);
|
|
529
|
+
if (components.length === 0)
|
|
530
|
+
return `it is empty.`;
|
|
531
|
+
for (let i = 0; i < components.length; i++) {
|
|
532
|
+
const component = components[i].trim();
|
|
533
|
+
if (component.length === 0)
|
|
534
|
+
return `the component #${i + 1} is empty.`;
|
|
535
|
+
if (component.length > 64)
|
|
536
|
+
return `the component '${component}' must have 64 characters or less.`;
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
function validateAndSanitiseSlashedPathOrThrow(unsanitisedPath, fnName) {
|
|
540
|
+
const sanitisedPath = normalizeSlashedPath(unsanitisedPath);
|
|
541
|
+
if (process.env.NODE_ENV !== "development") {
|
|
542
|
+
return sanitisedPath;
|
|
543
|
+
}
|
|
544
|
+
const validation = getValidationErrorsOfSlashedPath(sanitisedPath);
|
|
545
|
+
if (validation) {
|
|
546
|
+
throw new InvalidArgumentError(
|
|
547
|
+
`The path in ${fnName}(${typeof unsanitisedPath === "string" ? `"${unsanitisedPath}"` : ""}) is invalid because ${validation}`
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
if (unsanitisedPath !== sanitisedPath) {
|
|
551
|
+
notify.warning(
|
|
552
|
+
"Invalid path provided to object",
|
|
553
|
+
`The path in \`${fnName}("${unsanitisedPath}")\` was sanitized to \`"${sanitisedPath}"\`.
|
|
554
|
+
|
|
555
|
+
Please replace the path with the sanitized one, otherwise it will likely break in the future.`,
|
|
556
|
+
[
|
|
557
|
+
{
|
|
558
|
+
url: "https://www.theatrejs.com/docs/latest/manual/objects#creating-sheet-objects",
|
|
559
|
+
title: "Sheet Objects"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
url: "https://www.theatrejs.com/docs/latest/api/core#sheet.object",
|
|
563
|
+
title: "API"
|
|
564
|
+
}
|
|
565
|
+
]
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
return sanitisedPath;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// ../../theatre/shared/src/gsap/buildGsapSheetObjectKey.ts
|
|
572
|
+
function buildGsapSheetObjectKey(namespace, label) {
|
|
573
|
+
return validateAndSanitiseSlashedPathOrThrow(
|
|
574
|
+
`${namespace} / ${label}`,
|
|
575
|
+
"buildGsapSheetObjectKey"
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// ../../theatre/shared/src/gsap/introspectGsapTimelineChildren.ts
|
|
580
|
+
function isGsapTimeline(animation) {
|
|
581
|
+
const root2 = animation;
|
|
582
|
+
const children = root2.getChildren?.(false, true, false);
|
|
583
|
+
return Array.isArray(children) && children.length > 0;
|
|
584
|
+
}
|
|
585
|
+
function childLabel(child, index) {
|
|
586
|
+
const tween = child;
|
|
587
|
+
const id = tween.vars?.id;
|
|
588
|
+
if (typeof id === "string" && id.length > 0)
|
|
589
|
+
return id;
|
|
590
|
+
return `Tween ${index + 1}`;
|
|
591
|
+
}
|
|
592
|
+
function readChildLocalTiming(child) {
|
|
593
|
+
const tween = child;
|
|
594
|
+
const localStart = typeof tween.startTime === "function" ? tween.startTime() : 0;
|
|
595
|
+
let localDuration = typeof tween.duration === "function" ? tween.duration() : 0;
|
|
596
|
+
if (localDuration <= 0 && typeof tween.endTime === "function") {
|
|
597
|
+
localDuration = Math.max(tween.endTime() - localStart, 0.01);
|
|
598
|
+
}
|
|
599
|
+
return {
|
|
600
|
+
localStart: Math.max(localStart, 0),
|
|
601
|
+
localDuration: Math.max(localDuration, 0.01)
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
function introspectGsapTimelineChildren(animation) {
|
|
605
|
+
if (!isGsapTimeline(animation))
|
|
606
|
+
return [];
|
|
607
|
+
const root2 = animation;
|
|
608
|
+
const raw = root2.getChildren(false, true, false);
|
|
609
|
+
return raw.map((child, index) => {
|
|
610
|
+
const { localStart, localDuration } = readChildLocalTiming(child);
|
|
611
|
+
return {
|
|
612
|
+
childId: `child_${index}`,
|
|
613
|
+
label: childLabel(child, index),
|
|
614
|
+
localStart,
|
|
615
|
+
localDuration
|
|
616
|
+
};
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
function linkGsapTimelineChildAnimations(animation) {
|
|
620
|
+
const map = /* @__PURE__ */ new Map();
|
|
621
|
+
if (!isGsapTimeline(animation))
|
|
622
|
+
return map;
|
|
623
|
+
const root2 = animation;
|
|
624
|
+
const raw = root2.getChildren(false, true, false);
|
|
625
|
+
raw.forEach((child, index) => {
|
|
626
|
+
map.set(`child_${index}`, child);
|
|
627
|
+
});
|
|
628
|
+
return map;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// ../../theatre/shared/src/gsap/gsapSheetObjectKey.ts
|
|
632
|
+
var GSAP_NAMESPACE_STORE_KEY = "__unseenco_theatre_gsap_configuredNamespace__";
|
|
633
|
+
function setConfiguredGsapSheetObjectNamespace(namespace) {
|
|
634
|
+
const g = globalThis;
|
|
635
|
+
g[GSAP_NAMESPACE_STORE_KEY] = namespace.trim();
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// ../../theatre/shared/src/sequence/trackData.ts
|
|
639
|
+
function gsapClipEndTime(clip) {
|
|
640
|
+
return clip.start + clip.duration;
|
|
641
|
+
}
|
|
642
|
+
function gsapClipSyncProgress(sequencePosition, clip) {
|
|
643
|
+
if (clip.duration <= 0)
|
|
644
|
+
return 0;
|
|
645
|
+
if (sequencePosition < clip.start)
|
|
646
|
+
return 0;
|
|
647
|
+
const clipEnd = gsapClipEndTime(clip);
|
|
648
|
+
if (sequencePosition >= clipEnd - 1e-5)
|
|
649
|
+
return 1;
|
|
650
|
+
const raw = (sequencePosition - clip.start) / clip.duration;
|
|
651
|
+
if (raw <= 0)
|
|
652
|
+
return 0;
|
|
653
|
+
if (raw >= 1)
|
|
654
|
+
return 1;
|
|
655
|
+
return raw;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// ../../theatre/shared/src/gsap/applyTimelineChildTiming.ts
|
|
659
|
+
function applyTimelineChildTimingToGsap(rootAnimation, timelineChildren, childById, onRebuild) {
|
|
660
|
+
if (!timelineChildren.length)
|
|
661
|
+
return true;
|
|
662
|
+
let ok = applyTimelineChildTimingToGsapInner(
|
|
663
|
+
rootAnimation,
|
|
664
|
+
timelineChildren,
|
|
665
|
+
childById
|
|
666
|
+
);
|
|
667
|
+
if (!ok && onRebuild) {
|
|
668
|
+
const rebuilt = onRebuild();
|
|
669
|
+
if (rebuilt) {
|
|
670
|
+
ok = applyTimelineChildTimingToGsapInner(
|
|
671
|
+
rebuilt,
|
|
672
|
+
timelineChildren,
|
|
673
|
+
childById
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return ok;
|
|
678
|
+
}
|
|
679
|
+
function applyTimelineChildTimingToGsapInner(rootAnimation, timelineChildren, childById) {
|
|
680
|
+
if (!childById || timelineChildren.length === 0)
|
|
681
|
+
return true;
|
|
682
|
+
let ok = true;
|
|
683
|
+
for (const childState of timelineChildren) {
|
|
684
|
+
const tween = childById.get(childState.childId);
|
|
685
|
+
if (!tween)
|
|
686
|
+
continue;
|
|
687
|
+
try {
|
|
688
|
+
const t = tween;
|
|
689
|
+
if (typeof t.startTime === "function") {
|
|
690
|
+
t.startTime(childState.localStart);
|
|
691
|
+
}
|
|
692
|
+
if (typeof t.duration === "function") {
|
|
693
|
+
t.duration(childState.localDuration);
|
|
694
|
+
}
|
|
695
|
+
} catch {
|
|
696
|
+
ok = false;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
return ok;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// ../../theatre/shared/src/gsap/syncGsapClipProgress.ts
|
|
703
|
+
function getGsapAnimationTargetKey(animation, fallbackAnimationId) {
|
|
704
|
+
const tween = animation;
|
|
705
|
+
const targets = tween.targets?.();
|
|
706
|
+
if (targets && targets.length > 0) {
|
|
707
|
+
return targets[0];
|
|
708
|
+
}
|
|
709
|
+
return fallbackAnimationId;
|
|
710
|
+
}
|
|
711
|
+
function syncRegisteredGsapAnimationsForClips(sequencePosition, clips) {
|
|
712
|
+
const enriched = [];
|
|
713
|
+
for (const clip of clips) {
|
|
714
|
+
const entry = getAnimationEntryBySheetAddressKey(
|
|
715
|
+
clip.sheetObjectAddressKey,
|
|
716
|
+
clip.gsapAnimationId
|
|
717
|
+
);
|
|
718
|
+
if (!entry?.animation)
|
|
719
|
+
continue;
|
|
720
|
+
enriched.push({
|
|
721
|
+
...clip,
|
|
722
|
+
entry,
|
|
723
|
+
targetKey: getGsapAnimationTargetKey(
|
|
724
|
+
entry.animation,
|
|
725
|
+
clip.gsapAnimationId
|
|
726
|
+
)
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
const byTarget = /* @__PURE__ */ new Map();
|
|
730
|
+
for (const item of enriched) {
|
|
731
|
+
const list = byTarget.get(item.targetKey) ?? [];
|
|
732
|
+
list.push(item);
|
|
733
|
+
byTarget.set(item.targetKey, list);
|
|
734
|
+
}
|
|
735
|
+
for (const group of byTarget.values()) {
|
|
736
|
+
const sorted = [...group].sort((a, b) => a.start - b.start);
|
|
737
|
+
for (const clip of sorted) {
|
|
738
|
+
const progress = gsapClipSyncProgress(sequencePosition, clip);
|
|
739
|
+
const entry = clip.entry;
|
|
740
|
+
const animation = entry.animation;
|
|
741
|
+
if (entry.kind === "timeline" && clip.timelineChildren && clip.timelineChildren.length > 0) {
|
|
742
|
+
applyTimelineChildTimingToGsap(
|
|
743
|
+
entry.animation,
|
|
744
|
+
clip.timelineChildren,
|
|
745
|
+
entry.timelineChildById,
|
|
746
|
+
entry.onRebuildTimeline
|
|
747
|
+
);
|
|
748
|
+
const span = clip.timelineSpan ?? readGsapTweenTimelineDuration(entry.animation);
|
|
749
|
+
const t = progress * Math.max(span, 0.01);
|
|
750
|
+
if (typeof animation.time === "function") {
|
|
751
|
+
animation.time(t, true);
|
|
752
|
+
} else {
|
|
753
|
+
animation.progress?.(progress, true);
|
|
754
|
+
}
|
|
755
|
+
} else {
|
|
756
|
+
animation.progress?.(progress, true);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
function readGsapTweenTimelineDuration(animation) {
|
|
762
|
+
const tween = animation;
|
|
763
|
+
const total = tween.totalDuration?.();
|
|
764
|
+
if (typeof total === "number" && total > 0)
|
|
765
|
+
return total;
|
|
766
|
+
const d = tween.duration();
|
|
767
|
+
return d > 0 ? d : 1;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// ../../theatre/shared/src/gsap/gsapClipBaseline.ts
|
|
771
|
+
function cloneTimelineChildren(children) {
|
|
772
|
+
return children.map((c) => ({ ...c }));
|
|
773
|
+
}
|
|
774
|
+
function buildGsapClipBaselineTiming(p) {
|
|
775
|
+
const duration = Math.max(p.duration, 0.01);
|
|
776
|
+
const baseline = { duration };
|
|
777
|
+
if (p.timelineChildren && p.timelineChildren.length > 0) {
|
|
778
|
+
baseline.timelineSpan = p.timelineSpan ?? duration;
|
|
779
|
+
baseline.timelineChildren = cloneTimelineChildren(p.timelineChildren);
|
|
780
|
+
}
|
|
781
|
+
return baseline;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// ../../theatre/shared/src/gsap/gsapObjectBinding.ts
|
|
785
|
+
var STORE_KEY = "__unseenco_theatre_gsap_objectBindings__";
|
|
786
|
+
function addressKey(sheetObject) {
|
|
787
|
+
const a = sheetObject.address;
|
|
788
|
+
return `${a.projectId}|${a.sheetId}|${a.sheetInstanceId}|${a.objectKey}`;
|
|
789
|
+
}
|
|
790
|
+
function getStore() {
|
|
791
|
+
const g = globalThis;
|
|
792
|
+
if (!g[STORE_KEY]) {
|
|
793
|
+
g[STORE_KEY] = /* @__PURE__ */ new Map();
|
|
794
|
+
}
|
|
795
|
+
return g[STORE_KEY];
|
|
796
|
+
}
|
|
797
|
+
function registerGsapObjectBinding(sheetObject, binding) {
|
|
798
|
+
getStore().set(addressKey(sheetObject), binding);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// ../../node_modules/lodash-es/isArray.js
|
|
802
|
+
var isArray = Array.isArray;
|
|
803
|
+
var isArray_default = isArray;
|
|
804
|
+
|
|
805
|
+
// ../../node_modules/lodash-es/_freeGlobal.js
|
|
806
|
+
var freeGlobal = typeof window == "object" && window && window.Object === Object && window;
|
|
807
|
+
var freeGlobal_default = freeGlobal;
|
|
808
|
+
|
|
809
|
+
// ../../node_modules/lodash-es/_root.js
|
|
810
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
811
|
+
var root = freeGlobal_default || freeSelf || Function("return this")();
|
|
812
|
+
var root_default = root;
|
|
813
|
+
|
|
814
|
+
// ../../node_modules/lodash-es/_Symbol.js
|
|
815
|
+
var Symbol2 = root_default.Symbol;
|
|
816
|
+
var Symbol_default = Symbol2;
|
|
817
|
+
|
|
818
|
+
// ../../node_modules/lodash-es/_getRawTag.js
|
|
819
|
+
var objectProto = Object.prototype;
|
|
820
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
821
|
+
var nativeObjectToString = objectProto.toString;
|
|
822
|
+
var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
823
|
+
function getRawTag(value) {
|
|
824
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
|
|
825
|
+
try {
|
|
826
|
+
value[symToStringTag] = void 0;
|
|
827
|
+
var unmasked = true;
|
|
828
|
+
} catch (e) {
|
|
829
|
+
}
|
|
830
|
+
var result = nativeObjectToString.call(value);
|
|
831
|
+
if (unmasked) {
|
|
832
|
+
if (isOwn) {
|
|
833
|
+
value[symToStringTag] = tag;
|
|
834
|
+
} else {
|
|
835
|
+
delete value[symToStringTag];
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return result;
|
|
839
|
+
}
|
|
840
|
+
var getRawTag_default = getRawTag;
|
|
841
|
+
|
|
842
|
+
// ../../node_modules/lodash-es/_objectToString.js
|
|
843
|
+
var objectProto2 = Object.prototype;
|
|
844
|
+
var nativeObjectToString2 = objectProto2.toString;
|
|
845
|
+
function objectToString(value) {
|
|
846
|
+
return nativeObjectToString2.call(value);
|
|
847
|
+
}
|
|
848
|
+
var objectToString_default = objectToString;
|
|
849
|
+
|
|
850
|
+
// ../../node_modules/lodash-es/_baseGetTag.js
|
|
851
|
+
var nullTag = "[object Null]";
|
|
852
|
+
var undefinedTag = "[object Undefined]";
|
|
853
|
+
var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
854
|
+
function baseGetTag(value) {
|
|
855
|
+
if (value == null) {
|
|
856
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
857
|
+
}
|
|
858
|
+
return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
|
|
859
|
+
}
|
|
860
|
+
var baseGetTag_default = baseGetTag;
|
|
861
|
+
|
|
862
|
+
// ../../node_modules/lodash-es/isObjectLike.js
|
|
863
|
+
function isObjectLike(value) {
|
|
864
|
+
return value != null && typeof value == "object";
|
|
865
|
+
}
|
|
866
|
+
var isObjectLike_default = isObjectLike;
|
|
867
|
+
|
|
868
|
+
// ../../node_modules/lodash-es/isSymbol.js
|
|
869
|
+
var symbolTag = "[object Symbol]";
|
|
870
|
+
function isSymbol(value) {
|
|
871
|
+
return typeof value == "symbol" || isObjectLike_default(value) && baseGetTag_default(value) == symbolTag;
|
|
872
|
+
}
|
|
873
|
+
var isSymbol_default = isSymbol;
|
|
874
|
+
|
|
875
|
+
// ../../node_modules/lodash-es/_isKey.js
|
|
876
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
877
|
+
var reIsPlainProp = /^\w*$/;
|
|
878
|
+
function isKey(value, object) {
|
|
879
|
+
if (isArray_default(value)) {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
var type = typeof value;
|
|
883
|
+
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol_default(value)) {
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
886
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
887
|
+
}
|
|
888
|
+
var isKey_default = isKey;
|
|
889
|
+
|
|
890
|
+
// ../../node_modules/lodash-es/isObject.js
|
|
891
|
+
function isObject(value) {
|
|
892
|
+
var type = typeof value;
|
|
893
|
+
return value != null && (type == "object" || type == "function");
|
|
894
|
+
}
|
|
895
|
+
var isObject_default = isObject;
|
|
896
|
+
|
|
897
|
+
// ../../node_modules/lodash-es/isFunction.js
|
|
898
|
+
var asyncTag = "[object AsyncFunction]";
|
|
899
|
+
var funcTag = "[object Function]";
|
|
900
|
+
var genTag = "[object GeneratorFunction]";
|
|
901
|
+
var proxyTag = "[object Proxy]";
|
|
902
|
+
function isFunction(value) {
|
|
903
|
+
if (!isObject_default(value)) {
|
|
904
|
+
return false;
|
|
905
|
+
}
|
|
906
|
+
var tag = baseGetTag_default(value);
|
|
907
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
908
|
+
}
|
|
909
|
+
var isFunction_default = isFunction;
|
|
910
|
+
|
|
911
|
+
// ../../node_modules/lodash-es/_coreJsData.js
|
|
912
|
+
var coreJsData = root_default["__core-js_shared__"];
|
|
913
|
+
var coreJsData_default = coreJsData;
|
|
914
|
+
|
|
915
|
+
// ../../node_modules/lodash-es/_isMasked.js
|
|
916
|
+
var maskSrcKey = function() {
|
|
917
|
+
var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
|
|
918
|
+
return uid ? "Symbol(src)_1." + uid : "";
|
|
919
|
+
}();
|
|
920
|
+
function isMasked(func) {
|
|
921
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
922
|
+
}
|
|
923
|
+
var isMasked_default = isMasked;
|
|
924
|
+
|
|
925
|
+
// ../../node_modules/lodash-es/_toSource.js
|
|
926
|
+
var funcProto = Function.prototype;
|
|
927
|
+
var funcToString = funcProto.toString;
|
|
928
|
+
function toSource(func) {
|
|
929
|
+
if (func != null) {
|
|
930
|
+
try {
|
|
931
|
+
return funcToString.call(func);
|
|
932
|
+
} catch (e) {
|
|
933
|
+
}
|
|
934
|
+
try {
|
|
935
|
+
return func + "";
|
|
936
|
+
} catch (e) {
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return "";
|
|
940
|
+
}
|
|
941
|
+
var toSource_default = toSource;
|
|
942
|
+
|
|
943
|
+
// ../../node_modules/lodash-es/_baseIsNative.js
|
|
944
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
945
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
946
|
+
var funcProto2 = Function.prototype;
|
|
947
|
+
var objectProto3 = Object.prototype;
|
|
948
|
+
var funcToString2 = funcProto2.toString;
|
|
949
|
+
var hasOwnProperty2 = objectProto3.hasOwnProperty;
|
|
950
|
+
var reIsNative = RegExp(
|
|
951
|
+
"^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
952
|
+
);
|
|
953
|
+
function baseIsNative(value) {
|
|
954
|
+
if (!isObject_default(value) || isMasked_default(value)) {
|
|
955
|
+
return false;
|
|
956
|
+
}
|
|
957
|
+
var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
|
|
958
|
+
return pattern.test(toSource_default(value));
|
|
959
|
+
}
|
|
960
|
+
var baseIsNative_default = baseIsNative;
|
|
961
|
+
|
|
962
|
+
// ../../node_modules/lodash-es/_getValue.js
|
|
963
|
+
function getValue(object, key) {
|
|
964
|
+
return object == null ? void 0 : object[key];
|
|
965
|
+
}
|
|
966
|
+
var getValue_default = getValue;
|
|
967
|
+
|
|
968
|
+
// ../../node_modules/lodash-es/_getNative.js
|
|
969
|
+
function getNative(object, key) {
|
|
970
|
+
var value = getValue_default(object, key);
|
|
971
|
+
return baseIsNative_default(value) ? value : void 0;
|
|
972
|
+
}
|
|
973
|
+
var getNative_default = getNative;
|
|
974
|
+
|
|
975
|
+
// ../../node_modules/lodash-es/_nativeCreate.js
|
|
976
|
+
var nativeCreate = getNative_default(Object, "create");
|
|
977
|
+
var nativeCreate_default = nativeCreate;
|
|
978
|
+
|
|
979
|
+
// ../../node_modules/lodash-es/_hashClear.js
|
|
980
|
+
function hashClear() {
|
|
981
|
+
this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
|
|
982
|
+
this.size = 0;
|
|
983
|
+
}
|
|
984
|
+
var hashClear_default = hashClear;
|
|
985
|
+
|
|
986
|
+
// ../../node_modules/lodash-es/_hashDelete.js
|
|
987
|
+
function hashDelete(key) {
|
|
988
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
989
|
+
this.size -= result ? 1 : 0;
|
|
990
|
+
return result;
|
|
991
|
+
}
|
|
992
|
+
var hashDelete_default = hashDelete;
|
|
993
|
+
|
|
994
|
+
// ../../node_modules/lodash-es/_hashGet.js
|
|
995
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
996
|
+
var objectProto4 = Object.prototype;
|
|
997
|
+
var hasOwnProperty3 = objectProto4.hasOwnProperty;
|
|
998
|
+
function hashGet(key) {
|
|
999
|
+
var data = this.__data__;
|
|
1000
|
+
if (nativeCreate_default) {
|
|
1001
|
+
var result = data[key];
|
|
1002
|
+
return result === HASH_UNDEFINED ? void 0 : result;
|
|
1003
|
+
}
|
|
1004
|
+
return hasOwnProperty3.call(data, key) ? data[key] : void 0;
|
|
1005
|
+
}
|
|
1006
|
+
var hashGet_default = hashGet;
|
|
1007
|
+
|
|
1008
|
+
// ../../node_modules/lodash-es/_hashHas.js
|
|
1009
|
+
var objectProto5 = Object.prototype;
|
|
1010
|
+
var hasOwnProperty4 = objectProto5.hasOwnProperty;
|
|
1011
|
+
function hashHas(key) {
|
|
1012
|
+
var data = this.__data__;
|
|
1013
|
+
return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty4.call(data, key);
|
|
1014
|
+
}
|
|
1015
|
+
var hashHas_default = hashHas;
|
|
1016
|
+
|
|
1017
|
+
// ../../node_modules/lodash-es/_hashSet.js
|
|
1018
|
+
var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
|
|
1019
|
+
function hashSet(key, value) {
|
|
1020
|
+
var data = this.__data__;
|
|
1021
|
+
this.size += this.has(key) ? 0 : 1;
|
|
1022
|
+
data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
|
|
1023
|
+
return this;
|
|
1024
|
+
}
|
|
1025
|
+
var hashSet_default = hashSet;
|
|
1026
|
+
|
|
1027
|
+
// ../../node_modules/lodash-es/_Hash.js
|
|
1028
|
+
function Hash(entries) {
|
|
1029
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
1030
|
+
this.clear();
|
|
1031
|
+
while (++index < length) {
|
|
1032
|
+
var entry = entries[index];
|
|
1033
|
+
this.set(entry[0], entry[1]);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
Hash.prototype.clear = hashClear_default;
|
|
1037
|
+
Hash.prototype["delete"] = hashDelete_default;
|
|
1038
|
+
Hash.prototype.get = hashGet_default;
|
|
1039
|
+
Hash.prototype.has = hashHas_default;
|
|
1040
|
+
Hash.prototype.set = hashSet_default;
|
|
1041
|
+
var Hash_default = Hash;
|
|
1042
|
+
|
|
1043
|
+
// ../../node_modules/lodash-es/_listCacheClear.js
|
|
1044
|
+
function listCacheClear() {
|
|
1045
|
+
this.__data__ = [];
|
|
1046
|
+
this.size = 0;
|
|
1047
|
+
}
|
|
1048
|
+
var listCacheClear_default = listCacheClear;
|
|
1049
|
+
|
|
1050
|
+
// ../../node_modules/lodash-es/eq.js
|
|
1051
|
+
function eq(value, other) {
|
|
1052
|
+
return value === other || value !== value && other !== other;
|
|
1053
|
+
}
|
|
1054
|
+
var eq_default = eq;
|
|
1055
|
+
|
|
1056
|
+
// ../../node_modules/lodash-es/_assocIndexOf.js
|
|
1057
|
+
function assocIndexOf(array, key) {
|
|
1058
|
+
var length = array.length;
|
|
1059
|
+
while (length--) {
|
|
1060
|
+
if (eq_default(array[length][0], key)) {
|
|
1061
|
+
return length;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
return -1;
|
|
1065
|
+
}
|
|
1066
|
+
var assocIndexOf_default = assocIndexOf;
|
|
1067
|
+
|
|
1068
|
+
// ../../node_modules/lodash-es/_listCacheDelete.js
|
|
1069
|
+
var arrayProto = Array.prototype;
|
|
1070
|
+
var splice = arrayProto.splice;
|
|
1071
|
+
function listCacheDelete(key) {
|
|
1072
|
+
var data = this.__data__, index = assocIndexOf_default(data, key);
|
|
1073
|
+
if (index < 0) {
|
|
1074
|
+
return false;
|
|
1075
|
+
}
|
|
1076
|
+
var lastIndex = data.length - 1;
|
|
1077
|
+
if (index == lastIndex) {
|
|
1078
|
+
data.pop();
|
|
1079
|
+
} else {
|
|
1080
|
+
splice.call(data, index, 1);
|
|
1081
|
+
}
|
|
1082
|
+
--this.size;
|
|
1083
|
+
return true;
|
|
1084
|
+
}
|
|
1085
|
+
var listCacheDelete_default = listCacheDelete;
|
|
1086
|
+
|
|
1087
|
+
// ../../node_modules/lodash-es/_listCacheGet.js
|
|
1088
|
+
function listCacheGet(key) {
|
|
1089
|
+
var data = this.__data__, index = assocIndexOf_default(data, key);
|
|
1090
|
+
return index < 0 ? void 0 : data[index][1];
|
|
1091
|
+
}
|
|
1092
|
+
var listCacheGet_default = listCacheGet;
|
|
1093
|
+
|
|
1094
|
+
// ../../node_modules/lodash-es/_listCacheHas.js
|
|
1095
|
+
function listCacheHas(key) {
|
|
1096
|
+
return assocIndexOf_default(this.__data__, key) > -1;
|
|
1097
|
+
}
|
|
1098
|
+
var listCacheHas_default = listCacheHas;
|
|
1099
|
+
|
|
1100
|
+
// ../../node_modules/lodash-es/_listCacheSet.js
|
|
1101
|
+
function listCacheSet(key, value) {
|
|
1102
|
+
var data = this.__data__, index = assocIndexOf_default(data, key);
|
|
1103
|
+
if (index < 0) {
|
|
1104
|
+
++this.size;
|
|
1105
|
+
data.push([key, value]);
|
|
1106
|
+
} else {
|
|
1107
|
+
data[index][1] = value;
|
|
1108
|
+
}
|
|
1109
|
+
return this;
|
|
1110
|
+
}
|
|
1111
|
+
var listCacheSet_default = listCacheSet;
|
|
1112
|
+
|
|
1113
|
+
// ../../node_modules/lodash-es/_ListCache.js
|
|
1114
|
+
function ListCache(entries) {
|
|
1115
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
1116
|
+
this.clear();
|
|
1117
|
+
while (++index < length) {
|
|
1118
|
+
var entry = entries[index];
|
|
1119
|
+
this.set(entry[0], entry[1]);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
ListCache.prototype.clear = listCacheClear_default;
|
|
1123
|
+
ListCache.prototype["delete"] = listCacheDelete_default;
|
|
1124
|
+
ListCache.prototype.get = listCacheGet_default;
|
|
1125
|
+
ListCache.prototype.has = listCacheHas_default;
|
|
1126
|
+
ListCache.prototype.set = listCacheSet_default;
|
|
1127
|
+
var ListCache_default = ListCache;
|
|
1128
|
+
|
|
1129
|
+
// ../../node_modules/lodash-es/_Map.js
|
|
1130
|
+
var Map2 = getNative_default(root_default, "Map");
|
|
1131
|
+
var Map_default = Map2;
|
|
1132
|
+
|
|
1133
|
+
// ../../node_modules/lodash-es/_mapCacheClear.js
|
|
1134
|
+
function mapCacheClear() {
|
|
1135
|
+
this.size = 0;
|
|
1136
|
+
this.__data__ = {
|
|
1137
|
+
"hash": new Hash_default(),
|
|
1138
|
+
"map": new (Map_default || ListCache_default)(),
|
|
1139
|
+
"string": new Hash_default()
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
var mapCacheClear_default = mapCacheClear;
|
|
1143
|
+
|
|
1144
|
+
// ../../node_modules/lodash-es/_isKeyable.js
|
|
1145
|
+
function isKeyable(value) {
|
|
1146
|
+
var type = typeof value;
|
|
1147
|
+
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
1148
|
+
}
|
|
1149
|
+
var isKeyable_default = isKeyable;
|
|
1150
|
+
|
|
1151
|
+
// ../../node_modules/lodash-es/_getMapData.js
|
|
1152
|
+
function getMapData(map, key) {
|
|
1153
|
+
var data = map.__data__;
|
|
1154
|
+
return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
1155
|
+
}
|
|
1156
|
+
var getMapData_default = getMapData;
|
|
1157
|
+
|
|
1158
|
+
// ../../node_modules/lodash-es/_mapCacheDelete.js
|
|
1159
|
+
function mapCacheDelete(key) {
|
|
1160
|
+
var result = getMapData_default(this, key)["delete"](key);
|
|
1161
|
+
this.size -= result ? 1 : 0;
|
|
1162
|
+
return result;
|
|
1163
|
+
}
|
|
1164
|
+
var mapCacheDelete_default = mapCacheDelete;
|
|
1165
|
+
|
|
1166
|
+
// ../../node_modules/lodash-es/_mapCacheGet.js
|
|
1167
|
+
function mapCacheGet(key) {
|
|
1168
|
+
return getMapData_default(this, key).get(key);
|
|
1169
|
+
}
|
|
1170
|
+
var mapCacheGet_default = mapCacheGet;
|
|
1171
|
+
|
|
1172
|
+
// ../../node_modules/lodash-es/_mapCacheHas.js
|
|
1173
|
+
function mapCacheHas(key) {
|
|
1174
|
+
return getMapData_default(this, key).has(key);
|
|
1175
|
+
}
|
|
1176
|
+
var mapCacheHas_default = mapCacheHas;
|
|
1177
|
+
|
|
1178
|
+
// ../../node_modules/lodash-es/_mapCacheSet.js
|
|
1179
|
+
function mapCacheSet(key, value) {
|
|
1180
|
+
var data = getMapData_default(this, key), size = data.size;
|
|
1181
|
+
data.set(key, value);
|
|
1182
|
+
this.size += data.size == size ? 0 : 1;
|
|
1183
|
+
return this;
|
|
1184
|
+
}
|
|
1185
|
+
var mapCacheSet_default = mapCacheSet;
|
|
1186
|
+
|
|
1187
|
+
// ../../node_modules/lodash-es/_MapCache.js
|
|
1188
|
+
function MapCache(entries) {
|
|
1189
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
1190
|
+
this.clear();
|
|
1191
|
+
while (++index < length) {
|
|
1192
|
+
var entry = entries[index];
|
|
1193
|
+
this.set(entry[0], entry[1]);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
MapCache.prototype.clear = mapCacheClear_default;
|
|
1197
|
+
MapCache.prototype["delete"] = mapCacheDelete_default;
|
|
1198
|
+
MapCache.prototype.get = mapCacheGet_default;
|
|
1199
|
+
MapCache.prototype.has = mapCacheHas_default;
|
|
1200
|
+
MapCache.prototype.set = mapCacheSet_default;
|
|
1201
|
+
var MapCache_default = MapCache;
|
|
1202
|
+
|
|
1203
|
+
// ../../node_modules/lodash-es/memoize.js
|
|
1204
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
1205
|
+
function memoize(func, resolver) {
|
|
1206
|
+
if (typeof func != "function" || resolver != null && typeof resolver != "function") {
|
|
1207
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
1208
|
+
}
|
|
1209
|
+
var memoized = function() {
|
|
1210
|
+
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
1211
|
+
if (cache.has(key)) {
|
|
1212
|
+
return cache.get(key);
|
|
1213
|
+
}
|
|
1214
|
+
var result = func.apply(this, args);
|
|
1215
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
1216
|
+
return result;
|
|
1217
|
+
};
|
|
1218
|
+
memoized.cache = new (memoize.Cache || MapCache_default)();
|
|
1219
|
+
return memoized;
|
|
1220
|
+
}
|
|
1221
|
+
memoize.Cache = MapCache_default;
|
|
1222
|
+
var memoize_default = memoize;
|
|
1223
|
+
|
|
1224
|
+
// ../../node_modules/lodash-es/_memoizeCapped.js
|
|
1225
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
1226
|
+
function memoizeCapped(func) {
|
|
1227
|
+
var result = memoize_default(func, function(key) {
|
|
1228
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
1229
|
+
cache.clear();
|
|
1230
|
+
}
|
|
1231
|
+
return key;
|
|
1232
|
+
});
|
|
1233
|
+
var cache = result.cache;
|
|
1234
|
+
return result;
|
|
1235
|
+
}
|
|
1236
|
+
var memoizeCapped_default = memoizeCapped;
|
|
1237
|
+
|
|
1238
|
+
// ../../node_modules/lodash-es/_stringToPath.js
|
|
1239
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
1240
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
1241
|
+
var stringToPath = memoizeCapped_default(function(string) {
|
|
1242
|
+
var result = [];
|
|
1243
|
+
if (string.charCodeAt(0) === 46) {
|
|
1244
|
+
result.push("");
|
|
1245
|
+
}
|
|
1246
|
+
string.replace(rePropName, function(match, number, quote, subString) {
|
|
1247
|
+
result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
|
|
1248
|
+
});
|
|
1249
|
+
return result;
|
|
1250
|
+
});
|
|
1251
|
+
var stringToPath_default = stringToPath;
|
|
1252
|
+
|
|
1253
|
+
// ../../node_modules/lodash-es/_arrayMap.js
|
|
1254
|
+
function arrayMap(array, iteratee) {
|
|
1255
|
+
var index = -1, length = array == null ? 0 : array.length, result = Array(length);
|
|
1256
|
+
while (++index < length) {
|
|
1257
|
+
result[index] = iteratee(array[index], index, array);
|
|
1258
|
+
}
|
|
1259
|
+
return result;
|
|
1260
|
+
}
|
|
1261
|
+
var arrayMap_default = arrayMap;
|
|
1262
|
+
|
|
1263
|
+
// ../../node_modules/lodash-es/_baseToString.js
|
|
1264
|
+
var INFINITY = 1 / 0;
|
|
1265
|
+
var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
|
|
1266
|
+
var symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
1267
|
+
function baseToString(value) {
|
|
1268
|
+
if (typeof value == "string") {
|
|
1269
|
+
return value;
|
|
1270
|
+
}
|
|
1271
|
+
if (isArray_default(value)) {
|
|
1272
|
+
return arrayMap_default(value, baseToString) + "";
|
|
1273
|
+
}
|
|
1274
|
+
if (isSymbol_default(value)) {
|
|
1275
|
+
return symbolToString ? symbolToString.call(value) : "";
|
|
1276
|
+
}
|
|
1277
|
+
var result = value + "";
|
|
1278
|
+
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
|
|
1279
|
+
}
|
|
1280
|
+
var baseToString_default = baseToString;
|
|
1281
|
+
|
|
1282
|
+
// ../../node_modules/lodash-es/toString.js
|
|
1283
|
+
function toString(value) {
|
|
1284
|
+
return value == null ? "" : baseToString_default(value);
|
|
1285
|
+
}
|
|
1286
|
+
var toString_default = toString;
|
|
1287
|
+
|
|
1288
|
+
// ../../node_modules/lodash-es/_castPath.js
|
|
1289
|
+
function castPath(value, object) {
|
|
1290
|
+
if (isArray_default(value)) {
|
|
1291
|
+
return value;
|
|
1292
|
+
}
|
|
1293
|
+
return isKey_default(value, object) ? [value] : stringToPath_default(toString_default(value));
|
|
1294
|
+
}
|
|
1295
|
+
var castPath_default = castPath;
|
|
1296
|
+
|
|
1297
|
+
// ../../node_modules/lodash-es/_toKey.js
|
|
1298
|
+
var INFINITY2 = 1 / 0;
|
|
1299
|
+
function toKey(value) {
|
|
1300
|
+
if (typeof value == "string" || isSymbol_default(value)) {
|
|
1301
|
+
return value;
|
|
1302
|
+
}
|
|
1303
|
+
var result = value + "";
|
|
1304
|
+
return result == "0" && 1 / value == -INFINITY2 ? "-0" : result;
|
|
1305
|
+
}
|
|
1306
|
+
var toKey_default = toKey;
|
|
1307
|
+
|
|
1308
|
+
// ../../node_modules/lodash-es/_baseGet.js
|
|
1309
|
+
function baseGet(object, path) {
|
|
1310
|
+
path = castPath_default(path, object);
|
|
1311
|
+
var index = 0, length = path.length;
|
|
1312
|
+
while (object != null && index < length) {
|
|
1313
|
+
object = object[toKey_default(path[index++])];
|
|
1314
|
+
}
|
|
1315
|
+
return index && index == length ? object : void 0;
|
|
1316
|
+
}
|
|
1317
|
+
var baseGet_default = baseGet;
|
|
1318
|
+
|
|
1319
|
+
// ../../node_modules/lodash-es/get.js
|
|
1320
|
+
function get(object, path, defaultValue) {
|
|
1321
|
+
var result = object == null ? void 0 : baseGet_default(object, path);
|
|
1322
|
+
return result === void 0 ? defaultValue : result;
|
|
1323
|
+
}
|
|
1324
|
+
var get_default = get;
|
|
1325
|
+
|
|
1326
|
+
// ../../node_modules/lodash-es/_overArg.js
|
|
1327
|
+
function overArg(func, transform) {
|
|
1328
|
+
return function(arg) {
|
|
1329
|
+
return func(transform(arg));
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
var overArg_default = overArg;
|
|
1333
|
+
|
|
1334
|
+
// ../../node_modules/lodash-es/_getPrototype.js
|
|
1335
|
+
var getPrototype = overArg_default(Object.getPrototypeOf, Object);
|
|
1336
|
+
var getPrototype_default = getPrototype;
|
|
1337
|
+
|
|
1338
|
+
// ../../node_modules/lodash-es/isPlainObject.js
|
|
1339
|
+
var objectTag = "[object Object]";
|
|
1340
|
+
var funcProto3 = Function.prototype;
|
|
1341
|
+
var objectProto6 = Object.prototype;
|
|
1342
|
+
var funcToString3 = funcProto3.toString;
|
|
1343
|
+
var hasOwnProperty5 = objectProto6.hasOwnProperty;
|
|
1344
|
+
var objectCtorString = funcToString3.call(Object);
|
|
1345
|
+
function isPlainObject(value) {
|
|
1346
|
+
if (!isObjectLike_default(value) || baseGetTag_default(value) != objectTag) {
|
|
1347
|
+
return false;
|
|
1348
|
+
}
|
|
1349
|
+
var proto = getPrototype_default(value);
|
|
1350
|
+
if (proto === null) {
|
|
1351
|
+
return true;
|
|
1352
|
+
}
|
|
1353
|
+
var Ctor = hasOwnProperty5.call(proto, "constructor") && proto.constructor;
|
|
1354
|
+
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
|
|
1355
|
+
}
|
|
1356
|
+
var isPlainObject_default = isPlainObject;
|
|
1357
|
+
|
|
1358
|
+
// ../../node_modules/lodash-es/last.js
|
|
1359
|
+
function last(array) {
|
|
1360
|
+
var length = array == null ? 0 : array.length;
|
|
1361
|
+
return length ? array[length - 1] : void 0;
|
|
1362
|
+
}
|
|
1363
|
+
var last_default = last;
|
|
1364
|
+
|
|
1365
|
+
// ../dataverse/src/pointer.ts
|
|
1366
|
+
var pointerMetaWeakMap = /* @__PURE__ */ new WeakMap();
|
|
1367
|
+
var cachedSubPathPointersWeakMap = /* @__PURE__ */ new WeakMap();
|
|
1368
|
+
var pointerMetaSymbol = Symbol("pointerMeta");
|
|
1369
|
+
var proxyHandler = {
|
|
1370
|
+
get(pointerKey, prop) {
|
|
1371
|
+
if (prop === pointerMetaSymbol)
|
|
1372
|
+
return pointerMetaWeakMap.get(pointerKey);
|
|
1373
|
+
let subPathPointers = cachedSubPathPointersWeakMap.get(pointerKey);
|
|
1374
|
+
if (!subPathPointers) {
|
|
1375
|
+
subPathPointers = /* @__PURE__ */ new Map();
|
|
1376
|
+
cachedSubPathPointersWeakMap.set(pointerKey, subPathPointers);
|
|
1377
|
+
}
|
|
1378
|
+
const existing = subPathPointers.get(prop);
|
|
1379
|
+
if (existing !== void 0)
|
|
1380
|
+
return existing;
|
|
1381
|
+
const meta = pointerMetaWeakMap.get(pointerKey);
|
|
1382
|
+
const subPointer = pointer({ root: meta.root, path: [...meta.path, prop] });
|
|
1383
|
+
subPathPointers.set(prop, subPointer);
|
|
1384
|
+
return subPointer;
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
var getPointerMeta = (p) => {
|
|
1388
|
+
const meta = p[pointerMetaSymbol];
|
|
1389
|
+
return meta;
|
|
1390
|
+
};
|
|
1391
|
+
var getPointerParts = (p) => {
|
|
1392
|
+
const { root: root2, path } = getPointerMeta(p);
|
|
1393
|
+
return { root: root2, path };
|
|
1394
|
+
};
|
|
1395
|
+
function pointer(args) {
|
|
1396
|
+
const meta = {
|
|
1397
|
+
root: args.root,
|
|
1398
|
+
path: args.path ?? []
|
|
1399
|
+
};
|
|
1400
|
+
const pointerKey = {};
|
|
1401
|
+
pointerMetaWeakMap.set(pointerKey, meta);
|
|
1402
|
+
return new Proxy(pointerKey, proxyHandler);
|
|
1403
|
+
}
|
|
1404
|
+
var pointer_default = pointer;
|
|
1405
|
+
var isPointer = (p) => {
|
|
1406
|
+
return p && !!getPointerMeta(p);
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1409
|
+
// ../dataverse/src/utils/updateDeep.ts
|
|
1410
|
+
function updateDeep(state2, path, reducer) {
|
|
1411
|
+
if (path.length === 0)
|
|
1412
|
+
return reducer(state2);
|
|
1413
|
+
return hoop(state2, path, reducer);
|
|
1414
|
+
}
|
|
1415
|
+
var hoop = (s, path, reducer) => {
|
|
1416
|
+
if (path.length === 0) {
|
|
1417
|
+
return reducer(s);
|
|
1418
|
+
}
|
|
1419
|
+
if (Array.isArray(s)) {
|
|
1420
|
+
let [index, ...restOfPath] = path;
|
|
1421
|
+
index = parseInt(String(index), 10);
|
|
1422
|
+
if (isNaN(index))
|
|
1423
|
+
index = 0;
|
|
1424
|
+
const oldVal = s[index];
|
|
1425
|
+
const newVal = hoop(oldVal, restOfPath, reducer);
|
|
1426
|
+
if (oldVal === newVal)
|
|
1427
|
+
return s;
|
|
1428
|
+
const newS = [...s];
|
|
1429
|
+
newS.splice(index, 1, newVal);
|
|
1430
|
+
return newS;
|
|
1431
|
+
} else if (typeof s === "object" && s !== null) {
|
|
1432
|
+
const [key, ...restOfPath] = path;
|
|
1433
|
+
const oldVal = s[key];
|
|
1434
|
+
const newVal = hoop(oldVal, restOfPath, reducer);
|
|
1435
|
+
if (oldVal === newVal)
|
|
1436
|
+
return s;
|
|
1437
|
+
const newS = { ...s, [key]: newVal };
|
|
1438
|
+
return newS;
|
|
1439
|
+
} else {
|
|
1440
|
+
const [key, ...restOfPath] = path;
|
|
1441
|
+
return { [key]: hoop(void 0, restOfPath, reducer) };
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1445
|
+
// ../dataverse/src/utils/Stack.ts
|
|
1446
|
+
var Stack = class {
|
|
1447
|
+
constructor() {
|
|
1448
|
+
this._head = void 0;
|
|
1449
|
+
}
|
|
1450
|
+
peek() {
|
|
1451
|
+
return this._head && this._head.data;
|
|
1452
|
+
}
|
|
1453
|
+
pop() {
|
|
1454
|
+
const head = this._head;
|
|
1455
|
+
if (!head) {
|
|
1456
|
+
return void 0;
|
|
1457
|
+
}
|
|
1458
|
+
this._head = head.next;
|
|
1459
|
+
return head.data;
|
|
1460
|
+
}
|
|
1461
|
+
push(data) {
|
|
1462
|
+
const node = { next: this._head, data };
|
|
1463
|
+
this._head = node;
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
// ../dataverse/src/prism/Interface.ts
|
|
1468
|
+
function isPrism(d) {
|
|
1469
|
+
return !!(d && d.isPrism && d.isPrism === true);
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
// ../dataverse/src/prism/discoveryMechanism.ts
|
|
1473
|
+
function createMechanism() {
|
|
1474
|
+
const noop = () => {
|
|
1475
|
+
};
|
|
1476
|
+
const stack = new Stack();
|
|
1477
|
+
const noopCollector = noop;
|
|
1478
|
+
const pushCollector2 = (collector) => {
|
|
1479
|
+
stack.push(collector);
|
|
1480
|
+
};
|
|
1481
|
+
const popCollector2 = (collector) => {
|
|
1482
|
+
const existing = stack.peek();
|
|
1483
|
+
if (existing !== collector) {
|
|
1484
|
+
throw new Error(`Popped collector is not on top of the stack`);
|
|
1485
|
+
}
|
|
1486
|
+
stack.pop();
|
|
1487
|
+
};
|
|
1488
|
+
const startIgnoringDependencies2 = () => {
|
|
1489
|
+
stack.push(noopCollector);
|
|
1490
|
+
};
|
|
1491
|
+
const stopIgnoringDependencies2 = () => {
|
|
1492
|
+
if (stack.peek() !== noopCollector) {
|
|
1493
|
+
if (process.env.NODE_ENV === "development") {
|
|
1494
|
+
console.warn("This should never happen");
|
|
1495
|
+
}
|
|
1496
|
+
} else {
|
|
1497
|
+
stack.pop();
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
const reportResolutionStart2 = (d) => {
|
|
1501
|
+
const possibleCollector = stack.peek();
|
|
1502
|
+
if (possibleCollector) {
|
|
1503
|
+
possibleCollector(d);
|
|
1504
|
+
}
|
|
1505
|
+
stack.push(noopCollector);
|
|
1506
|
+
};
|
|
1507
|
+
const reportResolutionEnd2 = (_d) => {
|
|
1508
|
+
stack.pop();
|
|
1509
|
+
};
|
|
1510
|
+
return {
|
|
1511
|
+
type: "Dataverse_discoveryMechanism",
|
|
1512
|
+
startIgnoringDependencies: startIgnoringDependencies2,
|
|
1513
|
+
stopIgnoringDependencies: stopIgnoringDependencies2,
|
|
1514
|
+
reportResolutionStart: reportResolutionStart2,
|
|
1515
|
+
reportResolutionEnd: reportResolutionEnd2,
|
|
1516
|
+
pushCollector: pushCollector2,
|
|
1517
|
+
popCollector: popCollector2
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
function getSharedMechanism() {
|
|
1521
|
+
const varName = "__dataverse_discoveryMechanism_sharedStack";
|
|
1522
|
+
const root2 = typeof window !== "undefined" ? window : typeof window !== "undefined" ? window : {};
|
|
1523
|
+
if (root2) {
|
|
1524
|
+
const existingMechanism = (
|
|
1525
|
+
// @ts-ignore ignore
|
|
1526
|
+
root2[varName]
|
|
1527
|
+
);
|
|
1528
|
+
if (existingMechanism && typeof existingMechanism === "object" && existingMechanism.type === "Dataverse_discoveryMechanism") {
|
|
1529
|
+
return existingMechanism;
|
|
1530
|
+
} else {
|
|
1531
|
+
const mechanism = createMechanism();
|
|
1532
|
+
root2[varName] = mechanism;
|
|
1533
|
+
return mechanism;
|
|
1534
|
+
}
|
|
1535
|
+
} else {
|
|
1536
|
+
return createMechanism();
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
var {
|
|
1540
|
+
startIgnoringDependencies,
|
|
1541
|
+
stopIgnoringDependencies,
|
|
1542
|
+
reportResolutionEnd,
|
|
1543
|
+
reportResolutionStart,
|
|
1544
|
+
pushCollector,
|
|
1545
|
+
popCollector
|
|
1546
|
+
} = getSharedMechanism();
|
|
1547
|
+
|
|
1548
|
+
// ../dataverse/src/prism/prism.ts
|
|
1549
|
+
var voidFn = () => {
|
|
1550
|
+
};
|
|
1551
|
+
var HotHandle = class {
|
|
1552
|
+
constructor(_fn, _prismInstance) {
|
|
1553
|
+
this._fn = _fn;
|
|
1554
|
+
this._prismInstance = _prismInstance;
|
|
1555
|
+
this._didMarkDependentsAsStale = false;
|
|
1556
|
+
this._isFresh = false;
|
|
1557
|
+
this._cacheOfDendencyValues = /* @__PURE__ */ new Map();
|
|
1558
|
+
/**
|
|
1559
|
+
* @internal
|
|
1560
|
+
*/
|
|
1561
|
+
this._dependents = /* @__PURE__ */ new Set();
|
|
1562
|
+
/**
|
|
1563
|
+
* @internal
|
|
1564
|
+
*/
|
|
1565
|
+
this._dependencies = /* @__PURE__ */ new Set();
|
|
1566
|
+
this._possiblyStaleDeps = /* @__PURE__ */ new Set();
|
|
1567
|
+
this._scope = new HotScope(
|
|
1568
|
+
this
|
|
1569
|
+
);
|
|
1570
|
+
/**
|
|
1571
|
+
* @internal
|
|
1572
|
+
*/
|
|
1573
|
+
this._lastValue = void 0;
|
|
1574
|
+
/**
|
|
1575
|
+
* If true, the prism is stale even though its dependencies aren't
|
|
1576
|
+
* marked as such. This is used by `prism.source()` and `prism.state()`
|
|
1577
|
+
* to mark the prism as stale.
|
|
1578
|
+
*/
|
|
1579
|
+
this._forciblySetToStale = false;
|
|
1580
|
+
this._reactToDependencyGoingStale = (which) => {
|
|
1581
|
+
this._possiblyStaleDeps.add(which);
|
|
1582
|
+
this._markAsStale();
|
|
1583
|
+
};
|
|
1584
|
+
for (const d of this._dependencies) {
|
|
1585
|
+
d._addDependent(this._reactToDependencyGoingStale);
|
|
1586
|
+
}
|
|
1587
|
+
startIgnoringDependencies();
|
|
1588
|
+
this.getValue();
|
|
1589
|
+
stopIgnoringDependencies();
|
|
1590
|
+
}
|
|
1591
|
+
get hasDependents() {
|
|
1592
|
+
return this._dependents.size > 0;
|
|
1593
|
+
}
|
|
1594
|
+
removeDependent(d) {
|
|
1595
|
+
this._dependents.delete(d);
|
|
1596
|
+
}
|
|
1597
|
+
addDependent(d) {
|
|
1598
|
+
this._dependents.add(d);
|
|
1599
|
+
}
|
|
1600
|
+
destroy() {
|
|
1601
|
+
for (const d of this._dependencies) {
|
|
1602
|
+
d._removeDependent(this._reactToDependencyGoingStale);
|
|
1603
|
+
}
|
|
1604
|
+
cleanupScopeStack(this._scope);
|
|
1605
|
+
}
|
|
1606
|
+
getValue() {
|
|
1607
|
+
if (!this._isFresh) {
|
|
1608
|
+
const newValue = this._recalculate();
|
|
1609
|
+
this._lastValue = newValue;
|
|
1610
|
+
this._isFresh = true;
|
|
1611
|
+
this._didMarkDependentsAsStale = false;
|
|
1612
|
+
this._forciblySetToStale = false;
|
|
1613
|
+
}
|
|
1614
|
+
return this._lastValue;
|
|
1615
|
+
}
|
|
1616
|
+
_recalculate() {
|
|
1617
|
+
let value;
|
|
1618
|
+
if (!this._forciblySetToStale) {
|
|
1619
|
+
if (this._possiblyStaleDeps.size > 0) {
|
|
1620
|
+
let anActuallyStaleDepWasFound = false;
|
|
1621
|
+
startIgnoringDependencies();
|
|
1622
|
+
for (const dep of this._possiblyStaleDeps) {
|
|
1623
|
+
if (this._cacheOfDendencyValues.get(dep) !== dep.getValue()) {
|
|
1624
|
+
anActuallyStaleDepWasFound = true;
|
|
1625
|
+
break;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
stopIgnoringDependencies();
|
|
1629
|
+
this._possiblyStaleDeps.clear();
|
|
1630
|
+
if (!anActuallyStaleDepWasFound) {
|
|
1631
|
+
return this._lastValue;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
const newDeps = /* @__PURE__ */ new Set();
|
|
1636
|
+
this._cacheOfDendencyValues.clear();
|
|
1637
|
+
const collector = (observedDep) => {
|
|
1638
|
+
newDeps.add(observedDep);
|
|
1639
|
+
this._addDependency(observedDep);
|
|
1640
|
+
};
|
|
1641
|
+
pushCollector(collector);
|
|
1642
|
+
hookScopeStack.push(this._scope);
|
|
1643
|
+
try {
|
|
1644
|
+
value = this._fn();
|
|
1645
|
+
} catch (error) {
|
|
1646
|
+
console.error(error);
|
|
1647
|
+
} finally {
|
|
1648
|
+
const topOfTheStack = hookScopeStack.pop();
|
|
1649
|
+
if (topOfTheStack !== this._scope) {
|
|
1650
|
+
console.warn(
|
|
1651
|
+
// @todo guide the user to report the bug in an issue
|
|
1652
|
+
`The Prism hook stack has slipped. This is a bug.`
|
|
1653
|
+
);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
popCollector(collector);
|
|
1657
|
+
for (const dep of this._dependencies) {
|
|
1658
|
+
if (!newDeps.has(dep)) {
|
|
1659
|
+
this._removeDependency(dep);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
this._dependencies = newDeps;
|
|
1663
|
+
startIgnoringDependencies();
|
|
1664
|
+
for (const dep of newDeps) {
|
|
1665
|
+
this._cacheOfDendencyValues.set(dep, dep.getValue());
|
|
1666
|
+
}
|
|
1667
|
+
stopIgnoringDependencies();
|
|
1668
|
+
return value;
|
|
1669
|
+
}
|
|
1670
|
+
forceStale() {
|
|
1671
|
+
this._forciblySetToStale = true;
|
|
1672
|
+
this._markAsStale();
|
|
1673
|
+
}
|
|
1674
|
+
_markAsStale() {
|
|
1675
|
+
if (this._didMarkDependentsAsStale)
|
|
1676
|
+
return;
|
|
1677
|
+
this._didMarkDependentsAsStale = true;
|
|
1678
|
+
this._isFresh = false;
|
|
1679
|
+
for (const dependent of this._dependents) {
|
|
1680
|
+
dependent(this._prismInstance);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* @internal
|
|
1685
|
+
*/
|
|
1686
|
+
_addDependency(d) {
|
|
1687
|
+
if (this._dependencies.has(d))
|
|
1688
|
+
return;
|
|
1689
|
+
this._dependencies.add(d);
|
|
1690
|
+
d._addDependent(this._reactToDependencyGoingStale);
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* @internal
|
|
1694
|
+
*/
|
|
1695
|
+
_removeDependency(d) {
|
|
1696
|
+
if (!this._dependencies.has(d))
|
|
1697
|
+
return;
|
|
1698
|
+
this._dependencies.delete(d);
|
|
1699
|
+
d._removeDependent(this._reactToDependencyGoingStale);
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
var emptyObject = {};
|
|
1703
|
+
var PrismInstance = class {
|
|
1704
|
+
constructor(_fn) {
|
|
1705
|
+
this._fn = _fn;
|
|
1706
|
+
/**
|
|
1707
|
+
* Whether the object is a prism.
|
|
1708
|
+
*/
|
|
1709
|
+
this.isPrism = true;
|
|
1710
|
+
this._state = {
|
|
1711
|
+
hot: false,
|
|
1712
|
+
handle: void 0
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
/**
|
|
1716
|
+
* Whether the prism is hot.
|
|
1717
|
+
*/
|
|
1718
|
+
get isHot() {
|
|
1719
|
+
return this._state.hot;
|
|
1720
|
+
}
|
|
1721
|
+
onChange(ticker, listener, immediate = false) {
|
|
1722
|
+
const dependent = () => {
|
|
1723
|
+
ticker.onThisOrNextTick(refresh);
|
|
1724
|
+
};
|
|
1725
|
+
let lastValue = (
|
|
1726
|
+
// use an empty object as the initial value so that the listener is called on the first tick.
|
|
1727
|
+
// if we were to use, say, undefined, and this.getValue() also returned undefined, the listener
|
|
1728
|
+
// would never be called.
|
|
1729
|
+
emptyObject
|
|
1730
|
+
);
|
|
1731
|
+
const refresh = () => {
|
|
1732
|
+
const newValue = this.getValue();
|
|
1733
|
+
if (newValue === lastValue)
|
|
1734
|
+
return;
|
|
1735
|
+
lastValue = newValue;
|
|
1736
|
+
listener(newValue);
|
|
1737
|
+
};
|
|
1738
|
+
this._addDependent(dependent);
|
|
1739
|
+
if (immediate) {
|
|
1740
|
+
lastValue = this.getValue();
|
|
1741
|
+
listener(lastValue);
|
|
1742
|
+
}
|
|
1743
|
+
const unsubscribe = () => {
|
|
1744
|
+
this._removeDependent(dependent);
|
|
1745
|
+
ticker.offThisOrNextTick(refresh);
|
|
1746
|
+
ticker.offNextTick(refresh);
|
|
1747
|
+
};
|
|
1748
|
+
return unsubscribe;
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Calls `callback` every time the prism's state goes from `fresh-\>stale.` Returns an `unsubscribe()` function.
|
|
1752
|
+
*/
|
|
1753
|
+
onStale(callback) {
|
|
1754
|
+
const untap = () => {
|
|
1755
|
+
this._removeDependent(fn);
|
|
1756
|
+
};
|
|
1757
|
+
const fn = () => callback();
|
|
1758
|
+
this._addDependent(fn);
|
|
1759
|
+
return untap;
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Keep the prism hot, even if there are no tappers (subscribers).
|
|
1763
|
+
*/
|
|
1764
|
+
keepHot() {
|
|
1765
|
+
return this.onStale(() => {
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Add a prism as a dependent of this prism.
|
|
1770
|
+
*
|
|
1771
|
+
* @param d - The prism to be made a dependent of this prism.
|
|
1772
|
+
*
|
|
1773
|
+
* @see _removeDependent
|
|
1774
|
+
*/
|
|
1775
|
+
_addDependent(d) {
|
|
1776
|
+
if (!this._state.hot) {
|
|
1777
|
+
this._goHot();
|
|
1778
|
+
}
|
|
1779
|
+
this._state.handle.addDependent(d);
|
|
1780
|
+
}
|
|
1781
|
+
_goHot() {
|
|
1782
|
+
const hotHandle = new HotHandle(this._fn, this);
|
|
1783
|
+
this._state = {
|
|
1784
|
+
hot: true,
|
|
1785
|
+
handle: hotHandle
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Remove a prism as a dependent of this prism.
|
|
1790
|
+
*
|
|
1791
|
+
* @param d - The prism to be removed from as a dependent of this prism.
|
|
1792
|
+
*
|
|
1793
|
+
* @see _addDependent
|
|
1794
|
+
*/
|
|
1795
|
+
_removeDependent(d) {
|
|
1796
|
+
const state2 = this._state;
|
|
1797
|
+
if (!state2.hot) {
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
const handle = state2.handle;
|
|
1801
|
+
handle.removeDependent(d);
|
|
1802
|
+
if (!handle.hasDependents) {
|
|
1803
|
+
this._state = { hot: false, handle: void 0 };
|
|
1804
|
+
handle.destroy();
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Gets the current value of the prism. If the value is stale, it causes the prism to freshen.
|
|
1809
|
+
*/
|
|
1810
|
+
getValue() {
|
|
1811
|
+
reportResolutionStart(this);
|
|
1812
|
+
const state2 = this._state;
|
|
1813
|
+
let val2;
|
|
1814
|
+
if (state2.hot) {
|
|
1815
|
+
val2 = state2.handle.getValue();
|
|
1816
|
+
} else {
|
|
1817
|
+
val2 = calculateColdPrism(this._fn);
|
|
1818
|
+
}
|
|
1819
|
+
reportResolutionEnd(this);
|
|
1820
|
+
return val2;
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
var HotScope = class _HotScope {
|
|
1824
|
+
constructor(_hotHandle) {
|
|
1825
|
+
this._hotHandle = _hotHandle;
|
|
1826
|
+
this._refs = /* @__PURE__ */ new Map();
|
|
1827
|
+
this.isPrismScope = true;
|
|
1828
|
+
// NOTE probably not a great idea to eager-allocate all of these objects/maps for every scope,
|
|
1829
|
+
// especially because most wouldn't get used in the majority of cases. However, back when these
|
|
1830
|
+
// were stored on weakmaps, they were uncomfortable to inspect in the debugger.
|
|
1831
|
+
this.subs = {};
|
|
1832
|
+
this.effects = /* @__PURE__ */ new Map();
|
|
1833
|
+
this.memos = /* @__PURE__ */ new Map();
|
|
1834
|
+
}
|
|
1835
|
+
ref(key, initialValue) {
|
|
1836
|
+
let ref2 = this._refs.get(key);
|
|
1837
|
+
if (ref2 !== void 0) {
|
|
1838
|
+
return ref2;
|
|
1839
|
+
} else {
|
|
1840
|
+
const ref3 = {
|
|
1841
|
+
current: initialValue
|
|
1842
|
+
};
|
|
1843
|
+
this._refs.set(key, ref3);
|
|
1844
|
+
return ref3;
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
effect(key, cb, deps) {
|
|
1848
|
+
let effect2 = this.effects.get(key);
|
|
1849
|
+
if (effect2 === void 0) {
|
|
1850
|
+
effect2 = {
|
|
1851
|
+
cleanup: voidFn,
|
|
1852
|
+
deps: void 0
|
|
1853
|
+
};
|
|
1854
|
+
this.effects.set(key, effect2);
|
|
1855
|
+
}
|
|
1856
|
+
if (depsHaveChanged(effect2.deps, deps)) {
|
|
1857
|
+
effect2.cleanup();
|
|
1858
|
+
startIgnoringDependencies();
|
|
1859
|
+
effect2.cleanup = safelyRun(cb, voidFn).value;
|
|
1860
|
+
stopIgnoringDependencies();
|
|
1861
|
+
effect2.deps = deps;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
memo(key, fn, deps) {
|
|
1865
|
+
let memo2 = this.memos.get(key);
|
|
1866
|
+
if (memo2 === void 0) {
|
|
1867
|
+
memo2 = {
|
|
1868
|
+
cachedValue: null,
|
|
1869
|
+
// undefined will always indicate "deps have changed", so we set its initial value as such
|
|
1870
|
+
deps: void 0
|
|
1871
|
+
};
|
|
1872
|
+
this.memos.set(key, memo2);
|
|
1873
|
+
}
|
|
1874
|
+
if (depsHaveChanged(memo2.deps, deps)) {
|
|
1875
|
+
startIgnoringDependencies();
|
|
1876
|
+
memo2.cachedValue = safelyRun(fn, void 0).value;
|
|
1877
|
+
stopIgnoringDependencies();
|
|
1878
|
+
memo2.deps = deps;
|
|
1879
|
+
}
|
|
1880
|
+
return memo2.cachedValue;
|
|
1881
|
+
}
|
|
1882
|
+
state(key, initialValue) {
|
|
1883
|
+
const { value, setValue } = this.memo(
|
|
1884
|
+
"state/" + key,
|
|
1885
|
+
() => {
|
|
1886
|
+
const value2 = { current: initialValue };
|
|
1887
|
+
const setValue2 = (newValue) => {
|
|
1888
|
+
value2.current = newValue;
|
|
1889
|
+
this._hotHandle.forceStale();
|
|
1890
|
+
};
|
|
1891
|
+
return { value: value2, setValue: setValue2 };
|
|
1892
|
+
},
|
|
1893
|
+
[]
|
|
1894
|
+
);
|
|
1895
|
+
return [value.current, setValue];
|
|
1896
|
+
}
|
|
1897
|
+
sub(key) {
|
|
1898
|
+
if (!this.subs[key]) {
|
|
1899
|
+
this.subs[key] = new _HotScope(this._hotHandle);
|
|
1900
|
+
}
|
|
1901
|
+
return this.subs[key];
|
|
1902
|
+
}
|
|
1903
|
+
cleanupEffects() {
|
|
1904
|
+
for (const effect2 of this.effects.values()) {
|
|
1905
|
+
safelyRun(effect2.cleanup, void 0);
|
|
1906
|
+
}
|
|
1907
|
+
this.effects.clear();
|
|
1908
|
+
}
|
|
1909
|
+
source(subscribe, getValue2) {
|
|
1910
|
+
const sourceKey = "$$source/blah";
|
|
1911
|
+
this.effect(
|
|
1912
|
+
sourceKey,
|
|
1913
|
+
() => {
|
|
1914
|
+
const unsub = subscribe(() => {
|
|
1915
|
+
this._hotHandle.forceStale();
|
|
1916
|
+
});
|
|
1917
|
+
return unsub;
|
|
1918
|
+
},
|
|
1919
|
+
[subscribe]
|
|
1920
|
+
);
|
|
1921
|
+
return getValue2();
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
function cleanupScopeStack(scope2) {
|
|
1925
|
+
for (const sub2 of Object.values(scope2.subs)) {
|
|
1926
|
+
cleanupScopeStack(sub2);
|
|
1927
|
+
}
|
|
1928
|
+
scope2.cleanupEffects();
|
|
1929
|
+
}
|
|
1930
|
+
function safelyRun(fn, returnValueInCaseOfError) {
|
|
1931
|
+
try {
|
|
1932
|
+
return { value: fn(), ok: true };
|
|
1933
|
+
} catch (error) {
|
|
1934
|
+
setTimeout(function PrismReportThrow() {
|
|
1935
|
+
throw error;
|
|
1936
|
+
});
|
|
1937
|
+
return { value: returnValueInCaseOfError, ok: false };
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
var hookScopeStack = new Stack();
|
|
1941
|
+
function ref(key, initialValue) {
|
|
1942
|
+
const scope2 = hookScopeStack.peek();
|
|
1943
|
+
if (!scope2) {
|
|
1944
|
+
throw new Error(`prism.ref() is called outside of a prism() call.`);
|
|
1945
|
+
}
|
|
1946
|
+
return scope2.ref(key, initialValue);
|
|
1947
|
+
}
|
|
1948
|
+
function effect(key, cb, deps) {
|
|
1949
|
+
const scope2 = hookScopeStack.peek();
|
|
1950
|
+
if (!scope2) {
|
|
1951
|
+
throw new Error(`prism.effect() is called outside of a prism() call.`);
|
|
1952
|
+
}
|
|
1953
|
+
return scope2.effect(key, cb, deps);
|
|
1954
|
+
}
|
|
1955
|
+
function depsHaveChanged(oldDeps, newDeps) {
|
|
1956
|
+
if (oldDeps === void 0 || newDeps === void 0) {
|
|
1957
|
+
return true;
|
|
1958
|
+
}
|
|
1959
|
+
const len = oldDeps.length;
|
|
1960
|
+
if (len !== newDeps.length)
|
|
1961
|
+
return true;
|
|
1962
|
+
for (let i = 0; i < len; i++) {
|
|
1963
|
+
if (oldDeps[i] !== newDeps[i])
|
|
1964
|
+
return true;
|
|
1965
|
+
}
|
|
1966
|
+
return false;
|
|
1967
|
+
}
|
|
1968
|
+
function memo(key, fn, deps) {
|
|
1969
|
+
const scope2 = hookScopeStack.peek();
|
|
1970
|
+
if (!scope2) {
|
|
1971
|
+
throw new Error(`prism.memo() is called outside of a prism() call.`);
|
|
1972
|
+
}
|
|
1973
|
+
return scope2.memo(key, fn, deps);
|
|
1974
|
+
}
|
|
1975
|
+
function state(key, initialValue) {
|
|
1976
|
+
const scope2 = hookScopeStack.peek();
|
|
1977
|
+
if (!scope2) {
|
|
1978
|
+
throw new Error(`prism.state() is called outside of a prism() call.`);
|
|
1979
|
+
}
|
|
1980
|
+
return scope2.state(key, initialValue);
|
|
1981
|
+
}
|
|
1982
|
+
function ensurePrism() {
|
|
1983
|
+
const scope2 = hookScopeStack.peek();
|
|
1984
|
+
if (!scope2) {
|
|
1985
|
+
throw new Error(`The parent function is called outside of a prism() call.`);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
function scope(key, fn) {
|
|
1989
|
+
const parentScope = hookScopeStack.peek();
|
|
1990
|
+
if (!parentScope) {
|
|
1991
|
+
throw new Error(`prism.scope() is called outside of a prism() call.`);
|
|
1992
|
+
}
|
|
1993
|
+
const subScope = parentScope.sub(key);
|
|
1994
|
+
hookScopeStack.push(subScope);
|
|
1995
|
+
const ret = safelyRun(fn, void 0).value;
|
|
1996
|
+
hookScopeStack.pop();
|
|
1997
|
+
return ret;
|
|
1998
|
+
}
|
|
1999
|
+
function sub(key, fn, deps) {
|
|
2000
|
+
return memo(key, () => prism(fn), deps).getValue();
|
|
2001
|
+
}
|
|
2002
|
+
function inPrism() {
|
|
2003
|
+
return !!hookScopeStack.peek();
|
|
2004
|
+
}
|
|
2005
|
+
function source(subscribe, getValue2) {
|
|
2006
|
+
const scope2 = hookScopeStack.peek();
|
|
2007
|
+
if (!scope2) {
|
|
2008
|
+
throw new Error(`prism.source() is called outside of a prism() call.`);
|
|
2009
|
+
}
|
|
2010
|
+
return scope2.source(subscribe, getValue2);
|
|
2011
|
+
}
|
|
2012
|
+
var prism = (fn) => {
|
|
2013
|
+
return new PrismInstance(fn);
|
|
2014
|
+
};
|
|
2015
|
+
var ColdScope = class _ColdScope {
|
|
2016
|
+
effect(key, cb, deps) {
|
|
2017
|
+
console.warn(`prism.effect() does not run in cold prisms`);
|
|
2018
|
+
}
|
|
2019
|
+
memo(key, fn, deps) {
|
|
2020
|
+
return fn();
|
|
2021
|
+
}
|
|
2022
|
+
state(key, initialValue) {
|
|
2023
|
+
return [initialValue, () => {
|
|
2024
|
+
}];
|
|
2025
|
+
}
|
|
2026
|
+
ref(key, initialValue) {
|
|
2027
|
+
return { current: initialValue };
|
|
2028
|
+
}
|
|
2029
|
+
sub(key) {
|
|
2030
|
+
return new _ColdScope();
|
|
2031
|
+
}
|
|
2032
|
+
source(subscribe, getValue2) {
|
|
2033
|
+
return getValue2();
|
|
2034
|
+
}
|
|
2035
|
+
};
|
|
2036
|
+
function calculateColdPrism(fn) {
|
|
2037
|
+
const scope2 = new ColdScope();
|
|
2038
|
+
hookScopeStack.push(scope2);
|
|
2039
|
+
let value;
|
|
2040
|
+
try {
|
|
2041
|
+
value = fn();
|
|
2042
|
+
} catch (error) {
|
|
2043
|
+
console.error(error);
|
|
2044
|
+
} finally {
|
|
2045
|
+
const topOfTheStack = hookScopeStack.pop();
|
|
2046
|
+
if (topOfTheStack !== scope2) {
|
|
2047
|
+
console.warn(
|
|
2048
|
+
// @todo guide the user to report the bug in an issue
|
|
2049
|
+
`The Prism hook stack has slipped. This is a bug.`
|
|
2050
|
+
);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
return value;
|
|
2054
|
+
}
|
|
2055
|
+
prism.ref = ref;
|
|
2056
|
+
prism.effect = effect;
|
|
2057
|
+
prism.memo = memo;
|
|
2058
|
+
prism.ensurePrism = ensurePrism;
|
|
2059
|
+
prism.state = state;
|
|
2060
|
+
prism.scope = scope;
|
|
2061
|
+
prism.sub = sub;
|
|
2062
|
+
prism.inPrism = inPrism;
|
|
2063
|
+
prism.source = source;
|
|
2064
|
+
var prism_default = prism;
|
|
2065
|
+
|
|
2066
|
+
// ../dataverse/src/Atom.ts
|
|
2067
|
+
var getTypeOfValue = (v) => {
|
|
2068
|
+
if (Array.isArray(v))
|
|
2069
|
+
return 1 /* Array */;
|
|
2070
|
+
if (isPlainObject_default(v))
|
|
2071
|
+
return 0 /* Dict */;
|
|
2072
|
+
return 2 /* Other */;
|
|
2073
|
+
};
|
|
2074
|
+
var getKeyOfValue = (v, key, vType = getTypeOfValue(v)) => {
|
|
2075
|
+
if (vType === 0 /* Dict */ && typeof key === "string") {
|
|
2076
|
+
return v[key];
|
|
2077
|
+
} else if (vType === 1 /* Array */ && isValidArrayIndex(key)) {
|
|
2078
|
+
return v[key];
|
|
2079
|
+
} else {
|
|
2080
|
+
return void 0;
|
|
2081
|
+
}
|
|
2082
|
+
};
|
|
2083
|
+
var isValidArrayIndex = (key) => {
|
|
2084
|
+
const inNumber = typeof key === "number" ? key : parseInt(key, 10);
|
|
2085
|
+
return !isNaN(inNumber) && inNumber >= 0 && inNumber < Infinity && (inNumber | 0) === inNumber;
|
|
2086
|
+
};
|
|
2087
|
+
var Scope = class _Scope {
|
|
2088
|
+
constructor(_parent, _path) {
|
|
2089
|
+
this._parent = _parent;
|
|
2090
|
+
this._path = _path;
|
|
2091
|
+
this.children = /* @__PURE__ */ new Map();
|
|
2092
|
+
this.identityChangeListeners = /* @__PURE__ */ new Set();
|
|
2093
|
+
}
|
|
2094
|
+
addIdentityChangeListener(cb) {
|
|
2095
|
+
this.identityChangeListeners.add(cb);
|
|
2096
|
+
}
|
|
2097
|
+
removeIdentityChangeListener(cb) {
|
|
2098
|
+
this.identityChangeListeners.delete(cb);
|
|
2099
|
+
this._checkForGC();
|
|
2100
|
+
}
|
|
2101
|
+
removeChild(key) {
|
|
2102
|
+
this.children.delete(key);
|
|
2103
|
+
this._checkForGC();
|
|
2104
|
+
}
|
|
2105
|
+
getChild(key) {
|
|
2106
|
+
return this.children.get(key);
|
|
2107
|
+
}
|
|
2108
|
+
getOrCreateChild(key) {
|
|
2109
|
+
let child = this.children.get(key);
|
|
2110
|
+
if (!child) {
|
|
2111
|
+
child = child = new _Scope(this, this._path.concat([key]));
|
|
2112
|
+
this.children.set(key, child);
|
|
2113
|
+
}
|
|
2114
|
+
return child;
|
|
2115
|
+
}
|
|
2116
|
+
_checkForGC() {
|
|
2117
|
+
if (this.identityChangeListeners.size > 0)
|
|
2118
|
+
return;
|
|
2119
|
+
if (this.children.size > 0)
|
|
2120
|
+
return;
|
|
2121
|
+
if (this._parent) {
|
|
2122
|
+
this._parent.removeChild(last_default(this._path));
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
var Atom = class {
|
|
2127
|
+
constructor(initialState) {
|
|
2128
|
+
/**
|
|
2129
|
+
* @internal
|
|
2130
|
+
*/
|
|
2131
|
+
this.$$isPointerToPrismProvider = true;
|
|
2132
|
+
/**
|
|
2133
|
+
* Convenience property that gives you a pointer to the root of the atom.
|
|
2134
|
+
*
|
|
2135
|
+
* @remarks
|
|
2136
|
+
* Equivalent to `pointer({ root: thisAtom, path: [] })`.
|
|
2137
|
+
*/
|
|
2138
|
+
this.pointer = pointer_default({ root: this, path: [] });
|
|
2139
|
+
this.prism = this.pointerToPrism(
|
|
2140
|
+
this.pointer
|
|
2141
|
+
);
|
|
2142
|
+
this._onPointerValueChange = (pointer2, cb) => {
|
|
2143
|
+
const { path } = getPointerParts(pointer2);
|
|
2144
|
+
const scope2 = this._getOrCreateScopeForPath(path);
|
|
2145
|
+
scope2.identityChangeListeners.add(cb);
|
|
2146
|
+
const unsubscribe = () => {
|
|
2147
|
+
scope2.identityChangeListeners.delete(cb);
|
|
2148
|
+
};
|
|
2149
|
+
return unsubscribe;
|
|
2150
|
+
};
|
|
2151
|
+
this._currentState = initialState;
|
|
2152
|
+
this._rootScope = new Scope(void 0, []);
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* Sets the state of the atom.
|
|
2156
|
+
*
|
|
2157
|
+
* @param newState - The new state of the atom.
|
|
2158
|
+
*/
|
|
2159
|
+
set(newState) {
|
|
2160
|
+
const oldState = this._currentState;
|
|
2161
|
+
this._currentState = newState;
|
|
2162
|
+
this._checkUpdates(this._rootScope, oldState, newState);
|
|
2163
|
+
}
|
|
2164
|
+
get() {
|
|
2165
|
+
return this._currentState;
|
|
2166
|
+
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Returns the value at the given pointer
|
|
2169
|
+
*
|
|
2170
|
+
* @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer
|
|
2171
|
+
*
|
|
2172
|
+
* Example
|
|
2173
|
+
* ```ts
|
|
2174
|
+
* const atom = atom({ a: { b: 1 } })
|
|
2175
|
+
* atom.getByPointer(atom.pointer.a.b) // 1
|
|
2176
|
+
* atom.getByPointer((p) => p.a.b) // 1
|
|
2177
|
+
* ```
|
|
2178
|
+
*/
|
|
2179
|
+
getByPointer(pointerOrFn) {
|
|
2180
|
+
const pointer2 = isPointer(pointerOrFn) ? pointerOrFn : pointerOrFn(this.pointer);
|
|
2181
|
+
const path = getPointerParts(pointer2).path;
|
|
2182
|
+
return this._getIn(path);
|
|
2183
|
+
}
|
|
2184
|
+
/**
|
|
2185
|
+
* Gets the state of the atom at `path`.
|
|
2186
|
+
*/
|
|
2187
|
+
_getIn(path) {
|
|
2188
|
+
return path.length === 0 ? this.get() : get_default(this.get(), path);
|
|
2189
|
+
}
|
|
2190
|
+
reduce(fn) {
|
|
2191
|
+
this.set(fn(this.get()));
|
|
2192
|
+
}
|
|
2193
|
+
/**
|
|
2194
|
+
* Reduces the value at the given pointer
|
|
2195
|
+
*
|
|
2196
|
+
* @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer
|
|
2197
|
+
*
|
|
2198
|
+
* Example
|
|
2199
|
+
* ```ts
|
|
2200
|
+
* const atom = atom({ a: { b: 1 } })
|
|
2201
|
+
* atom.reduceByPointer(atom.pointer.a.b, (b) => b + 1) // atom.get().a.b === 2
|
|
2202
|
+
* atom.reduceByPointer((p) => p.a.b, (b) => b + 1) // atom.get().a.b === 2
|
|
2203
|
+
* ```
|
|
2204
|
+
*/
|
|
2205
|
+
reduceByPointer(pointerOrFn, reducer) {
|
|
2206
|
+
const pointer2 = isPointer(pointerOrFn) ? pointerOrFn : pointerOrFn(this.pointer);
|
|
2207
|
+
const path = getPointerParts(pointer2).path;
|
|
2208
|
+
const newState = updateDeep(this.get(), path, reducer);
|
|
2209
|
+
this.set(newState);
|
|
2210
|
+
}
|
|
2211
|
+
/**
|
|
2212
|
+
* Sets the value at the given pointer
|
|
2213
|
+
*
|
|
2214
|
+
* @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer
|
|
2215
|
+
*
|
|
2216
|
+
* Example
|
|
2217
|
+
* ```ts
|
|
2218
|
+
* const atom = atom({ a: { b: 1 } })
|
|
2219
|
+
* atom.setByPointer(atom.pointer.a.b, 2) // atom.get().a.b === 2
|
|
2220
|
+
* atom.setByPointer((p) => p.a.b, 2) // atom.get().a.b === 2
|
|
2221
|
+
* ```
|
|
2222
|
+
*/
|
|
2223
|
+
setByPointer(pointerOrFn, val2) {
|
|
2224
|
+
this.reduceByPointer(pointerOrFn, () => val2);
|
|
2225
|
+
}
|
|
2226
|
+
_checkUpdates(scope2, oldState, newState) {
|
|
2227
|
+
if (oldState === newState)
|
|
2228
|
+
return;
|
|
2229
|
+
for (const cb of scope2.identityChangeListeners) {
|
|
2230
|
+
cb(newState);
|
|
2231
|
+
}
|
|
2232
|
+
if (scope2.children.size === 0)
|
|
2233
|
+
return;
|
|
2234
|
+
const oldValueType = getTypeOfValue(oldState);
|
|
2235
|
+
const newValueType = getTypeOfValue(newState);
|
|
2236
|
+
if (oldValueType === 2 /* Other */ && oldValueType === newValueType)
|
|
2237
|
+
return;
|
|
2238
|
+
for (const [childKey, childScope] of scope2.children) {
|
|
2239
|
+
const oldChildVal = getKeyOfValue(oldState, childKey, oldValueType);
|
|
2240
|
+
const newChildVal = getKeyOfValue(newState, childKey, newValueType);
|
|
2241
|
+
this._checkUpdates(childScope, oldChildVal, newChildVal);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
_getOrCreateScopeForPath(path) {
|
|
2245
|
+
let curScope = this._rootScope;
|
|
2246
|
+
for (const pathEl of path) {
|
|
2247
|
+
curScope = curScope.getOrCreateChild(pathEl);
|
|
2248
|
+
}
|
|
2249
|
+
return curScope;
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Returns a new prism of the value at the provided path.
|
|
2253
|
+
*
|
|
2254
|
+
* @param pointer - The path to create the prism at.
|
|
2255
|
+
*
|
|
2256
|
+
* ```ts
|
|
2257
|
+
* const pr = atom({ a: { b: 1 } }).pointerToPrism(atom.pointer.a.b)
|
|
2258
|
+
* pr.getValue() // 1
|
|
2259
|
+
* ```
|
|
2260
|
+
*/
|
|
2261
|
+
pointerToPrism(pointer2) {
|
|
2262
|
+
const { path } = getPointerParts(pointer2);
|
|
2263
|
+
const subscribe = (listener) => this._onPointerValueChange(pointer2, listener);
|
|
2264
|
+
const getValue2 = () => this._getIn(path);
|
|
2265
|
+
return prism_default(() => {
|
|
2266
|
+
return prism_default.source(subscribe, getValue2);
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
|
|
2271
|
+
// ../dataverse/src/pointerToPrism.ts
|
|
2272
|
+
var identifyPrismWeakMap = /* @__PURE__ */ new WeakMap();
|
|
2273
|
+
function isPointerToPrismProvider(val2) {
|
|
2274
|
+
return typeof val2 === "object" && val2 !== null && val2["$$isPointerToPrismProvider"] === true;
|
|
2275
|
+
}
|
|
2276
|
+
var pointerToPrism = (pointer2) => {
|
|
2277
|
+
const meta = getPointerMeta(pointer2);
|
|
2278
|
+
let prismInstance = identifyPrismWeakMap.get(meta);
|
|
2279
|
+
if (!prismInstance) {
|
|
2280
|
+
const root2 = meta.root;
|
|
2281
|
+
if (!isPointerToPrismProvider(root2)) {
|
|
2282
|
+
throw new Error(
|
|
2283
|
+
`Cannot run pointerToPrism() on a pointer whose root is not an PointerToPrismProvider`
|
|
2284
|
+
);
|
|
2285
|
+
}
|
|
2286
|
+
prismInstance = root2.pointerToPrism(pointer2);
|
|
2287
|
+
identifyPrismWeakMap.set(meta, prismInstance);
|
|
2288
|
+
}
|
|
2289
|
+
return prismInstance;
|
|
2290
|
+
};
|
|
2291
|
+
|
|
2292
|
+
// ../dataverse/src/val.ts
|
|
2293
|
+
var val = (input) => {
|
|
2294
|
+
if (isPointer(input)) {
|
|
2295
|
+
return pointerToPrism(input).getValue();
|
|
2296
|
+
} else if (isPrism(input)) {
|
|
2297
|
+
return input.getValue();
|
|
2298
|
+
} else {
|
|
2299
|
+
return input;
|
|
2300
|
+
}
|
|
2301
|
+
};
|
|
2302
|
+
|
|
2303
|
+
// ../../theatre/shared/src/gsap/gsapStudioRegistryRevision.ts
|
|
2304
|
+
var revisionAtom = new Atom(0);
|
|
2305
|
+
function bumpGsapStudioRegistryRevision() {
|
|
2306
|
+
revisionAtom.set(revisionAtom.get() + 1);
|
|
2307
|
+
}
|
|
2308
|
+
var gsapStudioRegistryRevisionPointer = revisionAtom.pointer;
|
|
2309
|
+
|
|
2310
|
+
// ../../theatre/shared/src/gsap/gsapAnimationRegistry.ts
|
|
2311
|
+
var DEFAULT_SHEET_INSTANCE_ID = "default";
|
|
2312
|
+
var REGISTRY_KEY = "__unseenco_theatre_gsap_animationRegistry__";
|
|
2313
|
+
function sheetObjectAddressKeyFromParts(address) {
|
|
2314
|
+
const sheetInstanceId = address.sheetInstanceId ?? DEFAULT_SHEET_INSTANCE_ID;
|
|
2315
|
+
return `${address.projectId}|${address.sheetId}|${sheetInstanceId}|${address.objectKey}`;
|
|
2316
|
+
}
|
|
2317
|
+
function sheetObjectAddressKey(sheetObject) {
|
|
2318
|
+
return sheetObjectAddressKeyFromParts(sheetObject.address);
|
|
2319
|
+
}
|
|
2320
|
+
function getStore2() {
|
|
2321
|
+
const g = globalThis;
|
|
2322
|
+
if (!g[REGISTRY_KEY]) {
|
|
2323
|
+
g[REGISTRY_KEY] = {
|
|
2324
|
+
bySheetAddress: /* @__PURE__ */ new Map()
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
return g[REGISTRY_KEY];
|
|
2328
|
+
}
|
|
2329
|
+
function getSheetEntryMap(sheetKey) {
|
|
2330
|
+
const store = getStore2();
|
|
2331
|
+
let map = store.bySheetAddress.get(sheetKey);
|
|
2332
|
+
if (!map) {
|
|
2333
|
+
map = /* @__PURE__ */ new Map();
|
|
2334
|
+
store.bySheetAddress.set(sheetKey, map);
|
|
2335
|
+
}
|
|
2336
|
+
return map;
|
|
2337
|
+
}
|
|
2338
|
+
function registerAnimationInRegistry(entry) {
|
|
2339
|
+
const kind = entry.animation && isGsapTimeline(entry.animation) ? "timeline" : "tween";
|
|
2340
|
+
const timelineChildById = kind === "timeline" && entry.animation ? linkGsapTimelineChildAnimations(entry.animation) : void 0;
|
|
2341
|
+
const defaultDuration = entry.defaultDuration ?? readGsapTweenTimelineDuration(entry.animation);
|
|
2342
|
+
const timelineChildren = kind === "timeline" && entry.animation ? introspectGsapTimelineChildren(entry.animation) : [];
|
|
2343
|
+
const originalTiming = entry.originalTiming ?? (entry.animation ? buildGsapClipBaselineTiming({
|
|
2344
|
+
duration: defaultDuration,
|
|
2345
|
+
...timelineChildren.length > 0 ? {
|
|
2346
|
+
timelineSpan: readGsapTweenTimelineDuration(entry.animation),
|
|
2347
|
+
timelineChildren
|
|
2348
|
+
} : {}
|
|
2349
|
+
}) : void 0);
|
|
2350
|
+
const normalized = {
|
|
2351
|
+
...entry,
|
|
2352
|
+
kind,
|
|
2353
|
+
timelineChildById,
|
|
2354
|
+
originalTiming
|
|
2355
|
+
};
|
|
2356
|
+
if (entry.sheetObject) {
|
|
2357
|
+
const sheetKey = sheetObjectAddressKey(entry.sheetObject);
|
|
2358
|
+
getSheetEntryMap(sheetKey).set(entry.id, normalized);
|
|
2359
|
+
registerGsapObjectBinding(entry.sheetObject, {
|
|
2360
|
+
gsapAnimationId: entry.id,
|
|
2361
|
+
defaultDuration
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
bumpGsapStudioRegistryRevision();
|
|
2365
|
+
}
|
|
2366
|
+
function getAnimationEntryForAddress(address, animationId) {
|
|
2367
|
+
const animId = animationId ?? address.objectKey;
|
|
2368
|
+
const sheetKey = sheetObjectAddressKeyFromParts(address);
|
|
2369
|
+
return getStore2().bySheetAddress.get(sheetKey)?.get(animId);
|
|
2370
|
+
}
|
|
2371
|
+
function getAnimationEntry(sheetObject, animationId) {
|
|
2372
|
+
return getAnimationEntryForAddress(
|
|
2373
|
+
sheetObject.address,
|
|
2374
|
+
animationId ?? sheetObject.address.objectKey
|
|
2375
|
+
);
|
|
2376
|
+
}
|
|
2377
|
+
function getAnimationEntryForSheetObject(sheetObject) {
|
|
2378
|
+
return getAnimationEntry(sheetObject);
|
|
2379
|
+
}
|
|
2380
|
+
function getAnimationEntryBySheetAddressKey(sheetObjectAddressKey2, animationId) {
|
|
2381
|
+
return getStore2().bySheetAddress.get(sheetObjectAddressKey2)?.get(animationId);
|
|
2382
|
+
}
|
|
2383
|
+
function listAnimationEntries() {
|
|
2384
|
+
const entries = [];
|
|
2385
|
+
for (const byAnim of getStore2().bySheetAddress.values()) {
|
|
2386
|
+
entries.push(...byAnim.values());
|
|
2387
|
+
}
|
|
2388
|
+
return entries;
|
|
2389
|
+
}
|
|
38
2390
|
|
|
39
2391
|
// src/config.ts
|
|
40
|
-
var import_gsapSheetObjectKey = require("@unseenco/theatre-shared/gsap/gsapSheetObjectKey");
|
|
41
2392
|
var activeConfig = {
|
|
42
2393
|
namespace: "GSAP",
|
|
43
2394
|
outlineNamespace: { defaultCollapsed: false }
|
|
44
2395
|
};
|
|
45
|
-
|
|
2396
|
+
setConfiguredGsapSheetObjectNamespace(activeConfig.namespace);
|
|
46
2397
|
function configureTheatreGsap(config) {
|
|
47
2398
|
const prev = activeConfig;
|
|
48
2399
|
activeConfig = {
|
|
49
2400
|
namespace: config.namespace ?? prev.namespace ?? "GSAP",
|
|
50
2401
|
outlineNamespace: config.outlineNamespace ?? prev.outlineNamespace
|
|
51
2402
|
};
|
|
52
|
-
|
|
2403
|
+
setConfiguredGsapSheetObjectNamespace(activeConfig.namespace ?? "GSAP");
|
|
53
2404
|
return {
|
|
54
2405
|
reset() {
|
|
55
2406
|
activeConfig = prev;
|
|
@@ -61,10 +2412,8 @@ function getTheatreGsapConfig() {
|
|
|
61
2412
|
}
|
|
62
2413
|
|
|
63
2414
|
// src/animationRegistry.ts
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
function registerAnimationInRegistry(entry) {
|
|
67
|
-
(0, import_gsapAnimationRegistry.registerAnimationInRegistry)({
|
|
2415
|
+
function registerAnimationInRegistry2(entry) {
|
|
2416
|
+
registerAnimationInRegistry({
|
|
68
2417
|
...entry,
|
|
69
2418
|
animation: entry.animation,
|
|
70
2419
|
defaultDuration: entry.defaultDuration ?? defaultClipDuration(entry.animation),
|
|
@@ -72,7 +2421,7 @@ function registerAnimationInRegistry(entry) {
|
|
|
72
2421
|
});
|
|
73
2422
|
}
|
|
74
2423
|
function defaultClipDuration(animation) {
|
|
75
|
-
return
|
|
2424
|
+
return readGsapTweenTimelineDuration(animation);
|
|
76
2425
|
}
|
|
77
2426
|
function toPackageEntry(entry) {
|
|
78
2427
|
if (!entry || !entry.animation)
|
|
@@ -86,19 +2435,19 @@ function toPackageEntry(entry) {
|
|
|
86
2435
|
onRebuildTimeline: entry.onRebuildTimeline
|
|
87
2436
|
};
|
|
88
2437
|
}
|
|
89
|
-
function
|
|
90
|
-
return toPackageEntry(
|
|
2438
|
+
function getAnimationEntry2(sheetObject, animationId) {
|
|
2439
|
+
return toPackageEntry(getAnimationEntry(sheetObject, animationId));
|
|
91
2440
|
}
|
|
92
2441
|
function getAnimationEntryById(id) {
|
|
93
2442
|
return toPackageEntry(
|
|
94
|
-
|
|
2443
|
+
listAnimationEntries().find((entry) => entry.id === id)
|
|
95
2444
|
);
|
|
96
2445
|
}
|
|
97
|
-
function
|
|
98
|
-
return toPackageEntry(
|
|
2446
|
+
function getAnimationEntryForSheetObject2(sheetObject) {
|
|
2447
|
+
return toPackageEntry(getAnimationEntryForSheetObject(sheetObject));
|
|
99
2448
|
}
|
|
100
|
-
function
|
|
101
|
-
return
|
|
2449
|
+
function listAnimationEntries2() {
|
|
2450
|
+
return listAnimationEntries().filter((e) => !!e.animation).map((entry) => ({
|
|
102
2451
|
id: entry.id,
|
|
103
2452
|
label: entry.label,
|
|
104
2453
|
animation: entry.animation,
|
|
@@ -106,24 +2455,28 @@ function listAnimationEntries() {
|
|
|
106
2455
|
}));
|
|
107
2456
|
}
|
|
108
2457
|
|
|
2458
|
+
// ../../theatre/shared/src/utils/outlineNamespaces.ts
|
|
2459
|
+
function formatOutlineNamespacePathKey(pathSegments) {
|
|
2460
|
+
return pathSegments.join(" / ");
|
|
2461
|
+
}
|
|
2462
|
+
|
|
109
2463
|
// src/registerGsapAnimation.ts
|
|
110
|
-
var import_outlineNamespaces = require("@unseenco/theatre-shared/utils/outlineNamespaces");
|
|
111
2464
|
function registerGsapAnimation(animation, sheet, options) {
|
|
112
2465
|
const config = getTheatreGsapConfig();
|
|
113
2466
|
const namespace = options.namespace ?? config.namespace ?? "GSAP";
|
|
114
|
-
const objectKey =
|
|
2467
|
+
const objectKey = buildGsapSheetObjectKey(namespace, options.label);
|
|
115
2468
|
const id = options.id ?? objectKey;
|
|
116
2469
|
animation.pause();
|
|
117
2470
|
const sheetObjectPublic = sheet.object(objectKey, {}, { reconfigure: false });
|
|
118
2471
|
const sheetObjectInternal = (0, import_privateAPIs.privateAPI)(sheetObjectPublic);
|
|
119
|
-
const existing =
|
|
2472
|
+
const existing = getAnimationEntry(sheetObjectInternal, id);
|
|
120
2473
|
if (config.outlineNamespace && !existing) {
|
|
121
2474
|
(0, import_privateAPIs.privateAPI)(sheet).template.setOutlineNamespaceConfig(
|
|
122
|
-
|
|
2475
|
+
formatOutlineNamespacePathKey([namespace]),
|
|
123
2476
|
config.outlineNamespace
|
|
124
2477
|
);
|
|
125
2478
|
}
|
|
126
|
-
|
|
2479
|
+
registerAnimationInRegistry2({
|
|
127
2480
|
id,
|
|
128
2481
|
label: options.label,
|
|
129
2482
|
animation,
|
|
@@ -136,15 +2489,43 @@ function registerGsapAnimation(animation, sheet, options) {
|
|
|
136
2489
|
|
|
137
2490
|
// src/attachGsapSequenceBridge.ts
|
|
138
2491
|
var import_privateAPIs2 = require("@unseenco/theatre-core/privateAPIs");
|
|
139
|
-
|
|
140
|
-
|
|
2492
|
+
|
|
2493
|
+
// ../../theatre/shared/src/gsap/syncGsapClipsAtSequencePosition.ts
|
|
2494
|
+
function syncGsapClipsAtSequencePosition(position, clips) {
|
|
2495
|
+
syncRegisteredGsapAnimationsForClips(
|
|
2496
|
+
position,
|
|
2497
|
+
clips
|
|
2498
|
+
);
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
// ../../theatre/shared/src/gsap/subscribeGsapClipSyncAtPlayhead.ts
|
|
2502
|
+
function subscribeGsapClipSyncAtPlayhead(source2) {
|
|
2503
|
+
const positionPointer = source2.pointer.position;
|
|
2504
|
+
const positionPrism = pointerToPrism(positionPointer);
|
|
2505
|
+
const clipsPrism = prism_default(() => source2.getGsapClipTimings());
|
|
2506
|
+
const syncNow = () => {
|
|
2507
|
+
const clips = clipsPrism.getValue();
|
|
2508
|
+
if (clips.length === 0)
|
|
2509
|
+
return;
|
|
2510
|
+
syncGsapClipsAtSequencePosition(val(positionPointer), clips);
|
|
2511
|
+
};
|
|
2512
|
+
const untapPosition = positionPrism.onStale(syncNow);
|
|
2513
|
+
const untapClips = clipsPrism.onStale(syncNow);
|
|
2514
|
+
syncNow();
|
|
2515
|
+
return () => {
|
|
2516
|
+
untapPosition();
|
|
2517
|
+
untapClips();
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
// src/attachGsapSequenceBridge.ts
|
|
141
2522
|
function attachGsapSequenceBridge(sheet) {
|
|
142
2523
|
const sequence = sheet.sequence;
|
|
143
2524
|
const sheetAddress = (0, import_privateAPIs2.privateAPI)(sheet).address;
|
|
144
|
-
return
|
|
2525
|
+
return subscribeGsapClipSyncAtPlayhead({
|
|
145
2526
|
pointer: sequence.pointer,
|
|
146
2527
|
getGsapClipTimings: () => sequence.__experimental_getGsapClips().map(({ objectKey, clip }) => ({
|
|
147
|
-
sheetObjectAddressKey:
|
|
2528
|
+
sheetObjectAddressKey: sheetObjectAddressKeyFromParts({
|
|
148
2529
|
projectId: sheetAddress.projectId,
|
|
149
2530
|
sheetId: sheetAddress.sheetId,
|
|
150
2531
|
sheetInstanceId: sheetAddress.sheetInstanceId,
|