@powerlines/plugin-tamagui 0.1.419 → 0.1.421
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 +1 -29
- package/dist/index.cjs +1 -229
- package/dist/index.mjs +1 -225
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +5 -5
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
|
package/dist/index.cjs
CHANGED
|
@@ -1,229 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,
|
|
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, 1);
|
|
8
|
-
let defu = require("defu");
|
|
9
|
-
defu = require_runtime.__toESM(defu, 1);
|
|
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;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`);let t=require(`@stryke/fs/resolve`),n=require(`@stryke/hash/neutral`),r=require(`@stryke/path/join`),i=require(`@tamagui/static-worker`);i=e.__toESM(i,1);let a=require(`defu`);a=e.__toESM(a,1);let o=require(`powerlines/plugin-utils`),s=require(`vite`);const c=(e={})=>{let c={},l=0,u=()=>{c={},l=0},d=new Map,f=null;return{name:`tamagui`,async config(){let n=(0,o.getConfigPath)(this,`tamagui`),s=await(0,i.loadTamaguiBuildConfig)((0,a.default)({...e,components:[(0,r.joinPaths)(`{root}`,`src/components`)]},{config:n,disableExtraction:!1,platform:`web`,logTimings:this.config.logLevel===`debug`||this.config.logLevel===`trace`,prefixLogs:`Powerlines`})),c=[];if(s.platform!==`native`&&(c.push({find:`react-native/Libraries/Renderer/shims/ReactFabric`,replacement:await(0,t.resolvePackage)(`@tamagui/proxy-worm`)||`@tamagui/proxy-worm`}),c.push({find:`react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry`,replacement:await(0,t.resolvePackage)(`@tamagui/proxy-worm`)||`@tamagui/proxy-worm`}),c.push({find:`react-native-svg`,replacement:await(0,t.resolvePackage)(`react-native-svg`)||`react-native-svg`}),s?.useReactNativeWebLite)){c.push({find:`react-native`,replacement:await(0,t.resolvePackage)(`react-native-web-lite`)||`react-native-web-lite`});let e=await(0,t.resolvePackage)(s?.useReactNativeWebLite===`without-animated`?`@tamagui/react-native-web-lite/without-animated`:`@tamagui/react-native-web-lite`)||s?.useReactNativeWebLite===`without-animated`?`@tamagui/react-native-web-lite/without-animated`:`@tamagui/react-native-web-lite`;c.push({find:/^react-native$/,replacement:e}),c.push({find:/^react-native\/(.+)$/,replacement:`${e}/$1`}),c.push({find:/^react-native-web$/,replacement:e}),c.push({find:/^react-native-web\/(.+)$/,replacement:`${e}/$1`}),c.push({find:/react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,replacement:await(0,t.resolvePackage)(`@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle`)||`@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle`})}return{tamagui:s,build:{platform:`browser`,extensions:[`.web.mjs`,`.web.js`,`.web.jsx`,`.web.ts`,`.web.tsx`,`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],define:{_frameTimestamp:void 0,_WORKLET:!1,__DEV__:`${this.config.mode===`development`}`,"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||this.config.mode),"process.env.ENABLE_RSC":JSON.stringify(process.env.ENABLE_RSC||``),"process.env.ENABLE_STEPS":JSON.stringify(process.env.ENABLE_STEPS||``),"process.env.IS_STATIC":JSON.stringify(!1),...this.config.mode===`production`&&{"process.env.TAMAGUI_OPTIMIZE_THEMES":JSON.stringify(!0)}},alias:c}}},configEnvironment(e,t){return t.consumer===`client`||e===`client`?{build:{define:{"process.env.TAMAGUI_IS_CLIENT":JSON.stringify(!0),"process.env.TAMAGUI_ENVIRONMENT":`"client"`}}}:null},configResolved(){if(!this.config.tamagui.components||this.config.tamagui.components.length===0)throw Error(`Tamagui Plugin: No components paths defined in Tamagui configuration. Please ensure that the 'components' option is set correctly.`);this.config.tamagui.components=this.config.tamagui.components.map(e=>(0,o.replacePathTokens)(this,e)).filter(Boolean),this.config.vite&&(this.config.vite.optimizeDeps??={},this.config.vite.optimizeDeps.include??=[],this.config.vite.optimizeDeps.include.push(`@tamagui/core/inject-styles`))},async resolveId(e){if(this.environment?.name&&(this.environment.name===`ios`||this.environment.name===`android`)||this.config?.tamagui?.disableServerOptimization&&this.environment?.name&&this.environment.name!==`client`)return;let[t,n]=e.split(`?`);if(!t?.endsWith(`.tamagui.css`))return;let i=e;return e.startsWith(this.config.root)||(i=(0,r.joinPaths)(this.config.root,t)),d.has(i)?i+(n?`?${n}`:``):null},async load(e){if(this.config?.tamagui?.disableExtraction||this.environment?.name&&(this.environment.name===`ios`||this.environment.name===`android`)||this.config?.tamagui?.disableServerOptimization&&this.environment?.name&&this.environment.name!==`client`)return;let[t]=e.split(`?`);return t?d.get(t):null},transform:{order:`pre`,async handler(e,t){if(t.includes(`expo-linear-gradient`))return(0,s.transformWithEsbuild)(e,t,{loader:`jsx`,jsx:`automatic`});if(this.config?.tamagui?.disableExtraction||this.environment?.name&&(this.environment.name===`ios`||this.environment.name===`android`)||this.config?.tamagui?.disableServerOptimization&&this.environment?.name&&this.environment.name!==`client`)return;let[a]=t.split(`?`);if(!a?.endsWith(`.tsx`))return;let o=e.indexOf(`// `),{shouldDisable:p,shouldPrintDebug:m}=await(0,i.getPragmaOptions)({source:o>=0?e.slice(o):``,path:a});if(m&&this.trace(`Current file: ${t} in environment: ${this.environment?.name}, shouldDisable: ${p}\n\nOriginal source:\n${e}\n\n`),p)return;let h=(0,n.murmurhash)({cacheEnv:this.environment.name===`client`||this.environment.name===`ssr`?`web`:this.environment.name,code:e,id:t}),g=c[h];if(g)return g;let _;try{_=await i.extractToClassNames({source:e,sourcePath:a,options:this.config.tamagui,shouldPrintDebug:m})}catch(e){this.error(e instanceof Error?e.message:String(e));return}if(!_)return;let v=`${a}.tamagui.css`,y=v;y.startsWith(this.config.root)||(y=(0,r.joinPaths)(this.config.root,v));let b=_.js;if(_.styles){if(this.addWatchFile(v),f&&d.has(y)&&f){let{moduleGraph:e}=f,t=e.getModulesByFile(v);if(t)for(let n of t)e.invalidateModule(n),n.lastHMRTimestamp=n.lastInvalidationTimestamp||Date.now()}b=`${b.toString()}\nimport "${v}";`,d.set(y,_.styles)}let x={code:b.toString(),map:_.map};return l+=x.code.length,l>26214400&&u(),c[h]=x,x}},async finalize(){await i?.destroyPool()},vite:{configureServer(e){f=e}}}};exports.default=c,exports.plugin=c;
|
package/dist/index.mjs
CHANGED
|
@@ -1,225 +1 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{resolvePackage as e}from"@stryke/fs/resolve";import{murmurhash as t}from"@stryke/hash/neutral";import{joinPaths as n}from"@stryke/path/join";import*as r from"@tamagui/static-worker";import{getPragmaOptions as i,loadTamaguiBuildConfig as a}from"@tamagui/static-worker";import o from"defu";import{getConfigPath as s,replacePathTokens as c}from"powerlines/plugin-utils";import{transformWithEsbuild as l}from"vite";const u=(u={})=>{let d={},f=0,p=()=>{d={},f=0},m=new Map,h=null;return{name:`tamagui`,async config(){let t=s(this,`tamagui`),r=await a(o({...u,components:[n(`{root}`,`src/components`)]},{config:t,disableExtraction:!1,platform:`web`,logTimings:this.config.logLevel===`debug`||this.config.logLevel===`trace`,prefixLogs:`Powerlines`})),i=[];if(r.platform!==`native`&&(i.push({find:`react-native/Libraries/Renderer/shims/ReactFabric`,replacement:await e(`@tamagui/proxy-worm`)||`@tamagui/proxy-worm`}),i.push({find:`react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry`,replacement:await e(`@tamagui/proxy-worm`)||`@tamagui/proxy-worm`}),i.push({find:`react-native-svg`,replacement:await e(`react-native-svg`)||`react-native-svg`}),r?.useReactNativeWebLite)){i.push({find:`react-native`,replacement:await e(`react-native-web-lite`)||`react-native-web-lite`});let t=await e(r?.useReactNativeWebLite===`without-animated`?`@tamagui/react-native-web-lite/without-animated`:`@tamagui/react-native-web-lite`)||r?.useReactNativeWebLite===`without-animated`?`@tamagui/react-native-web-lite/without-animated`:`@tamagui/react-native-web-lite`;i.push({find:/^react-native$/,replacement:t}),i.push({find:/^react-native\/(.+)$/,replacement:`${t}/$1`}),i.push({find:/^react-native-web$/,replacement:t}),i.push({find:/^react-native-web\/(.+)$/,replacement:`${t}/$1`}),i.push({find:/react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,replacement:await e(`@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle`)||`@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle`})}return{tamagui:r,build:{platform:`browser`,extensions:[`.web.mjs`,`.web.js`,`.web.jsx`,`.web.ts`,`.web.tsx`,`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],define:{_frameTimestamp:void 0,_WORKLET:!1,__DEV__:`${this.config.mode===`development`}`,"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||this.config.mode),"process.env.ENABLE_RSC":JSON.stringify(process.env.ENABLE_RSC||``),"process.env.ENABLE_STEPS":JSON.stringify(process.env.ENABLE_STEPS||``),"process.env.IS_STATIC":JSON.stringify(!1),...this.config.mode===`production`&&{"process.env.TAMAGUI_OPTIMIZE_THEMES":JSON.stringify(!0)}},alias:i}}},configEnvironment(e,t){return t.consumer===`client`||e===`client`?{build:{define:{"process.env.TAMAGUI_IS_CLIENT":JSON.stringify(!0),"process.env.TAMAGUI_ENVIRONMENT":`"client"`}}}:null},configResolved(){if(!this.config.tamagui.components||this.config.tamagui.components.length===0)throw Error(`Tamagui Plugin: No components paths defined in Tamagui configuration. Please ensure that the 'components' option is set correctly.`);this.config.tamagui.components=this.config.tamagui.components.map(e=>c(this,e)).filter(Boolean),this.config.vite&&(this.config.vite.optimizeDeps??={},this.config.vite.optimizeDeps.include??=[],this.config.vite.optimizeDeps.include.push(`@tamagui/core/inject-styles`))},async resolveId(e){if(this.environment?.name&&(this.environment.name===`ios`||this.environment.name===`android`)||this.config?.tamagui?.disableServerOptimization&&this.environment?.name&&this.environment.name!==`client`)return;let[t,r]=e.split(`?`);if(!t?.endsWith(`.tamagui.css`))return;let i=e;return e.startsWith(this.config.root)||(i=n(this.config.root,t)),m.has(i)?i+(r?`?${r}`:``):null},async load(e){if(this.config?.tamagui?.disableExtraction||this.environment?.name&&(this.environment.name===`ios`||this.environment.name===`android`)||this.config?.tamagui?.disableServerOptimization&&this.environment?.name&&this.environment.name!==`client`)return;let[t]=e.split(`?`);return t?m.get(t):null},transform:{order:`pre`,async handler(e,a){if(a.includes(`expo-linear-gradient`))return l(e,a,{loader:`jsx`,jsx:`automatic`});if(this.config?.tamagui?.disableExtraction||this.environment?.name&&(this.environment.name===`ios`||this.environment.name===`android`)||this.config?.tamagui?.disableServerOptimization&&this.environment?.name&&this.environment.name!==`client`)return;let[o]=a.split(`?`);if(!o?.endsWith(`.tsx`))return;let s=e.indexOf(`// `),{shouldDisable:c,shouldPrintDebug:u}=await i({source:s>=0?e.slice(s):``,path:o});if(u&&this.trace(`Current file: ${a} in environment: ${this.environment?.name}, shouldDisable: ${c}\n\nOriginal source:\n${e}\n\n`),c)return;let g=t({cacheEnv:this.environment.name===`client`||this.environment.name===`ssr`?`web`:this.environment.name,code:e,id:a}),_=d[g];if(_)return _;let v;try{v=await r.extractToClassNames({source:e,sourcePath:o,options:this.config.tamagui,shouldPrintDebug:u})}catch(e){this.error(e instanceof Error?e.message:String(e));return}if(!v)return;let y=`${o}.tamagui.css`,b=y;b.startsWith(this.config.root)||(b=n(this.config.root,y));let x=v.js;if(v.styles){if(this.addWatchFile(y),h&&m.has(b)&&h){let{moduleGraph:e}=h,t=e.getModulesByFile(y);if(t)for(let n of t)e.invalidateModule(n),n.lastHMRTimestamp=n.lastInvalidationTimestamp||Date.now()}x=`${x.toString()}\nimport "${y}";`,m.set(b,v.styles)}let S={code:x.toString(),map:v.map};return f+=S.code.length,f>26214400&&p(),d[g]=S,S}},async finalize(){await r?.destroyPool()},vite:{configureServer(e){h=e}}}};export{u as default,u as plugin};
|
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.421",
|
|
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.425",
|
|
94
94
|
"@stryke/fs": "^0.33.67",
|
|
95
95
|
"@stryke/hash": "^0.13.20",
|
|
96
96
|
"@stryke/path": "^0.27.5",
|
|
97
97
|
"@tamagui/static-worker": "^1.144.4",
|
|
98
98
|
"@tamagui/types": "^1.144.4",
|
|
99
99
|
"defu": "^6.1.7",
|
|
100
|
-
"powerlines": "^0.43.
|
|
100
|
+
"powerlines": "^0.43.27",
|
|
101
101
|
"typescript": "^6.0.3",
|
|
102
102
|
"vite": "^8.0.10"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
105
|
+
"@powerlines/plugin-plugin": "^0.12.382",
|
|
106
106
|
"@types/node": "^25.6.0"
|
|
107
107
|
},
|
|
108
108
|
"publishConfig": { "access": "public" },
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "ad851a239011b884c15b0444db518d74927fd13f"
|
|
110
110
|
}
|