@tamagui/static-worker 1.139.0 → 1.139.2
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/cjs/index.cjs +39 -24
- package/dist/cjs/index.js +37 -24
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +37 -24
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +39 -24
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +49 -40
- package/types/index.d.ts.map +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -51,20 +51,34 @@ const import_meta = {},
|
|
|
51
51
|
} = await import("@tamagui/static");
|
|
52
52
|
return Static.getPragmaOptions(props);
|
|
53
53
|
},
|
|
54
|
-
getWorkerPath = () => typeof import_meta < "u" && import_meta.url ? (0, import_node_url.fileURLToPath)(import_meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js")
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
getWorkerPath = () => typeof import_meta < "u" && import_meta.url ? (0, import_node_url.fileURLToPath)(import_meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js"),
|
|
55
|
+
POOL_KEY = "__tamagui_piscina_pool__",
|
|
56
|
+
CLOSING_KEY = "__tamagui_piscina_closing__";
|
|
57
|
+
function getSharedPool() {
|
|
58
|
+
return globalThis[POOL_KEY] ?? null;
|
|
59
|
+
}
|
|
60
|
+
function setSharedPool(pool) {
|
|
61
|
+
globalThis[POOL_KEY] = pool;
|
|
62
|
+
}
|
|
63
|
+
function isClosing() {
|
|
64
|
+
return globalThis[CLOSING_KEY] === !0;
|
|
65
|
+
}
|
|
66
|
+
function setClosing(value) {
|
|
67
|
+
globalThis[CLOSING_KEY] = value;
|
|
68
|
+
}
|
|
57
69
|
function getPool() {
|
|
58
|
-
|
|
70
|
+
let pool = getSharedPool();
|
|
71
|
+
return pool || (pool = new import_piscina.default({
|
|
59
72
|
filename: getWorkerPath(),
|
|
60
73
|
// Single worker for state consistency and simpler caching
|
|
61
74
|
minThreads: 1,
|
|
62
75
|
maxThreads: 1,
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
// Never terminate due to idle - worker stays alive until close() or process exit
|
|
77
|
+
// This prevents "Terminating worker thread" errors from Piscina during idle
|
|
78
|
+
idleTimeout: Number.POSITIVE_INFINITY
|
|
79
|
+
}), pool.on("error", err => {
|
|
80
|
+
isClosing() || (err && typeof err == "object" && "message" in err ? String(err.message) : "").includes("Terminating worker thread") || console.error("[tamagui] Worker pool error:", err);
|
|
81
|
+
}), setSharedPool(pool)), pool;
|
|
68
82
|
}
|
|
69
83
|
async function loadTamagui(options) {
|
|
70
84
|
const pool = getPool(),
|
|
@@ -141,7 +155,7 @@ async function watchTamaguiConfig(options) {
|
|
|
141
155
|
const originalDispose = watcher.dispose;
|
|
142
156
|
return {
|
|
143
157
|
dispose: () => {
|
|
144
|
-
originalDispose(),
|
|
158
|
+
originalDispose(), getSharedPool() && clearWorkerCache();
|
|
145
159
|
}
|
|
146
160
|
};
|
|
147
161
|
}
|
|
@@ -152,32 +166,33 @@ async function loadTamaguiBuildConfig(tamaguiOptions) {
|
|
|
152
166
|
return Static.loadTamaguiBuildConfigSync(tamaguiOptions);
|
|
153
167
|
}
|
|
154
168
|
async function clearWorkerCache() {
|
|
155
|
-
|
|
169
|
+
const pool = getSharedPool();
|
|
170
|
+
if (!pool || isClosing()) return;
|
|
156
171
|
const task = {
|
|
157
172
|
type: "clearCache"
|
|
158
173
|
};
|
|
159
|
-
await
|
|
174
|
+
await pool.run(task, {
|
|
160
175
|
name: "runTask"
|
|
161
176
|
});
|
|
162
177
|
}
|
|
163
178
|
async function destroyPool() {
|
|
164
|
-
|
|
165
|
-
|
|
179
|
+
const pool = getSharedPool();
|
|
180
|
+
if (pool) {
|
|
181
|
+
setClosing(!0);
|
|
166
182
|
try {
|
|
167
|
-
await
|
|
168
|
-
} catch (err) {
|
|
169
|
-
if (err && typeof err == "object" && "message" in err && !String(err.message).includes("Terminating worker thread")) throw err;
|
|
183
|
+
await pool.close();
|
|
170
184
|
} finally {
|
|
171
|
-
|
|
185
|
+
setSharedPool(null), setClosing(!1);
|
|
172
186
|
}
|
|
173
187
|
}
|
|
174
188
|
}
|
|
175
189
|
function getPoolStats() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
const pool = getSharedPool();
|
|
191
|
+
return pool ? {
|
|
192
|
+
threads: pool.threads.length,
|
|
193
|
+
queueSize: pool.queueSize,
|
|
194
|
+
completed: pool.completed,
|
|
195
|
+
duration: pool.duration,
|
|
196
|
+
utilization: pool.utilization
|
|
182
197
|
} : null;
|
|
183
198
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -37,19 +37,32 @@ var import_node_url = require("node:url"), import_piscina = __toESM(require("pis
|
|
|
37
37
|
const import_meta = {}, getPragmaOptions = async (props) => {
|
|
38
38
|
const { default: Static } = await import("@tamagui/static");
|
|
39
39
|
return Static.getPragmaOptions(props);
|
|
40
|
-
}, getWorkerPath = () => typeof import_meta < "u" && import_meta.url ? (0, import_node_url.fileURLToPath)(import_meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js");
|
|
41
|
-
|
|
40
|
+
}, getWorkerPath = () => typeof import_meta < "u" && import_meta.url ? (0, import_node_url.fileURLToPath)(import_meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js"), POOL_KEY = "__tamagui_piscina_pool__", CLOSING_KEY = "__tamagui_piscina_closing__";
|
|
41
|
+
function getSharedPool() {
|
|
42
|
+
return globalThis[POOL_KEY] ?? null;
|
|
43
|
+
}
|
|
44
|
+
function setSharedPool(pool) {
|
|
45
|
+
globalThis[POOL_KEY] = pool;
|
|
46
|
+
}
|
|
47
|
+
function isClosing() {
|
|
48
|
+
return globalThis[CLOSING_KEY] === !0;
|
|
49
|
+
}
|
|
50
|
+
function setClosing(value) {
|
|
51
|
+
globalThis[CLOSING_KEY] = value;
|
|
52
|
+
}
|
|
42
53
|
function getPool() {
|
|
43
|
-
|
|
54
|
+
let pool = getSharedPool();
|
|
55
|
+
return pool || (pool = new import_piscina.default({
|
|
44
56
|
filename: getWorkerPath(),
|
|
45
57
|
// Single worker for state consistency and simpler caching
|
|
46
58
|
minThreads: 1,
|
|
47
59
|
maxThreads: 1,
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
// Never terminate due to idle - worker stays alive until close() or process exit
|
|
61
|
+
// This prevents "Terminating worker thread" errors from Piscina during idle
|
|
62
|
+
idleTimeout: Number.POSITIVE_INFINITY
|
|
63
|
+
}), pool.on("error", (err) => {
|
|
64
|
+
isClosing() || (err && typeof err == "object" && "message" in err ? String(err.message) : "").includes("Terminating worker thread") || console.error("[tamagui] Worker pool error:", err);
|
|
65
|
+
}), setSharedPool(pool)), pool;
|
|
53
66
|
}
|
|
54
67
|
async function loadTamagui(options) {
|
|
55
68
|
const pool = getPool(), task = {
|
|
@@ -119,7 +132,7 @@ async function watchTamaguiConfig(options) {
|
|
|
119
132
|
const originalDispose = watcher.dispose;
|
|
120
133
|
return {
|
|
121
134
|
dispose: () => {
|
|
122
|
-
originalDispose(),
|
|
135
|
+
originalDispose(), getSharedPool() && clearWorkerCache();
|
|
123
136
|
}
|
|
124
137
|
};
|
|
125
138
|
}
|
|
@@ -128,30 +141,30 @@ async function loadTamaguiBuildConfig(tamaguiOptions) {
|
|
|
128
141
|
return Static.loadTamaguiBuildConfigSync(tamaguiOptions);
|
|
129
142
|
}
|
|
130
143
|
async function clearWorkerCache() {
|
|
131
|
-
|
|
144
|
+
const pool = getSharedPool();
|
|
145
|
+
if (!pool || isClosing()) return;
|
|
132
146
|
const task = { type: "clearCache" };
|
|
133
|
-
await
|
|
147
|
+
await pool.run(task, { name: "runTask" });
|
|
134
148
|
}
|
|
135
149
|
async function destroyPool() {
|
|
136
|
-
|
|
137
|
-
|
|
150
|
+
const pool = getSharedPool();
|
|
151
|
+
if (pool) {
|
|
152
|
+
setClosing(!0);
|
|
138
153
|
try {
|
|
139
|
-
await
|
|
140
|
-
} catch (err) {
|
|
141
|
-
if (err && typeof err == "object" && "message" in err && !String(err.message).includes("Terminating worker thread"))
|
|
142
|
-
throw err;
|
|
154
|
+
await pool.close();
|
|
143
155
|
} finally {
|
|
144
|
-
|
|
156
|
+
setSharedPool(null), setClosing(!1);
|
|
145
157
|
}
|
|
146
158
|
}
|
|
147
159
|
}
|
|
148
160
|
function getPoolStats() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
const pool = getSharedPool();
|
|
162
|
+
return pool ? {
|
|
163
|
+
threads: pool.threads.length,
|
|
164
|
+
queueSize: pool.queueSize,
|
|
165
|
+
completed: pool.completed,
|
|
166
|
+
duration: pool.duration,
|
|
167
|
+
utilization: pool.utilization
|
|
155
168
|
} : null;
|
|
156
169
|
}
|
|
157
170
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAA8B,qBAC9B,iBAAoB;AAbpB,wBAqBa,mBAAmB,OAAO,UAGjC;AACJ,QAAM,EAAE,SAAS,OAAO,IAAI,MAAM,OAAO,iBAAiB;AA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tB,WAAW,KAAK;AAAA,IAChB,WAAW,KAAK;AAAA,IAChB,UAAU,KAAK;AAAA,IACf,aAAa,KAAK;AAAA,EACpB,IARS;AASX;",
|
|
5
5
|
"names": ["Piscina"]
|
|
6
6
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -3,19 +3,32 @@ import Piscina from "piscina";
|
|
|
3
3
|
const getPragmaOptions = async (props) => {
|
|
4
4
|
const { default: Static } = await import("@tamagui/static");
|
|
5
5
|
return Static.getPragmaOptions(props);
|
|
6
|
-
}, getWorkerPath = () => typeof import.meta < "u" && import.meta.url ? fileURLToPath(import.meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js");
|
|
7
|
-
|
|
6
|
+
}, getWorkerPath = () => typeof import.meta < "u" && import.meta.url ? fileURLToPath(import.meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js"), POOL_KEY = "__tamagui_piscina_pool__", CLOSING_KEY = "__tamagui_piscina_closing__";
|
|
7
|
+
function getSharedPool() {
|
|
8
|
+
return globalThis[POOL_KEY] ?? null;
|
|
9
|
+
}
|
|
10
|
+
function setSharedPool(pool) {
|
|
11
|
+
globalThis[POOL_KEY] = pool;
|
|
12
|
+
}
|
|
13
|
+
function isClosing() {
|
|
14
|
+
return globalThis[CLOSING_KEY] === !0;
|
|
15
|
+
}
|
|
16
|
+
function setClosing(value) {
|
|
17
|
+
globalThis[CLOSING_KEY] = value;
|
|
18
|
+
}
|
|
8
19
|
function getPool() {
|
|
9
|
-
|
|
20
|
+
let pool = getSharedPool();
|
|
21
|
+
return pool || (pool = new Piscina({
|
|
10
22
|
filename: getWorkerPath(),
|
|
11
23
|
// Single worker for state consistency and simpler caching
|
|
12
24
|
minThreads: 1,
|
|
13
25
|
maxThreads: 1,
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
// Never terminate due to idle - worker stays alive until close() or process exit
|
|
27
|
+
// This prevents "Terminating worker thread" errors from Piscina during idle
|
|
28
|
+
idleTimeout: Number.POSITIVE_INFINITY
|
|
29
|
+
}), pool.on("error", (err) => {
|
|
30
|
+
isClosing() || (err && typeof err == "object" && "message" in err ? String(err.message) : "").includes("Terminating worker thread") || console.error("[tamagui] Worker pool error:", err);
|
|
31
|
+
}), setSharedPool(pool)), pool;
|
|
19
32
|
}
|
|
20
33
|
async function loadTamagui(options) {
|
|
21
34
|
const pool = getPool(), task = {
|
|
@@ -85,7 +98,7 @@ async function watchTamaguiConfig(options) {
|
|
|
85
98
|
const originalDispose = watcher.dispose;
|
|
86
99
|
return {
|
|
87
100
|
dispose: () => {
|
|
88
|
-
originalDispose(),
|
|
101
|
+
originalDispose(), getSharedPool() && clearWorkerCache();
|
|
89
102
|
}
|
|
90
103
|
};
|
|
91
104
|
}
|
|
@@ -94,30 +107,30 @@ async function loadTamaguiBuildConfig(tamaguiOptions) {
|
|
|
94
107
|
return Static.loadTamaguiBuildConfigSync(tamaguiOptions);
|
|
95
108
|
}
|
|
96
109
|
async function clearWorkerCache() {
|
|
97
|
-
|
|
110
|
+
const pool = getSharedPool();
|
|
111
|
+
if (!pool || isClosing()) return;
|
|
98
112
|
const task = { type: "clearCache" };
|
|
99
|
-
await
|
|
113
|
+
await pool.run(task, { name: "runTask" });
|
|
100
114
|
}
|
|
101
115
|
async function destroyPool() {
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
const pool = getSharedPool();
|
|
117
|
+
if (pool) {
|
|
118
|
+
setClosing(!0);
|
|
104
119
|
try {
|
|
105
|
-
await
|
|
106
|
-
} catch (err) {
|
|
107
|
-
if (err && typeof err == "object" && "message" in err && !String(err.message).includes("Terminating worker thread"))
|
|
108
|
-
throw err;
|
|
120
|
+
await pool.close();
|
|
109
121
|
} finally {
|
|
110
|
-
|
|
122
|
+
setSharedPool(null), setClosing(!1);
|
|
111
123
|
}
|
|
112
124
|
}
|
|
113
125
|
}
|
|
114
126
|
function getPoolStats() {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
const pool = getSharedPool();
|
|
128
|
+
return pool ? {
|
|
129
|
+
threads: pool.threads.length,
|
|
130
|
+
queueSize: pool.queueSize,
|
|
131
|
+
completed: pool.completed,
|
|
132
|
+
duration: pool.duration,
|
|
133
|
+
utilization: pool.utilization
|
|
121
134
|
} : null;
|
|
122
135
|
}
|
|
123
136
|
export {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAYA,SAAS,qBAAqB;AAC9B,OAAO,aAAa;AAQb,MAAM,mBAAmB,OAAO,UAGjC;AACJ,QAAM,EAAE,SAAS,OAAO,IAAI,MAAM,OAAO,iBAAiB;AAC1D,SAAO,OAAO,iBAAiB,KAAK;AACtC,GAGM,gBAAgB,MAGhB,OAAO,cAAgB,OAAe,YAAY,MACjC,cAAc,YAAY,QAAQ,wBAAwB,CAAC,EAE5D,QAAQ,UAAU,KAAK,IAIpC,gBAAgB,wBAAwB,EAAE,QAAQ,UAAU,KAAK;
|
|
4
|
+
"mappings": "AAYA,SAAS,qBAAqB;AAC9B,OAAO,aAAa;AAQb,MAAM,mBAAmB,OAAO,UAGjC;AACJ,QAAM,EAAE,SAAS,OAAO,IAAI,MAAM,OAAO,iBAAiB;AAC1D,SAAO,OAAO,iBAAiB,KAAK;AACtC,GAGM,gBAAgB,MAGhB,OAAO,cAAgB,OAAe,YAAY,MACjC,cAAc,YAAY,QAAQ,wBAAwB,CAAC,EAE5D,QAAQ,UAAU,KAAK,IAIpC,gBAAgB,wBAAwB,EAAE,QAAQ,UAAU,KAAK,GAIpE,WAAW,4BACX,cAAc;AAEpB,SAAS,gBAAgC;AACvC,SAAQ,W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O,OAAO,2BAA2B,cAAc;AACzD;AAMA,eAAsB,mBAAkC;AACtD,QAAM,OAAO,cAAc;AAC3B,MAAI,CAAC,QAAQ,UAAU,EAAG;AAE1B,QAAM,OAAO,EAAE,MAAM,aAAa;AAClC,QAAM,KAAK,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC1C;AAMA,eAAsB,cAA6B;AACjD,QAAM,OAAO,cAAc;AAC3B,MAAI,MAAM;AACR,eAAW,EAAI;AACf,QAAI;AACF,YAAM,KAAK,MAAM;AAAA,IACnB,UAAE;AACA,oBAAc,IAAI,GAClB,WAAW,EAAK;AAAA,IAClB;AAAA,EACF;AACF;AAKO,SAAS,eAAe;AAC7B,QAAM,OAAO,cAAc;AAC3B,SAAK,OAGE;AAAA,IACL,SAAS,KAAK,QAAQ;AAAA,IACtB,WAAW,KAAK;AAAA,IAChB,WAAW,KAAK;AAAA,IAChB,UAAU,KAAK;AAAA,IACf,aAAa,KAAK;AAAA,EACpB,IARS;AASX;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -6,20 +6,34 @@ const getPragmaOptions = async props => {
|
|
|
6
6
|
} = await import("@tamagui/static");
|
|
7
7
|
return Static.getPragmaOptions(props);
|
|
8
8
|
},
|
|
9
|
-
getWorkerPath = () => typeof import.meta < "u" && import.meta.url ? fileURLToPath(import.meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js")
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
getWorkerPath = () => typeof import.meta < "u" && import.meta.url ? fileURLToPath(import.meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js"),
|
|
10
|
+
POOL_KEY = "__tamagui_piscina_pool__",
|
|
11
|
+
CLOSING_KEY = "__tamagui_piscina_closing__";
|
|
12
|
+
function getSharedPool() {
|
|
13
|
+
return globalThis[POOL_KEY] ?? null;
|
|
14
|
+
}
|
|
15
|
+
function setSharedPool(pool) {
|
|
16
|
+
globalThis[POOL_KEY] = pool;
|
|
17
|
+
}
|
|
18
|
+
function isClosing() {
|
|
19
|
+
return globalThis[CLOSING_KEY] === !0;
|
|
20
|
+
}
|
|
21
|
+
function setClosing(value) {
|
|
22
|
+
globalThis[CLOSING_KEY] = value;
|
|
23
|
+
}
|
|
12
24
|
function getPool() {
|
|
13
|
-
|
|
25
|
+
let pool = getSharedPool();
|
|
26
|
+
return pool || (pool = new Piscina({
|
|
14
27
|
filename: getWorkerPath(),
|
|
15
28
|
// Single worker for state consistency and simpler caching
|
|
16
29
|
minThreads: 1,
|
|
17
30
|
maxThreads: 1,
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
// Never terminate due to idle - worker stays alive until close() or process exit
|
|
32
|
+
// This prevents "Terminating worker thread" errors from Piscina during idle
|
|
33
|
+
idleTimeout: Number.POSITIVE_INFINITY
|
|
34
|
+
}), pool.on("error", err => {
|
|
35
|
+
isClosing() || (err && typeof err == "object" && "message" in err ? String(err.message) : "").includes("Terminating worker thread") || console.error("[tamagui] Worker pool error:", err);
|
|
36
|
+
}), setSharedPool(pool)), pool;
|
|
23
37
|
}
|
|
24
38
|
async function loadTamagui(options) {
|
|
25
39
|
const pool = getPool(),
|
|
@@ -96,7 +110,7 @@ async function watchTamaguiConfig(options) {
|
|
|
96
110
|
const originalDispose = watcher.dispose;
|
|
97
111
|
return {
|
|
98
112
|
dispose: () => {
|
|
99
|
-
originalDispose(),
|
|
113
|
+
originalDispose(), getSharedPool() && clearWorkerCache();
|
|
100
114
|
}
|
|
101
115
|
};
|
|
102
116
|
}
|
|
@@ -107,33 +121,34 @@ async function loadTamaguiBuildConfig(tamaguiOptions) {
|
|
|
107
121
|
return Static.loadTamaguiBuildConfigSync(tamaguiOptions);
|
|
108
122
|
}
|
|
109
123
|
async function clearWorkerCache() {
|
|
110
|
-
|
|
124
|
+
const pool = getSharedPool();
|
|
125
|
+
if (!pool || isClosing()) return;
|
|
111
126
|
const task = {
|
|
112
127
|
type: "clearCache"
|
|
113
128
|
};
|
|
114
|
-
await
|
|
129
|
+
await pool.run(task, {
|
|
115
130
|
name: "runTask"
|
|
116
131
|
});
|
|
117
132
|
}
|
|
118
133
|
async function destroyPool() {
|
|
119
|
-
|
|
120
|
-
|
|
134
|
+
const pool = getSharedPool();
|
|
135
|
+
if (pool) {
|
|
136
|
+
setClosing(!0);
|
|
121
137
|
try {
|
|
122
|
-
await
|
|
123
|
-
} catch (err) {
|
|
124
|
-
if (err && typeof err == "object" && "message" in err && !String(err.message).includes("Terminating worker thread")) throw err;
|
|
138
|
+
await pool.close();
|
|
125
139
|
} finally {
|
|
126
|
-
|
|
140
|
+
setSharedPool(null), setClosing(!1);
|
|
127
141
|
}
|
|
128
142
|
}
|
|
129
143
|
}
|
|
130
144
|
function getPoolStats() {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
145
|
+
const pool = getSharedPool();
|
|
146
|
+
return pool ? {
|
|
147
|
+
threads: pool.threads.length,
|
|
148
|
+
queueSize: pool.queueSize,
|
|
149
|
+
completed: pool.completed,
|
|
150
|
+
duration: pool.duration,
|
|
151
|
+
utilization: pool.utilization
|
|
137
152
|
} : null;
|
|
138
153
|
}
|
|
139
154
|
export { clearWorkerCache, destroyPool, extractToClassNames, extractToNative, getPoolStats, getPragmaOptions, loadTamagui, loadTamaguiBuildConfig, watchTamaguiConfig };
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fileURLToPath","Piscina","getPragmaOptions","props","default","Static","getWorkerPath","import","meta","url","resolve","replace","require","
|
|
1
|
+
{"version":3,"names":["fileURLToPath","Piscina","getPragmaOptions","props","default","Static","getWorkerPath","import","meta","url","resolve","replace","require","POOL_KEY","CLOSING_KEY","getSharedPool","globalThis","setSharedPool","pool","isClosing","setClosing","value","getPool","filename","minThreads","maxThreads","idleTimeout","Number","POSITIVE_INFINITY","on","err","String","message","includes","console","error","loadTamagui","options","task","type","source","sourcePath","components","shouldPrintDebug","run","name","success","extractToClassNames","params","Error","result","errorMessage","stack","filter","Boolean","join","data","extractToNative","sourceFileName","sourceCode","watchTamaguiConfig","watcher","originalDispose","dispose","clearWorkerCache","loadTamaguiBuildConfig","tamaguiOptions","loadTamaguiBuildConfigSync","destroyPool","close","getPoolStats","threads","length","queueSize","completed","duration","utilization"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAYA,SAASA,aAAA,QAAqB;AAC9B,OAAOC,OAAA,MAAa;AAQb,MAAMC,gBAAA,GAAmB,MAAOC,KAAA,IAGjC;IACJ,MAAM;MAAEC,OAAA,EAASC;IAAO,IAAI,MAAM,OAAO,iBAAiB;IAC1D,OAAOA,MAAA,CAAOH,gBAAA,CAAiBC,KAAK;EACtC;EAGMG,aAAA,GAAgBA,CAAA,KAGhB,OAAOC,MAAA,CAAAC,IAAA,GAAgB,OAAeD,MAAA,CAAAC,IAAA,CAAYC,GAAA,GACjCT,aAAA,CAAcO,MAAA,CAAAC,IAAA,CAAYE,OAAA,CAAQ,wBAAwB,CAAC,EAE5DC,OAAA,CAAQ,UAAU,KAAK,IAIpCC,OAAA,CAAAF,OAAA,CAAgB,wBAAwB,EAAEC,OAAA,CAAQ,UAAU,KAAK;EAIpEE,QAAA,GAAW;EACXC,WAAA,GAAc;AAEpB,SAASC,cAAA,EAAgC;EACvC,OAAQC,UAAA,CAAmBH,QAAQ,KAAK;AAC1C;AAEA,SAASI,cAAcC,IAAA,EAAsB;EACzCF,UAAA,CAAmBH,QAAQ,IAAIK,IAAA;AACnC;AAEA,SAASC,UAAA,EAAqB;EAC5B,OAAQH,UAAA,CAAmBF,WAAW,MAAM;AAC9C;AAEA,SAASM,WAAWC,KAAA,EAAgB;EAChCL,UAAA,CAAmBF,WAA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A,EAAUzD,IAAA,CAAKyD,QAAA;IACfC,WAAA,EAAa1D,IAAA,CAAK0D;EACpB,IARS;AASX","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static-worker",
|
|
3
|
-
"version": "1.139.
|
|
3
|
+
"version": "1.139.2",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
},
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tamagui/static": "1.139.
|
|
38
|
-
"@tamagui/types": "1.139.
|
|
37
|
+
"@tamagui/static": "1.139.2",
|
|
38
|
+
"@tamagui/types": "1.139.2",
|
|
39
39
|
"piscina": "^4.7.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.139.
|
|
42
|
+
"@tamagui/build": "1.139.2",
|
|
43
43
|
"vitest": "^4.0.4"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/index.ts
CHANGED
|
@@ -41,40 +41,55 @@ const getWorkerPath = () => {
|
|
|
41
41
|
return require.resolve('@tamagui/static/worker').replace(/\.mjs$/, '.js')
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// Use globalThis to share pool across module instances (Vite environments)
|
|
45
|
+
const POOL_KEY = '__tamagui_piscina_pool__'
|
|
46
|
+
const CLOSING_KEY = '__tamagui_piscina_closing__'
|
|
47
|
+
|
|
48
|
+
function getSharedPool(): Piscina | null {
|
|
49
|
+
return (globalThis as any)[POOL_KEY] ?? null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function setSharedPool(pool: Piscina | null) {
|
|
53
|
+
;(globalThis as any)[POOL_KEY] = pool
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isClosing(): boolean {
|
|
57
|
+
return (globalThis as any)[CLOSING_KEY] === true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function setClosing(value: boolean) {
|
|
61
|
+
;(globalThis as any)[CLOSING_KEY] = value
|
|
62
|
+
}
|
|
46
63
|
|
|
47
64
|
/**
|
|
48
65
|
* Get or create the Piscina worker pool
|
|
49
66
|
*/
|
|
50
67
|
function getPool(): Piscina {
|
|
51
|
-
|
|
52
|
-
|
|
68
|
+
let pool = getSharedPool()
|
|
69
|
+
if (!pool) {
|
|
70
|
+
pool = new Piscina({
|
|
53
71
|
filename: getWorkerPath(),
|
|
54
72
|
// Single worker for state consistency and simpler caching
|
|
55
73
|
minThreads: 1,
|
|
56
74
|
maxThreads: 1,
|
|
57
|
-
|
|
75
|
+
// Never terminate due to idle - worker stays alive until close() or process exit
|
|
76
|
+
// This prevents "Terminating worker thread" errors from Piscina during idle
|
|
77
|
+
idleTimeout: Number.POSITIVE_INFINITY,
|
|
58
78
|
})
|
|
59
79
|
|
|
60
80
|
// Handle error events to prevent uncaught exceptions during pool destruction
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
piscinaPool.on('error', (err) => {
|
|
64
|
-
// suppress termination errors during shutdown or idle timeout
|
|
65
|
-
if (isClosing) {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
81
|
+
pool.on('error', (err) => {
|
|
82
|
+
if (isClosing()) return
|
|
68
83
|
const message =
|
|
69
84
|
err && typeof err === 'object' && 'message' in err ? String(err.message) : ''
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
// Log other errors for debugging
|
|
85
|
+
// Suppress termination errors (can still occur during explicit close/destroy)
|
|
86
|
+
if (message.includes('Terminating worker thread')) return
|
|
74
87
|
console.error('[tamagui] Worker pool error:', err)
|
|
75
88
|
})
|
|
89
|
+
|
|
90
|
+
setSharedPool(pool)
|
|
76
91
|
}
|
|
77
|
-
return
|
|
92
|
+
return pool
|
|
78
93
|
}
|
|
79
94
|
|
|
80
95
|
/**
|
|
@@ -202,7 +217,7 @@ export async function watchTamaguiConfig(
|
|
|
202
217
|
return {
|
|
203
218
|
dispose: () => {
|
|
204
219
|
originalDispose()
|
|
205
|
-
if (
|
|
220
|
+
if (getSharedPool()) {
|
|
206
221
|
// Fire and forget - errors are handled internally
|
|
207
222
|
clearWorkerCache()
|
|
208
223
|
}
|
|
@@ -228,10 +243,11 @@ export async function loadTamaguiBuildConfig(
|
|
|
228
243
|
* Call this when config files change
|
|
229
244
|
*/
|
|
230
245
|
export async function clearWorkerCache(): Promise<void> {
|
|
231
|
-
|
|
246
|
+
const pool = getSharedPool()
|
|
247
|
+
if (!pool || isClosing()) return
|
|
232
248
|
|
|
233
249
|
const task = { type: 'clearCache' }
|
|
234
|
-
await
|
|
250
|
+
await pool.run(task, { name: 'runTask' })
|
|
235
251
|
}
|
|
236
252
|
|
|
237
253
|
/**
|
|
@@ -239,22 +255,14 @@ export async function clearWorkerCache(): Promise<void> {
|
|
|
239
255
|
* Should be called when the build process completes
|
|
240
256
|
*/
|
|
241
257
|
export async function destroyPool(): Promise<void> {
|
|
242
|
-
|
|
243
|
-
|
|
258
|
+
const pool = getSharedPool()
|
|
259
|
+
if (pool) {
|
|
260
|
+
setClosing(true)
|
|
244
261
|
try {
|
|
245
|
-
await
|
|
246
|
-
} catch (err) {
|
|
247
|
-
// Only ignore worker termination errors during shutdown
|
|
248
|
-
// Re-throw any other errors as they may be legitimate issues
|
|
249
|
-
if (err && typeof err === 'object' && 'message' in err) {
|
|
250
|
-
const message = String(err.message)
|
|
251
|
-
if (!message.includes('Terminating worker thread')) {
|
|
252
|
-
throw err
|
|
253
|
-
}
|
|
254
|
-
}
|
|
262
|
+
await pool.close()
|
|
255
263
|
} finally {
|
|
256
|
-
|
|
257
|
-
|
|
264
|
+
setSharedPool(null)
|
|
265
|
+
setClosing(false)
|
|
258
266
|
}
|
|
259
267
|
}
|
|
260
268
|
}
|
|
@@ -263,14 +271,15 @@ export async function destroyPool(): Promise<void> {
|
|
|
263
271
|
* Get pool statistics for debugging
|
|
264
272
|
*/
|
|
265
273
|
export function getPoolStats() {
|
|
266
|
-
|
|
274
|
+
const pool = getSharedPool()
|
|
275
|
+
if (!pool) {
|
|
267
276
|
return null
|
|
268
277
|
}
|
|
269
278
|
return {
|
|
270
|
-
threads:
|
|
271
|
-
queueSize:
|
|
272
|
-
completed:
|
|
273
|
-
duration:
|
|
274
|
-
utilization:
|
|
279
|
+
threads: pool.threads.length,
|
|
280
|
+
queueSize: pool.queueSize,
|
|
281
|
+
completed: pool.completed,
|
|
282
|
+
duration: pool.duration,
|
|
283
|
+
utilization: pool.utilization,
|
|
275
284
|
}
|
|
276
285
|
}
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAKpD,YAAY,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,eAAO,MAAM,gBAAgB,GAAU,OAAO;IAC5C,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb;;;EAGA,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAKpD,YAAY,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,eAAO,MAAM,gBAAgB,GAAU,OAAO;IAC5C,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb;;;EAG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