@powerlines/plugin-tamagui 0.1.352 → 0.1.353
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/package.json +5 -5
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/_virtual/_rolldown/runtime.mjs +0 -3
- package/dist/index.cjs +0 -229
- package/dist/index.mjs +0 -225
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.mjs +0 -1
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.mjs +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-tamagui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.353",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing the Tamagui plugin for Powerlines.",
|
|
6
6
|
"keywords": ["tamagui", "powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -90,21 +90,21 @@
|
|
|
90
90
|
"typings": "dist/index.d.mts",
|
|
91
91
|
"files": ["dist/**/*"],
|
|
92
92
|
"dependencies": {
|
|
93
|
-
"@powerlines/plugin-vite": "^0.14.
|
|
93
|
+
"@powerlines/plugin-vite": "^0.14.361",
|
|
94
94
|
"@stryke/fs": "^0.33.63",
|
|
95
95
|
"@stryke/hash": "^0.13.16",
|
|
96
96
|
"@stryke/path": "^0.27.2",
|
|
97
97
|
"@tamagui/static-worker": "^1.144.4",
|
|
98
98
|
"defu": "^6.1.4",
|
|
99
|
-
"powerlines": "^0.42.
|
|
99
|
+
"powerlines": "^0.42.4",
|
|
100
100
|
"typescript": "^5.9.3",
|
|
101
101
|
"vite": "^8.0.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
104
|
+
"@powerlines/plugin-plugin": "^0.12.314",
|
|
105
105
|
"@tamagui/types": "^1.144.4",
|
|
106
106
|
"@types/node": "^25.5.0"
|
|
107
107
|
},
|
|
108
108
|
"publishConfig": { "access": "public" },
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "c3243c1ec0fbacb4afd4bd3db20432f443334076"
|
|
110
110
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
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
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _stryke_fs_resolve = require("@stryke/fs/resolve");
|
|
4
|
-
let _stryke_hash_neutral = require("@stryke/hash/neutral");
|
|
5
|
-
let _stryke_path_join = require("@stryke/path/join");
|
|
6
|
-
let _tamagui_static_worker = require("@tamagui/static-worker");
|
|
7
|
-
_tamagui_static_worker = require_runtime.__toESM(_tamagui_static_worker);
|
|
8
|
-
let defu = require("defu");
|
|
9
|
-
defu = require_runtime.__toESM(defu);
|
|
10
|
-
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
11
|
-
let vite = require("vite");
|
|
12
|
-
|
|
13
|
-
//#region src/index.ts
|
|
14
|
-
/**
|
|
15
|
-
* Tamagui plugin for Powerlines.
|
|
16
|
-
*
|
|
17
|
-
* @param options - The Tamagui plugin user configuration options.
|
|
18
|
-
* @returns A Powerlines plugin that integrates Tamagui into an existing Powerlines project.
|
|
19
|
-
*/
|
|
20
|
-
const plugin = (options = {}) => {
|
|
21
|
-
let memoryCache = {};
|
|
22
|
-
let cacheSize = 0;
|
|
23
|
-
const clearCompilerCache = () => {
|
|
24
|
-
memoryCache = {};
|
|
25
|
-
cacheSize = 0;
|
|
26
|
-
};
|
|
27
|
-
const cssMap = /* @__PURE__ */ new Map();
|
|
28
|
-
let server = null;
|
|
29
|
-
return {
|
|
30
|
-
name: "tamagui",
|
|
31
|
-
async config() {
|
|
32
|
-
const configPath = (0, powerlines_plugin_utils.getConfigPath)(this, "tamagui");
|
|
33
|
-
const tamaguiOptions = await (0, _tamagui_static_worker.loadTamaguiBuildConfig)((0, defu.default)({
|
|
34
|
-
...options,
|
|
35
|
-
components: [(0, _stryke_path_join.joinPaths)("{root}", "src/components")]
|
|
36
|
-
}, {
|
|
37
|
-
config: configPath,
|
|
38
|
-
disableExtraction: false,
|
|
39
|
-
platform: "web",
|
|
40
|
-
logTimings: this.config.logLevel === "debug" || this.config.logLevel === "trace",
|
|
41
|
-
prefixLogs: "Powerlines"
|
|
42
|
-
}));
|
|
43
|
-
const alias = [];
|
|
44
|
-
if (tamaguiOptions.platform !== "native") {
|
|
45
|
-
alias.push({
|
|
46
|
-
find: "react-native/Libraries/Renderer/shims/ReactFabric",
|
|
47
|
-
replacement: await (0, _stryke_fs_resolve.resolvePackage)("@tamagui/proxy-worm") || "@tamagui/proxy-worm"
|
|
48
|
-
});
|
|
49
|
-
alias.push({
|
|
50
|
-
find: "react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry",
|
|
51
|
-
replacement: await (0, _stryke_fs_resolve.resolvePackage)("@tamagui/proxy-worm") || "@tamagui/proxy-worm"
|
|
52
|
-
});
|
|
53
|
-
alias.push({
|
|
54
|
-
find: "react-native-svg",
|
|
55
|
-
replacement: await (0, _stryke_fs_resolve.resolvePackage)("react-native-svg") || "react-native-svg"
|
|
56
|
-
});
|
|
57
|
-
if (tamaguiOptions?.useReactNativeWebLite) {
|
|
58
|
-
alias.push({
|
|
59
|
-
find: "react-native",
|
|
60
|
-
replacement: await (0, _stryke_fs_resolve.resolvePackage)("react-native-web-lite") || "react-native-web-lite"
|
|
61
|
-
});
|
|
62
|
-
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";
|
|
63
|
-
alias.push({
|
|
64
|
-
find: /^react-native$/,
|
|
65
|
-
replacement: reactNativeWebLite
|
|
66
|
-
});
|
|
67
|
-
alias.push({
|
|
68
|
-
find: /^react-native\/(.+)$/,
|
|
69
|
-
replacement: `${reactNativeWebLite}/$1`
|
|
70
|
-
});
|
|
71
|
-
alias.push({
|
|
72
|
-
find: /^react-native-web$/,
|
|
73
|
-
replacement: reactNativeWebLite
|
|
74
|
-
});
|
|
75
|
-
alias.push({
|
|
76
|
-
find: /^react-native-web\/(.+)$/,
|
|
77
|
-
replacement: `${reactNativeWebLite}/$1`
|
|
78
|
-
});
|
|
79
|
-
alias.push({
|
|
80
|
-
find: /react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,
|
|
81
|
-
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"
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
tamagui: tamaguiOptions,
|
|
87
|
-
build: {
|
|
88
|
-
platform: "browser",
|
|
89
|
-
extensions: [
|
|
90
|
-
`.web.mjs`,
|
|
91
|
-
`.web.js`,
|
|
92
|
-
`.web.jsx`,
|
|
93
|
-
`.web.ts`,
|
|
94
|
-
`.web.tsx`,
|
|
95
|
-
".mjs",
|
|
96
|
-
".js",
|
|
97
|
-
".mts",
|
|
98
|
-
".ts",
|
|
99
|
-
".jsx",
|
|
100
|
-
".tsx",
|
|
101
|
-
".json"
|
|
102
|
-
],
|
|
103
|
-
define: {
|
|
104
|
-
_frameTimestamp: void 0,
|
|
105
|
-
_WORKLET: false,
|
|
106
|
-
__DEV__: `${this.config.mode === "development"}`,
|
|
107
|
-
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || this.config.mode),
|
|
108
|
-
"process.env.ENABLE_RSC": JSON.stringify(process.env.ENABLE_RSC || ""),
|
|
109
|
-
"process.env.ENABLE_STEPS": JSON.stringify(process.env.ENABLE_STEPS || ""),
|
|
110
|
-
"process.env.IS_STATIC": JSON.stringify(false),
|
|
111
|
-
...this.config.mode === "production" && { "process.env.TAMAGUI_OPTIMIZE_THEMES": JSON.stringify(true) }
|
|
112
|
-
},
|
|
113
|
-
alias
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
},
|
|
117
|
-
configEnvironment(name, environment) {
|
|
118
|
-
if (environment.consumer === "client" || name === "client") return { build: { define: {
|
|
119
|
-
"process.env.TAMAGUI_IS_CLIENT": JSON.stringify(true),
|
|
120
|
-
"process.env.TAMAGUI_ENVIRONMENT": "\"client\""
|
|
121
|
-
} } };
|
|
122
|
-
return null;
|
|
123
|
-
},
|
|
124
|
-
configResolved() {
|
|
125
|
-
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.`);
|
|
126
|
-
this.config.tamagui.components = this.config.tamagui.components.map((path) => (0, powerlines_plugin_utils.replacePathTokens)(this, path)).filter(Boolean);
|
|
127
|
-
if (this.config.vite) {
|
|
128
|
-
this.config.vite.optimizeDeps ??= {};
|
|
129
|
-
this.config.vite.optimizeDeps.include ??= [];
|
|
130
|
-
this.config.vite.optimizeDeps.include.push("@tamagui/core/inject-styles");
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
async resolveId(id) {
|
|
134
|
-
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
135
|
-
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
136
|
-
const [validId, query] = id.split("?");
|
|
137
|
-
if (!validId?.endsWith(".tamagui.css")) return;
|
|
138
|
-
let absoluteId = id;
|
|
139
|
-
if (!id.startsWith(this.config.root)) absoluteId = (0, _stryke_path_join.joinPaths)(this.config.root, validId);
|
|
140
|
-
if (cssMap.has(absoluteId)) return absoluteId + (query ? `?${query}` : "");
|
|
141
|
-
return null;
|
|
142
|
-
},
|
|
143
|
-
async load(id) {
|
|
144
|
-
if (this.config?.tamagui?.disableExtraction) return;
|
|
145
|
-
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
146
|
-
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
147
|
-
const [validId] = id.split("?");
|
|
148
|
-
return validId ? cssMap.get(validId) : null;
|
|
149
|
-
},
|
|
150
|
-
transform: {
|
|
151
|
-
order: "pre",
|
|
152
|
-
async handler(code, id) {
|
|
153
|
-
if (id.includes("expo-linear-gradient")) return (0, vite.transformWithEsbuild)(code, id, {
|
|
154
|
-
loader: "jsx",
|
|
155
|
-
jsx: "automatic"
|
|
156
|
-
});
|
|
157
|
-
if (this.config?.tamagui?.disableExtraction) return;
|
|
158
|
-
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
159
|
-
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
160
|
-
const [validId] = id.split("?");
|
|
161
|
-
if (!validId?.endsWith(".tsx")) return;
|
|
162
|
-
const firstCommentIndex = code.indexOf("// ");
|
|
163
|
-
const { shouldDisable, shouldPrintDebug } = await (0, _tamagui_static_worker.getPragmaOptions)({
|
|
164
|
-
source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : "",
|
|
165
|
-
path: validId
|
|
166
|
-
});
|
|
167
|
-
if (shouldPrintDebug) this.trace(`Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}\n\nOriginal source:\n${code}\n\n`);
|
|
168
|
-
if (shouldDisable) return;
|
|
169
|
-
const cacheKey = (0, _stryke_hash_neutral.murmurhash)({
|
|
170
|
-
cacheEnv: this.environment.name === "client" || this.environment.name === "ssr" ? "web" : this.environment.name,
|
|
171
|
-
code,
|
|
172
|
-
id
|
|
173
|
-
});
|
|
174
|
-
const cached = memoryCache[cacheKey];
|
|
175
|
-
if (cached) return cached;
|
|
176
|
-
let extracted;
|
|
177
|
-
try {
|
|
178
|
-
extracted = await _tamagui_static_worker.extractToClassNames({
|
|
179
|
-
source: code,
|
|
180
|
-
sourcePath: validId,
|
|
181
|
-
options: this.config.tamagui,
|
|
182
|
-
shouldPrintDebug
|
|
183
|
-
});
|
|
184
|
-
} catch (err) {
|
|
185
|
-
this.error(err instanceof Error ? err.message : String(err));
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (!extracted) return;
|
|
189
|
-
const rootRelativeId = `${validId}.tamagui.css`;
|
|
190
|
-
let absoluteId = rootRelativeId;
|
|
191
|
-
if (!absoluteId.startsWith(this.config.root)) absoluteId = (0, _stryke_path_join.joinPaths)(this.config.root, rootRelativeId);
|
|
192
|
-
let source = extracted.js;
|
|
193
|
-
if (extracted.styles) {
|
|
194
|
-
this.addWatchFile(rootRelativeId);
|
|
195
|
-
if (server && cssMap.has(absoluteId)) {
|
|
196
|
-
if (server) {
|
|
197
|
-
const { moduleGraph } = server;
|
|
198
|
-
const modules = moduleGraph.getModulesByFile(rootRelativeId);
|
|
199
|
-
if (modules) for (const module of modules) {
|
|
200
|
-
moduleGraph.invalidateModule(module);
|
|
201
|
-
module.lastHMRTimestamp = module.lastInvalidationTimestamp || Date.now();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
source = `${source.toString()}\nimport "${rootRelativeId}";`;
|
|
206
|
-
cssMap.set(absoluteId, extracted.styles);
|
|
207
|
-
}
|
|
208
|
-
const result = {
|
|
209
|
-
code: source.toString(),
|
|
210
|
-
map: extracted.map
|
|
211
|
-
};
|
|
212
|
-
cacheSize += result.code.length;
|
|
213
|
-
if (cacheSize > 26214400) clearCompilerCache();
|
|
214
|
-
memoryCache[cacheKey] = result;
|
|
215
|
-
return result;
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
async finalize() {
|
|
219
|
-
await _tamagui_static_worker?.destroyPool();
|
|
220
|
-
},
|
|
221
|
-
vite: { configureServer(_server) {
|
|
222
|
-
server = _server;
|
|
223
|
-
} }
|
|
224
|
-
};
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
//#endregion
|
|
228
|
-
exports.default = plugin;
|
|
229
|
-
exports.plugin = plugin;
|
package/dist/index.mjs
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import { resolvePackage } from "@stryke/fs/resolve";
|
|
2
|
-
import { murmurhash } from "@stryke/hash/neutral";
|
|
3
|
-
import { joinPaths } from "@stryke/path/join";
|
|
4
|
-
import * as Static from "@tamagui/static-worker";
|
|
5
|
-
import { getPragmaOptions, loadTamaguiBuildConfig } from "@tamagui/static-worker";
|
|
6
|
-
import defu from "defu";
|
|
7
|
-
import { getConfigPath, replacePathTokens } from "powerlines/plugin-utils";
|
|
8
|
-
import { transformWithEsbuild } from "vite";
|
|
9
|
-
|
|
10
|
-
//#region src/index.ts
|
|
11
|
-
/**
|
|
12
|
-
* Tamagui plugin for Powerlines.
|
|
13
|
-
*
|
|
14
|
-
* @param options - The Tamagui plugin user configuration options.
|
|
15
|
-
* @returns A Powerlines plugin that integrates Tamagui into an existing Powerlines project.
|
|
16
|
-
*/
|
|
17
|
-
const plugin = (options = {}) => {
|
|
18
|
-
let memoryCache = {};
|
|
19
|
-
let cacheSize = 0;
|
|
20
|
-
const clearCompilerCache = () => {
|
|
21
|
-
memoryCache = {};
|
|
22
|
-
cacheSize = 0;
|
|
23
|
-
};
|
|
24
|
-
const cssMap = /* @__PURE__ */ new Map();
|
|
25
|
-
let server = null;
|
|
26
|
-
return {
|
|
27
|
-
name: "tamagui",
|
|
28
|
-
async config() {
|
|
29
|
-
const configPath = getConfigPath(this, "tamagui");
|
|
30
|
-
const tamaguiOptions = await loadTamaguiBuildConfig(defu({
|
|
31
|
-
...options,
|
|
32
|
-
components: [joinPaths("{root}", "src/components")]
|
|
33
|
-
}, {
|
|
34
|
-
config: configPath,
|
|
35
|
-
disableExtraction: false,
|
|
36
|
-
platform: "web",
|
|
37
|
-
logTimings: this.config.logLevel === "debug" || this.config.logLevel === "trace",
|
|
38
|
-
prefixLogs: "Powerlines"
|
|
39
|
-
}));
|
|
40
|
-
const alias = [];
|
|
41
|
-
if (tamaguiOptions.platform !== "native") {
|
|
42
|
-
alias.push({
|
|
43
|
-
find: "react-native/Libraries/Renderer/shims/ReactFabric",
|
|
44
|
-
replacement: await resolvePackage("@tamagui/proxy-worm") || "@tamagui/proxy-worm"
|
|
45
|
-
});
|
|
46
|
-
alias.push({
|
|
47
|
-
find: "react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry",
|
|
48
|
-
replacement: await resolvePackage("@tamagui/proxy-worm") || "@tamagui/proxy-worm"
|
|
49
|
-
});
|
|
50
|
-
alias.push({
|
|
51
|
-
find: "react-native-svg",
|
|
52
|
-
replacement: await resolvePackage("react-native-svg") || "react-native-svg"
|
|
53
|
-
});
|
|
54
|
-
if (tamaguiOptions?.useReactNativeWebLite) {
|
|
55
|
-
alias.push({
|
|
56
|
-
find: "react-native",
|
|
57
|
-
replacement: await resolvePackage("react-native-web-lite") || "react-native-web-lite"
|
|
58
|
-
});
|
|
59
|
-
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";
|
|
60
|
-
alias.push({
|
|
61
|
-
find: /^react-native$/,
|
|
62
|
-
replacement: reactNativeWebLite
|
|
63
|
-
});
|
|
64
|
-
alias.push({
|
|
65
|
-
find: /^react-native\/(.+)$/,
|
|
66
|
-
replacement: `${reactNativeWebLite}/$1`
|
|
67
|
-
});
|
|
68
|
-
alias.push({
|
|
69
|
-
find: /^react-native-web$/,
|
|
70
|
-
replacement: reactNativeWebLite
|
|
71
|
-
});
|
|
72
|
-
alias.push({
|
|
73
|
-
find: /^react-native-web\/(.+)$/,
|
|
74
|
-
replacement: `${reactNativeWebLite}/$1`
|
|
75
|
-
});
|
|
76
|
-
alias.push({
|
|
77
|
-
find: /react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,
|
|
78
|
-
replacement: await resolvePackage("@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle") || "@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle"
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
tamagui: tamaguiOptions,
|
|
84
|
-
build: {
|
|
85
|
-
platform: "browser",
|
|
86
|
-
extensions: [
|
|
87
|
-
`.web.mjs`,
|
|
88
|
-
`.web.js`,
|
|
89
|
-
`.web.jsx`,
|
|
90
|
-
`.web.ts`,
|
|
91
|
-
`.web.tsx`,
|
|
92
|
-
".mjs",
|
|
93
|
-
".js",
|
|
94
|
-
".mts",
|
|
95
|
-
".ts",
|
|
96
|
-
".jsx",
|
|
97
|
-
".tsx",
|
|
98
|
-
".json"
|
|
99
|
-
],
|
|
100
|
-
define: {
|
|
101
|
-
_frameTimestamp: void 0,
|
|
102
|
-
_WORKLET: false,
|
|
103
|
-
__DEV__: `${this.config.mode === "development"}`,
|
|
104
|
-
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || this.config.mode),
|
|
105
|
-
"process.env.ENABLE_RSC": JSON.stringify(process.env.ENABLE_RSC || ""),
|
|
106
|
-
"process.env.ENABLE_STEPS": JSON.stringify(process.env.ENABLE_STEPS || ""),
|
|
107
|
-
"process.env.IS_STATIC": JSON.stringify(false),
|
|
108
|
-
...this.config.mode === "production" && { "process.env.TAMAGUI_OPTIMIZE_THEMES": JSON.stringify(true) }
|
|
109
|
-
},
|
|
110
|
-
alias
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
configEnvironment(name, environment) {
|
|
115
|
-
if (environment.consumer === "client" || name === "client") return { build: { define: {
|
|
116
|
-
"process.env.TAMAGUI_IS_CLIENT": JSON.stringify(true),
|
|
117
|
-
"process.env.TAMAGUI_ENVIRONMENT": "\"client\""
|
|
118
|
-
} } };
|
|
119
|
-
return null;
|
|
120
|
-
},
|
|
121
|
-
configResolved() {
|
|
122
|
-
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.`);
|
|
123
|
-
this.config.tamagui.components = this.config.tamagui.components.map((path) => replacePathTokens(this, path)).filter(Boolean);
|
|
124
|
-
if (this.config.vite) {
|
|
125
|
-
this.config.vite.optimizeDeps ??= {};
|
|
126
|
-
this.config.vite.optimizeDeps.include ??= [];
|
|
127
|
-
this.config.vite.optimizeDeps.include.push("@tamagui/core/inject-styles");
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
async resolveId(id) {
|
|
131
|
-
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
132
|
-
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
133
|
-
const [validId, query] = id.split("?");
|
|
134
|
-
if (!validId?.endsWith(".tamagui.css")) return;
|
|
135
|
-
let absoluteId = id;
|
|
136
|
-
if (!id.startsWith(this.config.root)) absoluteId = joinPaths(this.config.root, validId);
|
|
137
|
-
if (cssMap.has(absoluteId)) return absoluteId + (query ? `?${query}` : "");
|
|
138
|
-
return null;
|
|
139
|
-
},
|
|
140
|
-
async load(id) {
|
|
141
|
-
if (this.config?.tamagui?.disableExtraction) return;
|
|
142
|
-
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
143
|
-
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
144
|
-
const [validId] = id.split("?");
|
|
145
|
-
return validId ? cssMap.get(validId) : null;
|
|
146
|
-
},
|
|
147
|
-
transform: {
|
|
148
|
-
order: "pre",
|
|
149
|
-
async handler(code, id) {
|
|
150
|
-
if (id.includes("expo-linear-gradient")) return transformWithEsbuild(code, id, {
|
|
151
|
-
loader: "jsx",
|
|
152
|
-
jsx: "automatic"
|
|
153
|
-
});
|
|
154
|
-
if (this.config?.tamagui?.disableExtraction) return;
|
|
155
|
-
if (this.environment?.name && (this.environment.name === "ios" || this.environment.name === "android")) return;
|
|
156
|
-
if (this.config?.tamagui?.disableServerOptimization && this.environment?.name && this.environment.name !== "client") return;
|
|
157
|
-
const [validId] = id.split("?");
|
|
158
|
-
if (!validId?.endsWith(".tsx")) return;
|
|
159
|
-
const firstCommentIndex = code.indexOf("// ");
|
|
160
|
-
const { shouldDisable, shouldPrintDebug } = await getPragmaOptions({
|
|
161
|
-
source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : "",
|
|
162
|
-
path: validId
|
|
163
|
-
});
|
|
164
|
-
if (shouldPrintDebug) this.trace(`Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}\n\nOriginal source:\n${code}\n\n`);
|
|
165
|
-
if (shouldDisable) return;
|
|
166
|
-
const cacheKey = murmurhash({
|
|
167
|
-
cacheEnv: this.environment.name === "client" || this.environment.name === "ssr" ? "web" : this.environment.name,
|
|
168
|
-
code,
|
|
169
|
-
id
|
|
170
|
-
});
|
|
171
|
-
const cached = memoryCache[cacheKey];
|
|
172
|
-
if (cached) return cached;
|
|
173
|
-
let extracted;
|
|
174
|
-
try {
|
|
175
|
-
extracted = await Static.extractToClassNames({
|
|
176
|
-
source: code,
|
|
177
|
-
sourcePath: validId,
|
|
178
|
-
options: this.config.tamagui,
|
|
179
|
-
shouldPrintDebug
|
|
180
|
-
});
|
|
181
|
-
} catch (err) {
|
|
182
|
-
this.error(err instanceof Error ? err.message : String(err));
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (!extracted) return;
|
|
186
|
-
const rootRelativeId = `${validId}.tamagui.css`;
|
|
187
|
-
let absoluteId = rootRelativeId;
|
|
188
|
-
if (!absoluteId.startsWith(this.config.root)) absoluteId = joinPaths(this.config.root, rootRelativeId);
|
|
189
|
-
let source = extracted.js;
|
|
190
|
-
if (extracted.styles) {
|
|
191
|
-
this.addWatchFile(rootRelativeId);
|
|
192
|
-
if (server && cssMap.has(absoluteId)) {
|
|
193
|
-
if (server) {
|
|
194
|
-
const { moduleGraph } = server;
|
|
195
|
-
const modules = moduleGraph.getModulesByFile(rootRelativeId);
|
|
196
|
-
if (modules) for (const module of modules) {
|
|
197
|
-
moduleGraph.invalidateModule(module);
|
|
198
|
-
module.lastHMRTimestamp = module.lastInvalidationTimestamp || Date.now();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
source = `${source.toString()}\nimport "${rootRelativeId}";`;
|
|
203
|
-
cssMap.set(absoluteId, extracted.styles);
|
|
204
|
-
}
|
|
205
|
-
const result = {
|
|
206
|
-
code: source.toString(),
|
|
207
|
-
map: extracted.map
|
|
208
|
-
};
|
|
209
|
-
cacheSize += result.code.length;
|
|
210
|
-
if (cacheSize > 26214400) clearCompilerCache();
|
|
211
|
-
memoryCache[cacheKey] = result;
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
async finalize() {
|
|
216
|
-
await Static?.destroyPool();
|
|
217
|
-
},
|
|
218
|
-
vite: { configureServer(_server) {
|
|
219
|
-
server = _server;
|
|
220
|
-
} }
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
//#endregion
|
|
225
|
-
export { plugin as default, plugin };
|
package/dist/types/index.cjs
DELETED
|
File without changes
|
package/dist/types/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/types/plugin.cjs
DELETED
|
File without changes
|
package/dist/types/plugin.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|