@tamagui/vite-plugin 2.0.0-rc.4 → 2.0.0-rc.40

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.
Files changed (45) hide show
  1. package/dist/cjs/extensions.cjs +12 -10
  2. package/dist/cjs/index.cjs +7 -5
  3. package/dist/cjs/loadTamagui.cjs +58 -39
  4. package/dist/cjs/plugin.cjs +252 -130
  5. package/dist/esm/index.js +1 -1
  6. package/dist/esm/index.js.map +1 -6
  7. package/dist/esm/loadTamagui.mjs +34 -17
  8. package/dist/esm/loadTamagui.mjs.map +1 -1
  9. package/dist/esm/plugin.mjs +221 -101
  10. package/dist/esm/plugin.mjs.map +1 -1
  11. package/package.json +12 -11
  12. package/src/plugin.ts +18 -15
  13. package/types/plugin.d.ts +2 -2
  14. package/types/plugin.d.ts.map +1 -1
  15. package/dist/cjs/cache.cjs +0 -70
  16. package/dist/cjs/cache.js +0 -63
  17. package/dist/cjs/cache.js.map +0 -6
  18. package/dist/cjs/extensions.js +0 -32
  19. package/dist/cjs/extensions.js.map +0 -6
  20. package/dist/cjs/extract.cjs +0 -159
  21. package/dist/cjs/extract.js +0 -148
  22. package/dist/cjs/extract.js.map +0 -6
  23. package/dist/cjs/index.js +0 -15
  24. package/dist/cjs/index.js.map +0 -6
  25. package/dist/cjs/loadTamagui.js +0 -75
  26. package/dist/cjs/loadTamagui.js.map +0 -6
  27. package/dist/cjs/plugin.js +0 -307
  28. package/dist/cjs/plugin.js.map +0 -6
  29. package/dist/esm/cache.js +0 -47
  30. package/dist/esm/cache.js.map +0 -6
  31. package/dist/esm/cache.mjs +0 -40
  32. package/dist/esm/cache.mjs.map +0 -1
  33. package/dist/esm/extensions.js +0 -16
  34. package/dist/esm/extensions.js.map +0 -6
  35. package/dist/esm/extract.js +0 -129
  36. package/dist/esm/extract.js.map +0 -6
  37. package/dist/esm/extract.mjs +0 -125
  38. package/dist/esm/extract.mjs.map +0 -1
  39. package/dist/esm/loadTamagui.js +0 -51
  40. package/dist/esm/loadTamagui.js.map +0 -6
  41. package/dist/esm/plugin.js +0 -294
  42. package/dist/esm/plugin.js.map +0 -6
  43. package/types/cache.d.ts +0 -50
  44. package/types/cache.d.ts.map +0 -1
  45. package/types/extract.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAA;AAM/E,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAA;AAkDjE,KAAK,YAAY,GAAG;IAClB,gFAAgF;IAChF,OAAO,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAAA;IACtC,0DAA0D;IAC1D,GAAG,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,YAAiB,GAAG,UAAU,EAAE,CA8CvE;AAED,wBAAgB,aAAa,CAAC,EAC5B,oBAAoB,EACpB,GAAG,gBAAgB,EACpB,GAAE,cAAc,GAAG;IAAE,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,GAAG,MAAM,EAAE,CA+a9E"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAA;AAO/E,OAAO,KAAK,EAAU,YAAY,EAAiC,MAAM,MAAM,CAAA;AAkD/E,KAAK,YAAY,GAAG;IAClB,gFAAgF;IAChF,OAAO,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAAA;IACtC,0DAA0D;IAC1D,GAAG,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,YAAiB,GAAG,UAAU,EAAE,CA8CvE;AAED,wBAAgB,aAAa,CAAC,EAC5B,oBAAoB,EACpB,GAAG,gBAAgB,EACpB,GAAE,cAAc,GAAG;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC1B,GAAG,YAAY,CA+apB"}
