Comparing version
@@ -1,14 +0,42 @@ | ||
import { ModuleDriver, ModuleContext, ApiHooks, LiffPluginContext } from './types'; | ||
export declare class ModuleContextImpl<Liff, Hooks extends ApiHooks = never> implements ModuleContext<Liff> { | ||
import { SyncHook, AsyncHook } from '@liff/hooks'; | ||
import { HooksRegisters, ModuleDriver } from './driver'; | ||
export type HookTimings = { | ||
[timing: string]: SyncHook | AsyncHook; | ||
}; | ||
export type ApiHooks = Record<string, HookTimings>; | ||
export type HooksRegistersFromApiHooks<Hooks extends ApiHooks> = { | ||
[apiName in keyof Hooks]: { | ||
[timing in keyof Hooks[apiName]]: Hooks[apiName][timing]['on']; | ||
}; | ||
}; | ||
interface BaseModuleContext<Liff, Hooks extends HooksRegisters = HooksRegisters, InternalHooks extends HooksRegisters = HooksRegisters> { | ||
liff: Liff; | ||
hooks: Hooks; | ||
internalHooks: InternalHooks; | ||
} | ||
export type ModuleContext<Liff, Hooks extends ApiHooks = ApiHooks, InternalHooks extends ApiHooks = ApiHooks> = BaseModuleContext<Liff, HooksRegistersFromApiHooks<Hooks>, HooksRegistersFromApiHooks<InternalHooks>>; | ||
declare class ModuleContextImpl<Liff> implements ModuleContext<Liff> { | ||
private _driver; | ||
liff: Liff; | ||
constructor(_driver: ModuleDriver<Hooks>, liff: Liff); | ||
hooks: import("./types").HooksRegisters<import("./types").OfficialHooks & Hooks>; | ||
internalHooks: import("./types").HooksRegisters<import("./types").InternallHooks & ApiHooks>; | ||
constructor(_driver: ModuleDriver, liff: Liff); | ||
hooks: HooksRegisters; | ||
internalHooks: HooksRegisters; | ||
} | ||
export declare class LiffPluginContextImpl<Liff, Hooks extends ApiHooks = never> implements LiffPluginContext<Liff> { | ||
export interface PluginContext<Liff, Hooks extends HooksRegisters = HooksRegisters> { | ||
liff: Liff; | ||
hooks: Hooks; | ||
} | ||
declare class PluginContextImpl<Liff> implements PluginContext<Liff> { | ||
private _driver; | ||
liff: Liff; | ||
constructor(_driver: ModuleDriver<Hooks>, liff: Liff); | ||
hooks: import("./types").HooksRegisters<import("./types").OfficialHooks & Hooks>; | ||
constructor(_driver: ModuleDriver, liff: Liff); | ||
hooks: HooksRegisters; | ||
} | ||
export declare class ContextHolder<Liff> { | ||
private pluginCtx; | ||
private moduleCtx; | ||
constructor(driver: ModuleDriver, liff: Liff); | ||
get pluginContext(): PluginContextImpl<Liff>; | ||
get moduleContext(): ModuleContextImpl<Liff>; | ||
} | ||
export {}; |
@@ -1,8 +0,23 @@ | ||
import { ApiHooks, HooksRegisters, InternallHooks, LiffModule, ModuleDriver, OfficialHooks } from './types'; | ||
export declare class ModuleDriverImpl<Hooks extends ApiHooks = never, IHooks extends ApiHooks = never> implements ModuleDriver<Hooks, IHooks> { | ||
import { SyncHook, AsyncHook } from '@liff/hooks'; | ||
import { LiffModule, LiffPlugin } from './module'; | ||
type AddHookListener = SyncHook['on'] | AsyncHook['on']; | ||
export type HooksRegisters = { | ||
[apiName: string]: { | ||
[timing: string]: AddHookListener; | ||
}; | ||
}; | ||
type LiffModuleOrLiffPlugin = LiffModule<unknown, unknown, unknown> | LiffPlugin<unknown, unknown, unknown>; | ||
export interface ModuleDriver { | ||
addModule(name: string, module: LiffModuleOrLiffPlugin): void; | ||
hasModule(name: string): boolean; | ||
hooks: HooksRegisters; | ||
internalHooks: HooksRegisters; | ||
} | ||
export declare class ModuleDriverImpl implements ModuleDriver { | ||
private modules; | ||
hooks: HooksRegisters<OfficialHooks & Hooks>; | ||
internalHooks: HooksRegisters<InternallHooks & IHooks>; | ||
addModule(name: string, module: LiffModule): void; | ||
hooks: HooksRegisters; | ||
internalHooks: HooksRegisters; | ||
addModule(name: string, module: LiffModuleOrLiffPlugin): void; | ||
hasModule(name: string): boolean; | ||
} | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),e=require("@liff/logger"),n=function(t,e){this._driver=t,this.liff=e,this.hooks=this._driver.hooks,this.internalHooks=this._driver.internalHooks},o=function(t,e){this._driver=t,this.liff=e,this.hooks=this._driver.hooks},i=function(){function e(){this.modules=new Map,this.hooks={},this.internalHooks={}}return e.prototype.addModule=function(e,n){this.modules.set(e,n),n.hooks&&(this.hooks[e]=Object.entries(n.hooks).reduce((function(e,n){var o,i=t.__read(n,2),r=i[0],s=i[1];return t.__assign(t.__assign({},e),((o={})[r]=s.on.bind(s),o))}),{})),n.internalHooks&&(this.internalHooks[e]=Object.entries(n.internalHooks).reduce((function(e,n){var o,i=t.__read(n,2),r=i[0],s=i[1];return t.__assign(t.__assign({},e),((o={})[r]=s.on.bind(s),o))}),{}))},e.prototype.hasModule=function(t){return this.modules.has(t)},e}(),r=function(){function t(t,e,n){this.driver=t,this.context=e,this.option=n}return t.prototype.install=function(){return this.factory(this.driver,this.context)},Object.defineProperty(t.prototype,"name",{get:function(){return"use"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"defaultOption",{get:function(){return{namespacePrefix:"$"}},enumerable:!1,configurable:!0}),t.prototype.factory=function(t,n){var o=Object.assign({},this.defaultOption,this.option).namespacePrefix;return function(i,r){if(!i||"function"!=typeof i.install||"string"!=typeof i.name)return e.logger.warn("To install the plugin, you need to define the `name` property and the `install` method."),this;var s="".concat(o).concat(i.name);if(t.hasModule(s))return this;var a=i.install.call(i,n,r);return this["".concat(s)]?(e.logger.warn("There is a duplicate plugin name. `".concat(s,"` plugin namespace will be override.")),this["".concat(s)]=a):void 0!==a&&(this["".concat(s)]=a),t.addModule(s,i),this}},t}();exports.LiffPluginContextImpl=o,exports.ModuleContextImpl=n,exports.ModuleDriverImpl=i,exports.UseModule=r; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("@liff/logger"),n=function(e,t){this._driver=e,this.liff=t,this.hooks=this._driver.hooks,this.internalHooks=this._driver.internalHooks},o=function(e,t){this._driver=e,this.liff=t,this.hooks=this._driver.hooks},i=function(){function e(e,t){this.pluginCtx=new o(e,t),this.moduleCtx=new n(e,t)}return Object.defineProperty(e.prototype,"pluginContext",{get:function(){return this.pluginCtx},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"moduleContext",{get:function(){return this.moduleCtx},enumerable:!1,configurable:!0}),e}(),r=function(){function t(){this.modules=new Map,this.hooks={},this.internalHooks={}}return t.prototype.addModule=function(t,n){this.modules.set(t,n),n.hooks&&(this.hooks[t]=Object.entries(n.hooks).reduce((function(t,n){var o,i=e.__read(n,2),r=i[0],s=i[1];return e.__assign(e.__assign({},t),((o={})[r]=s.on.bind(s),o))}),{})),"internalHooks"in n&&n.internalHooks&&(this.internalHooks[t]=Object.entries(n.internalHooks).reduce((function(t,n){var o,i=e.__read(n,2),r=i[0],s=i[1];return e.__assign(e.__assign({},t),((o={})[r]=s.on.bind(s),o))}),{}))},t.prototype.hasModule=function(e){return this.modules.has(e)},t}(),s=function(){},u=function(e){return e instanceof s},a=function(n){function o(e,t,o){var i=n.call(this)||this;return i.driver=e,i.contextHolder=t,i.option=o,i}return e.__extends(o,n),o.prototype.install=function(){return this.factory(this.driver,this.contextHolder)},Object.defineProperty(o.prototype,"name",{get:function(){return"use"},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"defaultOption",{get:function(){return{namespacePrefix:"$"}},enumerable:!1,configurable:!0}),o.prototype.factory=function(e,n){var o=Object.assign({},this.defaultOption,this.option).namespacePrefix;return function(i,r){if(!i||"function"!=typeof i.install||"string"!=typeof i.name)return t.logger.warn("To install the plugin, you need to define the `name` property and the `install` method."),this;var s=u(i)?i.name:"".concat(o).concat(i.name);if(e.hasModule(s))return this;var a=u(i)?i.install.call(i,n.moduleContext,r):i.install.call(i,n.pluginContext,r);return this["".concat(s)]?(t.logger.warn("There is a duplicate plugin name. `".concat(s,"` plugin namespace will be override.")),this["".concat(s)]=a):void 0!==a&&(this["".concat(s)]=a),e.addModule(s,i),this}},o}(s);exports.ContextHolder=i,exports.LiffModule=s,exports.ModuleDriverImpl=r,exports.UseModule=a,exports.isLiffModule=u; |
export * from './context'; | ||
export * from './driver'; | ||
export * from './types'; | ||
export * from './module'; | ||
export * from './use'; |
@@ -1,1 +0,1 @@ | ||
import{__read as t,__assign as e}from"tslib";import{logger as n}from"@liff/logger";var o=function(t,e){this._driver=t,this.liff=e,this.hooks=this._driver.hooks,this.internalHooks=this._driver.internalHooks},i=function(t,e){this._driver=t,this.liff=e,this.hooks=this._driver.hooks},r=function(){function n(){this.modules=new Map,this.hooks={},this.internalHooks={}}return n.prototype.addModule=function(n,o){this.modules.set(n,o),o.hooks&&(this.hooks[n]=Object.entries(o.hooks).reduce((function(n,o){var i,r=t(o,2),s=r[0],a=r[1];return e(e({},n),((i={})[s]=a.on.bind(a),i))}),{})),o.internalHooks&&(this.internalHooks[n]=Object.entries(o.internalHooks).reduce((function(n,o){var i,r=t(o,2),s=r[0],a=r[1];return e(e({},n),((i={})[s]=a.on.bind(a),i))}),{}))},n.prototype.hasModule=function(t){return this.modules.has(t)},n}(),s=function(){function t(t,e,n){this.driver=t,this.context=e,this.option=n}return t.prototype.install=function(){return this.factory(this.driver,this.context)},Object.defineProperty(t.prototype,"name",{get:function(){return"use"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"defaultOption",{get:function(){return{namespacePrefix:"$"}},enumerable:!1,configurable:!0}),t.prototype.factory=function(t,e){var o=Object.assign({},this.defaultOption,this.option).namespacePrefix;return function(i,r){if(!i||"function"!=typeof i.install||"string"!=typeof i.name)return n.warn("To install the plugin, you need to define the `name` property and the `install` method."),this;var s="".concat(o).concat(i.name);if(t.hasModule(s))return this;var a=i.install.call(i,e,r);return this["".concat(s)]?(n.warn("There is a duplicate plugin name. `".concat(s,"` plugin namespace will be override.")),this["".concat(s)]=a):void 0!==a&&(this["".concat(s)]=a),t.addModule(s,i),this}},t}();export{i as LiffPluginContextImpl,o as ModuleContextImpl,r as ModuleDriverImpl,s as UseModule}; | ||
import{__read as t,__assign as e,__extends as n}from"tslib";import{logger as o}from"@liff/logger";var i=function(t,e){this._driver=t,this.liff=e,this.hooks=this._driver.hooks,this.internalHooks=this._driver.internalHooks},r=function(t,e){this._driver=t,this.liff=e,this.hooks=this._driver.hooks},s=function(){function t(t,e){this.pluginCtx=new r(t,e),this.moduleCtx=new i(t,e)}return Object.defineProperty(t.prototype,"pluginContext",{get:function(){return this.pluginCtx},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"moduleContext",{get:function(){return this.moduleCtx},enumerable:!1,configurable:!0}),t}(),u=function(){function n(){this.modules=new Map,this.hooks={},this.internalHooks={}}return n.prototype.addModule=function(n,o){this.modules.set(n,o),o.hooks&&(this.hooks[n]=Object.entries(o.hooks).reduce((function(n,o){var i,r=t(o,2),s=r[0],u=r[1];return e(e({},n),((i={})[s]=u.on.bind(u),i))}),{})),"internalHooks"in o&&o.internalHooks&&(this.internalHooks[n]=Object.entries(o.internalHooks).reduce((function(n,o){var i,r=t(o,2),s=r[0],u=r[1];return e(e({},n),((i={})[s]=u.on.bind(u),i))}),{}))},n.prototype.hasModule=function(t){return this.modules.has(t)},n}(),a=function(){},l=function(t){return t instanceof a},c=function(t){function e(e,n,o){var i=t.call(this)||this;return i.driver=e,i.contextHolder=n,i.option=o,i}return n(e,t),e.prototype.install=function(){return this.factory(this.driver,this.contextHolder)},Object.defineProperty(e.prototype,"name",{get:function(){return"use"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultOption",{get:function(){return{namespacePrefix:"$"}},enumerable:!1,configurable:!0}),e.prototype.factory=function(t,e){var n=Object.assign({},this.defaultOption,this.option).namespacePrefix;return function(i,r){if(!i||"function"!=typeof i.install||"string"!=typeof i.name)return o.warn("To install the plugin, you need to define the `name` property and the `install` method."),this;var s=l(i)?i.name:"".concat(n).concat(i.name);if(t.hasModule(s))return this;var u=l(i)?i.install.call(i,e.moduleContext,r):i.install.call(i,e.pluginContext,r);return this["".concat(s)]?(o.warn("There is a duplicate plugin name. `".concat(s,"` plugin namespace will be override.")),this["".concat(s)]=u):void 0!==u&&(this["".concat(s)]=u),t.addModule(s,i),this}},e}(a);export{s as ContextHolder,a as LiffModule,u as ModuleDriverImpl,c as UseModule,l as isLiffModule}; |
@@ -1,15 +0,19 @@ | ||
import { ModuleDriver, ModuleContext, LiffModule } from './types'; | ||
export declare type Use = <LiffModuleApi = unknown, LiffModuleOptions = unknown, Liff = unknown>(this: Liff, module: LiffModule<LiffModuleApi, LiffModuleOptions>, option?: LiffModuleOptions) => Liff; | ||
declare type Option = { | ||
import { ContextHolder } from './context'; | ||
import { ModuleDriver } from './driver'; | ||
import { LiffModule, LiffPlugin } from './module'; | ||
export type Use<Liff> = <Api, Option>(this: Liff, module: LiffModule<Api, Option, Liff> | LiffPlugin<Api, Option, Liff>, option?: Option) => Liff; | ||
export type ExtendLiffCoreUse<Liff> = { | ||
use: Use<Liff>; | ||
}; | ||
type Option = { | ||
namespacePrefix?: string; | ||
}; | ||
export declare type ExtendLiffCore = { | ||
use: Use; | ||
}; | ||
export declare class UseModule<Liff> implements LiffModule<Use> { | ||
type UseApi<Liff> = Use<Liff>; | ||
type UseOption = never; | ||
export declare class UseModule<Liff> extends LiffModule<UseApi<Liff>, UseOption, Liff> { | ||
private driver; | ||
private context; | ||
private contextHolder; | ||
private option?; | ||
constructor(driver: ModuleDriver, context: ModuleContext<Liff>, option?: Option | undefined); | ||
install(): Use; | ||
constructor(driver: ModuleDriver, contextHolder: ContextHolder<Liff>, option?: Option | undefined); | ||
install(): Use<Liff>; | ||
get name(): string; | ||
@@ -16,0 +20,0 @@ private get defaultOption(); |
{ | ||
"name": "@liff/use", | ||
"version": "2.21.4", | ||
"version": "2.22.0", | ||
"description": "@liff/use", | ||
@@ -31,9 +31,8 @@ "license": "SEE LICENSE IN README.md", | ||
"dependencies": { | ||
"@liff/hooks": "2.21.4", | ||
"@liff/logger": "2.21.4" | ||
"@liff/hooks": "2.22.0", | ||
"@liff/logger": "2.22.0" | ||
}, | ||
"peerDependencies": { | ||
"tslib": "^2.3.0" | ||
}, | ||
"gitHead": "af2b35a241fa715f3aa1ce484f011c9da9524e12" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
10469
8.46%125
5.93%3
50%1
Infinity%+ Added
+ Added
- Removed
- Removed
Updated
Updated