Skip to content

Commit 12bb2e8

Browse files
committed
fix: use globalThis
1 parent e7d70d6 commit 12bb2e8

File tree

11 files changed

+599
-581
lines changed

11 files changed

+599
-581
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
},
99
"bugs": "https://github.com/escapace/cassiopeia/issues",
1010
"devDependencies": {
11-
"@commitlint/cli": "19.7.1",
12-
"@commitlint/config-conventional": "19.7.1",
11+
"@commitlint/cli": "19.8.1",
12+
"@commitlint/config-conventional": "19.8.1",
1313
"@escapace/pnpm-pack": "0.6.0",
1414
"@ls-lint/ls-lint": "2.3.0",
15-
"eslint": "9.25.1",
15+
"eslint": "9.27.0",
1616
"eslint-config-escapace": "5.6.0",
17-
"knip": "5.43.6",
18-
"lefthook": "1.10.10",
17+
"knip": "5.57.2",
18+
"lefthook": "1.11.13",
1919
"prettier": "3.5.3",
2020
"prettier-config-escapace": "1.2.1",
2121
"syncpack": "13.0.4"

packages/cassiopeia/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
"bugs": "https://github.com/escapace/cassiopeia/issues",
1010
"devDependencies": {
1111
"@ls-lint/ls-lint": "2.3.0",
12-
"@types/node": "22.15.3",
13-
"@vitest/coverage-v8": "3.1.2",
14-
"eslint": "9.25.1",
12+
"@types/node": "22.15.21",
13+
"@vitest/coverage-v8": "3.1.4",
14+
"eslint": "9.27.0",
1515
"eslint-config-escapace": "5.6.0",
16-
"esroll": "0.4.3",
16+
"esroll": "0.4.4",
1717
"jsdom": "26.1.0",
1818
"prettier": "3.5.3",
1919
"prettier-config-escapace": "1.2.1",
2020
"syncpack": "13.0.4",
2121
"tsx": "4.19.4",
2222
"typescript": "5.8.3",
23-
"vitest": "3.1.2"
23+
"vitest": "3.1.4"
2424
},
2525
"engines": {
2626
"node": ">=22.15.0",

packages/source-dom/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
"bugs": "https://github.com/escapace/cassiopeia/issues",
1010
"devDependencies": {
1111
"@ls-lint/ls-lint": "2.3.0",
12-
"@vitest/coverage-v8": "3.1.2",
12+
"@vitest/coverage-v8": "3.1.4",
1313
"cassiopeia": "workspace:*",
14-
"eslint": "9.25.1",
14+
"eslint": "9.27.0",
1515
"eslint-config-escapace": "5.6.0",
16-
"esroll": "0.4.3",
16+
"esroll": "0.4.4",
1717
"jsdom": "26.1.0",
1818
"prettier": "3.5.3",
1919
"prettier-config-escapace": "1.2.1",
2020
"syncpack": "13.0.4",
2121
"tsx": "4.19.4",
2222
"typescript": "5.8.3",
23-
"vitest": "3.1.2"
23+
"vitest": "3.1.4"
2424
},
2525
"engines": {
2626
"pnpm": ">=10.10.0"

packages/vite/package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,24 @@
88
},
99
"bugs": "https://github.com/escapace/cassiopeia/issues",
1010
"dependencies": {
11-
"@ast-grep/napi": "^0.37.0",
12-
"@vitejs/plugin-vue": "^5.2.3",
13-
"@vue/compiler-sfc": "^3.5.13",
14-
"cassiopeia": "workspace:*",
11+
"@ast-grep/napi": "^0.38.2",
1512
"magic-string": "^0.30.17"
1613
},
1714
"devDependencies": {
1815
"@ls-lint/ls-lint": "2.3.0",
19-
"@types/node": "22.15.3",
20-
"@vitest/coverage-v8": "3.1.2",
21-
"eslint": "9.25.1",
16+
"@types/node": "22.15.21",
17+
"@vitest/coverage-v8": "3.1.4",
18+
"cassiopeia": "workspace:*",
19+
"eslint": "9.27.0",
2220
"eslint-config-escapace": "5.6.0",
23-
"esroll": "0.4.3",
21+
"esroll": "0.4.4",
2422
"prettier": "3.5.3",
2523
"prettier-config-escapace": "1.2.1",
2624
"syncpack": "13.0.4",
2725
"tsx": "4.19.4",
2826
"typescript": "5.8.3",
29-
"vite": "6.3.4",
30-
"vitest": "3.1.2",
31-
"vue": "3.5.13"
27+
"vite": "6.3.5",
28+
"vitest": "3.1.4"
3229
},
3330
"engines": {
3431
"node": ">=22.15.0",
@@ -47,6 +44,10 @@
4744
"homepage": "https://github.com/escapace/cassiopeia/tree/trunk/packages/vite#readme",
4845
"license": "MPL-2.0",
4946
"module": "./lib/node/index.js",
47+
"peerDependencies": {
48+
"@vitejs/plugin-vue": ">=5.2.4",
49+
"@vue/compiler-sfc": ">=3.5.14"
50+
},
5051
"private": false,
5152
"publishConfig": {
5253
"access": "public",

packages/vite/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ const createProductionPlugin = (): Plugin[] => {
155155

156156
if (
157157
state.variables.has(filename) &&
158+
state.variables.get(filename)?.size !== 0 &&
158159
Object.values(query).filter((value) => value !== undefined).length === 0
159160
) {
160161
if (isSSR) {

packages/vue/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
"bugs": "https://github.com/escapace/cassiopeia/issues",
1010
"dependencies": {
1111
"cassiopeia": "workspace:*",
12-
"vue": "^3.5.13"
12+
"vue": "^3.5.14"
1313
},
1414
"devDependencies": {
1515
"@ls-lint/ls-lint": "2.3.0",
16-
"@types/node": "22.15.3",
17-
"@vitest/coverage-v8": "3.1.2",
16+
"@types/node": "22.15.21",
17+
"@vitest/coverage-v8": "3.1.4",
1818
"cassiopeia": "workspace:*",
19-
"eslint": "9.25.1",
19+
"eslint": "9.27.0",
2020
"eslint-config-escapace": "5.6.0",
21-
"esroll": "0.4.3",
21+
"esroll": "0.4.4",
2222
"jsdom": "26.1.0",
2323
"prettier": "3.5.3",
2424
"prettier-config-escapace": "1.2.1",
2525
"syncpack": "13.0.4",
2626
"tsx": "4.19.4",
2727
"typescript": "5.8.3",
28-
"vitest": "3.1.2"
28+
"vitest": "3.1.4"
2929
},
3030
"engines": {
3131
"node": ">=22.15.0",
@@ -61,7 +61,7 @@
6161
"homepage": "https://github.com/escapace/cassiopeia/tree/trunk/packages/vue#readme",
6262
"license": "MPL-2.0",
6363
"peerDependencies": {
64-
"vue": ">=3.5.13"
64+
"vue": ">=3.5.14"
6565
},
6666
"private": false,
6767
"publishConfig": {

packages/vue/src/create-cassiopeia.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function* createVariableIterator(sets: Set<Set<string>>): Variables {
2222

2323
const createCassiopeiaVue = (options: Options): Cassiopeia => {
2424
if (__PLATFORM__ === 'browser') {
25-
if (window.__CASSIOPEIA_VUE__ !== undefined) {
26-
return window.__CASSIOPEIA_VUE__
25+
if (globalThis.__CASSIOPEIA_VUE__ !== undefined) {
26+
return globalThis.__CASSIOPEIA_VUE__
2727
}
2828
}
2929

@@ -93,7 +93,7 @@ const createCassiopeiaVue = (options: Options): Cassiopeia => {
9393
sets.clear()
9494

9595
if (__PLATFORM__ === 'browser') {
96-
window.__CASSIOPEIA_VUE__ = undefined
96+
globalThis.__CASSIOPEIA_VUE__ = undefined
9797
}
9898
cassiopeia[STORE].subscriptions.clear()
9999
cassiopeia[STORE].iterators.clear()
@@ -108,7 +108,7 @@ const createCassiopeiaVue = (options: Options): Cassiopeia => {
108108
}
109109

110110
if (__PLATFORM__ === 'browser') {
111-
window.__CASSIOPEIA_VUE__ = cassiopeiaVue
111+
globalThis.__CASSIOPEIA_VUE__ = cassiopeiaVue
112112
}
113113

114114
return cassiopeiaVue

packages/vue/src/global.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
/* eslint-disable no-var */
12
import type { Cassiopeia } from './types'
23

34
declare global {
4-
interface Window {
5-
__CASSIOPEIA_VUE__: Cassiopeia | undefined
6-
}
5+
var __CASSIOPEIA_VUE__: Cassiopeia | undefined
76
}

packages/vue/src/update-style.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const updateStyle = (
77
onDispose: (callback: () => void) => void,
88
index = 0,
99
) => {
10-
if (window.__CASSIOPEIA_VUE__ === undefined) {
10+
if (globalThis.__CASSIOPEIA_VUE__ === undefined) {
1111
// 3 seconds
1212
if (index === 30) {
1313
console.warn(`[cassiopeia] update failed for '${__vite__id}'`)
@@ -20,7 +20,7 @@ export const updateStyle = (
2020
)
2121

2222
if (variables.length !== 0) {
23-
const cassiopeia = window.__CASSIOPEIA_VUE__
23+
const cassiopeia = globalThis.__CASSIOPEIA_VUE__
2424

2525
const scope = cassiopeia.createScope()
2626

packages/vue/src/use-cassiopeia.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { UseCassiopeia } from './types'
55
export const useCassiopeia = (): UseCassiopeia => {
66
const cassiopeia = inject(
77
CASSIOPEIA_VUE_SYMBOL,
8-
__PLATFORM__ === 'browser' ? window.__CASSIOPEIA_VUE__ : undefined,
8+
__PLATFORM__ === 'browser' ? globalThis.__CASSIOPEIA_VUE__ : undefined,
99
)
1010

1111
if (cassiopeia === undefined) {

0 commit comments

Comments
 (0)