@@ -1,70 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- return to;
17
- };
18
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
20
- }), mod);
21
- var cache_exports = {};
22
- __export(cache_exports, {
23
- clearCache: () => clearCache,
24
- clearPendingExtraction: () => clearPendingExtraction,
25
- getCache: () => getCache,
26
- getCached: () => getCached,
27
- getPending: () => getPending,
28
- getPendingExtraction: () => getPendingExtraction,
29
- setCache: () => setCache,
30
- setPendingExtraction: () => setPendingExtraction
31
- });
32
- module.exports = __toCommonJS(cache_exports);
33
- const KEYS = {
34
- cache: "__tamagui_vite_cache__",
35
- size: "__tamagui_vite_cache_size__",
36
- pending: "__tamagui_vite_pending__"
37
- },
38
- MAX_CACHE_SIZE = 67108864;
39
- function getGlobal(key, defaultValue) {
40
- return globalThis[key] === void 0 && (globalThis[key] = defaultValue), globalThis[key];
41
- }
42
- function setGlobal(key, value) {
43
- globalThis[key] = value;
44
- }
45
- function getCache() {
46
- return getGlobal(KEYS.cache, {});
47
- }
48
- function getCached(key) {
49
- return getCache()[key];
50
- }
51
- function setCache(key, entry) {
52
- const cache = getCache(),
53
- newSize = getGlobal(KEYS.size, 0) + entry.js.length;
54
- newSize > MAX_CACHE_SIZE ? clearCache() : setGlobal(KEYS.size, newSize), cache[key] = entry;
55
- }
56
- function clearCache() {
57
- setGlobal(KEYS.cache, {}), setGlobal(KEYS.size, 0);
58
- }
59
- function getPending() {
60
- return getGlobal(KEYS.pending, /* @__PURE__ */new Map());
61
- }
62
- function getPendingExtraction(key) {
63
- return getPending().get(key);
64
- }
65
- function setPendingExtraction(key, promise) {
66
- getPending().set(key, promise);
67
- }
68
- function clearPendingExtraction(key) {
69
- getPending().delete(key);
70
- }
package/dist/cjs/cache.js DELETED
@@ -1,63 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var cache_exports = {};
16
- __export(cache_exports, {
17
- clearCache: () => clearCache,
18
- clearPendingExtraction: () => clearPendingExtraction,
19
- getCache: () => getCache,
20
- getCached: () => getCached,
21
- getPending: () => getPending,
22
- getPendingExtraction: () => getPendingExtraction,
23
- setCache: () => setCache,
24
- setPendingExtraction: () => setPendingExtraction
25
- });
26
- module.exports = __toCommonJS(cache_exports);
27
- const KEYS = {
28
- cache: "__tamagui_vite_cache__",
29
- size: "__tamagui_vite_cache_size__",
30
- pending: "__tamagui_vite_pending__"
31
- }, MAX_CACHE_SIZE = 67108864;
32
- function getGlobal(key, defaultValue) {
33
- return globalThis[key] === void 0 && (globalThis[key] = defaultValue), globalThis[key];
34
- }
35
- function setGlobal(key, value) {
36
- globalThis[key] = value;
37
- }
38
- function getCache() {
39
- return getGlobal(KEYS.cache, {});
40
- }
41
- function getCached(key) {
42
- return getCache()[key];
43
- }
44
- function setCache(key, entry) {
45
- const cache = getCache(), newSize = getGlobal(KEYS.size, 0) + entry.js.length;
46
- newSize > MAX_CACHE_SIZE ? clearCache() : setGlobal(KEYS.size, newSize), cache[key] = entry;
47
- }
48
- function clearCache() {
49
- setGlobal(KEYS.cache, {}), setGlobal(KEYS.size, 0);
50
- }
51
- function getPending() {
52
- return getGlobal(KEYS.pending, /* @__PURE__ */ new Map());
53
- }
54
- function getPendingExtraction(key) {
55
- return getPending().get(key);
56
- }
57
- function setPendingExtraction(key, promise) {
58
- getPending().set(key, promise);
59
- }
60
- function clearPendingExtraction(key) {
61
- getPending().delete(key);
62
- }
63
- //# sourceMappingURL=cache.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/cache.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,MAAM,OAAO;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AACX,GAGM,iBAAiB;AAEvB,SAAS,UAAa,KAAa,cAAoB;AACrD,SAAK,WAAmB,GAAG,MAAM,WAC7B,WAAmB,GAAG,IAAI,eAEtB,WAAmB,GAAG;AAChC;AAEA,SAAS,UAAa,KAAa,OAAgB;AAChD,EAAC,WAAmB,GAAG,IAAI;AAC9B;AAKO,SAAS,WAAuC;AACrD,SAAO,UAAU,KAAK,OAAO,CAAC,CAAC;AACjC;AAKO,SAAS,UAAU,KAAqC;AAC7D,SAAO,SAAS,EAAE,GAAG;AACvB;AAMO,SAAS,SAAS,KAAa,OAAyB;AAC7D,QAAM,QAAQ,SAAS,GAEjB,UADc,UAAkB,KAAK,MAAM,CAAC,IACpB,MAAM,GAAG;AAEvC,EAAI,UAAU,iBACZ,WAAW,IAEX,UAAU,KAAK,MAAM,OAAO,GAG9B,MAAM,GAAG,IAAI;AACf;AAKO,SAAS,aAAmB;AACjC,YAAU,KAAK,OAAO,CAAC,CAAC,GACxB,UAAU,KAAK,MAAM,CAAC;AACxB;AAMO,SAAS,aAAsD;AACpE,SAAO,UAAU,KAAK,SAAS,oBAAI,IAAI,CAAC;AAC1C;AAKO,SAAS,qBACd,KACwC;AACxC,SAAO,WAAW,EAAE,IAAI,GAAG;AAC7B;AAKO,SAAS,qBACd,KACA,SACM;AACN,aAAW,EAAE,IAAI,KAAK,OAAO;AAC/B;AAKO,SAAS,uBAAuB,KAAmB;AACxD,aAAW,EAAE,OAAO,GAAG;AACzB;",
5
- "names": []
6
- }
@@ -1,32 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var extensions_exports = {};
16
- __export(extensions_exports, {
17
- extensions: () => extensions
18
- });
19
- module.exports = __toCommonJS(extensions_exports);
20
- const extensions = [
21
- ".ios.js",
22
- ".native.js",
23
- ".native.ts",
24
- ".native.tsx",
25
- ".js",
26
- ".jsx",
27
- ".json",
28
- ".ts",
29
- ".tsx",
30
- ".mjs"
31
- ];
32
- //# sourceMappingURL=extensions.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/extensions.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
5
- "names": []
6
- }
@@ -1,159 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
32
- var extract_exports = {};
33
- __export(extract_exports, {
34
- tamaguiExtractPlugin: () => tamaguiExtractPlugin
35
- });
36
- module.exports = __toCommonJS(extract_exports);
37
- var Static = __toESM(require("@tamagui/static-worker"), 1),
38
- import_static_worker = require("@tamagui/static-worker"),
39
- import_node_path = __toESM(require("node:path"), 1),
40
- import_vite = require("vite"),
41
- import_loadTamagui = require("./loadTamagui.cjs"),
42
- import_node_crypto = require("node:crypto");
43
- function tamaguiExtractPlugin(optionsIn) {
44
- if (optionsIn?.disable) return {
45
- name: "tamagui-extract"
46
- };
47
- const getHash = input => (0, import_node_crypto.createHash)("sha1").update(input).digest("base64"),
48
- clearCompilerCache = () => {
49
- memoryCache = {}, cacheSize = 0;
50
- };
51
- let memoryCache = {},
52
- cacheSize = 0;
53
- const cssMap = /* @__PURE__ */new Map();
54
- let config, server;
55
- const virtualExt = ".tamagui.css",
56
- getAbsoluteVirtualFileId = filePath => filePath.startsWith(config.root) ? filePath : (0, import_vite.normalizePath)(import_node_path.default.join(config.root, filePath));
57
- function isVite6AndNotClient(environment) {
58
- return environment?.name && environment.name !== "client";
59
- }
60
- function isVite6Native(environment) {
61
- return environment?.name && (environment.name === "ios" || environment.name === "android");
62
- }
63
- function invalidateModule(absoluteId) {
64
- if (!server) return;
65
- const {
66
- moduleGraph
67
- } = server,
68
- modules = moduleGraph.getModulesByFile(absoluteId);
69
- if (modules) for (const module2 of modules) moduleGraph.invalidateModule(module2), module2.lastHMRTimestamp = module2.lastInvalidationTimestamp || Date.now();
70
- }
71
- return {
72
- name: "tamagui-extract",
73
- enforce: "pre",
74
- configureServer(_server) {
75
- server = _server;
76
- },
77
- async buildStart() {
78
- await (0, import_loadTamagui.loadTamaguiBuildConfig)(optionsIn);
79
- },
80
- async closeBundle() {},
81
- config(userConf) {
82
- userConf.optimizeDeps ||= {}, userConf.optimizeDeps.include ||= [], userConf.optimizeDeps.include.push("@tamagui/core/inject-styles");
83
- },
84
- async configResolved(resolvedConfig) {
85
- config = resolvedConfig;
86
- },
87
- async resolveId(source) {
88
- if (isVite6Native(this.environment) || import_loadTamagui.tamaguiOptions?.disableServerOptimization && isVite6AndNotClient(this.environment)) return;
89
- const [validId, query] = source.split("?");
90
- if (!validId.endsWith(virtualExt)) return;
91
- const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(validId);
92
- if (cssMap.has(absoluteId)) return absoluteId + (query ? `?${query}` : "");
93
- },
94
- /**
95
- * TODO
96
- *
97
- * mainFields module:jsx breaks, so lets just have a mapping here
98
- * where we load() and map it to the jsx path before transform
99
- *
100
- */
101
- async load(id) {
102
- if (import_loadTamagui.disableStatic || isVite6Native(this.environment) || import_loadTamagui.tamaguiOptions?.disableServerOptimization && isVite6AndNotClient(this.environment)) return;
103
- const [validId] = id.split("?");
104
- return cssMap.get(validId);
105
- },
106
- transform: {
107
- order: "pre",
108
- async handler(code, id) {
109
- if (import_loadTamagui.disableStatic || isVite6Native(this.environment) || import_loadTamagui.tamaguiOptions?.disableServerOptimization && isVite6AndNotClient(this.environment)) return;
110
- const [validId] = id.split("?");
111
- if (!validId.endsWith(".tsx")) return;
112
- const firstCommentIndex = code.indexOf("// "),
113
- {
114
- shouldDisable,
115
- shouldPrintDebug
116
- } = await (0, import_static_worker.getPragmaOptions)({
117
- source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : "",
118
- path: validId
119
- });
120
- if (shouldPrintDebug && (console.trace(`Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}`), console.info(`
121
-
122
- Original source:
123
- ${code}
124
-
125
- `)), shouldDisable) return;
126
- const cacheEnv = this.environment.name === "client" || this.environment.name === "ssr" ?
127
- // same cache key for ssr and web since they are the same
128
- "web" : this.environment.name,
129
- cacheKey = getHash(`${cacheEnv}${code}${id}`),
130
- cached = memoryCache[cacheKey];
131
- if (cached) return cached;
132
- let extracted;
133
- try {
134
- extracted = await Static.extractToClassNames({
135
- source: code,
136
- sourcePath: validId,
137
- options: import_loadTamagui.tamaguiOptions,
138
- shouldPrintDebug
139
- });
140
- } catch (err) {
141
- console.error(err instanceof Error ? err.message : String(err));
142
- return;
143
- }
144
- if (!extracted) return;
145
- const rootRelativeId = `${validId}${virtualExt}`,
146
- absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
147
- let source = extracted.js;
148
- extracted.styles && (this.addWatchFile(rootRelativeId), server && cssMap.has(absoluteId) && invalidateModule(rootRelativeId), source = `${source}
149
- import "${rootRelativeId}";`, cssMap.set(absoluteId, extracted.styles));
150
- const codeOut = source.toString(),
151
- out = {
152
- code: codeOut,
153
- map: extracted.map
154
- };
155
- return cacheSize += codeOut.length, cacheSize > 26214400 && clearCompilerCache(), memoryCache[cacheKey] = out, out;
156
- }
157
- }
158
- };
159
- }
@@ -1,148 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var extract_exports = {};
24
- __export(extract_exports, {
25
- tamaguiExtractPlugin: () => tamaguiExtractPlugin
26
- });
27
- module.exports = __toCommonJS(extract_exports);
28
- var Static = __toESM(require("@tamagui/static-worker"), 1), import_static_worker = require("@tamagui/static-worker"), import_node_path = __toESM(require("node:path"), 1), import_vite = require("vite"), import_loadTamagui = require("./loadTamagui"), import_node_crypto = require("node:crypto");
29
- function tamaguiExtractPlugin(optionsIn) {
30
- if (optionsIn?.disable)
31
- return {
32
- name: "tamagui-extract"
33
- };
34
- const getHash = (input) => (0, import_node_crypto.createHash)("sha1").update(input).digest("base64"), clearCompilerCache = () => {
35
- memoryCache = {}, cacheSize = 0;
36
- };
37
- let memoryCache = {}, cacheSize = 0;
38
- const cssMap = /* @__PURE__ */ new Map();
39
- let config, server;
40
- const virtualExt = ".tamagui.css", getAbsoluteVirtualFileId = (filePath) => filePath.startsWith(config.root) ? filePath : (0, import_vite.normalizePath)(import_node_path.default.join(config.root, filePath));
41
- function isVite6AndNotClient(environment) {
42
- return environment?.name && environment.name !== "client";
43
- }
44
- function isVite6Native(environment) {
45
- return environment?.name && (environment.name === "ios" || environment.name === "android");
46
- }
47
- function invalidateModule(absoluteId) {
48
- if (!server) return;
49
- const { moduleGraph } = server, modules = moduleGraph.getModulesByFile(absoluteId);
50
- if (modules)
51
- for (const module2 of modules)
52
- moduleGraph.invalidateModule(module2), module2.lastHMRTimestamp = module2.lastInvalidationTimestamp || Date.now();
53
- }
54
- return {
55
- name: "tamagui-extract",
56
- enforce: "pre",
57
- configureServer(_server) {
58
- server = _server;
59
- },
60
- async buildStart() {
61
- await (0, import_loadTamagui.loadTamaguiBuildConfig)(optionsIn);
62
- },
63
- async closeBundle() {
64
- },
65
- config(userConf) {
66
- userConf.optimizeDeps ||= {}, userConf.optimizeDeps.include ||= [], userConf.optimizeDeps.include.push("@tamagui/core/inject-styles");
67
- },
68
- async configResolved(resolvedConfig) {
69
- config = resolvedConfig;
70
- },
71
- async resolveId(source) {
72
- if (isVite6Native(this.environment) || import_loadTamagui.tamaguiOptions?.disableServerOptimization && isVite6AndNotClient(this.environment))
73
- return;
74
- const [validId, query] = source.split("?");
75
- if (!validId.endsWith(virtualExt))
76
- return;
77
- const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(validId);
78
- if (cssMap.has(absoluteId))
79
- return absoluteId + (query ? `?${query}` : "");
80
- },
81
- /**
82
- * TODO
83
- *
84
- * mainFields module:jsx breaks, so lets just have a mapping here
85
- * where we load() and map it to the jsx path before transform
86
- *
87
- */
88
- async load(id) {
89
- if (import_loadTamagui.disableStatic || isVite6Native(this.environment) || import_loadTamagui.tamaguiOptions?.disableServerOptimization && isVite6AndNotClient(this.environment))
90
- return;
91
- const [validId] = id.split("?");
92
- return cssMap.get(validId);
93
- },
94
- transform: {
95
- order: "pre",
96
- async handler(code, id) {
97
- if (import_loadTamagui.disableStatic || isVite6Native(this.environment) || import_loadTamagui.tamaguiOptions?.disableServerOptimization && isVite6AndNotClient(this.environment))
98
- return;
99
- const [validId] = id.split("?");
100
- if (!validId.endsWith(".tsx"))
101
- return;
102
- const firstCommentIndex = code.indexOf("// "), { shouldDisable, shouldPrintDebug } = await (0, import_static_worker.getPragmaOptions)({
103
- source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : "",
104
- path: validId
105
- });
106
- if (shouldPrintDebug && (console.trace(
107
- `Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}`
108
- ), console.info(`
109
-
110
- Original source:
111
- ${code}
112
-
113
- `)), shouldDisable)
114
- return;
115
- const cacheEnv = this.environment.name === "client" || this.environment.name === "ssr" ? (
116
- // same cache key for ssr and web since they are the same
117
- "web"
118
- ) : this.environment.name, cacheKey = getHash(`${cacheEnv}${code}${id}`), cached = memoryCache[cacheKey];
119
- if (cached)
120
- return cached;
121
- let extracted;
122
- try {
123
- extracted = await Static.extractToClassNames({
124
- source: code,
125
- sourcePath: validId,
126
- options: import_loadTamagui.tamaguiOptions,
127
- shouldPrintDebug
128
- });
129
- } catch (err) {
130
- console.error(err instanceof Error ? err.message : String(err));
131
- return;
132
- }
133
- if (!extracted)
134
- return;
135
- const rootRelativeId = `${validId}${virtualExt}`, absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
136
- let source = extracted.js;
137
- extracted.styles && (this.addWatchFile(rootRelativeId), server && cssMap.has(absoluteId) && invalidateModule(rootRelativeId), source = `${source}
138
- import "${rootRelativeId}";`, cssMap.set(absoluteId, extracted.styles));
139
- const codeOut = source.toString(), out = {
140
- code: codeOut,
141
- map: extracted.map
142
- };
143
- return cacheSize += codeOut.length, cacheSize > 26214400 && clearCompilerCache(), memoryCache[cacheKey] = out, out;
144
- }
145
- }
146
- };
147
- }
148
- //# sourceMappingURL=extract.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/extract.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,aAAwB,+CACxB,uBAAiC,mCACjC,mBAAiB,kCAEjB,cAAgD,iBAChD,qBAAsE,0BAEtE,qBAA2B;AAEpB,SAAS,qBAAqB,WAA6C;AAChF,MAAI,WAAW;AACb,WAAO;AAAA,MACL,MAAM;AAAA,IACR;AAGF,QAAM,UAAU,CAAC,cAAkB,+BAAW,MAAM,EAAE,OAAO,KAAK,EAAE,OAAO,QAAQ,GAE7E,qBAAqB,MAAM;AAC/B,kBAAc,CAAC,GACf,YAAY;AAAA,EACd;AAEA,MAAI,cAAc,CAAC,GACf,YAAY;AAEhB,QAAM,SAAS,oBAAI,IAAoB;AAEvC,MAAI,QACA;AACJ,QAAM,aAAa,gBAEb,2BAA2B,CAAC,aAC5B,SAAS,WAAW,OAAO,IAAI,IAC1B,eAEF,2BAAc,iBAAAA,QAAK,K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AAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAC9D;AAAA,QACF;AAEA,YAAI,CAAC;AACH;AAGF,cAAM,iBAAiB,GAAG,OAAO,GAAG,UAAU,IACxC,aAAa,yBAAyB,cAAc;AAE1D,YAAI,SAAS,UAAU;AAEvB,QAAI,UAAU,WACZ,KAAK,aAAa,cAAc,GAE5B,UAAU,OAAO,IAAI,UAAU,KACjC,iBAAiB,cAAc,GAGjC,SAAS,GAAG,MAAM;AAAA,UAAa,cAAc,MAC7C,OAAO,IAAI,YAAY,UAAU,MAAM;AAGzC,cAAM,UAAU,OAAO,SAAS,GAC1B,MAAM;AAAA,UACV,MAAM;AAAA,UACN,KAAK,UAAU;AAAA,QACjB;AAEA,4BAAa,QAAQ,QAEjB,YAAY,YACd,mBAAmB,GAErB,YAAY,QAAQ,IAAI,KAEjB;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;",
5
- "names": ["path", "module"]
6
- }
package/dist/cjs/index.js DELETED
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var index_exports = {};
13
- module.exports = __toCommonJS(index_exports);
14
- __reExport(index_exports, require("./plugin"), module.exports);
15
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,qBAAd;",
5
- "names": []
6
- }
@@ -1,75 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var loadTamagui_exports = {};
24
- __export(loadTamagui_exports, {
25
- cleanup: () => cleanup,
26
- ensureFullConfigLoaded: () => ensureFullConfigLoaded,
27
- getLoadPromise: () => getLoadPromise,
28
- getTamaguiOptions: () => getTamaguiOptions,
29
- loadTamaguiBuildConfig: () => loadTamaguiBuildConfig
30
- });
31
- module.exports = __toCommonJS(loadTamagui_exports);
32
- var StaticWorker = __toESM(require("@tamagui/static-worker"), 1);
33
- const LOAD_STATE_KEY = "__tamagui_load_state__";
34
- function getLoadState() {
35
- return globalThis[LOAD_STATE_KEY] || (globalThis[LOAD_STATE_KEY] = {
36
- loadPromise: null,
37
- loadedOptions: null,
38
- fullConfigLoaded: !1,
39
- fullConfigLoadPromise: null
40
- }), globalThis[LOAD_STATE_KEY];
41
- }
42
- function getTamaguiOptions() {
43
- return getLoadState().loadedOptions;
44
- }
45
- function getLoadPromise() {
46
- return getLoadState().loadPromise;
47
- }
48
- async function loadTamaguiBuildConfig(optionsIn) {
49
- const state = getLoadState();
50
- return state.loadedOptions ? state.loadedOptions : (state.loadPromise || (state.loadPromise = (async () => {
51
- const options = await StaticWorker.loadTamaguiBuildConfig({
52
- ...optionsIn,
53
- platform: "web"
54
- });
55
- return state.loadedOptions = options, options;
56
- })()), state.loadPromise);
57
- }
58
- async function ensureFullConfigLoaded() {
59
- const state = getLoadState();
60
- if (!state.fullConfigLoaded)
61
- return state.fullConfigLoadPromise || (state.fullConfigLoadPromise = (async () => {
62
- const options = await loadTamaguiBuildConfig();
63
- !options.disableWatchTamaguiConfig && !options.disable && await StaticWorker.loadTamagui({
64
- components: ["tamagui"],
65
- platform: "web",
66
- ...options
67
- }), state.fullConfigLoaded = !0;
68
- })()), state.fullConfigLoadPromise;
69
- }
70
- async function cleanup() {
71
- await StaticWorker.destroyPool();
72
- const state = getLoadState();
73
- state.loadPromise = null, state.loadedOptions = null, state.fullConfigLoaded = !1, state.fullConfigLoadPromise = null;
74
- }
75
- //# sourceMappingURL=loadTamagui.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/loadTamagui.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAI9B,MAAM,iBAAiB;AASvB,SAAS,eAA0B;AACjC,SAAM,WAAmB,cAAc,MACnC,WAAmB,cAAc,IAAI;AAAA,IACrC,aAAa;AAAA,IACb,eAAe;AAAA,IACf,kBAAkB;AAAA,IAClB,uBAAuB;AAAA,EACzB,IAEM,WA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