@powerlines/plugin-tamagui 0.1.106 → 0.1.108
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/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/index.cjs +231 -1
- package/dist/index.mjs +227 -1
- package/dist/powerlines/src/plugin-utils/get-config-path.cjs +49 -1
- package/dist/powerlines/src/plugin-utils/get-config-path.mjs +48 -1
- package/dist/powerlines/src/plugin-utils/paths.cjs +36 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +35 -1
- package/dist/powerlines/src/types/context.d.cts +43 -2
- package/dist/powerlines/src/types/context.d.mts +43 -2
- package/dist/powerlines/src/types/fs.d.cts +14 -0
- package/dist/powerlines/src/types/fs.d.mts +14 -0
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +7 -7
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
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) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,231 @@
|
|
|
1
|
-
Object.defineProperty(exports
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_get_config_path = require('./powerlines/src/plugin-utils/get-config-path.cjs');
|
|
4
|
+
const require_paths = require('./powerlines/src/plugin-utils/paths.cjs');
|
|
5
|
+
let __stryke_fs_resolve = require("@stryke/fs/resolve");
|
|
6
|
+
let __stryke_hash_neutral = require("@stryke/hash/neutral");
|
|
7
|
+
let __stryke_path_join = require("@stryke/path/join");
|
|
8
|
+
let __tamagui_static_worker = require("@tamagui/static-worker");
|
|
9
|
+
__tamagui_static_worker = require_rolldown_runtime.__toESM(__tamagui_static_worker);
|
|
10
|
+
let defu = require("defu");
|
|
11
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
12
|
+
let vite = require("vite");
|
|
13
|
+
|
|
14
|
+
//#region src/index.ts
|
|
15
|
+
/**
|
|
16
|
+
* Tamagui plugin for Powerlines.
|
|
17
|
+
*
|
|
18
|
+
* @param options - The Tamagui plugin user configuration options.
|
|
19
|
+
* @returns A Powerlines plugin that integrates Tamagui into an existing Powerlines project.
|
|
20
|
+
*/
|
|
21
|
+
const plugin = (options = {}) => {
|
|
22
|
+
let memoryCache = {};
|
|
23
|
+
let cacheSize = 0;
|
|
24
|
+
const clearCompilerCache = () => {
|
|
25
|
+
memoryCache = {};
|
|
26
|
+
cacheSize = 0;
|
|
27
|
+
};
|
|
28
|
+
const cssMap = /* @__PURE__ */ new Map();
|
|
29
|
+
let server = null;
|
|
30
|
+
return {
|
|
31
|
+
name: "tamagui",
|
|
32
|
+
async config() {
|
|
33
|
+
const configPath = require_get_config_path.getConfigPath(this, "tamagui");
|
|
34
|
+
const tamaguiOptions = await (0, __tamagui_static_worker.loadTamaguiBuildConfig)((0, defu.default)({
|
|
35
|
+
...options,
|
|
36
|
+
components: [(0, __stryke_path_join.joinPaths)("{projectRoot}", "src/components")]
|
|
37
|
+
}, {
|
|
38
|
+
config: configPath,
|
|
39
|
+
disableExtraction: false,
|
|
40
|
+
platform: "web",
|
|
41
|
+
logTimings: this.config.logLevel === "debug" || this.config.logLevel === "trace",
|
|
42
|
+
prefixLogs: "Powerlines"
|
|
43
|
+
}));
|
|
44
|
+
const alias = [];
|
|
45
|
+
if (tamaguiOptions.platform !== "native") {
|
|
46
|
+
alias.push({
|
|
47
|
+
find: "react-native/Libraries/Renderer/shims/ReactFabric",
|
|
48
|
+
replacement: await (0, __stryke_fs_resolve.resolvePackage)("@tamagui/proxy-worm") || "@tamagui/proxy-worm"
|
|
49
|
+
});
|
|
50
|
+
alias.push({
|
|
51
|
+
find: "react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry",
|
|
52
|
+
replacement: await (0, __stryke_fs_resolve.resolvePackage)("@tamagui/proxy-worm") || "@tamagui/proxy-worm"
|
|
53
|
+
});
|
|
54
|
+
alias.push({
|
|
55
|
+
find: "react-native-svg",
|
|
56
|
+
replacement: await (0, __stryke_fs_resolve.resolvePackage)("react-native-svg") || "react-native-svg"
|
|
57
|
+
});
|
|
58
|
+
if (tamaguiOptions?.useReactNativeWebLite) {
|
|
59
|
+
alias.push({
|
|
60
|
+
find: "react-native",
|
|
61
|
+
replacement: await (0, __stryke_fs_resolve.resolvePackage)("react-native-web-lite") || "react-native-web-lite"
|
|
62
|
+
});
|
|
63
|
+
const reactNativeWebLite = await (0, __stryke_fs_resolve.resolvePackage)(tamaguiOptions?.useReactNativeWebLite === "without-animated" ? "@tamagui/react-native-web-lite/without-animated" : "@tamagui/react-native-web-lite") || tamaguiOptions?.useReactNativeWebLite === "without-animated" ? "@tamagui/react-native-web-lite/without-animated" : "@tamagui/react-native-web-lite";
|
|
64
|
+
alias.push({
|
|
65
|
+
find: /^react-native$/,
|
|
66
|
+
replacement: reactNativeWebLite
|
|
67
|
+
});
|
|
68
|
+
alias.push({
|
|
69
|
+
find: /^react-native\/(.+)$/,
|
|
70
|
+
replacement: `${reactNativeWebLite}/$1`
|
|
71
|
+
});
|
|
72
|
+
alias.push({
|
|
73
|
+
find: /^react-native-web$/,
|
|
74
|
+
replacement: reactNativeWebLite
|
|
75
|
+
});
|
|
76
|
+
alias.push({
|
|
77
|
+
find: /^react-native-web\/(.+)$/,
|
|
78
|
+
replacement: `${reactNativeWebLite}/$1`
|
|
79
|
+
});
|
|
80
|
+
alias.push({
|
|
81
|
+
find: /react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,
|
|
82
|
+
replacement: await (0, __stryke_fs_resolve.resolvePackage)("@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle") || "@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
tamagui: tamaguiOptions,
|
|
88
|
+
build: {
|
|
89
|
+
platform: "browser",
|
|
90
|
+
extensions: [
|
|
91
|
+
`.web.mjs`,
|
|
92
|
+
`.web.js`,
|
|
93
|
+
`.web.jsx`,
|
|
94
|
+
`.web.ts`,
|
|
95
|
+
`.web.tsx`,
|
|
96
|
+
".mjs",
|
|
97
|
+
".js",
|
|
98
|
+
".mts",
|
|
99
|
+
".ts",
|
|
100
|
+
".jsx",
|
|
101
|
+
".tsx",
|
|
102
|
+
".json"
|
|
103
|
+
],
|
|
104
|
+
define: {
|
|
105
|
+
_frameTimestamp: void 0,
|
|
106
|
+
_WORKLET: false,
|
|
107
|
+
__DEV__: `${this.config.mode === "development"}`,
|
|
108
|
+
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || this.config.mode),
|
|
109
|
+
"process.env.ENABLE_RSC": JSON.stringify(process.env.ENABLE_RSC || ""),
|
|
110
|
+
"process.env.ENABLE_STEPS": JSON.stringify(process.env.ENABLE_STEPS || ""),
|
|
111
|
+
"process.env.IS_STATIC": JSON.stringify(false),
|
|
112
|
+
...this.config.mode === "production" && { "process.env.TAMAGUI_OPTIMIZE_THEMES": JSON.stringify(true) }
|
|
113
|
+
},
|
|
114
|
+
alias
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
configEnvironment(name, environment) {
|
|
119
|
+
if (environment.consumer === "client" || name === "client") return { build: { define: {
|
|
120
|
+
"process.env.TAMAGUI_IS_CLIENT": JSON.stringify(true),
|
|
121
|
+
"process.env.TAMAGUI_ENVIRONMENT": "\"client\""
|
|
122
|
+
} } };
|
|
123
|
+
return null;
|
|
124
|
+
},
|
|
125
|
+
configResolved() {
|
|
126
|
+
if (!this.config.tamagui.components || this.config.tamagui.components.length === 0) throw new Error(`Tamagui Plugin: No components paths defined in Tamagui configuration. Please ensure that the 'components' option is set correctly.`);
|
|
127
|
+
this.config.tamagui.components = this.config.tamagui.components.map((path) => require_paths.replacePathTokens(this, path)).filter(Boolean);
|
|
128
|
+
if (this.config.build.variant === "vite") {
|
|
129
|
+
this.config.build.optimizeDeps ??= {};
|
|
130
|
+
this.config.build.optimizeDeps.include ??= [];
|
|
131
|
+
this.config.build.optimizeDeps.include.push("@tamagui/core/inject-styles");
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
async resolveId(id) {
|
|
135
|
+
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
136
|
+
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
137
|
+
const [validId, query] = id.split("?");
|
|
138
|
+
if (!validId?.endsWith(".tamagui.css")) return;
|
|
139
|
+
let absoluteId = id;
|
|
140
|
+
if (!id.startsWith(this.config.projectRoot)) absoluteId = (0, __stryke_path_join.joinPaths)(this.config.projectRoot, validId);
|
|
141
|
+
if (cssMap.has(absoluteId)) return absoluteId + (query ? `?${query}` : "");
|
|
142
|
+
return null;
|
|
143
|
+
},
|
|
144
|
+
async load(id) {
|
|
145
|
+
if (this.config?.tamagui?.disableExtraction) return;
|
|
146
|
+
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
147
|
+
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
148
|
+
const [validId] = id.split("?");
|
|
149
|
+
return validId ? cssMap.get(validId) : null;
|
|
150
|
+
},
|
|
151
|
+
transform: {
|
|
152
|
+
order: "pre",
|
|
153
|
+
async handler(code, id) {
|
|
154
|
+
if (id.includes("expo-linear-gradient")) return (0, vite.transformWithEsbuild)(code, id, {
|
|
155
|
+
loader: "jsx",
|
|
156
|
+
jsx: "automatic"
|
|
157
|
+
});
|
|
158
|
+
if (this.config?.tamagui?.disableExtraction) return;
|
|
159
|
+
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
160
|
+
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
161
|
+
const [validId] = id.split("?");
|
|
162
|
+
if (!validId?.endsWith(".tsx")) return;
|
|
163
|
+
const firstCommentIndex = code.indexOf("// ");
|
|
164
|
+
const { shouldDisable, shouldPrintDebug } = await (0, __tamagui_static_worker.getPragmaOptions)({
|
|
165
|
+
source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : "",
|
|
166
|
+
path: validId
|
|
167
|
+
});
|
|
168
|
+
if (shouldPrintDebug) this.trace(`Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}\n\nOriginal source:\n${code}\n\n`);
|
|
169
|
+
if (shouldDisable) return;
|
|
170
|
+
const cacheKey = (0, __stryke_hash_neutral.murmurhash)({
|
|
171
|
+
cacheEnv: this.environment.name === "client" || this.environment.name === "ssr" ? "web" : this.environment.name,
|
|
172
|
+
code,
|
|
173
|
+
id
|
|
174
|
+
});
|
|
175
|
+
const cached = memoryCache[cacheKey];
|
|
176
|
+
if (cached) return cached;
|
|
177
|
+
let extracted;
|
|
178
|
+
try {
|
|
179
|
+
extracted = await __tamagui_static_worker.extractToClassNames({
|
|
180
|
+
source: code,
|
|
181
|
+
sourcePath: validId,
|
|
182
|
+
options: this.config.tamagui,
|
|
183
|
+
shouldPrintDebug
|
|
184
|
+
});
|
|
185
|
+
} catch (err) {
|
|
186
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!extracted) return;
|
|
190
|
+
const rootRelativeId = `${validId}.tamagui.css`;
|
|
191
|
+
let absoluteId = rootRelativeId;
|
|
192
|
+
if (!absoluteId.startsWith(this.config.projectRoot)) absoluteId = (0, __stryke_path_join.joinPaths)(this.config.projectRoot, rootRelativeId);
|
|
193
|
+
let source = extracted.js;
|
|
194
|
+
if (extracted.styles) {
|
|
195
|
+
this.addWatchFile(rootRelativeId);
|
|
196
|
+
if (server && cssMap.has(absoluteId)) {
|
|
197
|
+
if (server) {
|
|
198
|
+
const { moduleGraph } = server;
|
|
199
|
+
const modules = moduleGraph.getModulesByFile(rootRelativeId);
|
|
200
|
+
if (modules) for (const module$1 of modules) {
|
|
201
|
+
moduleGraph.invalidateModule(module$1);
|
|
202
|
+
module$1.lastHMRTimestamp = module$1.lastInvalidationTimestamp || Date.now();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
source = `${source.toString()}\nimport "${rootRelativeId}";`;
|
|
207
|
+
cssMap.set(absoluteId, extracted.styles);
|
|
208
|
+
}
|
|
209
|
+
const result = {
|
|
210
|
+
code: source.toString(),
|
|
211
|
+
map: extracted.map
|
|
212
|
+
};
|
|
213
|
+
cacheSize += result.code.length;
|
|
214
|
+
if (cacheSize > 26214400) clearCompilerCache();
|
|
215
|
+
memoryCache[cacheKey] = result;
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
async finalize() {
|
|
220
|
+
await __tamagui_static_worker?.destroyPool();
|
|
221
|
+
},
|
|
222
|
+
vite: { configureServer(_server) {
|
|
223
|
+
server = _server;
|
|
224
|
+
} }
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
var src_default = plugin;
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
exports.default = src_default;
|
|
231
|
+
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,227 @@
|
|
|
1
|
-
import{getConfigPath
|
|
1
|
+
import { getConfigPath } from "./powerlines/src/plugin-utils/get-config-path.mjs";
|
|
2
|
+
import { replacePathTokens } from "./powerlines/src/plugin-utils/paths.mjs";
|
|
3
|
+
import { resolvePackage } from "@stryke/fs/resolve";
|
|
4
|
+
import { murmurhash } from "@stryke/hash/neutral";
|
|
5
|
+
import { joinPaths } from "@stryke/path/join";
|
|
6
|
+
import * as Static from "@tamagui/static-worker";
|
|
7
|
+
import { getPragmaOptions, loadTamaguiBuildConfig } from "@tamagui/static-worker";
|
|
8
|
+
import defu from "defu";
|
|
9
|
+
import { transformWithEsbuild } from "vite";
|
|
10
|
+
|
|
11
|
+
//#region src/index.ts
|
|
12
|
+
/**
|
|
13
|
+
* Tamagui plugin for Powerlines.
|
|
14
|
+
*
|
|
15
|
+
* @param options - The Tamagui plugin user configuration options.
|
|
16
|
+
* @returns A Powerlines plugin that integrates Tamagui into an existing Powerlines project.
|
|
17
|
+
*/
|
|
18
|
+
const plugin = (options = {}) => {
|
|
19
|
+
let memoryCache = {};
|
|
20
|
+
let cacheSize = 0;
|
|
21
|
+
const clearCompilerCache = () => {
|
|
22
|
+
memoryCache = {};
|
|
23
|
+
cacheSize = 0;
|
|
24
|
+
};
|
|
25
|
+
const cssMap = /* @__PURE__ */ new Map();
|
|
26
|
+
let server = null;
|
|
27
|
+
return {
|
|
28
|
+
name: "tamagui",
|
|
29
|
+
async config() {
|
|
30
|
+
const configPath = getConfigPath(this, "tamagui");
|
|
31
|
+
const tamaguiOptions = await loadTamaguiBuildConfig(defu({
|
|
32
|
+
...options,
|
|
33
|
+
components: [joinPaths("{projectRoot}", "src/components")]
|
|
34
|
+
}, {
|
|
35
|
+
config: configPath,
|
|
36
|
+
disableExtraction: false,
|
|
37
|
+
platform: "web",
|
|
38
|
+
logTimings: this.config.logLevel === "debug" || this.config.logLevel === "trace",
|
|
39
|
+
prefixLogs: "Powerlines"
|
|
40
|
+
}));
|
|
41
|
+
const alias = [];
|
|
42
|
+
if (tamaguiOptions.platform !== "native") {
|
|
43
|
+
alias.push({
|
|
44
|
+
find: "react-native/Libraries/Renderer/shims/ReactFabric",
|
|
45
|
+
replacement: await resolvePackage("@tamagui/proxy-worm") || "@tamagui/proxy-worm"
|
|
46
|
+
});
|
|
47
|
+
alias.push({
|
|
48
|
+
find: "react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry",
|
|
49
|
+
replacement: await resolvePackage("@tamagui/proxy-worm") || "@tamagui/proxy-worm"
|
|
50
|
+
});
|
|
51
|
+
alias.push({
|
|
52
|
+
find: "react-native-svg",
|
|
53
|
+
replacement: await resolvePackage("react-native-svg") || "react-native-svg"
|
|
54
|
+
});
|
|
55
|
+
if (tamaguiOptions?.useReactNativeWebLite) {
|
|
56
|
+
alias.push({
|
|
57
|
+
find: "react-native",
|
|
58
|
+
replacement: await resolvePackage("react-native-web-lite") || "react-native-web-lite"
|
|
59
|
+
});
|
|
60
|
+
const reactNativeWebLite = await resolvePackage(tamaguiOptions?.useReactNativeWebLite === "without-animated" ? "@tamagui/react-native-web-lite/without-animated" : "@tamagui/react-native-web-lite") || tamaguiOptions?.useReactNativeWebLite === "without-animated" ? "@tamagui/react-native-web-lite/without-animated" : "@tamagui/react-native-web-lite";
|
|
61
|
+
alias.push({
|
|
62
|
+
find: /^react-native$/,
|
|
63
|
+
replacement: reactNativeWebLite
|
|
64
|
+
});
|
|
65
|
+
alias.push({
|
|
66
|
+
find: /^react-native\/(.+)$/,
|
|
67
|
+
replacement: `${reactNativeWebLite}/$1`
|
|
68
|
+
});
|
|
69
|
+
alias.push({
|
|
70
|
+
find: /^react-native-web$/,
|
|
71
|
+
replacement: reactNativeWebLite
|
|
72
|
+
});
|
|
73
|
+
alias.push({
|
|
74
|
+
find: /^react-native-web\/(.+)$/,
|
|
75
|
+
replacement: `${reactNativeWebLite}/$1`
|
|
76
|
+
});
|
|
77
|
+
alias.push({
|
|
78
|
+
find: /react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,
|
|
79
|
+
replacement: await resolvePackage("@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle") || "@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle"
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
tamagui: tamaguiOptions,
|
|
85
|
+
build: {
|
|
86
|
+
platform: "browser",
|
|
87
|
+
extensions: [
|
|
88
|
+
`.web.mjs`,
|
|
89
|
+
`.web.js`,
|
|
90
|
+
`.web.jsx`,
|
|
91
|
+
`.web.ts`,
|
|
92
|
+
`.web.tsx`,
|
|
93
|
+
".mjs",
|
|
94
|
+
".js",
|
|
95
|
+
".mts",
|
|
96
|
+
".ts",
|
|
97
|
+
".jsx",
|
|
98
|
+
".tsx",
|
|
99
|
+
".json"
|
|
100
|
+
],
|
|
101
|
+
define: {
|
|
102
|
+
_frameTimestamp: void 0,
|
|
103
|
+
_WORKLET: false,
|
|
104
|
+
__DEV__: `${this.config.mode === "development"}`,
|
|
105
|
+
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || this.config.mode),
|
|
106
|
+
"process.env.ENABLE_RSC": JSON.stringify(process.env.ENABLE_RSC || ""),
|
|
107
|
+
"process.env.ENABLE_STEPS": JSON.stringify(process.env.ENABLE_STEPS || ""),
|
|
108
|
+
"process.env.IS_STATIC": JSON.stringify(false),
|
|
109
|
+
...this.config.mode === "production" && { "process.env.TAMAGUI_OPTIMIZE_THEMES": JSON.stringify(true) }
|
|
110
|
+
},
|
|
111
|
+
alias
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
configEnvironment(name, environment) {
|
|
116
|
+
if (environment.consumer === "client" || name === "client") return { build: { define: {
|
|
117
|
+
"process.env.TAMAGUI_IS_CLIENT": JSON.stringify(true),
|
|
118
|
+
"process.env.TAMAGUI_ENVIRONMENT": "\"client\""
|
|
119
|
+
} } };
|
|
120
|
+
return null;
|
|
121
|
+
},
|
|
122
|
+
configResolved() {
|
|
123
|
+
if (!this.config.tamagui.components || this.config.tamagui.components.length === 0) throw new Error(`Tamagui Plugin: No components paths defined in Tamagui configuration. Please ensure that the 'components' option is set correctly.`);
|
|
124
|
+
this.config.tamagui.components = this.config.tamagui.components.map((path) => replacePathTokens(this, path)).filter(Boolean);
|
|
125
|
+
if (this.config.build.variant === "vite") {
|
|
126
|
+
this.config.build.optimizeDeps ??= {};
|
|
127
|
+
this.config.build.optimizeDeps.include ??= [];
|
|
128
|
+
this.config.build.optimizeDeps.include.push("@tamagui/core/inject-styles");
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
async resolveId(id) {
|
|
132
|
+
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
133
|
+
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
134
|
+
const [validId, query] = id.split("?");
|
|
135
|
+
if (!validId?.endsWith(".tamagui.css")) return;
|
|
136
|
+
let absoluteId = id;
|
|
137
|
+
if (!id.startsWith(this.config.projectRoot)) absoluteId = joinPaths(this.config.projectRoot, validId);
|
|
138
|
+
if (cssMap.has(absoluteId)) return absoluteId + (query ? `?${query}` : "");
|
|
139
|
+
return null;
|
|
140
|
+
},
|
|
141
|
+
async load(id) {
|
|
142
|
+
if (this.config?.tamagui?.disableExtraction) return;
|
|
143
|
+
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
144
|
+
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
145
|
+
const [validId] = id.split("?");
|
|
146
|
+
return validId ? cssMap.get(validId) : null;
|
|
147
|
+
},
|
|
148
|
+
transform: {
|
|
149
|
+
order: "pre",
|
|
150
|
+
async handler(code, id) {
|
|
151
|
+
if (id.includes("expo-linear-gradient")) return transformWithEsbuild(code, id, {
|
|
152
|
+
loader: "jsx",
|
|
153
|
+
jsx: "automatic"
|
|
154
|
+
});
|
|
155
|
+
if (this.config?.tamagui?.disableExtraction) return;
|
|
156
|
+
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
157
|
+
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
158
|
+
const [validId] = id.split("?");
|
|
159
|
+
if (!validId?.endsWith(".tsx")) return;
|
|
160
|
+
const firstCommentIndex = code.indexOf("// ");
|
|
161
|
+
const { shouldDisable, shouldPrintDebug } = await getPragmaOptions({
|
|
162
|
+
source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : "",
|
|
163
|
+
path: validId
|
|
164
|
+
});
|
|
165
|
+
if (shouldPrintDebug) this.trace(`Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}\n\nOriginal source:\n${code}\n\n`);
|
|
166
|
+
if (shouldDisable) return;
|
|
167
|
+
const cacheKey = murmurhash({
|
|
168
|
+
cacheEnv: this.environment.name === "client" || this.environment.name === "ssr" ? "web" : this.environment.name,
|
|
169
|
+
code,
|
|
170
|
+
id
|
|
171
|
+
});
|
|
172
|
+
const cached = memoryCache[cacheKey];
|
|
173
|
+
if (cached) return cached;
|
|
174
|
+
let extracted;
|
|
175
|
+
try {
|
|
176
|
+
extracted = await Static.extractToClassNames({
|
|
177
|
+
source: code,
|
|
178
|
+
sourcePath: validId,
|
|
179
|
+
options: this.config.tamagui,
|
|
180
|
+
shouldPrintDebug
|
|
181
|
+
});
|
|
182
|
+
} catch (err) {
|
|
183
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (!extracted) return;
|
|
187
|
+
const rootRelativeId = `${validId}.tamagui.css`;
|
|
188
|
+
let absoluteId = rootRelativeId;
|
|
189
|
+
if (!absoluteId.startsWith(this.config.projectRoot)) absoluteId = joinPaths(this.config.projectRoot, rootRelativeId);
|
|
190
|
+
let source = extracted.js;
|
|
191
|
+
if (extracted.styles) {
|
|
192
|
+
this.addWatchFile(rootRelativeId);
|
|
193
|
+
if (server && cssMap.has(absoluteId)) {
|
|
194
|
+
if (server) {
|
|
195
|
+
const { moduleGraph } = server;
|
|
196
|
+
const modules = moduleGraph.getModulesByFile(rootRelativeId);
|
|
197
|
+
if (modules) for (const module of modules) {
|
|
198
|
+
moduleGraph.invalidateModule(module);
|
|
199
|
+
module.lastHMRTimestamp = module.lastInvalidationTimestamp || Date.now();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
source = `${source.toString()}\nimport "${rootRelativeId}";`;
|
|
204
|
+
cssMap.set(absoluteId, extracted.styles);
|
|
205
|
+
}
|
|
206
|
+
const result = {
|
|
207
|
+
code: source.toString(),
|
|
208
|
+
map: extracted.map
|
|
209
|
+
};
|
|
210
|
+
cacheSize += result.code.length;
|
|
211
|
+
if (cacheSize > 26214400) clearCompilerCache();
|
|
212
|
+
memoryCache[cacheKey] = result;
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
async finalize() {
|
|
217
|
+
await Static?.destroyPool();
|
|
218
|
+
},
|
|
219
|
+
vite: { configureServer(_server) {
|
|
220
|
+
server = _server;
|
|
221
|
+
} }
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
var src_default = plugin;
|
|
225
|
+
|
|
226
|
+
//#endregion
|
|
227
|
+
export { src_default as default, plugin };
|
|
@@ -1 +1,49 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_path_join = require("@stryke/path/join");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
|
|
5
|
+
//#region ../powerlines/src/plugin-utils/get-config-path.ts
|
|
6
|
+
/**
|
|
7
|
+
* Get the configuration file path for a given name.
|
|
8
|
+
*
|
|
9
|
+
* @param context - The Powerlines context.
|
|
10
|
+
* @param name - The name of the configuration file (without extension).
|
|
11
|
+
* @returns The absolute path to the configuration file, or undefined if not found.
|
|
12
|
+
*/
|
|
13
|
+
function getConfigPath(context, name) {
|
|
14
|
+
if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`);
|
|
15
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`);
|
|
16
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`);
|
|
17
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`);
|
|
18
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`);
|
|
19
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`);
|
|
20
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`);
|
|
21
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`);
|
|
22
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`);
|
|
23
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`);
|
|
24
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`);
|
|
25
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`);
|
|
26
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`);
|
|
27
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`);
|
|
28
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`);
|
|
29
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`);
|
|
30
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.yml`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.yml`);
|
|
31
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.yaml`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.yaml`);
|
|
32
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.json`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.json`);
|
|
33
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.jsonc`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.jsonc`);
|
|
34
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.ts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.ts`);
|
|
35
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.cts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.cts`);
|
|
36
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.mts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.mts`);
|
|
37
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.js`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.js`);
|
|
38
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.cjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.cjs`);
|
|
39
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.mjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.mjs`);
|
|
40
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.ts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.ts`);
|
|
41
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.cts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.cts`);
|
|
42
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.mts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.mts`);
|
|
43
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.js`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.js`);
|
|
44
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`);
|
|
45
|
+
else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.getConfigPath = getConfigPath;
|
|
@@ -1 +1,48 @@
|
|
|
1
|
-
import{joinPaths
|
|
1
|
+
import { joinPaths } from "@stryke/path/join";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
//#region ../powerlines/src/plugin-utils/get-config-path.ts
|
|
5
|
+
/**
|
|
6
|
+
* Get the configuration file path for a given name.
|
|
7
|
+
*
|
|
8
|
+
* @param context - The Powerlines context.
|
|
9
|
+
* @param name - The name of the configuration file (without extension).
|
|
10
|
+
* @returns The absolute path to the configuration file, or undefined if not found.
|
|
11
|
+
*/
|
|
12
|
+
function getConfigPath(context, name) {
|
|
13
|
+
if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`);
|
|
14
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`);
|
|
15
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`);
|
|
16
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`);
|
|
17
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`);
|
|
18
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`);
|
|
19
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`);
|
|
20
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`);
|
|
21
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`);
|
|
22
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`);
|
|
23
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`);
|
|
24
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`);
|
|
25
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`);
|
|
26
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`);
|
|
27
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`);
|
|
28
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`);
|
|
29
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.yml`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.yml`);
|
|
30
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.yaml`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.yaml`);
|
|
31
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.json`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.json`);
|
|
32
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.jsonc`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.jsonc`);
|
|
33
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.ts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.ts`);
|
|
34
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.cts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.cts`);
|
|
35
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.mts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.mts`);
|
|
36
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.js`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.js`);
|
|
37
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.cjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.cjs`);
|
|
38
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.mjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.mjs`);
|
|
39
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.ts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.ts`);
|
|
40
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.cts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.cts`);
|
|
41
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.mts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.mts`);
|
|
42
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.js`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.js`);
|
|
43
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`);
|
|
44
|
+
else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { getConfigPath };
|
|
@@ -1 +1,36 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
3
|
+
|
|
4
|
+
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
5
|
+
/**
|
|
6
|
+
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* The following tokens are supported:
|
|
10
|
+
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
11
|
+
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
12
|
+
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
13
|
+
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
14
|
+
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
15
|
+
* - `{cachePath}` - The environment's directory for cached files.
|
|
16
|
+
* - `{dataPath}` - The environment's directory for data files.
|
|
17
|
+
* - `{logPath}` - The environment's directory for log files.
|
|
18
|
+
* - `{tempPath}` - The environment's directory for temporary files.
|
|
19
|
+
* - `{configPath}` - The environment's directory for configuration files.
|
|
20
|
+
* - `{outputPath}` - The configured output directory for the project.
|
|
21
|
+
* - `{buildPath}` - The configured distribution directory for the project.
|
|
22
|
+
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
23
|
+
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
24
|
+
* - `{entryPath}` - The configured directory for generated entry files.
|
|
25
|
+
*
|
|
26
|
+
* @param context - The context containing the values for the path tokens.
|
|
27
|
+
* @param path - The path string with tokens to replace.
|
|
28
|
+
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
29
|
+
*/
|
|
30
|
+
function replacePathTokens(context, path) {
|
|
31
|
+
if (!path) return path;
|
|
32
|
+
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", (0, __stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, __stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.replacePathTokens = replacePathTokens;
|
|
@@ -1 +1,35 @@
|
|
|
1
|
-
import{replacePath
|
|
1
|
+
import { replacePath } from "@stryke/path/replace";
|
|
2
|
+
|
|
3
|
+
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
4
|
+
/**
|
|
5
|
+
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The following tokens are supported:
|
|
9
|
+
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
10
|
+
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
11
|
+
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
12
|
+
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
13
|
+
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
14
|
+
* - `{cachePath}` - The environment's directory for cached files.
|
|
15
|
+
* - `{dataPath}` - The environment's directory for data files.
|
|
16
|
+
* - `{logPath}` - The environment's directory for log files.
|
|
17
|
+
* - `{tempPath}` - The environment's directory for temporary files.
|
|
18
|
+
* - `{configPath}` - The environment's directory for configuration files.
|
|
19
|
+
* - `{outputPath}` - The configured output directory for the project.
|
|
20
|
+
* - `{buildPath}` - The configured distribution directory for the project.
|
|
21
|
+
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
22
|
+
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
23
|
+
* - `{entryPath}` - The configured directory for generated entry files.
|
|
24
|
+
*
|
|
25
|
+
* @param context - The context containing the values for the path tokens.
|
|
26
|
+
* @param path - The path string with tokens to replace.
|
|
27
|
+
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
28
|
+
*/
|
|
29
|
+
function replacePathTokens(context, path) {
|
|
30
|
+
if (!path) return path;
|
|
31
|
+
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { replacePathTokens };
|
|
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
|
|
|
78
78
|
*/
|
|
79
79
|
allowReturnOutsideFunction?: boolean;
|
|
80
80
|
}
|
|
81
|
+
interface EmitOptions extends WriteOptions {
|
|
82
|
+
/**
|
|
83
|
+
* If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
|
|
84
|
+
*/
|
|
85
|
+
emitWithBundler?: boolean;
|
|
86
|
+
needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
|
|
87
|
+
originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
|
|
88
|
+
}
|
|
81
89
|
/**
|
|
82
90
|
* Options for emitting entry virtual files
|
|
83
91
|
*/
|
|
84
|
-
type EmitEntryOptions =
|
|
92
|
+
type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
|
|
85
93
|
/**
|
|
86
94
|
* The unresolved Powerlines context.
|
|
87
95
|
*
|
|
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
292
300
|
* The Powerlines builtin virtual files
|
|
293
301
|
*/
|
|
294
302
|
getBuiltins: () => Promise<VirtualFile[]>;
|
|
303
|
+
/**
|
|
304
|
+
* Resolves a file and writes it to the VFS if it does not already exist
|
|
305
|
+
*
|
|
306
|
+
* @param code - The source code of the file
|
|
307
|
+
* @param path - The path to write the file to
|
|
308
|
+
* @param options - Additional options for writing the file
|
|
309
|
+
*/
|
|
310
|
+
emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Synchronously resolves a file and writes it to the VFS if it does not already exist
|
|
313
|
+
*
|
|
314
|
+
* @param code - The source code of the file
|
|
315
|
+
* @param path - The path to write the file to
|
|
316
|
+
* @param options - Additional options for writing the file
|
|
317
|
+
*/
|
|
318
|
+
emitSync: (code: string, path: string, options?: EmitOptions) => void;
|
|
295
319
|
/**
|
|
296
320
|
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
297
321
|
*
|
|
@@ -300,7 +324,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
300
324
|
* @param path - An optional path to write the builtin file to
|
|
301
325
|
* @param options - Additional options for writing the builtin file
|
|
302
326
|
*/
|
|
303
|
-
emitBuiltin: (code: string, id: string, path?: string, options?:
|
|
327
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
330
|
+
*
|
|
331
|
+
* @param code - The source code of the builtin file
|
|
332
|
+
* @param id - The unique identifier of the builtin file
|
|
333
|
+
* @param path - An optional path to write the builtin file to
|
|
334
|
+
* @param options - Additional options for writing the builtin file
|
|
335
|
+
*/
|
|
336
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
304
337
|
/**
|
|
305
338
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
306
339
|
*
|
|
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
309
342
|
* @param options - Additional options for writing the entry file
|
|
310
343
|
*/
|
|
311
344
|
emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
|
|
345
|
+
/**
|
|
346
|
+
* Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
347
|
+
*
|
|
348
|
+
* @param code - The source code of the entry file
|
|
349
|
+
* @param path - An optional path to write the entry file to
|
|
350
|
+
* @param options - Additional options for writing the entry file
|
|
351
|
+
*/
|
|
352
|
+
emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
|
|
312
353
|
/**
|
|
313
354
|
* A function to update the context fields using a new user configuration options
|
|
314
355
|
*/
|
|
@@ -80,10 +80,18 @@ interface ParseOptions extends ParserOptions {
|
|
|
80
80
|
*/
|
|
81
81
|
allowReturnOutsideFunction?: boolean;
|
|
82
82
|
}
|
|
83
|
+
interface EmitOptions extends WriteOptions {
|
|
84
|
+
/**
|
|
85
|
+
* If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
|
|
86
|
+
*/
|
|
87
|
+
emitWithBundler?: boolean;
|
|
88
|
+
needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
|
|
89
|
+
originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
|
|
90
|
+
}
|
|
83
91
|
/**
|
|
84
92
|
* Options for emitting entry virtual files
|
|
85
93
|
*/
|
|
86
|
-
type EmitEntryOptions =
|
|
94
|
+
type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
|
|
87
95
|
/**
|
|
88
96
|
* The unresolved Powerlines context.
|
|
89
97
|
*
|
|
@@ -294,6 +302,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
294
302
|
* The Powerlines builtin virtual files
|
|
295
303
|
*/
|
|
296
304
|
getBuiltins: () => Promise<VirtualFile[]>;
|
|
305
|
+
/**
|
|
306
|
+
* Resolves a file and writes it to the VFS if it does not already exist
|
|
307
|
+
*
|
|
308
|
+
* @param code - The source code of the file
|
|
309
|
+
* @param path - The path to write the file to
|
|
310
|
+
* @param options - Additional options for writing the file
|
|
311
|
+
*/
|
|
312
|
+
emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
|
|
313
|
+
/**
|
|
314
|
+
* Synchronously resolves a file and writes it to the VFS if it does not already exist
|
|
315
|
+
*
|
|
316
|
+
* @param code - The source code of the file
|
|
317
|
+
* @param path - The path to write the file to
|
|
318
|
+
* @param options - Additional options for writing the file
|
|
319
|
+
*/
|
|
320
|
+
emitSync: (code: string, path: string, options?: EmitOptions) => void;
|
|
297
321
|
/**
|
|
298
322
|
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
299
323
|
*
|
|
@@ -302,7 +326,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
302
326
|
* @param path - An optional path to write the builtin file to
|
|
303
327
|
* @param options - Additional options for writing the builtin file
|
|
304
328
|
*/
|
|
305
|
-
emitBuiltin: (code: string, id: string, path?: string, options?:
|
|
329
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
332
|
+
*
|
|
333
|
+
* @param code - The source code of the builtin file
|
|
334
|
+
* @param id - The unique identifier of the builtin file
|
|
335
|
+
* @param path - An optional path to write the builtin file to
|
|
336
|
+
* @param options - Additional options for writing the builtin file
|
|
337
|
+
*/
|
|
338
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
306
339
|
/**
|
|
307
340
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
308
341
|
*
|
|
@@ -311,6 +344,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
311
344
|
* @param options - Additional options for writing the entry file
|
|
312
345
|
*/
|
|
313
346
|
emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
|
|
347
|
+
/**
|
|
348
|
+
* Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
349
|
+
*
|
|
350
|
+
* @param code - The source code of the entry file
|
|
351
|
+
* @param path - An optional path to write the entry file to
|
|
352
|
+
* @param options - Additional options for writing the entry file
|
|
353
|
+
*/
|
|
354
|
+
emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
|
|
314
355
|
/**
|
|
315
356
|
* A function to update the context fields using a new user configuration options
|
|
316
357
|
*/
|
|
@@ -13,6 +13,13 @@ interface StorageAdapter {
|
|
|
13
13
|
* A name identifying the storage adapter type.
|
|
14
14
|
*/
|
|
15
15
|
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The storage preset for the adapter.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This can be used as an alternate way to identify the type of storage being used.
|
|
21
|
+
*/
|
|
22
|
+
preset?: StoragePreset | null;
|
|
16
23
|
/**
|
|
17
24
|
* Checks if a key exists in the storage.
|
|
18
25
|
*
|
|
@@ -207,6 +214,13 @@ interface WriteOptions {
|
|
|
207
214
|
* @defaultValue false
|
|
208
215
|
*/
|
|
209
216
|
skipFormat?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* The storage preset or adapter name for the output file.
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* If not specified, the output mode will be determined by the provided `output.mode` value.
|
|
222
|
+
*/
|
|
223
|
+
storage?: StoragePreset | string;
|
|
210
224
|
/**
|
|
211
225
|
* Additional metadata for the file.
|
|
212
226
|
*/
|
|
@@ -13,6 +13,13 @@ interface StorageAdapter {
|
|
|
13
13
|
* A name identifying the storage adapter type.
|
|
14
14
|
*/
|
|
15
15
|
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The storage preset for the adapter.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This can be used as an alternate way to identify the type of storage being used.
|
|
21
|
+
*/
|
|
22
|
+
preset?: StoragePreset | null;
|
|
16
23
|
/**
|
|
17
24
|
* Checks if a key exists in the storage.
|
|
18
25
|
*
|
|
@@ -207,6 +214,13 @@ interface WriteOptions {
|
|
|
207
214
|
* @defaultValue false
|
|
208
215
|
*/
|
|
209
216
|
skipFormat?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* The storage preset or adapter name for the output file.
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* If not specified, the output mode will be determined by the provided `output.mode` value.
|
|
222
|
+
*/
|
|
223
|
+
storage?: StoragePreset | string;
|
|
210
224
|
/**
|
|
211
225
|
* Additional metadata for the file.
|
|
212
226
|
*/
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-tamagui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.108",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing the Tamagui plugin for Powerlines.",
|
|
6
6
|
"repository": {
|
|
@@ -117,20 +117,20 @@
|
|
|
117
117
|
"files": ["dist/**/*"],
|
|
118
118
|
"keywords": ["tamagui", "powerlines", "storm-software", "powerlines-plugin"],
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@stryke/path": "^0.24.
|
|
121
|
-
"@stryke/fs": "^0.33.
|
|
122
|
-
"@stryke/hash": "^0.12.
|
|
120
|
+
"@stryke/path": "^0.24.1",
|
|
121
|
+
"@stryke/fs": "^0.33.27",
|
|
122
|
+
"@stryke/hash": "^0.12.33",
|
|
123
123
|
"@tamagui/static-worker": "^1.142.0",
|
|
124
124
|
"defu": "^6.1.4",
|
|
125
|
-
"powerlines": "^0.36.
|
|
125
|
+
"powerlines": "^0.36.23",
|
|
126
126
|
"typescript": "^5.9.3",
|
|
127
127
|
"vite": "8.0.0-beta.2"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
|
-
"@powerlines/nx": "^0.11.
|
|
130
|
+
"@powerlines/nx": "^0.11.49",
|
|
131
131
|
"@tamagui/types": "^1.142.0",
|
|
132
132
|
"@types/node": "^24.10.4"
|
|
133
133
|
},
|
|
134
134
|
"publishConfig": { "access": "public" },
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
|
|
136
136
|
}
|