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/dist/plugins.js DELETED
@@ -1,143 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import * as fs from "node:fs";
3
- import { rollipopWorkletsPlugin } from "@rollipop/rolldown/experimental";
4
- import { invariant } from "es-toolkit";
5
- import chalk from "chalk";
6
- import dayjs from "dayjs";
7
- //#region \0rolldown/runtime.js
8
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
9
- //#endregion
10
- //#region src/common/env.ts
11
- const TRUTHY_VALUES = [
12
- "yes",
13
- "on",
14
- "true",
15
- "enabled"
16
- ];
17
- const FALSY_VALUES = [
18
- "no",
19
- "off",
20
- "false",
21
- "disabled"
22
- ];
23
- function parseDebugKeys() {
24
- return Object.keys(process.env).filter((key) => /^debug_/i.test(key)).reduce((acc, key) => {
25
- const prop = key.slice(6).toLowerCase().replace(/_([a-z])/g, (_, key) => key.toUpperCase());
26
- let value = process.env[key];
27
- const lowerCase = typeof value === "string" ? value.toLowerCase() : value.toString();
28
- if (TRUTHY_VALUES.includes(lowerCase)) value = true;
29
- else if (FALSY_VALUES.includes(lowerCase)) value = false;
30
- else value = Boolean(Number(value));
31
- acc[prop] = value;
32
- return acc;
33
- }, {});
34
- }
35
- let debugKeys = null;
36
- function isDebugEnabled() {
37
- if (debugKeys == null) debugKeys = parseDebugKeys();
38
- return debugKeys["rollipop"] ?? false;
39
- }
40
- //#endregion
41
- //#region src/plugins/logger.ts
42
- const logger = new class Logger {
43
- static blocked = false;
44
- static queuedMessages = [];
45
- static Colors = {
46
- trace: chalk.gray,
47
- debug: chalk.blue,
48
- log: chalk.green,
49
- info: chalk.cyan,
50
- warn: chalk.yellow,
51
- error: chalk.red
52
- };
53
- format = "HH:mm:ss.SSS";
54
- debugEnabled;
55
- static block() {
56
- this.blocked = true;
57
- }
58
- static unblock(flush = true) {
59
- this.blocked = false;
60
- if (flush) for (const args of Logger.queuedMessages) console.log(...args);
61
- Logger.queuedMessages.length = 0;
62
- }
63
- constructor(scope) {
64
- this.scope = scope;
65
- this.debugEnabled = isDebugEnabled();
66
- }
67
- getFormat() {
68
- return this.format;
69
- }
70
- setFormat(format) {
71
- this.format = format;
72
- }
73
- getTimestamp() {
74
- return dayjs().format(this.getFormat());
75
- }
76
- print(logLevel, ...args) {
77
- const timestamp = chalk.gray(this.getTimestamp());
78
- const level = Logger.Colors[logLevel](logLevel);
79
- if (this.scope) args = [
80
- timestamp,
81
- level,
82
- chalk.magenta(this.scope),
83
- ...args
84
- ];
85
- else args = [
86
- timestamp,
87
- level,
88
- ...args
89
- ];
90
- if (Logger.blocked) Logger.queuedMessages.push(args);
91
- else console.log(...args);
92
- }
93
- trace(...args) {
94
- this.debugEnabled && this.print("trace", ...args);
95
- }
96
- debug(...args) {
97
- this.debugEnabled && this.print("debug", ...args);
98
- }
99
- log(...args) {
100
- this.print("log", ...args);
101
- }
102
- info(...args) {
103
- this.print("info", ...args);
104
- }
105
- warn(...args) {
106
- this.print("warn", ...args);
107
- }
108
- error(...args) {
109
- this.print("error", ...args);
110
- }
111
- child(scope) {
112
- invariant(this.scope, "Logger must have a scope to create a child logger");
113
- return new Logger(`${this.scope}:${scope}`);
114
- }
115
- }("plugin:builtin");
116
- //#endregion
117
- //#region src/plugins/worklets.ts
118
- function worklets() {
119
- const builtinPlugin = rollipopWorkletsPlugin({
120
- root: "/",
121
- pluginVersion: "0.0.0",
122
- isRelease: false
123
- });
124
- return [{
125
- name: "rollipop:worklets:plugin-initializer",
126
- configResolved(config) {
127
- builtinPlugin._options = {
128
- root: config.root,
129
- isRelease: config.mode === "production",
130
- pluginVersion: resolveReactNativeWorkletsVersion(config.root)
131
- };
132
- logger.debug("[worklets] builtin plugin", builtinPlugin);
133
- }
134
- }, builtinPlugin];
135
- }
136
- function resolveReactNativeWorkletsVersion(projectRoot) {
137
- const packageJsonPath = __require.resolve("react-native-worklets/package.json", { paths: [projectRoot] });
138
- const { version } = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
139
- invariant(version, "could not find version in react-native-worklets package.json");
140
- return version;
141
- }
142
- //#endregion
143
- export { worklets };