rollipop 0.1.0-dev.20260424074146 → 1.0.0-alpha.21
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/CHANGELOG.md +36 -2
- package/dist/commands.cjs +2661 -2501
- package/dist/commands.d.cts +1 -1
- package/dist/commands.d.ts +1 -1
- package/dist/commands.js +2681 -2521
- package/dist/hmr-runtime.iife.js +11 -10
- package/dist/index.d.ts +171 -28
- package/dist/index.js +349 -174
- package/dist/runtime.cjs +2 -2
- package/dist/runtime.js +2 -2
- package/package.json +6 -19
- package/src/runtime/hmr-runtime.ts +271 -0
- package/src/runtime/react-native-core.d.ts +37 -0
- package/src/runtime/react-refresh-utils.ts +37 -0
- package/src/runtime/runtime-utils.ts +57 -0
- package/dist/plugins.cjs +0 -166
- package/dist/plugins.d.cts +0 -655
- package/dist/plugins.d.ts +0 -654
- package/dist/plugins.js +0 -143
package/dist/runtime.cjs
CHANGED
|
@@ -26,8 +26,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
26
26
|
//#region src/runtime.ts
|
|
27
27
|
function setCustomHMRHandler(_) {
|
|
28
28
|
if (__DEV__) {
|
|
29
|
-
if (
|
|
30
|
-
|
|
29
|
+
if (global.__ROLLIPOP_CUSTOM_HMR_HANDLER__ != null) console.warn("Custom HMR handler already set. replacing existing handler.");
|
|
30
|
+
global.__ROLLIPOP_CUSTOM_HMR_HANDLER__ = _;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
package/dist/runtime.js
CHANGED
|
@@ -2,8 +2,8 @@ import "./chunk-DXpK5_cz.js";
|
|
|
2
2
|
//#region src/runtime.ts
|
|
3
3
|
function setCustomHMRHandler(_) {
|
|
4
4
|
if (__DEV__) {
|
|
5
|
-
if (
|
|
6
|
-
|
|
5
|
+
if (global.__ROLLIPOP_CUSTOM_HMR_HANDLER__ != null) console.warn("Custom HMR handler already set. replacing existing handler.");
|
|
6
|
+
global.__ROLLIPOP_CUSTOM_HMR_HANDLER__ = _;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollipop",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-alpha.21",
|
|
4
4
|
"homepage": "https://github.com/leegeunhyeok/rollipop#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/leegeunhyeok/rollipop/issues"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"client.d.ts",
|
|
18
18
|
"bin",
|
|
19
19
|
"dist",
|
|
20
|
-
"src/runtime
|
|
20
|
+
"src/runtime/**"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
23
|
"main": "./dist/index.js",
|
|
@@ -41,16 +41,6 @@
|
|
|
41
41
|
"types": "./dist/pluginutils.d.ts",
|
|
42
42
|
"default": "./dist/pluginutils.js"
|
|
43
43
|
},
|
|
44
|
-
"./plugins": {
|
|
45
|
-
"import": {
|
|
46
|
-
"types": "./dist/plugins.d.ts",
|
|
47
|
-
"default": "./dist/plugins.js"
|
|
48
|
-
},
|
|
49
|
-
"require": {
|
|
50
|
-
"types": "./dist/plugins.d.cts",
|
|
51
|
-
"default": "./dist/plugins.cjs"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
44
|
"./runtime": {
|
|
55
45
|
"import": {
|
|
56
46
|
"types": "./dist/runtime.d.ts",
|
|
@@ -89,10 +79,8 @@
|
|
|
89
79
|
"@react-native-community/cli-types": "^20.1.2",
|
|
90
80
|
"@react-native/babel-plugin-codegen": "^0.84.1",
|
|
91
81
|
"@react-native/dev-middleware": "^0.84.1",
|
|
92
|
-
"@rollipop/rolldown": "1.0.
|
|
93
|
-
"@rollipop/rolldown-pluginutils": "1.0.
|
|
94
|
-
"@svgr/core": "^8.1.0",
|
|
95
|
-
"@svgr/plugin-jsx": "^8.1.0",
|
|
82
|
+
"@rollipop/rolldown": "1.0.8",
|
|
83
|
+
"@rollipop/rolldown-pluginutils": "1.0.8",
|
|
96
84
|
"@swc/core": "^1.15.18",
|
|
97
85
|
"@swc/helpers": "^0.5.19",
|
|
98
86
|
"@types/ws": "^8",
|
|
@@ -127,8 +115,7 @@
|
|
|
127
115
|
"@types/babel__core": "^7",
|
|
128
116
|
"@types/babel__generator": "^7",
|
|
129
117
|
"magic-string": "^0.30.21",
|
|
130
|
-
"typescript": "
|
|
118
|
+
"typescript": "6.0.3",
|
|
131
119
|
"vite-plus": "latest"
|
|
132
|
-
}
|
|
133
|
-
"stableVersion": "0.1.0-alpha.17"
|
|
120
|
+
}
|
|
134
121
|
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import mitt from 'mitt';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
DevRuntime as DefaultDevRuntime,
|
|
5
|
+
DevRuntimeMessenger,
|
|
6
|
+
HMRClientMessage,
|
|
7
|
+
HMRCustomHandler,
|
|
8
|
+
HMRCustomMessage,
|
|
9
|
+
HMRServerMessage,
|
|
10
|
+
HMRContext,
|
|
11
|
+
} from '../types/hmr';
|
|
12
|
+
import { enqueueUpdate, isReactRefreshBoundary } from './react-refresh-utils';
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
var __rolldown_runtime__: ReactNativeDevRuntime;
|
|
16
|
+
var __turboModuleProxy: (moduleName: string) => any;
|
|
17
|
+
var globalEvalWithSourceUrl: (code: string, sourceURL?: string) => void;
|
|
18
|
+
var nativeModuleProxy: Record<string, any>;
|
|
19
|
+
var __ReactRefresh: any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
var __ROLLIPOP_CUSTOM_HMR_HANDLER__: HMRCustomHandler | undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// DO NOT EDIT THIS CLASS NAME (`DevRuntime`)
|
|
27
|
+
declare const DevRuntime: typeof DefaultDevRuntime;
|
|
28
|
+
|
|
29
|
+
var BaseDevRuntime = DevRuntime;
|
|
30
|
+
|
|
31
|
+
class ModuleHotContext implements HMRContext {
|
|
32
|
+
private readonly removeListeners: (() => void)[] = [];
|
|
33
|
+
acceptCallbacks: { deps: string[]; fn: (moduleExports: Record<string, any>[]) => void }[] = [];
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
private moduleId: string,
|
|
37
|
+
private socketHolder: SocketHolder,
|
|
38
|
+
) {}
|
|
39
|
+
|
|
40
|
+
get refresh() {
|
|
41
|
+
return globalThis.__ReactRefresh;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get refreshUtils() {
|
|
45
|
+
return {
|
|
46
|
+
isReactRefreshBoundary,
|
|
47
|
+
enqueueUpdate,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
accept(...args: any[]) {
|
|
52
|
+
if (args.length === 1) {
|
|
53
|
+
const [cb] = args;
|
|
54
|
+
const acceptingPath = this.moduleId;
|
|
55
|
+
this.acceptCallbacks.push({
|
|
56
|
+
deps: [acceptingPath],
|
|
57
|
+
fn: cb,
|
|
58
|
+
});
|
|
59
|
+
} else if (args.length === 0) {
|
|
60
|
+
// noop
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error('Invalid arguments for `import.meta.hot.accept`');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
invalidate() {
|
|
67
|
+
this.socketHolder.send(
|
|
68
|
+
JSON.stringify({
|
|
69
|
+
type: 'hmr:invalidate',
|
|
70
|
+
moduleId: this.moduleId,
|
|
71
|
+
} satisfies HMRClientMessage),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
on(event: string, listener: (...args: any[]) => void) {
|
|
76
|
+
this.socketHolder.on(event, listener);
|
|
77
|
+
this.removeListeners.push(() => this.socketHolder.off(event, listener));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
off(event: string, listener: (...args: any[]) => void) {
|
|
81
|
+
this.socketHolder.off(event, listener);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
send(type: string, payload?: unknown) {
|
|
85
|
+
this.socketHolder.send(JSON.stringify({ type, payload }));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
cleanup() {
|
|
89
|
+
for (const removeListener of this.removeListeners) {
|
|
90
|
+
removeListener();
|
|
91
|
+
}
|
|
92
|
+
this.removeListeners.length = 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
class SocketHolder {
|
|
97
|
+
private readonly queuedMessages: string[] = [];
|
|
98
|
+
private readonly emitter = mitt();
|
|
99
|
+
private _socket: WebSocket | null = null;
|
|
100
|
+
private _origin: string | null = null;
|
|
101
|
+
|
|
102
|
+
get socket() {
|
|
103
|
+
return this._socket;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get origin() {
|
|
107
|
+
return this._origin;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
setup(socket: WebSocket, origin: string) {
|
|
111
|
+
this._socket = socket;
|
|
112
|
+
this._origin = origin;
|
|
113
|
+
|
|
114
|
+
if (socket.readyState !== WebSocket.OPEN) {
|
|
115
|
+
socket.addEventListener('open', () => this.flushQueuedMessages(), { once: true });
|
|
116
|
+
} else {
|
|
117
|
+
this.flushQueuedMessages();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
on(event: string, listener: (payload?: unknown) => void) {
|
|
122
|
+
this.emitter.on(event, listener);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
off(event: string, listener: (payload?: unknown) => void) {
|
|
126
|
+
this.emitter.off(event, listener);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
emit(event: string, payload?: unknown) {
|
|
130
|
+
this.emitter.emit(event, payload);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
send(message: string) {
|
|
134
|
+
if (this._socket == null || this._socket.readyState !== WebSocket.OPEN) {
|
|
135
|
+
this.queuedMessages.push(message);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
this.flushQueuedMessages();
|
|
139
|
+
this._socket.send(message);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
flushQueuedMessages() {
|
|
143
|
+
if (this._socket == null) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
for (const message of this.queuedMessages) {
|
|
147
|
+
this._socket.send(message);
|
|
148
|
+
}
|
|
149
|
+
this.queuedMessages.length = 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
close() {
|
|
153
|
+
if (this._socket == null) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
this._socket.close();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
class ReactNativeDevRuntime extends BaseDevRuntime {
|
|
161
|
+
socketHolder: SocketHolder;
|
|
162
|
+
moduleHotContexts = new Map<string, ModuleHotContext>();
|
|
163
|
+
moduleHotContextsToBeUpdated = new Map<string, ModuleHotContext>();
|
|
164
|
+
|
|
165
|
+
constructor() {
|
|
166
|
+
const socketHolder = new SocketHolder();
|
|
167
|
+
const messenger: DevRuntimeMessenger = {
|
|
168
|
+
send: (message) => socketHolder.send(JSON.stringify(message)),
|
|
169
|
+
};
|
|
170
|
+
super(messenger);
|
|
171
|
+
this.socketHolder = socketHolder;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
createModuleHotContext(moduleId: string) {
|
|
175
|
+
const hotContext = new ModuleHotContext(moduleId, this.socketHolder);
|
|
176
|
+
if (this.moduleHotContexts.has(moduleId)) {
|
|
177
|
+
this.moduleHotContextsToBeUpdated.set(moduleId, hotContext);
|
|
178
|
+
} else {
|
|
179
|
+
this.moduleHotContexts.set(moduleId, hotContext);
|
|
180
|
+
}
|
|
181
|
+
return hotContext;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
applyUpdates(boundaries: [string, string][]) {
|
|
185
|
+
for (let [moduleId, _acceptedVia] of boundaries) {
|
|
186
|
+
const hotContext = this.moduleHotContexts.get(moduleId);
|
|
187
|
+
if (hotContext) {
|
|
188
|
+
const acceptCallbacks = hotContext.acceptCallbacks;
|
|
189
|
+
acceptCallbacks.filter((cb) => {
|
|
190
|
+
cb.fn(this.modules[moduleId].exports);
|
|
191
|
+
});
|
|
192
|
+
hotContext.cleanup();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
this.moduleHotContextsToBeUpdated.forEach((hotContext, moduleId) => {
|
|
196
|
+
this.moduleHotContexts.set(moduleId, hotContext);
|
|
197
|
+
});
|
|
198
|
+
this.moduleHotContextsToBeUpdated.clear();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
setup(socket: WebSocket, origin: string) {
|
|
202
|
+
if (this.socketHolder.socket != null) {
|
|
203
|
+
console.warn('[HMR]: ReactNativeDevRuntime already setup');
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
this.socketHolder.setup(socket, origin);
|
|
208
|
+
|
|
209
|
+
socket.addEventListener('message', (event: MessageEvent) => {
|
|
210
|
+
const message = JSON.parse(event.data) as HMRServerMessage;
|
|
211
|
+
|
|
212
|
+
if (isCustomHMRMessage(message)) {
|
|
213
|
+
debug(`[HMR]: Custom HMR message received: ${message.type}`);
|
|
214
|
+
this.socketHolder.emit(message.type, message.payload);
|
|
215
|
+
globalThis.__ROLLIPOP_CUSTOM_HMR_HANDLER__?.(socket, message);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
switch (message.type) {
|
|
220
|
+
case 'hmr:update':
|
|
221
|
+
this.evaluate(message.code);
|
|
222
|
+
break;
|
|
223
|
+
|
|
224
|
+
case 'hmr:reload':
|
|
225
|
+
this.reload();
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private evaluate(code: string, sourceURL?: string) {
|
|
232
|
+
debug(`[HMR]: Evaluating code\n${code}`);
|
|
233
|
+
if (globalThis.globalEvalWithSourceUrl) {
|
|
234
|
+
globalThis.globalEvalWithSourceUrl(code, sourceURL);
|
|
235
|
+
} else {
|
|
236
|
+
// oxlint-disable-next-line no-eval
|
|
237
|
+
eval(code);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private reload() {
|
|
242
|
+
debug(`[HMR]: Reloading`);
|
|
243
|
+
const moduleName = 'DevSettings';
|
|
244
|
+
(globalThis.__turboModuleProxy
|
|
245
|
+
? globalThis.__turboModuleProxy(moduleName)
|
|
246
|
+
: globalThis.nativeModuleProxy[moduleName]
|
|
247
|
+
).reload();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function debug(...args: any[]) {
|
|
252
|
+
if (process.env.DEBUG_ROLLIPOP) {
|
|
253
|
+
console.log(...args);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function isCustomHMRMessage(message: unknown): message is HMRCustomMessage {
|
|
258
|
+
if (typeof message !== 'object' || message == null) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if ('type' in message && typeof message.type === 'string' && message.type.startsWith('hmr:')) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
globalThis.__rolldown_runtime__ ??= new ReactNativeDevRuntime();
|
|
270
|
+
|
|
271
|
+
export type { DevRuntime };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare module '*/LogBox' {
|
|
2
|
+
const LogBox: { clearAllLogs: () => void };
|
|
3
|
+
|
|
4
|
+
export default LogBox;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module '*/NativeRedBox' {
|
|
8
|
+
const NativeRedBox: { dismiss?: () => void };
|
|
9
|
+
|
|
10
|
+
export default NativeRedBox;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module '*/DevLoadingView' {
|
|
14
|
+
const DevLoadingView: {
|
|
15
|
+
showMessage: (message: string, type: string, options?: { dismissButton?: boolean }) => void;
|
|
16
|
+
hide: () => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default DevLoadingView;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare module '*/Platform' {
|
|
23
|
+
const Platform: { OS: string };
|
|
24
|
+
|
|
25
|
+
export default Platform;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare module 'pretty-format' {
|
|
29
|
+
const prettyFormat: {
|
|
30
|
+
format: (value: any, options?: any) => string;
|
|
31
|
+
plugins: {
|
|
32
|
+
ReactElement: any;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default prettyFormat;
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function isReactRefreshBoundary(moduleExports: Record<string, unknown>) {
|
|
2
|
+
if (globalThis.__ReactRefresh.isLikelyComponentType(moduleExports)) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (moduleExports === undefined || moduleExports === null || typeof moduleExports !== 'object') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var hasExports = false;
|
|
11
|
+
var areAllExportsComponents = true;
|
|
12
|
+
for (var key in moduleExports) {
|
|
13
|
+
hasExports = true;
|
|
14
|
+
|
|
15
|
+
if (key === '__esModule') {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var exportValue = moduleExports[key];
|
|
20
|
+
if (!globalThis.__ReactRefresh.isLikelyComponentType(exportValue)) {
|
|
21
|
+
areAllExportsComponents = false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return hasExports && areAllExportsComponents;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let timer: NodeJS.Timeout | null = null;
|
|
29
|
+
export function enqueueUpdate() {
|
|
30
|
+
if (timer) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
timer = setTimeout(() => {
|
|
34
|
+
globalThis.__ReactRefresh.performReactRefresh();
|
|
35
|
+
timer = null;
|
|
36
|
+
}, 50);
|
|
37
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* oxlint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Ported from:
|
|
4
|
+
* @see https://github.com/rolldown/rolldown/blob/feae112db77bf01e886b859e347ce3256944d360/crates/rolldown/src/runtime/runtime-base.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const __create$ = Object.create;
|
|
8
|
+
export const __defProp$ = Object.defineProperty;
|
|
9
|
+
export const __hasOwnProp$ = Object.prototype.hasOwnProperty;
|
|
10
|
+
export const __getProtoOf$ = Object.getPrototypeOf;
|
|
11
|
+
export const __getOwnPropNames$ = Object.getOwnPropertyNames;
|
|
12
|
+
export const __getOwnPropDesc$ = Object.getOwnPropertyDescriptor;
|
|
13
|
+
|
|
14
|
+
export const __copyProps$ = (to: any, from: any, except?: string, desc?: PropertyDescriptor) => {
|
|
15
|
+
if ((from && typeof from === 'object') || typeof from === 'function') {
|
|
16
|
+
for (var keys = __getOwnPropNames$(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
+
key = keys[i];
|
|
18
|
+
if (!__hasOwnProp$.call(to, key) && key !== except) {
|
|
19
|
+
__defProp$(to, key, {
|
|
20
|
+
get: ((k: string) => from[k]).bind(null, key),
|
|
21
|
+
enumerable: !(desc = __getOwnPropDesc$(from, key)) || desc.enumerable,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const __toESM$ = (mod: any, isNodeMode: boolean, target?: any) => (
|
|
30
|
+
(target = mod != null ? __create$(__getProtoOf$(mod)) : {}),
|
|
31
|
+
__copyProps$(
|
|
32
|
+
isNodeMode || !mod || !mod.__esModule$
|
|
33
|
+
? __defProp$(target, 'default', { value: mod, enumerable: true })
|
|
34
|
+
: target,
|
|
35
|
+
mod,
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export const __toCommonJS$ = (mod: any) =>
|
|
40
|
+
__hasOwnProp$.call(mod, 'module.exports')
|
|
41
|
+
? mod['module.exports']
|
|
42
|
+
: __copyProps$(__defProp$({}, '__esModule', { value: true }), mod);
|
|
43
|
+
|
|
44
|
+
export const __exportAll$ = (all: any, symbols: boolean) => {
|
|
45
|
+
let target = {};
|
|
46
|
+
for (var name in all) {
|
|
47
|
+
__defProp$(target, name, { get: all[name], enumerable: true });
|
|
48
|
+
}
|
|
49
|
+
if (symbols) {
|
|
50
|
+
__defProp$(target, Symbol.toStringTag, { value: 'Module' });
|
|
51
|
+
}
|
|
52
|
+
return target;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const __reExport$ = (target: any, mod: any, secondTarget: any) => (
|
|
56
|
+
__copyProps$(target, mod, 'default'), secondTarget && __copyProps$(secondTarget, mod, 'default')
|
|
57
|
+
);
|
package/dist/plugins.cjs
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
-
get: ((k) => from[k]).bind(null, key),
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
-
value: mod,
|
|
21
|
-
enumerable: true
|
|
22
|
-
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
|
-
let node_fs = require("node:fs");
|
|
25
|
-
node_fs = __toESM(node_fs);
|
|
26
|
-
let _rollipop_rolldown_experimental = require("@rollipop/rolldown/experimental");
|
|
27
|
-
let es_toolkit = require("es-toolkit");
|
|
28
|
-
let chalk = require("chalk");
|
|
29
|
-
chalk = __toESM(chalk);
|
|
30
|
-
let dayjs = require("dayjs");
|
|
31
|
-
dayjs = __toESM(dayjs);
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/common/env.ts
|
|
34
|
-
const TRUTHY_VALUES = [
|
|
35
|
-
"yes",
|
|
36
|
-
"on",
|
|
37
|
-
"true",
|
|
38
|
-
"enabled"
|
|
39
|
-
];
|
|
40
|
-
const FALSY_VALUES = [
|
|
41
|
-
"no",
|
|
42
|
-
"off",
|
|
43
|
-
"false",
|
|
44
|
-
"disabled"
|
|
45
|
-
];
|
|
46
|
-
function parseDebugKeys() {
|
|
47
|
-
return Object.keys(process.env).filter((key) => /^debug_/i.test(key)).reduce((acc, key) => {
|
|
48
|
-
const prop = key.slice(6).toLowerCase().replace(/_([a-z])/g, (_, key) => key.toUpperCase());
|
|
49
|
-
let value = process.env[key];
|
|
50
|
-
const lowerCase = typeof value === "string" ? value.toLowerCase() : value.toString();
|
|
51
|
-
if (TRUTHY_VALUES.includes(lowerCase)) value = true;
|
|
52
|
-
else if (FALSY_VALUES.includes(lowerCase)) value = false;
|
|
53
|
-
else value = Boolean(Number(value));
|
|
54
|
-
acc[prop] = value;
|
|
55
|
-
return acc;
|
|
56
|
-
}, {});
|
|
57
|
-
}
|
|
58
|
-
let debugKeys = null;
|
|
59
|
-
function isDebugEnabled() {
|
|
60
|
-
if (debugKeys == null) debugKeys = parseDebugKeys();
|
|
61
|
-
return debugKeys["rollipop"] ?? false;
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/plugins/logger.ts
|
|
65
|
-
const logger = new class Logger {
|
|
66
|
-
static blocked = false;
|
|
67
|
-
static queuedMessages = [];
|
|
68
|
-
static Colors = {
|
|
69
|
-
trace: chalk.default.gray,
|
|
70
|
-
debug: chalk.default.blue,
|
|
71
|
-
log: chalk.default.green,
|
|
72
|
-
info: chalk.default.cyan,
|
|
73
|
-
warn: chalk.default.yellow,
|
|
74
|
-
error: chalk.default.red
|
|
75
|
-
};
|
|
76
|
-
format = "HH:mm:ss.SSS";
|
|
77
|
-
debugEnabled;
|
|
78
|
-
static block() {
|
|
79
|
-
this.blocked = true;
|
|
80
|
-
}
|
|
81
|
-
static unblock(flush = true) {
|
|
82
|
-
this.blocked = false;
|
|
83
|
-
if (flush) for (const args of Logger.queuedMessages) console.log(...args);
|
|
84
|
-
Logger.queuedMessages.length = 0;
|
|
85
|
-
}
|
|
86
|
-
constructor(scope) {
|
|
87
|
-
this.scope = scope;
|
|
88
|
-
this.debugEnabled = isDebugEnabled();
|
|
89
|
-
}
|
|
90
|
-
getFormat() {
|
|
91
|
-
return this.format;
|
|
92
|
-
}
|
|
93
|
-
setFormat(format) {
|
|
94
|
-
this.format = format;
|
|
95
|
-
}
|
|
96
|
-
getTimestamp() {
|
|
97
|
-
return (0, dayjs.default)().format(this.getFormat());
|
|
98
|
-
}
|
|
99
|
-
print(logLevel, ...args) {
|
|
100
|
-
const timestamp = chalk.default.gray(this.getTimestamp());
|
|
101
|
-
const level = Logger.Colors[logLevel](logLevel);
|
|
102
|
-
if (this.scope) args = [
|
|
103
|
-
timestamp,
|
|
104
|
-
level,
|
|
105
|
-
chalk.default.magenta(this.scope),
|
|
106
|
-
...args
|
|
107
|
-
];
|
|
108
|
-
else args = [
|
|
109
|
-
timestamp,
|
|
110
|
-
level,
|
|
111
|
-
...args
|
|
112
|
-
];
|
|
113
|
-
if (Logger.blocked) Logger.queuedMessages.push(args);
|
|
114
|
-
else console.log(...args);
|
|
115
|
-
}
|
|
116
|
-
trace(...args) {
|
|
117
|
-
this.debugEnabled && this.print("trace", ...args);
|
|
118
|
-
}
|
|
119
|
-
debug(...args) {
|
|
120
|
-
this.debugEnabled && this.print("debug", ...args);
|
|
121
|
-
}
|
|
122
|
-
log(...args) {
|
|
123
|
-
this.print("log", ...args);
|
|
124
|
-
}
|
|
125
|
-
info(...args) {
|
|
126
|
-
this.print("info", ...args);
|
|
127
|
-
}
|
|
128
|
-
warn(...args) {
|
|
129
|
-
this.print("warn", ...args);
|
|
130
|
-
}
|
|
131
|
-
error(...args) {
|
|
132
|
-
this.print("error", ...args);
|
|
133
|
-
}
|
|
134
|
-
child(scope) {
|
|
135
|
-
(0, es_toolkit.invariant)(this.scope, "Logger must have a scope to create a child logger");
|
|
136
|
-
return new Logger(`${this.scope}:${scope}`);
|
|
137
|
-
}
|
|
138
|
-
}("plugin:builtin");
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/plugins/worklets.ts
|
|
141
|
-
function worklets() {
|
|
142
|
-
const builtinPlugin = (0, _rollipop_rolldown_experimental.rollipopWorkletsPlugin)({
|
|
143
|
-
root: "/",
|
|
144
|
-
pluginVersion: "0.0.0",
|
|
145
|
-
isRelease: false
|
|
146
|
-
});
|
|
147
|
-
return [{
|
|
148
|
-
name: "rollipop:worklets:plugin-initializer",
|
|
149
|
-
configResolved(config) {
|
|
150
|
-
builtinPlugin._options = {
|
|
151
|
-
root: config.root,
|
|
152
|
-
isRelease: config.mode === "production",
|
|
153
|
-
pluginVersion: resolveReactNativeWorkletsVersion(config.root)
|
|
154
|
-
};
|
|
155
|
-
logger.debug("[worklets] builtin plugin", builtinPlugin);
|
|
156
|
-
}
|
|
157
|
-
}, builtinPlugin];
|
|
158
|
-
}
|
|
159
|
-
function resolveReactNativeWorkletsVersion(projectRoot) {
|
|
160
|
-
const packageJsonPath = require.resolve("react-native-worklets/package.json", { paths: [projectRoot] });
|
|
161
|
-
const { version } = JSON.parse(node_fs.readFileSync(packageJsonPath, "utf-8"));
|
|
162
|
-
(0, es_toolkit.invariant)(version, "could not find version in react-native-worklets package.json");
|
|
163
|
-
return version;
|
|
164
|
-
}
|
|
165
|
-
//#endregion
|
|
166
|
-
exports.worklets = worklets;
|