MCPcopy
hub / github.com/crxjs/chrome-extension-tools / setupFileEmitter

Function setupFileEmitter

src/index.ts:100–130  ·  view source on GitHub ↗
(this: PluginContext)

Source from the content-addressed store, hash-verified

98 }
99
100 function setupFileEmitter(this: PluginContext) {
101 useConfig(service, {
102 actions: {
103 handleFile: (context, event) => {
104 try {
105 const { file: f } = narrowEvent(event, 'EMIT_FILE')
106 const file = Object.assign({}, f)
107
108 if (file.type === 'chunk')
109 file.fileName = getJsFilename(file.fileName)
110
111 const refId = this.emitFile(file)
112 service.send(
113 model.events.REF_ID({
114 id: file.id,
115 fileId: refId,
116 }),
117 )
118
119 const emittedFile = { ...file, refId }
120 filesByRefId.set(refId, emittedFile)
121 filesByFileName.set(file.fileName, emittedFile)
122
123 this.addWatchFile(file.id)
124 } catch (error) {
125 service.send(model.events.ERROR(error))
126 }
127 },
128 },
129 })
130 }
131
132 async function addFiles(
133 this: PluginContext,

Callers

nothing calls this directly

Calls 3

useConfigFunction · 0.90
narrowEventFunction · 0.90
getJsFilenameFunction · 0.90

Tested by

no test coverage detected