@plasmicapp/loader-core 1.0.100 → 1.0.101
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/bundles.d.ts +9 -9
- package/dist/deps-graph.d.ts +12 -12
- package/dist/index.d.ts +6 -4
- package/dist/index.js +532 -5
- package/dist/index.js.map +7 -0
- package/dist/registry.d.ts +18 -18
- package/dist/tracker/index.d.ts +29 -29
- package/dist/tracker/utils.d.ts +13 -13
- package/package.json +16 -33
- package/dist/loader-core.cjs.development.js +0 -1268
- package/dist/loader-core.cjs.development.js.map +0 -1
- package/dist/loader-core.cjs.production.min.js +0 -2
- package/dist/loader-core.cjs.production.min.js.map +0 -1
- package/dist/loader-core.esm.js +0 -1248
- package/dist/loader-core.esm.js.map +0 -1
package/dist/bundles.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';
|
|
2
|
-
/**
|
|
3
|
-
* Get sub-bundle including only modules that are reachable from `names`.
|
|
4
|
-
* @param opts.target by default, will target the browser modules. Can request
|
|
5
|
-
* the server modules instead.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getBundleSubset(bundle: LoaderBundleOutput, names: string[], opts?: {
|
|
8
|
-
target?: 'browser' | 'server';
|
|
9
|
-
}): LoaderBundleOutput;
|
|
1
|
+
import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';
|
|
2
|
+
/**
|
|
3
|
+
* Get sub-bundle including only modules that are reachable from `names`.
|
|
4
|
+
* @param opts.target by default, will target the browser modules. Can request
|
|
5
|
+
* the server modules instead.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getBundleSubset(bundle: LoaderBundleOutput, names: string[], opts?: {
|
|
8
|
+
target?: 'browser' | 'server';
|
|
9
|
+
}): LoaderBundleOutput;
|
package/dist/deps-graph.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';
|
|
2
|
-
export declare class DepsGraph {
|
|
3
|
-
private bundle;
|
|
4
|
-
private browserBuild;
|
|
5
|
-
private dependsOn;
|
|
6
|
-
private dependedBy;
|
|
7
|
-
constructor(bundle: LoaderBundleOutput, browserBuild: boolean);
|
|
8
|
-
getTransitiveDependers(name: string): string[];
|
|
9
|
-
getTransitiveDeps(name: string): string[];
|
|
10
|
-
private transitiveCrawl;
|
|
11
|
-
private rebuildGraph;
|
|
12
|
-
}
|
|
1
|
+
import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';
|
|
2
|
+
export declare class DepsGraph {
|
|
3
|
+
private bundle;
|
|
4
|
+
private browserBuild;
|
|
5
|
+
private dependsOn;
|
|
6
|
+
private dependedBy;
|
|
7
|
+
constructor(bundle: LoaderBundleOutput, browserBuild: boolean);
|
|
8
|
+
getTransitiveDependers(name: string): string[];
|
|
9
|
+
getTransitiveDeps(name: string): string[];
|
|
10
|
+
private transitiveCrawl;
|
|
11
|
+
private rebuildGraph;
|
|
12
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
export type { AssetModule, CodeModule, ComponentMeta, ExperimentSlice, FontMeta, GlobalGroupMeta, LoaderBundleCache, LoaderBundleOutput, LoaderHtmlOutput, PageMeta, PageMetadata, ProjectMeta, SegmentSlice, Split, } from "@plasmicapp/loader-fetcher";
|
|
2
|
+
export { Api, PlasmicModulesFetcher } from "@plasmicapp/loader-fetcher";
|
|
3
|
+
export { getBundleSubset } from "./bundles";
|
|
4
|
+
export { Registry } from "./registry";
|
|
5
|
+
export { PlasmicTracker } from "./tracker";
|
|
6
|
+
export type { TrackRenderOptions } from "./tracker";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,535 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name2 in all)
|
|
27
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __copyProps = (to, from, except, desc) => {
|
|
30
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(from))
|
|
32
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
+
mod
|
|
44
|
+
));
|
|
45
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
+
var __async = (__this, __arguments, generator) => {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
var fulfilled = (value) => {
|
|
49
|
+
try {
|
|
50
|
+
step(generator.next(value));
|
|
51
|
+
} catch (e) {
|
|
52
|
+
reject(e);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var rejected = (value) => {
|
|
56
|
+
try {
|
|
57
|
+
step(generator.throw(value));
|
|
58
|
+
} catch (e) {
|
|
59
|
+
reject(e);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
63
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
64
|
+
});
|
|
65
|
+
};
|
|
1
66
|
|
|
2
|
-
|
|
67
|
+
// src/index.ts
|
|
68
|
+
var src_exports = {};
|
|
69
|
+
__export(src_exports, {
|
|
70
|
+
Api: () => import_loader_fetcher.Api,
|
|
71
|
+
PlasmicModulesFetcher: () => import_loader_fetcher.PlasmicModulesFetcher,
|
|
72
|
+
PlasmicTracker: () => PlasmicTracker,
|
|
73
|
+
Registry: () => Registry,
|
|
74
|
+
getBundleSubset: () => getBundleSubset
|
|
75
|
+
});
|
|
76
|
+
module.exports = __toCommonJS(src_exports);
|
|
77
|
+
var import_loader_fetcher = require("@plasmicapp/loader-fetcher");
|
|
3
78
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
79
|
+
// src/deps-graph.ts
|
|
80
|
+
var DepsGraph = class {
|
|
81
|
+
constructor(bundle, browserBuild) {
|
|
82
|
+
this.bundle = bundle;
|
|
83
|
+
this.browserBuild = browserBuild;
|
|
84
|
+
this.dependsOn = {};
|
|
85
|
+
this.dependedBy = {};
|
|
86
|
+
this.rebuildGraph();
|
|
87
|
+
}
|
|
88
|
+
getTransitiveDependers(name2) {
|
|
89
|
+
return this.transitiveCrawl(name2, this.dependedBy);
|
|
90
|
+
}
|
|
91
|
+
getTransitiveDeps(name2) {
|
|
92
|
+
if (!(name2 in this.dependsOn)) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
return this.transitiveCrawl(name2, this.dependsOn);
|
|
96
|
+
}
|
|
97
|
+
transitiveCrawl(name2, edges) {
|
|
98
|
+
const deps = /* @__PURE__ */ new Set();
|
|
99
|
+
const crawl = (dep2) => {
|
|
100
|
+
var _a;
|
|
101
|
+
if (deps.has(dep2)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
deps.add(dep2);
|
|
105
|
+
for (const subdep of (_a = edges[dep2]) != null ? _a : []) {
|
|
106
|
+
crawl(subdep);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
for (const dep2 of edges[name2]) {
|
|
110
|
+
crawl(dep2);
|
|
111
|
+
}
|
|
112
|
+
return Array.from(deps);
|
|
113
|
+
}
|
|
114
|
+
rebuildGraph() {
|
|
115
|
+
this.dependedBy = {};
|
|
116
|
+
this.dependsOn = {};
|
|
117
|
+
for (const mod of this.browserBuild ? this.bundle.modules.browser : this.bundle.modules.server) {
|
|
118
|
+
if (mod.type === "code") {
|
|
119
|
+
for (const imported of mod.imports) {
|
|
120
|
+
if (!(mod.fileName in this.dependsOn)) {
|
|
121
|
+
this.dependsOn[mod.fileName] = [imported];
|
|
122
|
+
} else {
|
|
123
|
+
this.dependsOn[mod.fileName].push(imported);
|
|
124
|
+
}
|
|
125
|
+
if (!(imported in this.dependedBy)) {
|
|
126
|
+
this.dependedBy[imported] = [mod.fileName];
|
|
127
|
+
} else {
|
|
128
|
+
this.dependedBy[imported].push(mod.fileName);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// src/bundles.ts
|
|
137
|
+
function getBundleSubset(bundle, names, opts2) {
|
|
138
|
+
var _a;
|
|
139
|
+
const namesSet = new Set(names);
|
|
140
|
+
const target = (_a = opts2 == null ? void 0 : opts2.target) != null ? _a : "browser";
|
|
141
|
+
const forBrowser = target === "browser";
|
|
142
|
+
const graph = new DepsGraph(bundle, forBrowser);
|
|
143
|
+
const deps = new Set(names.flatMap((name2) => graph.getTransitiveDeps(name2)));
|
|
144
|
+
const isSubModule = (fileName) => deps.has(fileName) || namesSet.has(fileName);
|
|
145
|
+
const modules = bundle.modules[target];
|
|
146
|
+
const filteredModules = modules.filter((mod) => isSubModule(mod.fileName));
|
|
147
|
+
return {
|
|
148
|
+
modules: {
|
|
149
|
+
browser: forBrowser ? filteredModules : [],
|
|
150
|
+
server: forBrowser ? [] : filteredModules
|
|
151
|
+
},
|
|
152
|
+
external: bundle.external.filter((dep2) => deps.has(dep2)),
|
|
153
|
+
components: bundle.components.filter((c) => isSubModule(c.entry)),
|
|
154
|
+
globalGroups: bundle.globalGroups,
|
|
155
|
+
projects: bundle.projects,
|
|
156
|
+
activeSplits: bundle.activeSplits
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/registry.ts
|
|
161
|
+
var isBrowser = typeof window !== "undefined" && window != null && typeof window.document !== "undefined";
|
|
162
|
+
var Registry = class {
|
|
163
|
+
constructor() {
|
|
164
|
+
this.loadedModules = {};
|
|
165
|
+
this.registeredModules = {};
|
|
166
|
+
this.modules = {};
|
|
167
|
+
}
|
|
168
|
+
register(name2, module2) {
|
|
169
|
+
this.registeredModules[name2] = module2;
|
|
170
|
+
}
|
|
171
|
+
isEmpty() {
|
|
172
|
+
return Object.keys(this.loadedModules).length === 0;
|
|
173
|
+
}
|
|
174
|
+
clear() {
|
|
175
|
+
this.loadedModules = {};
|
|
176
|
+
}
|
|
177
|
+
getRegisteredModule(name2) {
|
|
178
|
+
return this.registeredModules[name2];
|
|
179
|
+
}
|
|
180
|
+
hasModule(name2, opts2 = {}) {
|
|
181
|
+
if (name2 in this.registeredModules && !opts2.forceOriginal) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
return name2 in this.modules;
|
|
185
|
+
}
|
|
186
|
+
load(name, opts = {}) {
|
|
187
|
+
if (name in this.registeredModules && !opts.forceOriginal) {
|
|
188
|
+
return this.registeredModules[name];
|
|
189
|
+
}
|
|
190
|
+
if (name in this.loadedModules) {
|
|
191
|
+
return this.loadedModules[name];
|
|
192
|
+
}
|
|
193
|
+
if (!(name in this.modules)) {
|
|
194
|
+
throw new Error(`Unknown module ${name}`);
|
|
195
|
+
}
|
|
196
|
+
const code = this.modules[name];
|
|
197
|
+
const requireFn = isBrowser ? (dep2) => {
|
|
198
|
+
const normalizedDep = resolvePath(dep2, name);
|
|
199
|
+
return this.load(normalizedDep);
|
|
200
|
+
} : (dep) => {
|
|
201
|
+
try {
|
|
202
|
+
const normalizedDep = resolvePath(dep, name);
|
|
203
|
+
return this.load(normalizedDep);
|
|
204
|
+
} catch (err) {
|
|
205
|
+
try {
|
|
206
|
+
return eval("require")(dep);
|
|
207
|
+
} catch (e) {
|
|
208
|
+
throw err;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
let func;
|
|
213
|
+
try {
|
|
214
|
+
func = new Function("require", "exports", code);
|
|
215
|
+
} catch (err2) {
|
|
216
|
+
throw new Error(`PLASMIC: Failed to create function for ${name}: ${err2}`);
|
|
217
|
+
}
|
|
218
|
+
const exports = {};
|
|
219
|
+
this.loadedModules[name] = exports;
|
|
220
|
+
try {
|
|
221
|
+
func(requireFn, exports);
|
|
222
|
+
} catch (err2) {
|
|
223
|
+
delete this.loadedModules[name];
|
|
224
|
+
throw new Error(`PLASMIC: Failed to load ${name}: ${err2}`);
|
|
225
|
+
}
|
|
226
|
+
return exports;
|
|
227
|
+
}
|
|
228
|
+
updateModules(bundle) {
|
|
229
|
+
let updated = false;
|
|
230
|
+
for (const mod of isBrowser ? bundle.modules.browser : bundle.modules.server) {
|
|
231
|
+
if (mod.type === "code" && mod.code !== this.modules[mod.fileName]) {
|
|
232
|
+
this.modules[mod.fileName] = mod.code;
|
|
233
|
+
updated = true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (updated) {
|
|
237
|
+
this.clear();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
function resolvePath(path, from) {
|
|
242
|
+
const fromParts = from.split("/");
|
|
243
|
+
const pathParts = path.split("/");
|
|
244
|
+
if (pathParts.length === 0) {
|
|
245
|
+
return path;
|
|
246
|
+
}
|
|
247
|
+
if (pathParts[0] === ".") {
|
|
248
|
+
return [
|
|
249
|
+
...fromParts.slice(0, fromParts.length - 1),
|
|
250
|
+
...pathParts.slice(1)
|
|
251
|
+
].join("/");
|
|
252
|
+
} else if (pathParts[0] === "..") {
|
|
253
|
+
let count = 0;
|
|
254
|
+
for (const part of pathParts) {
|
|
255
|
+
if (part === "..") {
|
|
256
|
+
count += 1;
|
|
257
|
+
} else {
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return [
|
|
262
|
+
...fromParts.slice(0, fromParts.length - count - 1),
|
|
263
|
+
...pathParts.slice(count)
|
|
264
|
+
].join("/");
|
|
265
|
+
} else {
|
|
266
|
+
return path;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/tracker/index.ts
|
|
271
|
+
var import_isomorphic_unfetch = __toESM(require("@plasmicapp/isomorphic-unfetch"));
|
|
272
|
+
|
|
273
|
+
// src/tracker/utils.ts
|
|
274
|
+
var isBrowser2 = typeof window !== "undefined" && window != null && typeof window.document !== "undefined";
|
|
275
|
+
function getPlasmicCookieValues() {
|
|
276
|
+
if (!isBrowser2) {
|
|
277
|
+
return {};
|
|
278
|
+
}
|
|
279
|
+
return Object.fromEntries(
|
|
280
|
+
document.cookie.split("; ").filter((cookie) => cookie.includes("plasmic:")).map((cookie) => cookie.split("=")).map(([key, value]) => [key.split(":")[1], value])
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
function getVariationCookieValues() {
|
|
284
|
+
const cookies = getPlasmicCookieValues();
|
|
285
|
+
return Object.fromEntries(
|
|
286
|
+
Object.keys(cookies).map((key) => [key.split(".")[1], cookies[key]]).filter((val) => !!val[0])
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
function generateUUID() {
|
|
290
|
+
var d = (/* @__PURE__ */ new Date()).getTime();
|
|
291
|
+
var d2 = typeof performance !== "undefined" && performance.now && performance.now() * 1e3 || 0;
|
|
292
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
293
|
+
var r = Math.random() * 16;
|
|
294
|
+
if (d > 0) {
|
|
295
|
+
r = (d + r) % 16 | 0;
|
|
296
|
+
d = Math.floor(d / 16);
|
|
297
|
+
} else {
|
|
298
|
+
r = (d2 + r) % 16 | 0;
|
|
299
|
+
d2 = Math.floor(d2 / 16);
|
|
300
|
+
}
|
|
301
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
function getDistinctId() {
|
|
305
|
+
if (!isBrowser2) {
|
|
306
|
+
return "LOADER-SERVER";
|
|
307
|
+
}
|
|
308
|
+
return generateUUID();
|
|
309
|
+
}
|
|
310
|
+
function getCampaignParams() {
|
|
311
|
+
const { location } = window;
|
|
312
|
+
const params = {};
|
|
313
|
+
try {
|
|
314
|
+
const url = new URL(location.href);
|
|
315
|
+
const CAMPAIGN_KEYWORDS = [
|
|
316
|
+
"utm_source",
|
|
317
|
+
"utm_medium",
|
|
318
|
+
"utm_campaign",
|
|
319
|
+
"utm_content",
|
|
320
|
+
"utm_term",
|
|
321
|
+
"gclid"
|
|
322
|
+
];
|
|
323
|
+
CAMPAIGN_KEYWORDS.forEach((keyword) => {
|
|
324
|
+
const value = url.searchParams.get(keyword);
|
|
325
|
+
if (value) {
|
|
326
|
+
params[keyword] = value;
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
} catch (err2) {
|
|
330
|
+
}
|
|
331
|
+
return params;
|
|
8
332
|
}
|
|
333
|
+
function getLocationMeta() {
|
|
334
|
+
const { location } = window;
|
|
335
|
+
const { referrer } = document;
|
|
336
|
+
return __spreadValues({
|
|
337
|
+
url: location.href,
|
|
338
|
+
host: location.host,
|
|
339
|
+
pathname: location.pathname,
|
|
340
|
+
referrer
|
|
341
|
+
}, getCampaignParams());
|
|
342
|
+
}
|
|
343
|
+
function getScreenMeta() {
|
|
344
|
+
const { screen } = window;
|
|
345
|
+
return {
|
|
346
|
+
screen_height: screen.height,
|
|
347
|
+
screen_width: screen.width,
|
|
348
|
+
viewport_height: window.innerHeight,
|
|
349
|
+
viewport_width: window.innerWidth
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function getOS(userAgent) {
|
|
353
|
+
if (/Windows/i.test(userAgent)) {
|
|
354
|
+
if (/Phone/.test(userAgent) || /WPDesktop/.test(userAgent)) {
|
|
355
|
+
return "Windows Phone";
|
|
356
|
+
}
|
|
357
|
+
return "Windows";
|
|
358
|
+
} else if (/(iPhone|iPad|iPod)/.test(userAgent)) {
|
|
359
|
+
return "iOS";
|
|
360
|
+
} else if (/Android/.test(userAgent)) {
|
|
361
|
+
return "Android";
|
|
362
|
+
} else if (/(BlackBerry|PlayBook|BB10)/i.test(userAgent)) {
|
|
363
|
+
return "BlackBerry";
|
|
364
|
+
} else if (/Mac/i.test(userAgent)) {
|
|
365
|
+
return "Mac OS X";
|
|
366
|
+
} else if (/Linux/.test(userAgent)) {
|
|
367
|
+
return "Linux";
|
|
368
|
+
} else if (/CrOS/.test(userAgent)) {
|
|
369
|
+
return "Chrome OS";
|
|
370
|
+
} else {
|
|
371
|
+
return "";
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function getDeviceInfo(userAgent) {
|
|
375
|
+
const PATTERNS = [
|
|
376
|
+
{
|
|
377
|
+
device: "iPhone",
|
|
378
|
+
patterns: [/iPhone/]
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
device: "iPad",
|
|
382
|
+
patterns: [/iPad/]
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
device: "iPod Touch",
|
|
386
|
+
patterns: [/iPod/]
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
device: "Windows Phone",
|
|
390
|
+
patterns: [/Windows Phone/i, /WPDesktop/]
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
device: "Android",
|
|
394
|
+
patterns: [/Android/]
|
|
395
|
+
}
|
|
396
|
+
];
|
|
397
|
+
const match = PATTERNS.find(
|
|
398
|
+
(pattern) => pattern.patterns.some((expr) => expr.test(userAgent))
|
|
399
|
+
);
|
|
400
|
+
const device = match == null ? void 0 : match.device;
|
|
401
|
+
return {
|
|
402
|
+
device: device != null ? device : "",
|
|
403
|
+
deviceType: device ? "Mobile" : "Desktop",
|
|
404
|
+
os: getOS(userAgent)
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function getUserAgentMeta() {
|
|
408
|
+
const { navigator } = window;
|
|
409
|
+
const { userAgent } = navigator;
|
|
410
|
+
return __spreadValues({}, getDeviceInfo(userAgent));
|
|
411
|
+
}
|
|
412
|
+
function getWindowMeta() {
|
|
413
|
+
if (!isBrowser2) {
|
|
414
|
+
return {};
|
|
415
|
+
}
|
|
416
|
+
return __spreadValues(__spreadValues(__spreadValues({}, getLocationMeta()), getScreenMeta()), getUserAgentMeta());
|
|
417
|
+
}
|
|
418
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
419
|
+
function getEnvMeta() {
|
|
420
|
+
return {
|
|
421
|
+
isBrowser: isBrowser2,
|
|
422
|
+
isProduction
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function rawSplitVariation(variation) {
|
|
426
|
+
const rawVariations = {};
|
|
427
|
+
Object.keys(variation).forEach((variationKey) => {
|
|
428
|
+
const [, splitId] = variationKey.split(".");
|
|
429
|
+
if (splitId) {
|
|
430
|
+
rawVariations[splitId] = variation[variationKey];
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
return rawVariations;
|
|
434
|
+
}
|
|
435
|
+
var POLL_TIME = 5e3;
|
|
436
|
+
function throttled(func2) {
|
|
437
|
+
let timerId = void 0;
|
|
438
|
+
return (param) => {
|
|
439
|
+
if (timerId) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
if (isBrowser2) {
|
|
443
|
+
timerId = window.requestAnimationFrame(() => {
|
|
444
|
+
timerId = void 0;
|
|
445
|
+
func2(param);
|
|
446
|
+
});
|
|
447
|
+
} else {
|
|
448
|
+
timerId = setTimeout(() => {
|
|
449
|
+
timerId = void 0;
|
|
450
|
+
func2(param);
|
|
451
|
+
}, POLL_TIME);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// src/tracker/index.ts
|
|
457
|
+
var API_ENDPOINT = "https://analytics.plasmic.app/capture";
|
|
458
|
+
var API_PUBLIC_KEY = "phc_BRvYTAoMoam9fDHfrIneF67KdtMJagLVVCM6ELNYd4n";
|
|
459
|
+
var TRACKER_VERSION = 3;
|
|
460
|
+
var PlasmicTracker = class {
|
|
461
|
+
constructor(opts2) {
|
|
462
|
+
this.opts = opts2;
|
|
463
|
+
this.eventQueue = [];
|
|
464
|
+
this.sendEvents = throttled((transport) => __async(this, null, function* () {
|
|
465
|
+
if (this.eventQueue.length === 0) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const events = [...this.eventQueue];
|
|
469
|
+
this.eventQueue.length = 0;
|
|
470
|
+
const body = {
|
|
471
|
+
api_key: API_PUBLIC_KEY,
|
|
472
|
+
batch: events
|
|
473
|
+
};
|
|
474
|
+
try {
|
|
475
|
+
const stringBody = JSON.stringify(body);
|
|
476
|
+
if (transport === "beacon") {
|
|
477
|
+
window.navigator.sendBeacon(API_ENDPOINT, stringBody);
|
|
478
|
+
} else {
|
|
479
|
+
(0, import_isomorphic_unfetch.default)(API_ENDPOINT, {
|
|
480
|
+
method: "POST",
|
|
481
|
+
headers: {
|
|
482
|
+
Accept: "application/json"
|
|
483
|
+
},
|
|
484
|
+
body: stringBody
|
|
485
|
+
}).then(() => {
|
|
486
|
+
}).catch(() => {
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
} catch (err2) {
|
|
490
|
+
}
|
|
491
|
+
}));
|
|
492
|
+
}
|
|
493
|
+
trackRender(opts2) {
|
|
494
|
+
var _a, _b;
|
|
495
|
+
this.enqueue({
|
|
496
|
+
event: "$render",
|
|
497
|
+
properties: __spreadValues(__spreadValues(__spreadValues({}, this.getProperties()), (_a = opts2 == null ? void 0 : opts2.renderCtx) != null ? _a : {}), rawSplitVariation((_b = opts2 == null ? void 0 : opts2.variation) != null ? _b : {}))
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
trackFetch() {
|
|
501
|
+
this.enqueue({
|
|
502
|
+
event: "$fetch",
|
|
503
|
+
properties: this.getProperties()
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
trackConversion(value = 0) {
|
|
507
|
+
this.enqueue({
|
|
508
|
+
event: "$conversion",
|
|
509
|
+
properties: __spreadProps(__spreadValues({}, this.getProperties()), {
|
|
510
|
+
value
|
|
511
|
+
})
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
getProperties() {
|
|
515
|
+
var _a;
|
|
516
|
+
return __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
517
|
+
distinct_id: getDistinctId()
|
|
518
|
+
}, getWindowMeta()), getEnvMeta()), this.getContextMeta()), getVariationCookieValues()), {
|
|
519
|
+
timestamp: (_a = Date.now()) != null ? _a : +/* @__PURE__ */ new Date(),
|
|
520
|
+
trackerVersion: TRACKER_VERSION
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
enqueue(event) {
|
|
524
|
+
this.eventQueue.push(event);
|
|
525
|
+
this.sendEvents("fetch");
|
|
526
|
+
}
|
|
527
|
+
getContextMeta() {
|
|
528
|
+
return {
|
|
529
|
+
platform: this.opts.platform,
|
|
530
|
+
preview: this.opts.preview,
|
|
531
|
+
projectIds: this.opts.projectIds
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/deps-graph.ts", "../src/bundles.ts", "../src/registry.ts", "../src/tracker/index.ts", "../src/tracker/utils.ts"],
|
|
4
|
+
"sourcesContent": ["export type {\n AssetModule,\n CodeModule,\n ComponentMeta,\n ExperimentSlice,\n FontMeta,\n GlobalGroupMeta,\n LoaderBundleCache,\n LoaderBundleOutput,\n LoaderHtmlOutput,\n PageMeta,\n PageMetadata,\n ProjectMeta,\n SegmentSlice,\n Split,\n} from \"@plasmicapp/loader-fetcher\";\nexport { Api, PlasmicModulesFetcher } from \"@plasmicapp/loader-fetcher\";\nexport { getBundleSubset } from \"./bundles\";\nexport { Registry } from \"./registry\";\nexport { PlasmicTracker } from \"./tracker\";\nexport type { TrackRenderOptions } from \"./tracker\";\n", "import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';\n\nexport class DepsGraph {\n private dependsOn: Record<string, string[]> = {};\n private dependedBy: Record<string, string[]> = {};\n constructor(\n private bundle: LoaderBundleOutput,\n private browserBuild: boolean\n ) {\n this.rebuildGraph();\n }\n\n getTransitiveDependers(name: string) {\n return this.transitiveCrawl(name, this.dependedBy);\n }\n\n getTransitiveDeps(name: string) {\n if (!(name in this.dependsOn)) {\n return [];\n }\n\n return this.transitiveCrawl(name, this.dependsOn);\n }\n\n private transitiveCrawl(name: string, edges: Record<string, string[]>) {\n const deps = new Set<string>();\n\n const crawl = (dep: string) => {\n if (deps.has(dep)) {\n return;\n }\n deps.add(dep);\n for (const subdep of edges[dep] ?? []) {\n crawl(subdep);\n }\n };\n\n for (const dep of edges[name]) {\n crawl(dep);\n }\n return Array.from(deps);\n }\n\n private rebuildGraph() {\n this.dependedBy = {};\n this.dependsOn = {};\n for (const mod of this.browserBuild\n ? this.bundle.modules.browser\n : this.bundle.modules.server) {\n if (mod.type === 'code') {\n for (const imported of mod.imports) {\n if (!(mod.fileName in this.dependsOn)) {\n this.dependsOn[mod.fileName] = [imported];\n } else {\n this.dependsOn[mod.fileName].push(imported);\n }\n\n if (!(imported in this.dependedBy)) {\n this.dependedBy[imported] = [mod.fileName];\n } else {\n this.dependedBy[imported].push(mod.fileName);\n }\n }\n }\n }\n }\n}\n", "import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';\nimport { DepsGraph } from './deps-graph';\n\n/**\n * Get sub-bundle including only modules that are reachable from `names`.\n * @param opts.target by default, will target the browser modules. Can request\n * the server modules instead.\n */\nexport function getBundleSubset(\n bundle: LoaderBundleOutput,\n names: string[],\n opts?: {\n target?: 'browser' | 'server';\n }\n): LoaderBundleOutput {\n const namesSet = new Set(names);\n const target = opts?.target ?? 'browser';\n\n const forBrowser = target === 'browser';\n const graph = new DepsGraph(bundle, forBrowser);\n const deps = new Set(names.flatMap((name) => graph.getTransitiveDeps(name)));\n const isSubModule = (fileName: string) =>\n deps.has(fileName) || namesSet.has(fileName);\n const modules = bundle.modules[target];\n const filteredModules = modules.filter((mod) => isSubModule(mod.fileName));\n return {\n modules: {\n browser: forBrowser ? filteredModules : [],\n server: forBrowser ? [] : filteredModules,\n },\n external: bundle.external.filter((dep) => deps.has(dep)),\n components: bundle.components.filter((c) => isSubModule(c.entry)),\n globalGroups: bundle.globalGroups,\n projects: bundle.projects,\n activeSplits: bundle.activeSplits,\n };\n}\n", "import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';\n\nconst isBrowser =\n typeof window !== 'undefined' &&\n window != null &&\n typeof window.document !== 'undefined';\n\nexport class Registry {\n private loadedModules: Record<string, any> = {};\n private registeredModules: Record<string, any> = {};\n private modules: Record<string, string> = {};\n\n constructor() {}\n\n register(name: string, module: any) {\n this.registeredModules[name] = module;\n }\n\n isEmpty() {\n return Object.keys(this.loadedModules).length === 0;\n }\n\n clear() {\n this.loadedModules = {};\n }\n\n getRegisteredModule(name: string) {\n return this.registeredModules[name];\n }\n\n hasModule(name: string, opts: { forceOriginal?: boolean } = {}) {\n if (name in this.registeredModules && !opts.forceOriginal) {\n return true;\n }\n\n return name in this.modules;\n }\n\n load(name: string, opts: { forceOriginal?: boolean } = {}) {\n if (name in this.registeredModules && !opts.forceOriginal) {\n return this.registeredModules[name];\n }\n\n if (name in this.loadedModules) {\n return this.loadedModules[name];\n }\n\n if (!(name in this.modules)) {\n throw new Error(`Unknown module ${name}`);\n }\n\n const code = this.modules[name];\n\n const requireFn = isBrowser\n ? (dep: string) => {\n const normalizedDep = resolvePath(dep, name);\n return this.load(normalizedDep);\n }\n : (dep: string) => {\n try {\n const normalizedDep = resolvePath(dep, name);\n return this.load(normalizedDep);\n } catch (err) {\n try {\n // Might be a nodeJs module such as tty\n return eval('require')(dep);\n } catch {\n throw err;\n }\n }\n };\n\n let func;\n try {\n func = new Function('require', 'exports', code);\n } catch (err) {\n throw new Error(`PLASMIC: Failed to create function for ${name}: ${err}`);\n }\n const exports = {};\n this.loadedModules[name] = exports;\n try {\n func(requireFn, exports);\n } catch (err) {\n // Delete exports from loadedModules, so subsequent uses don't incorrectly\n // believe that this module has been loaded.\n delete this.loadedModules[name];\n throw new Error(`PLASMIC: Failed to load ${name}: ${err}`);\n }\n return exports;\n }\n\n updateModules(bundle: LoaderBundleOutput) {\n let updated = false;\n for (const mod of isBrowser\n ? bundle.modules.browser\n : bundle.modules.server) {\n if (mod.type === 'code' && mod.code !== this.modules[mod.fileName]) {\n this.modules[mod.fileName] = mod.code;\n updated = true;\n }\n }\n\n if (updated) {\n // TODO: do something more efficient than tearing everything down?\n this.clear();\n }\n }\n}\n\nfunction resolvePath(path: string, from: string) {\n const fromParts = from.split('/');\n const pathParts = path.split('/');\n if (pathParts.length === 0) {\n return path;\n }\n\n if (pathParts[0] === '.') {\n return [\n ...fromParts.slice(0, fromParts.length - 1),\n ...pathParts.slice(1),\n ].join('/');\n } else if (pathParts[0] === '..') {\n let count = 0;\n for (const part of pathParts) {\n if (part === '..') {\n count += 1;\n } else {\n break;\n }\n }\n return [\n ...fromParts.slice(0, fromParts.length - count - 1),\n ...pathParts.slice(count),\n ].join('/');\n } else {\n return path;\n }\n}\n", "import fetch from '@plasmicapp/isomorphic-unfetch';\nimport {\n getDistinctId,\n getEnvMeta,\n getVariationCookieValues,\n getWindowMeta,\n rawSplitVariation,\n throttled,\n} from './utils';\n\nexport interface TrackerOptions {\n projectIds: string[];\n host?: string;\n platform?: string;\n preview?: boolean;\n}\n\ntype EventType = '$render' | '$fetch' | '$conversion';\n\ninterface Event {\n event: EventType;\n properties: Record<string, any>;\n}\n\nexport interface TrackerRenderProperties {\n rootProjectId?: string;\n rootComponentId?: string;\n rootComponentName?: string;\n teamIds: string[];\n projectIds: string[];\n}\n\nexport interface TrackRenderOptions {\n renderCtx?: TrackerRenderProperties;\n variation?: Record<string, string>;\n}\n\nconst API_ENDPOINT = 'https://analytics.plasmic.app/capture';\nconst API_PUBLIC_KEY = 'phc_BRvYTAoMoam9fDHfrIneF67KdtMJagLVVCM6ELNYd4n';\nconst TRACKER_VERSION = 3;\n\nexport class PlasmicTracker {\n private eventQueue: Event[] = [];\n\n constructor(private opts: TrackerOptions) {}\n\n public trackRender(opts?: TrackRenderOptions) {\n this.enqueue({\n event: '$render',\n properties: {\n ...this.getProperties(),\n ...(opts?.renderCtx ?? {}),\n ...rawSplitVariation(opts?.variation ?? {}),\n },\n });\n }\n\n public trackFetch() {\n this.enqueue({\n event: '$fetch',\n properties: this.getProperties(),\n });\n }\n\n public trackConversion(value: number = 0) {\n this.enqueue({\n event: '$conversion',\n properties: {\n ...this.getProperties(),\n value,\n },\n });\n }\n\n private getProperties() {\n return {\n distinct_id: getDistinctId(),\n ...getWindowMeta(),\n ...getEnvMeta(),\n ...this.getContextMeta(),\n ...getVariationCookieValues(),\n timestamp: Date.now() ?? +new Date(),\n trackerVersion: TRACKER_VERSION,\n };\n }\n\n private enqueue(event: Event) {\n this.eventQueue.push(event);\n\n this.sendEvents('fetch');\n }\n\n private getContextMeta() {\n return {\n platform: this.opts.platform,\n preview: this.opts.preview,\n projectIds: this.opts.projectIds,\n };\n }\n\n private sendEvents = throttled(async (transport: 'fetch' | 'beacon') => {\n if (this.eventQueue.length === 0) {\n return;\n }\n\n const events = [...this.eventQueue];\n this.eventQueue.length = 0;\n\n const body = {\n api_key: API_PUBLIC_KEY,\n batch: events,\n };\n\n try {\n const stringBody = JSON.stringify(body);\n if (transport === 'beacon') {\n // Triggers warning: https://chromestatus.com/feature/5629709824032768\n window.navigator.sendBeacon(API_ENDPOINT, stringBody);\n } else {\n fetch(API_ENDPOINT, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n },\n body: stringBody,\n })\n .then(() => {})\n .catch(() => {});\n }\n } catch (err) {}\n });\n}\n", "const isBrowser =\n typeof window !== 'undefined' &&\n window != null &&\n typeof window.document !== 'undefined';\n\nexport function getPlasmicCookieValues() {\n if (!isBrowser) {\n return {};\n }\n return Object.fromEntries(\n document.cookie\n .split('; ')\n .filter((cookie) => cookie.includes('plasmic:'))\n .map((cookie) => cookie.split('='))\n .map(([key, value]) => [key.split(':')[1], value])\n );\n}\n\nexport function getVariationCookieValues() {\n const cookies = getPlasmicCookieValues();\n return Object.fromEntries(\n Object.keys(cookies)\n .map((key) => [key.split('.')[1], cookies[key]])\n .filter((val) => !!val[0])\n );\n}\n\n// https://stackoverflow.com/a/8809472\nexport function generateUUID() {\n // Public Domain/MIT\n var d = new Date().getTime(); //Timestamp\n var d2 =\n (typeof performance !== 'undefined' &&\n performance.now &&\n performance.now() * 1000) ||\n 0; //Time in microseconds since page-load or 0 if unsupported\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n var r = Math.random() * 16; //random number between 0 and 16\n if (d > 0) {\n //Use timestamp until depleted\n r = (d + r) % 16 | 0;\n d = Math.floor(d / 16);\n } else {\n //Use microseconds since page-load if supported\n r = (d2 + r) % 16 | 0;\n d2 = Math.floor(d2 / 16);\n }\n return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);\n });\n}\n\nexport function getDistinctId(): string {\n if (!isBrowser) {\n return 'LOADER-SERVER';\n }\n return generateUUID();\n}\n\nfunction getCampaignParams() {\n const { location } = window;\n const params: Record<string, string> = {};\n try {\n const url = new URL(location.href);\n const CAMPAIGN_KEYWORDS = [\n 'utm_source',\n 'utm_medium',\n 'utm_campaign',\n 'utm_content',\n 'utm_term',\n 'gclid',\n ];\n CAMPAIGN_KEYWORDS.forEach((keyword) => {\n const value = url.searchParams.get(keyword);\n if (value) {\n params[keyword] = value;\n }\n });\n } catch (err) {}\n return params;\n}\n\nfunction getLocationMeta() {\n const { location } = window;\n const { referrer } = document;\n return {\n url: location.href,\n host: location.host,\n pathname: location.pathname,\n referrer,\n ...getCampaignParams(),\n };\n}\n\nfunction getScreenMeta() {\n const { screen } = window;\n return {\n screen_height: screen.height,\n screen_width: screen.width,\n viewport_height: window.innerHeight,\n viewport_width: window.innerWidth,\n };\n}\n\nfunction getOS(userAgent: string) {\n if (/Windows/i.test(userAgent)) {\n if (/Phone/.test(userAgent) || /WPDesktop/.test(userAgent)) {\n return 'Windows Phone';\n }\n return 'Windows';\n } else if (/(iPhone|iPad|iPod)/.test(userAgent)) {\n return 'iOS';\n } else if (/Android/.test(userAgent)) {\n return 'Android';\n } else if (/(BlackBerry|PlayBook|BB10)/i.test(userAgent)) {\n return 'BlackBerry';\n } else if (/Mac/i.test(userAgent)) {\n return 'Mac OS X';\n } else if (/Linux/.test(userAgent)) {\n return 'Linux';\n } else if (/CrOS/.test(userAgent)) {\n return 'Chrome OS';\n } else {\n return '';\n }\n}\n\nfunction getDeviceInfo(userAgent: string) {\n const PATTERNS = [\n {\n device: 'iPhone',\n patterns: [/iPhone/],\n },\n {\n device: 'iPad',\n patterns: [/iPad/],\n },\n {\n device: 'iPod Touch',\n patterns: [/iPod/],\n },\n {\n device: 'Windows Phone',\n patterns: [/Windows Phone/i, /WPDesktop/],\n },\n {\n device: 'Android',\n patterns: [/Android/],\n },\n ];\n const match = PATTERNS.find((pattern) =>\n pattern.patterns.some((expr) => expr.test(userAgent))\n );\n const device = match?.device;\n return {\n device: device ?? '',\n deviceType: device ? 'Mobile' : 'Desktop',\n os: getOS(userAgent),\n };\n}\n\nfunction getUserAgentMeta() {\n const { navigator } = window;\n const { userAgent } = navigator;\n return {\n ...getDeviceInfo(userAgent),\n };\n}\n\nexport function getWindowMeta() {\n if (!isBrowser) {\n return {};\n }\n return {\n ...getLocationMeta(),\n ...getScreenMeta(),\n ...getUserAgentMeta(),\n };\n}\n\nconst isProduction = process.env.NODE_ENV === 'production';\n\nexport function getEnvMeta() {\n return {\n isBrowser,\n isProduction,\n };\n}\n\nexport function rawSplitVariation(variation: Record<string, string>) {\n const rawVariations: Record<string, string> = {};\n Object.keys(variation).forEach((variationKey) => {\n const [, splitId] = variationKey.split('.');\n if (splitId) {\n rawVariations[splitId] = variation[variationKey];\n }\n });\n return rawVariations;\n}\n\nconst POLL_TIME = 5000;\n\nexport function throttled<T>(func: (param: T) => Promise<void>) {\n let timerId: number | undefined = undefined;\n return (param: T) => {\n if (timerId) {\n // will already be taken care of next time we run\n return;\n }\n\n if (isBrowser) {\n timerId = window.requestAnimationFrame(() => {\n timerId = undefined;\n func(param);\n });\n } else {\n timerId = setTimeout(() => {\n timerId = undefined;\n func(param);\n }, POLL_TIME) as any;\n }\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,4BAA2C;;;ACdpC,IAAM,YAAN,MAAgB;AAAA,EAGrB,YACU,QACA,cACR;AAFQ;AACA;AAJV,SAAQ,YAAsC,CAAC;AAC/C,SAAQ,aAAuC,CAAC;AAK9C,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,uBAAuBA,OAAc;AACnC,WAAO,KAAK,gBAAgBA,OAAM,KAAK,UAAU;AAAA,EACnD;AAAA,EAEA,kBAAkBA,OAAc;AAC9B,QAAI,EAAEA,SAAQ,KAAK,YAAY;AAC7B,aAAO,CAAC;AAAA,IACV;AAEA,WAAO,KAAK,gBAAgBA,OAAM,KAAK,SAAS;AAAA,EAClD;AAAA,EAEQ,gBAAgBA,OAAc,OAAiC;AACrE,UAAM,OAAO,oBAAI,IAAY;AAE7B,UAAM,QAAQ,CAACC,SAAgB;AA3BnC;AA4BM,UAAI,KAAK,IAAIA,IAAG,GAAG;AACjB;AAAA,MACF;AACA,WAAK,IAAIA,IAAG;AACZ,iBAAW,WAAU,WAAMA,IAAG,MAAT,YAAc,CAAC,GAAG;AACrC,cAAM,MAAM;AAAA,MACd;AAAA,IACF;AAEA,eAAWA,QAAO,MAAMD,KAAI,GAAG;AAC7B,YAAMC,IAAG;AAAA,IACX;AACA,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AAAA,EAEQ,eAAe;AACrB,SAAK,aAAa,CAAC;AACnB,SAAK,YAAY,CAAC;AAClB,eAAW,OAAO,KAAK,eACnB,KAAK,OAAO,QAAQ,UACpB,KAAK,OAAO,QAA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AQ,OAAc;AAC5B,SAAK,WAAW,KAAK,KAAK;AAE1B,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EAEQ,iBAAiB;AACvB,WAAO;AAAA,MACL,UAAU,KAAK,KAAK;AAAA,MACpB,SAAS,KAAK,KAAK;AAAA,MACnB,YAAY,KAAK,KAAK;AAAA,IACxB;AAAA,EACF;AAiCF;",
|
|
6
|
+
"names": ["name", "dep", "opts", "name", "dep", "name", "module", "opts", "dep", "err", "isBrowser", "err", "func", "opts", "fetch", "err"]
|
|
7
|
+
}
|