@oinone/kunlun-environment 6.4.2 → 7.1.0
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/oinone-kunlun-environment.esm.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/src/env/constant.d.ts +2 -2
- package/dist/types/src/env/index.d.ts +4 -4
- package/dist/types/src/env/manager.d.ts +14 -14
- package/dist/types/src/env/method/getContentHTMLElement.d.ts +2 -2
- package/dist/types/src/env/method/index.d.ts +1 -1
- package/dist/types/src/env/typing.d.ts +22 -22
- package/dist/types/src/env/utils.d.ts +2 -2
- package/dist/types/src/framework/index.d.ts +1 -1
- package/dist/types/src/framework/typing.d.ts +5 -5
- package/dist/types/src/index.d.ts +4 -4
- package/dist/types/src/instance/index.d.ts +3 -3
- package/dist/types/src/instance/typing.d.ts +14 -14
- package/dist/types/src/spi/framework.d.ts +1 -1
- package/dist/types/src/spi/index.d.ts +1 -1
- package/dist/types/src/spi/instance.d.ts +4 -4
- package/package.json +19 -8
- package/src/env/manager.ts +1 -1
- package/src/env/method/getContentHTMLElement.ts +1 -1
- package/src/env/typing.ts +1 -1
- package/src/env/utils.ts +14 -12
- package/src/framework/typing.ts +1 -1
- package/src/instance/index.ts +1 -1
- package/src/spi/instance.ts +2 -2
- package/rollup.config.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Manager as
|
|
1
|
+
import{Manager as n,ObjectUtils as e}from"@oinone/kunlun-shared";import{SPIOperator as t}from"@oinone/kunlun-spi";const r="oio-click-activated",i="__null__";function a(n,e){return new Proxy({handle:n,el:e},{get(n,t,r){let i;switch(i="function"==typeof e?e():e,t){case"w":return(null==i?void 0:i.getBoundingClientRect().width)||0;case"h":return(null==i?void 0:i.getBoundingClientRect().height)||0;case"x":return(null==i?void 0:i.getBoundingClientRect().x)||0;case"y":return(null==i?void 0:i.getBoundingClientRect().y)||0;case"ex":{const n=null==i?void 0:i.getBoundingClientRect();return n?n.x+n.width:0}case"ey":{const n=null==i?void 0:i.getBoundingClientRect();return n?n.y+n.height:0}case"el":return i}return Reflect.get(n,t,r)}})}const o={getContentHTMLElement:function(){const{contentSelector:n}=this,e=document.querySelector(n);if(e)return e}};class RuntimeEnvironmentManager{static getGlobalEnvironment(){return RuntimeEnvironmentManager.manager.get(RuntimeEnvironmentManager.ROOT_HANDLE)}static getCurrentEnvironment(){const n=RuntimeEnvironmentManager.currentHandle,e=RuntimeEnvironmentManager.manager.get(n);if(!e)throw new Error(`Invalid current environment. handle: ${n}`);return e}static get(n){return RuntimeEnvironmentManager.manager.get(n)}static createOrReplace(n,e){return RuntimeEnvironmentManager.manager.createOrReplace(n,e)}static delete(n,e=!0){RuntimeEnvironmentManager.manager.delete(n,e)}static select(n){if(!RuntimeEnvironmentManager.manager.get(n))throw new Error(`Invalid environment. ${n}`);this.currentHandle=n}}function u(){return RuntimeEnvironmentManager.getGlobalEnvironment()}function c(){return RuntimeEnvironmentManager.getCurrentEnvironment()}RuntimeEnvironmentManager.manager=new class InternalRuntimeEnvironmentManager extends n{constructor(){super()}generator(n){const t={contentSelector:i,mcx:0,mcy:0,st:0,sl:0,visibleArea:new Map,clickVisibleArea:[]},r=["contentVisibleArea","visibleArea"];for(const[n,e]of Object.entries(o))r.push(n),t[n]=e.bind(t);return t.contentVisibleArea=a(n,()=>t.getContentHTMLElement()),e.readonly(t,r)}},RuntimeEnvironmentManager.ROOT_HANDLE="__ROOT_HANDLE__",RuntimeEnvironmentManager.currentHandle=RuntimeEnvironmentManager.ROOT_HANDLE,RuntimeEnvironmentManager.manager.createOrReplace(RuntimeEnvironmentManager.ROOT_HANDLE);const m=Symbol("__current_instance_getter");function l(n,e){return t.register(m,n,e)}function g(n){return t.selector(m,n)}function s(){return g({framework:"vue"})()}t.createStorage({key:m,matchKeys:["framework","isMobile"]});export{r as CLICK_ACTIVATED_CLASS,i as CONTENT_NULL_SELECTOR,RuntimeEnvironmentManager,a as createVisibleArea,l as registerCurrentInstanceGetter,g as selectorCurrentInstanceGetter,s as useCurrentInstance,c as useEnv,u as useGlobalEnv};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './src';
|
|
1
|
+
export * from './src';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const CLICK_ACTIVATED_CLASS = "oio-click-activated";
|
|
2
|
-
export declare const CONTENT_NULL_SELECTOR = "__null__";
|
|
1
|
+
export declare const CLICK_ACTIVATED_CLASS = "oio-click-activated";
|
|
2
|
+
export declare const CONTENT_NULL_SELECTOR = "__null__";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './constant';
|
|
2
|
-
export * from './typing';
|
|
3
|
-
export * from './manager';
|
|
4
|
-
export * from './utils';
|
|
1
|
+
export * from './constant';
|
|
2
|
+
export * from './typing';
|
|
3
|
+
export * from './manager';
|
|
4
|
+
export * from './utils';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { RuntimeEnvironment } from './typing';
|
|
2
|
-
export declare class RuntimeEnvironmentManager {
|
|
3
|
-
private static manager;
|
|
4
|
-
private static ROOT_HANDLE;
|
|
5
|
-
private static currentHandle;
|
|
6
|
-
static getGlobalEnvironment(): RuntimeEnvironment;
|
|
7
|
-
static getCurrentEnvironment(): RuntimeEnvironment;
|
|
8
|
-
static get(handle: string): RuntimeEnvironment | undefined;
|
|
9
|
-
static createOrReplace(handle: string, parent?: RuntimeEnvironment): RuntimeEnvironment;
|
|
10
|
-
static delete(handle: string, deep?: boolean): void;
|
|
11
|
-
static select(handle: string): void;
|
|
12
|
-
}
|
|
13
|
-
export declare function useGlobalEnv(): RuntimeEnvironment;
|
|
14
|
-
export declare function useEnv(): RuntimeEnvironment;
|
|
1
|
+
import type { RuntimeEnvironment } from './typing';
|
|
2
|
+
export declare class RuntimeEnvironmentManager {
|
|
3
|
+
private static manager;
|
|
4
|
+
private static ROOT_HANDLE;
|
|
5
|
+
private static currentHandle;
|
|
6
|
+
static getGlobalEnvironment(): RuntimeEnvironment;
|
|
7
|
+
static getCurrentEnvironment(): RuntimeEnvironment;
|
|
8
|
+
static get(handle: string): RuntimeEnvironment | undefined;
|
|
9
|
+
static createOrReplace(handle: string, parent?: RuntimeEnvironment): RuntimeEnvironment;
|
|
10
|
+
static delete(handle: string, deep?: boolean): void;
|
|
11
|
+
static select(handle: string): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function useGlobalEnv(): RuntimeEnvironment;
|
|
14
|
+
export declare function useEnv(): RuntimeEnvironment;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RuntimeEnvironment } from '../typing';
|
|
2
|
-
export declare function getContentHTMLElement(this: RuntimeEnvironment): HTMLElement | undefined;
|
|
1
|
+
import type { RuntimeEnvironment } from '../typing';
|
|
2
|
+
export declare function getContentHTMLElement(this: RuntimeEnvironment): HTMLElement | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './getContentHTMLElement';
|
|
1
|
+
export * from './getContentHTMLElement';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ContextNode } from '@oinone/kunlun-shared';
|
|
2
|
-
export interface RuntimeEnvironment extends ContextNode<RuntimeEnvironment> {
|
|
3
|
-
contentSelector: string;
|
|
4
|
-
mcx: number;
|
|
5
|
-
mcy: number;
|
|
6
|
-
st: number;
|
|
7
|
-
sl: number;
|
|
8
|
-
contentVisibleArea: VisibleArea;
|
|
9
|
-
visibleArea: Map<string, VisibleArea>;
|
|
10
|
-
clickVisibleArea: VisibleArea[];
|
|
11
|
-
getContentHTMLElement(): HTMLElement | undefined;
|
|
12
|
-
}
|
|
13
|
-
export interface VisibleArea {
|
|
14
|
-
handle: string;
|
|
15
|
-
el?: HTMLElement;
|
|
16
|
-
h: number;
|
|
17
|
-
w: number;
|
|
18
|
-
x: number;
|
|
19
|
-
y: number;
|
|
20
|
-
ex: number;
|
|
21
|
-
ey: number;
|
|
22
|
-
}
|
|
1
|
+
import type { ContextNode } from '@oinone/kunlun-shared';
|
|
2
|
+
export interface RuntimeEnvironment extends ContextNode<RuntimeEnvironment> {
|
|
3
|
+
contentSelector: string;
|
|
4
|
+
mcx: number;
|
|
5
|
+
mcy: number;
|
|
6
|
+
st: number;
|
|
7
|
+
sl: number;
|
|
8
|
+
contentVisibleArea: VisibleArea;
|
|
9
|
+
visibleArea: Map<string, VisibleArea>;
|
|
10
|
+
clickVisibleArea: VisibleArea[];
|
|
11
|
+
getContentHTMLElement(): HTMLElement | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface VisibleArea {
|
|
14
|
+
handle: string;
|
|
15
|
+
el?: HTMLElement;
|
|
16
|
+
h: number;
|
|
17
|
+
w: number;
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
ex: number;
|
|
21
|
+
ey: number;
|
|
22
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { VisibleArea } from './typing';
|
|
2
|
-
export declare function createVisibleArea(handle: string, el?: HTMLElement | (() => HTMLElement | undefined)): VisibleArea;
|
|
1
|
+
import type { VisibleArea } from './typing';
|
|
2
|
+
export declare function createVisibleArea(handle: string, el?: HTMLElement | (() => HTMLElement | undefined)): VisibleArea;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './typing';
|
|
1
|
+
export * from './typing';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SPIOptions } from '@oinone/kunlun-spi';
|
|
2
|
-
export interface FrameworkInitializeOptions extends SPIOptions {
|
|
3
|
-
framework: string;
|
|
4
|
-
isMobile?: boolean;
|
|
5
|
-
}
|
|
1
|
+
import type { SPIOptions } from '@oinone/kunlun-spi';
|
|
2
|
+
export interface FrameworkInitializeOptions extends SPIOptions {
|
|
3
|
+
framework: string;
|
|
4
|
+
isMobile?: boolean;
|
|
5
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './env';
|
|
2
|
-
export * from './framework';
|
|
3
|
-
export * from './instance';
|
|
4
|
-
export * from './spi';
|
|
1
|
+
export * from './env';
|
|
2
|
+
export * from './framework';
|
|
3
|
+
export * from './instance';
|
|
4
|
+
export * from './spi';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FrameworkInstance } from './typing';
|
|
2
|
-
export declare function useCurrentInstance(): FrameworkInstance;
|
|
3
|
-
export * from './typing';
|
|
1
|
+
import type { FrameworkInstance } from './typing';
|
|
2
|
+
export declare function useCurrentInstance(): FrameworkInstance;
|
|
3
|
+
export * from './typing';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export interface FrameworkInstance {
|
|
2
|
-
app: FrameworkApplication;
|
|
3
|
-
currentInstance?: FrameworkComponentInstance | null;
|
|
4
|
-
}
|
|
5
|
-
export interface FrameworkApplication {
|
|
6
|
-
id: string;
|
|
7
|
-
}
|
|
8
|
-
export interface FrameworkComponentInstance {
|
|
9
|
-
vNode: FrameworkVNode;
|
|
10
|
-
}
|
|
11
|
-
export interface FrameworkVNode {
|
|
12
|
-
el: HTMLElement;
|
|
13
|
-
}
|
|
14
|
-
export
|
|
1
|
+
export interface FrameworkInstance {
|
|
2
|
+
app: FrameworkApplication;
|
|
3
|
+
currentInstance?: FrameworkComponentInstance | null;
|
|
4
|
+
}
|
|
5
|
+
export interface FrameworkApplication {
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FrameworkComponentInstance {
|
|
9
|
+
vNode: FrameworkVNode;
|
|
10
|
+
}
|
|
11
|
+
export interface FrameworkVNode {
|
|
12
|
+
el: HTMLElement;
|
|
13
|
+
}
|
|
14
|
+
export type FrameworkInstanceGetter = () => FrameworkInstance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './instance';
|
|
1
|
+
export * from './instance';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FrameworkInitializeOptions } from '../framework';
|
|
2
|
-
import { FrameworkInstanceGetter } from '../instance/typing';
|
|
3
|
-
export declare function registerCurrentInstanceGetter(options: FrameworkInitializeOptions, getter: FrameworkInstanceGetter): boolean;
|
|
4
|
-
export declare function selectorCurrentInstanceGetter(options: FrameworkInitializeOptions): FrameworkInstanceGetter | undefined;
|
|
1
|
+
import type { FrameworkInitializeOptions } from '../framework';
|
|
2
|
+
import type { FrameworkInstanceGetter } from '../instance/typing';
|
|
3
|
+
export declare function registerCurrentInstanceGetter(options: FrameworkInitializeOptions, getter: FrameworkInstanceGetter): boolean;
|
|
4
|
+
export declare function selectorCurrentInstanceGetter(options: FrameworkInitializeOptions): FrameworkInstanceGetter | undefined;
|
package/package.json
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oinone/kunlun-environment",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
3
|
+
"version": "7.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/oinone-kunlun-environment.esm.js",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"prebuild": "rimraf dist",
|
|
7
8
|
"build": "rollup -c",
|
|
8
9
|
"dist": "npm run prepublishOnly",
|
|
9
10
|
"index": "npm run postpublish",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
11
|
+
"format": "prettier --write --experimental-cli src/",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"prepublishOnly": "node ../../../../scripts/prepublish-only.cjs",
|
|
14
|
+
"deploy": "npm publish --exact",
|
|
15
|
+
"postpublish": "node ../../../../scripts/postpublish.cjs"
|
|
12
16
|
},
|
|
13
17
|
"devDependencies": {
|
|
14
|
-
"@oinone/kunlun-shared": "
|
|
15
|
-
"@oinone/kunlun-spi": "
|
|
18
|
+
"@oinone/kunlun-shared": "7.1.0",
|
|
19
|
+
"@oinone/kunlun-spi": "7.1.0"
|
|
16
20
|
},
|
|
17
|
-
"gitHead": "2b4c0c7911626c105ca71c2d41e54af470e2e079"
|
|
18
|
-
|
|
21
|
+
"gitHead": "2b4c0c7911626c105ca71c2d41e54af470e2e079",
|
|
22
|
+
"module": "dist/oinone-kunlun-environment.esm.js",
|
|
23
|
+
"typings": "dist/types/index.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"index.ts",
|
|
27
|
+
"src"
|
|
28
|
+
]
|
|
29
|
+
}
|
package/src/env/manager.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Manager, ObjectUtils } from '@oinone/kunlun-shared';
|
|
2
2
|
import { CONTENT_NULL_SELECTOR } from './constant';
|
|
3
3
|
import { getContentHTMLElement } from './method';
|
|
4
|
-
import { RuntimeEnvironment, VisibleArea } from './typing';
|
|
4
|
+
import type { RuntimeEnvironment, VisibleArea } from './typing';
|
|
5
5
|
import { createVisibleArea } from './utils';
|
|
6
6
|
|
|
7
7
|
const runtimeEnvironmentMethods: Record<string, Function> = {
|
package/src/env/typing.ts
CHANGED
package/src/env/utils.ts
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import { VisibleArea } from './typing';
|
|
1
|
+
import type { VisibleArea } from './typing';
|
|
2
2
|
|
|
3
3
|
export function createVisibleArea(handle: string, el?: HTMLElement | (() => HTMLElement | undefined)): VisibleArea {
|
|
4
4
|
const origin = { handle, el } as VisibleArea;
|
|
5
5
|
return new Proxy(origin, {
|
|
6
6
|
get(target, key, receiver) {
|
|
7
|
+
let tel: HTMLElement | undefined;
|
|
8
|
+
if (typeof el === 'function') {
|
|
9
|
+
tel = el();
|
|
10
|
+
} else {
|
|
11
|
+
tel = el;
|
|
12
|
+
}
|
|
7
13
|
switch (key) {
|
|
8
14
|
case 'w':
|
|
9
|
-
return
|
|
15
|
+
return tel?.getBoundingClientRect().width || 0;
|
|
10
16
|
case 'h':
|
|
11
|
-
return
|
|
17
|
+
return tel?.getBoundingClientRect().height || 0;
|
|
12
18
|
case 'x':
|
|
13
|
-
return
|
|
19
|
+
return tel?.getBoundingClientRect().x || 0;
|
|
14
20
|
case 'y':
|
|
15
|
-
return
|
|
21
|
+
return tel?.getBoundingClientRect().y || 0;
|
|
16
22
|
case 'ex': {
|
|
17
|
-
const rect =
|
|
23
|
+
const rect = tel?.getBoundingClientRect();
|
|
18
24
|
if (!rect) {
|
|
19
25
|
return 0;
|
|
20
26
|
}
|
|
21
27
|
return rect.x + rect.width;
|
|
22
28
|
}
|
|
23
29
|
case 'ey': {
|
|
24
|
-
const rect =
|
|
30
|
+
const rect = tel?.getBoundingClientRect();
|
|
25
31
|
if (!rect) {
|
|
26
32
|
return 0;
|
|
27
33
|
}
|
|
28
34
|
return rect.y + rect.height;
|
|
29
35
|
}
|
|
30
36
|
case 'el': {
|
|
31
|
-
|
|
32
|
-
if (typeof el === 'function') {
|
|
33
|
-
return el();
|
|
34
|
-
}
|
|
35
|
-
return el;
|
|
37
|
+
return tel;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
return Reflect.get(target, key, receiver);
|
package/src/framework/typing.ts
CHANGED
package/src/instance/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { selectorCurrentInstanceGetter } from '../spi';
|
|
2
|
-
import { FrameworkInstance } from './typing';
|
|
2
|
+
import type { FrameworkInstance } from './typing';
|
|
3
3
|
|
|
4
4
|
export function useCurrentInstance(): FrameworkInstance {
|
|
5
5
|
return selectorCurrentInstanceGetter({ framework: 'vue' })!();
|
package/src/spi/instance.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SPIOperator } from '@oinone/kunlun-spi';
|
|
2
|
-
import { FrameworkInitializeOptions } from '../framework';
|
|
3
|
-
import { FrameworkInstanceGetter } from '../instance/typing';
|
|
2
|
+
import type { FrameworkInitializeOptions } from '../framework';
|
|
3
|
+
import type { FrameworkInstanceGetter } from '../instance/typing';
|
|
4
4
|
|
|
5
5
|
const CURRENT_INSTANCE_GETTER_KEY = Symbol('__current_instance_getter');
|
|
6
6
|
|
package/rollup.config.js
DELETED