@ctx-core/window 14.2.28 → 15.0.1
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/CHANGELOG.md +42 -0
- package/package.json +4 -4
- package/src/hostname__/index.d.ts +9 -4
- package/src/hostname__/index.js +21 -4
- package/src/index.d.ts +0 -2
- package/src/index.js +0 -2
- package/src/pathname__/index.d.ts +7 -4
- package/src/pathname__/index.js +19 -4
- package/src/window_location__/index.d.ts +5 -6
- package/src/window_location__/index.js +30 -18
- package/COMMIT_EDITMSG +0 -3
- package/src/window_location_hostname__/index.d.ts +0 -4
- package/src/window_location_hostname__/index.js +0 -11
- package/src/window_location_pathname__/index.d.ts +0 -5
- package/src/window_location_pathname__/index.js +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @ctx-core/window
|
|
2
2
|
|
|
3
|
+
## 15.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @ctx-core/dom@12.0.0
|
|
23
|
+
|
|
24
|
+
## 15.0.0
|
|
25
|
+
|
|
26
|
+
### Major Changes
|
|
27
|
+
|
|
28
|
+
- window*location\_\_: Be<ReadableAtom*<Location>>
|
|
29
|
+
- pathname\__:Be<ReadableAtom_<string>>
|
|
30
|
+
- window_location**: - window_location**reset
|
|
31
|
+
- hostname\__:Be<ReadableAtom_<string|undefined>>
|
|
32
|
+
- - window_location\_\_T
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- - window_location\_\_reset
|
|
37
|
+
- - window*location*
|
|
38
|
+
- - hostname\_
|
|
39
|
+
- - pathname\_
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- fix: run on server
|
|
44
|
+
|
|
3
45
|
## 14.2.28
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctx-core/window",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.1",
|
|
4
4
|
"description": "ctx-core window",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"./package.json": "./package.json"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ctx-core/dom": "^
|
|
27
|
+
"@ctx-core/dom": "^12.0.0",
|
|
28
28
|
"@ctx-core/function": "^21.12.1",
|
|
29
29
|
"@ctx-core/nanostores": "^3.1.8",
|
|
30
30
|
"@ctx-core/object": "^27.1.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"c8": "^7.13.0",
|
|
34
|
-
"check-dts": "^0.7.
|
|
35
|
-
"tsx": "^3.12.
|
|
34
|
+
"check-dts": "^0.7.1",
|
|
35
|
+
"tsx": "^3.12.5",
|
|
36
36
|
"typescript": "next",
|
|
37
37
|
"uvu": "^0.5.6"
|
|
38
38
|
},
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Be } from '@ctx-core/object'
|
|
3
|
-
export declare const hostname__:Be<
|
|
4
|
-
export {
|
|
1
|
+
import type { ReadableAtom_ } from '@ctx-core/nanostores'
|
|
2
|
+
import type { Be, Ctx } from '@ctx-core/object'
|
|
3
|
+
export declare const hostname__:Be<ReadableAtom_<string>>
|
|
4
|
+
export {
|
|
5
|
+
hostname__ as hostname$_,
|
|
6
|
+
hostname__ as window_location_hostname__,
|
|
7
|
+
hostname__ as window_location_hostname$_
|
|
8
|
+
}
|
|
9
|
+
export declare function hostname_(ctx:Ctx):string
|
package/src/hostname__/index.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nullish__check_ } from '@ctx-core/function'
|
|
2
|
+
import { computed_ } from '@ctx-core/nanostores'
|
|
2
3
|
import { be_ } from '@ctx-core/object'
|
|
4
|
+
import { window_location__ } from '../window_location__/index.js'
|
|
5
|
+
/** @typedef {import('@ctx-core/object').Ctx}Ctx */
|
|
3
6
|
/** @type {typeof import('./index.d.ts').hostname__} */
|
|
4
|
-
export const hostname__ = be_('hostname__',
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
export const hostname__ = be_('hostname__', ctx =>
|
|
8
|
+
computed_(window_location__(ctx), window_location=>
|
|
9
|
+
nullish__check_([window_location], ()=>
|
|
10
|
+
window_location.hostname)))
|
|
11
|
+
export {
|
|
12
|
+
hostname__ as hostname$_,
|
|
13
|
+
hostname__ as window_location_hostname__,
|
|
14
|
+
hostname__ as window_location_hostname$_
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @param {Ctx}ctx
|
|
18
|
+
* @returns {string}
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
export function hostname_(ctx) {
|
|
22
|
+
return hostname__(ctx).$
|
|
23
|
+
}
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Be } from '@ctx-core/object'
|
|
3
|
-
export declare const pathname__:Be<
|
|
1
|
+
import type { ReadableAtom_ } from '@ctx-core/nanostores'
|
|
2
|
+
import type { Be, Ctx } from '@ctx-core/object'
|
|
3
|
+
export declare const pathname__:Be<ReadableAtom_<string>>
|
|
4
4
|
export {
|
|
5
5
|
pathname__ as pathname$_,
|
|
6
|
-
pathname__ as b__pathname
|
|
6
|
+
pathname__ as b__pathname,
|
|
7
|
+
pathname__ as window_location_pathname__,
|
|
8
|
+
pathname__ as window_location_pathname$_,
|
|
7
9
|
}
|
|
10
|
+
export declare function pathname_(ctx:Ctx):string
|
package/src/pathname__/index.js
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nullish__check_ } from '@ctx-core/function'
|
|
2
|
+
import { computed_ } from '@ctx-core/nanostores'
|
|
2
3
|
import { be_ } from '@ctx-core/object'
|
|
4
|
+
import { window_location__ } from '../window_location__/index.js'
|
|
5
|
+
/** @typedef {import('@ctx-core/object').Ctx}Ctx */
|
|
3
6
|
/** @type {typeof import('./index.d.ts').pathname__} */
|
|
4
|
-
export const pathname__ = be_('pathname__',
|
|
5
|
-
()=>
|
|
7
|
+
export const pathname__ = be_('pathname__', ctx=>
|
|
8
|
+
computed_(window_location__(ctx), window_location=>
|
|
9
|
+
nullish__check_([window_location], ()=>
|
|
10
|
+
window_location.pathname)))
|
|
6
11
|
export {
|
|
7
12
|
pathname__ as pathname$_,
|
|
8
|
-
pathname__ as b__pathname
|
|
13
|
+
pathname__ as b__pathname,
|
|
14
|
+
pathname__ as window_location_pathname__,
|
|
15
|
+
pathname__ as window_location_pathname$_,
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @param {Ctx}ctx
|
|
19
|
+
* @returns {string}
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
export function pathname_(ctx) {
|
|
23
|
+
return pathname__(ctx).$
|
|
9
24
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Be } from '@ctx-core/object'
|
|
3
|
-
export declare const window_location__:Be<
|
|
4
|
-
export
|
|
5
|
-
window_location__reset:()=>void;
|
|
6
|
-
}
|
|
1
|
+
import type { ReadableAtom_ } from '@ctx-core/nanostores'
|
|
2
|
+
import type { Be, Ctx } from '@ctx-core/object'
|
|
3
|
+
export declare const window_location__:Be<ReadableAtom_<Location>>
|
|
4
|
+
export declare function window_location_(ctx:Ctx):Location
|
|
7
5
|
export { window_location__ as window_location$_ }
|
|
6
|
+
export declare function window_location__reset(ctx:Ctx):void
|
|
@@ -1,23 +1,35 @@
|
|
|
1
|
-
import { has_dom } from '@ctx-core/dom'
|
|
2
|
-
import { atom_ } from '@ctx-core/nanostores'
|
|
3
|
-
import {
|
|
1
|
+
import { has_dom, no_dom } from '@ctx-core/dom'
|
|
2
|
+
import { atom_, computed_ } from '@ctx-core/nanostores'
|
|
3
|
+
import { be_ } from '@ctx-core/object'
|
|
4
|
+
const window_location__atom_ = be_('window_location__atom_', ()=>
|
|
5
|
+
atom_())
|
|
6
|
+
/** @typedef {import('@ctx-core/nanostores').WritableAtom_}WritableAtom_ */
|
|
7
|
+
/** @typedef {import('@ctx-core/object').Be}Be */
|
|
8
|
+
/** @typedef {import('@ctx-core/object').Ctx}Ctx */
|
|
4
9
|
/** @type {typeof import('./index.d.ts').window_location__} */
|
|
5
|
-
export const window_location__ = be_('window_location__',
|
|
6
|
-
const window_location_ = atom_(undefined)
|
|
7
|
-
const window_location__onpopstate__bound_ = atom_(false)
|
|
10
|
+
export const window_location__ = be_('window_location__', ctx=>{
|
|
8
11
|
if (has_dom) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return assign(window_location_, {
|
|
12
|
-
window_location__reset
|
|
13
|
-
})
|
|
14
|
-
function window_location__reset() {
|
|
15
|
-
if (!has_dom) return
|
|
16
|
-
if (!window_location__onpopstate__bound_.$) {
|
|
17
|
-
window_location__onpopstate__bound_.set(true)
|
|
18
|
-
window.addEventListener('popstate', window_location__reset)
|
|
19
|
-
}
|
|
20
|
-
window_location_.set(window.location)
|
|
12
|
+
window.addEventListener('popstate', ()=>
|
|
13
|
+
window_location__reset(ctx))
|
|
21
14
|
}
|
|
15
|
+
return computed_(
|
|
16
|
+
window_location__atom_(ctx),
|
|
17
|
+
$=>$)
|
|
22
18
|
})
|
|
23
19
|
export { window_location__ as window_location$_ }
|
|
20
|
+
/**
|
|
21
|
+
* @param {Ctx}ctx
|
|
22
|
+
* @returns {Location}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
export function window_location_(ctx) {
|
|
26
|
+
return window_location__(ctx).$
|
|
27
|
+
}
|
|
28
|
+
/** @typedef {Be<WritableAtom_<boolean>>} */
|
|
29
|
+
/**
|
|
30
|
+
* @param {Ctx}ctx
|
|
31
|
+
*/
|
|
32
|
+
export function window_location__reset(ctx) {
|
|
33
|
+
if (no_dom) return
|
|
34
|
+
window_location__atom_(ctx).$ = window.location
|
|
35
|
+
}
|
package/COMMIT_EDITMSG
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { computed_ } from '@ctx-core/nanostores'
|
|
2
|
-
import { be_ } from '@ctx-core/object'
|
|
3
|
-
import { hostname__ } from '../hostname__/index.js'
|
|
4
|
-
import { window_location__ } from '../window_location__/index.js'
|
|
5
|
-
/** @type {typeof import('./index.d.ts').window_location_hostname__} */
|
|
6
|
-
export const window_location_hostname__ = be_('window_location_hostname__', (ctx)=>computed_([
|
|
7
|
-
hostname__(ctx),
|
|
8
|
-
window_location__(ctx),
|
|
9
|
-
], (hostname, window_location)=>
|
|
10
|
-
window_location && window_location.hostname || hostname || ''))
|
|
11
|
-
export { window_location_hostname__ as window_location_hostname$_ }
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ReadableAtom_ } from '@ctx-core/nanostores'
|
|
2
|
-
import type { Be } from '@ctx-core/object'
|
|
3
|
-
export declare const window_location_pathname__:Be<ReadableAtom_<window_location_pathname_T>>
|
|
4
|
-
export declare type window_location_pathname_T = string|undefined
|
|
5
|
-
export { window_location_pathname__ as window_location_pathname$_ }
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { computed_ } from '@ctx-core/nanostores'
|
|
2
|
-
import { be_ } from '@ctx-core/object'
|
|
3
|
-
import { pathname__ } from '../pathname__/index.js'
|
|
4
|
-
import { window_location__ } from '../window_location__/index.js'
|
|
5
|
-
/** @type {typeof import('./index.d.ts').window_location_pathname__} */
|
|
6
|
-
export const window_location_pathname__ = be_('window_location_pathname__', ctx=>
|
|
7
|
-
computed_([
|
|
8
|
-
pathname__(ctx),
|
|
9
|
-
window_location__(ctx),
|
|
10
|
-
], (pathname, location__window)=>
|
|
11
|
-
location__window && location__window.pathname || pathname || ''))
|
|
12
|
-
export { window_location_pathname__ as window_location_pathname$_ }
|