blob: 6434aab1be8ef6c06b7cb434b6c4053eb76241f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#pragma once
#include "root.h"
#include "headers-handwritten.h"
#include "JavaScriptCore/JSGlobalObject.h"
#include "JavaScriptCore/Strong.h"
#include "JavaScriptCore/RegularExpression.h"
#include "helpers.h"
#include <JavaScriptCore/Yarr.h>
#include <JavaScriptCore/Strong.h>
namespace Bun {
using namespace JSC;
class BundlerPlugin final {
public:
class NamespaceList final {
public:
Vector<Yarr::RegularExpression> fileNamespace = {};
Vector<String> namespaces = {};
Vector<Vector<Yarr::RegularExpression>> groups = {};
BunPluginTarget target { BunPluginTargetBun };
Vector<Yarr::RegularExpression>* group(const String& namespaceStr)
{
if (namespaceStr.isEmpty()) {
return &fileNamespace;
}
size_t length = namespaces.size();
for (size_t i = 0; i < length; i++) {
if (namespaces[i] == namespaceStr) {
return &groups[i];
}
}
return nullptr;
}
void append(JSC::VM& vm, JSC::RegExp* filter, String& namespaceString);
};
public:
bool anyMatchesCrossThread(const ZigString* namespaceStr, const ZigString* path, bool isOnLoad);
void tombstone() { tombstoned = true; }
BundlerPlugin(void* config, BunPluginTarget target)
{
this->target = target;
this->config = config;
}
NamespaceList onLoad = {};
NamespaceList onResolve = {};
BunPluginTarget target { BunPluginTargetBrowser };
void* config { nullptr };
bool tombstoned { false };
};
} // namespace Zig
|