android&iOS:create context set this to undefined
This commit is contained in:
parent
cdaebe46cd
commit
0087c5bda4
@ -222,7 +222,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
||||
}
|
||||
|
||||
private String packageContextScript(String contextId, String content) {
|
||||
return String.format(DoricConstant.TEMPLATE_CONTEXT_CREATE, content, contextId, contextId, contextId);
|
||||
return String.format(DoricConstant.TEMPLATE_CONTEXT_CREATE, content, contextId, contextId);
|
||||
}
|
||||
|
||||
private String packageModuleScript(String moduleName, String content) {
|
||||
|
@ -38,7 +38,7 @@ public class DoricConstant {
|
||||
public static final String TEMPLATE_CONTEXT_CREATE = "Reflect.apply(" +
|
||||
"function(doric,context,Entry,require,exports){" + "\n" +
|
||||
"%s" + "\n" +
|
||||
"},doric.jsObtainContext(\"%s\"),[" +
|
||||
"},undefined,[" +
|
||||
"undefined," +
|
||||
"doric.jsObtainContext(\"%s\")," +
|
||||
"doric.jsObtainEntry(\"%s\")," +
|
||||
|
@ -150,7 +150,7 @@ - (JSValue *)invokeDoricMethod:(NSString *)method argumentsArray:(NSArray *)args
|
||||
}
|
||||
|
||||
- (NSString *)packageContextScript:(NSString *)contextId content:(NSString *)content {
|
||||
NSString *ret = [NSString stringWithFormat:TEMPLATE_CONTEXT_CREATE, content, contextId, contextId, contextId];
|
||||
NSString *ret = [NSString stringWithFormat:TEMPLATE_CONTEXT_CREATE, content, contextId, contextId];
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
NSString *const TEMPLATE_CONTEXT_CREATE = @"Reflect.apply("
|
||||
"function(doric,context,Entry,require,exports){" "\n"
|
||||
"%@" "\n"
|
||||
"},doric.jsObtainContext(\"%@\"),["
|
||||
"},undefined,["
|
||||
"undefined,"
|
||||
"doric.jsObtainContext(\"%@\"),"
|
||||
"doric.jsObtainEntry(\"%@\"),"
|
||||
|
@ -2081,6 +2081,25 @@ function animate(context) {
|
||||
}
|
||||
}
|
||||
|
||||
function notification(context) {
|
||||
return {
|
||||
publish: (args) => {
|
||||
if (args.data !== undefined) {
|
||||
args.data = JSON.stringify(args.data);
|
||||
}
|
||||
return context.notification.publish(args);
|
||||
},
|
||||
subscribe: (args) => {
|
||||
args.callback = context.function2Id(args.callback);
|
||||
return context.notification.subscribe(args);
|
||||
},
|
||||
unsubscribe: (subscribeId) => {
|
||||
context.removeFuncById(subscribeId);
|
||||
return context.notification.unsubscribe({ subscribeId });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class Observable {
|
||||
constructor(provider, clz) {
|
||||
this.observers = new Set;
|
||||
@ -2224,6 +2243,7 @@ exports.modal = modal;
|
||||
exports.navbar = navbar;
|
||||
exports.navigator = navigator;
|
||||
exports.network = network;
|
||||
exports.notification = notification;
|
||||
exports.obj2Model = obj2Model;
|
||||
exports.popover = popover;
|
||||
exports.pullable = pullable;
|
||||
|
@ -3540,6 +3540,25 @@ function animate(context) {
|
||||
}
|
||||
}
|
||||
|
||||
function notification(context) {
|
||||
return {
|
||||
publish: (args) => {
|
||||
if (args.data !== undefined) {
|
||||
args.data = JSON.stringify(args.data);
|
||||
}
|
||||
return context.notification.publish(args);
|
||||
},
|
||||
subscribe: (args) => {
|
||||
args.callback = context.function2Id(args.callback);
|
||||
return context.notification.subscribe(args);
|
||||
},
|
||||
unsubscribe: (subscribeId) => {
|
||||
context.removeFuncById(subscribeId);
|
||||
return context.notification.unsubscribe({ subscribeId });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class Observable {
|
||||
constructor(provider, clz) {
|
||||
this.observers = new Set;
|
||||
@ -3789,6 +3808,7 @@ exports.modal = modal;
|
||||
exports.navbar = navbar;
|
||||
exports.navigator = navigator;
|
||||
exports.network = network;
|
||||
exports.notification = notification;
|
||||
exports.obj2Model = obj2Model;
|
||||
exports.popover = popover;
|
||||
exports.pullable = pullable;
|
||||
|
20
doric-js/index.d.ts
vendored
20
doric-js/index.d.ts
vendored
@ -64,6 +64,7 @@ declare module 'doric/lib/src/native/index.native' {
|
||||
export * from 'doric/lib/src/native/storage';
|
||||
export * from 'doric/lib/src/native/popover';
|
||||
export * from 'doric/lib/src/native/animate';
|
||||
export * from 'doric/lib/src/native/notification';
|
||||
}
|
||||
|
||||
declare module 'doric/lib/src/util/index.util' {
|
||||
@ -792,6 +793,25 @@ declare module 'doric/lib/src/native/animate' {
|
||||
}) => Promise<any>;
|
||||
}
|
||||
|
||||
declare module 'doric/lib/src/native/notification' {
|
||||
import { BridgeContext } from "doric/lib/src/runtime/global";
|
||||
export function notification(context: BridgeContext): {
|
||||
publish: (args: {
|
||||
biz: string;
|
||||
name: string;
|
||||
data?: object | undefined;
|
||||
androidSystem?: boolean | undefined;
|
||||
}) => Promise<any>;
|
||||
subscribe: (args: {
|
||||
biz: string;
|
||||
name: string;
|
||||
callback: (data?: any) => void;
|
||||
androidSystem?: boolean | undefined;
|
||||
}) => Promise<string>;
|
||||
unsubscribe: (subscribeId: string) => Promise<any>;
|
||||
};
|
||||
}
|
||||
|
||||
declare module 'doric/lib/src/util/color' {
|
||||
import { Modeling } from "doric/lib/src/util/types";
|
||||
/**
|
||||
|
1
doric-js/lib/src/native/index.native.d.ts
vendored
1
doric-js/lib/src/native/index.native.d.ts
vendored
@ -5,3 +5,4 @@ export * from './network';
|
||||
export * from './storage';
|
||||
export * from './popover';
|
||||
export * from './animate';
|
||||
export * from './notification';
|
||||
|
@ -20,3 +20,4 @@ export * from './network';
|
||||
export * from './storage';
|
||||
export * from './popover';
|
||||
export * from './animate';
|
||||
export * from './notification';
|
||||
|
2
doric-js/lib/src/native/notification.d.ts
vendored
2
doric-js/lib/src/native/notification.d.ts
vendored
@ -9,7 +9,7 @@ export declare function notification(context: BridgeContext): {
|
||||
subscribe: (args: {
|
||||
biz: string;
|
||||
name: string;
|
||||
callback: (data?: object | undefined) => void;
|
||||
callback: (data?: any) => void;
|
||||
androidSystem?: boolean | undefined;
|
||||
}) => Promise<string>;
|
||||
unsubscribe: (subscribeId: string) => Promise<any>;
|
||||
|
Reference in New Issue
Block a user