@plasmicapp/loader-core 1.0.114 → 1.0.116

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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"],
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
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,SAAS,KAAK,6BAA6B;;;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,EAC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,yBAAyB,IALvB;AAAA,MAML,YAAW,UAAK,IAAI,MAAT,YAAc,CAAC,oBAAI,KAAK;AAAA,MACnC,gBAAgB;AAAA,IAClB;AAAA,EACF;AAAA,EAEQ,QAAQ,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
6
  "names": ["name", "dep", "opts", "name", "dep", "name", "opts", "dep", "err", "isBrowser", "err", "func", "opts", "err"]
7
7
  }
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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"],
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
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,g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AAmB,CAAC,CAAC;AAAA,IAE9C,CAAC;AAAA,EACH;AAAA,EAEO,aAAa;AAClB,SAAK,QAAQ;AAAA,MACX,OAAO;AAAA,MACP,YAAY,KAAK,cAAc;AAAA,IACjC,CAAC;AAAA,EACH;AAAA,EAEO,gBAAgB,QAAgB,GAAG;AACxC,SAAK,QAAQ;AAAA,MACX,OAAO;AAAA,MACP,YAAY,iCACP,KAAK,cAAc,IADZ;AAAA,QAEV;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,gBAAgB;AA1E1B;AA2EI,WAAO;AAAA,MACL,aAAa,cAAc;AAAA,OACxB,cAAc,IACd,WAAW,IACX,KAAK,eAAe,IACpB,yBAAyB,IALvB;AAAA,MAML,YAAW,UAAK,IAAI,MAAT,YAAc,CAAC,oBAAI,KAAK;AAAA,MACnC,gBAAgB;AAAA,IAClB;AAAA,EACF;AAAA,EAEQ,QAAQ,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
6
  "names": ["name", "dep", "opts", "name", "dep", "name", "module", "opts", "dep", "err", "isBrowser", "err", "func", "opts", "fetch", "err"]
7
7
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.114",
2
+ "version": "1.0.116",
3
3
  "license": "MIT",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
@@ -36,9 +36,12 @@
36
36
  "limit": "10 KB"
37
37
  }
38
38
  ],
39
+ "devDependencies": {
40
+ "@types/node": "^20.8.9"
41
+ },
39
42
  "dependencies": {
40
43
  "@plasmicapp/isomorphic-unfetch": "1.0.3",
41
- "@plasmicapp/loader-fetcher": "1.0.37"
44
+ "@plasmicapp/loader-fetcher": "1.0.38"
42
45
  },
43
- "gitHead": "7e568e741a82d5b77452edbc4d8d4492bf02441f"
46
+ "gitHead": "6db50a6b3e9ffd747e4a6521b42fcc0a8f32e97c"
44
47
  }