add ResourceLoader plugin

This commit is contained in:
pengfei.zhou
2021-11-18 16:38:35 +08:00
committed by osborn
parent ea85559977
commit d746c5b4d4
22 changed files with 312 additions and 7 deletions

View File

@@ -4203,6 +4203,14 @@ function keyboard(context) {
};
}
function resourceLoader(context) {
return {
load: function (resource) {
return context.callNative('resourceLoader', 'load', resource.toModel());
},
};
}
var __values = (undefined && undefined.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) { return m.call(o); }
@@ -4628,6 +4636,7 @@ exports.popover = popover;
exports.pullable = pullable;
exports.refreshable = refreshable;
exports.repeat = repeat;
exports.resourceLoader = resourceLoader;
exports.scroller = scroller;
exports.slideItem = slideItem;
exports.slider = slider;

View File

@@ -3222,6 +3222,14 @@ function keyboard(context) {
};
}
function resourceLoader(context) {
return {
load: (resource) => {
return context.callNative('resourceLoader', 'load', resource.toModel());
},
};
}
class Observable {
constructor(provider, clz) {
this.observers = new Set;
@@ -3559,6 +3567,7 @@ exports.popover = popover;
exports.pullable = pullable;
exports.refreshable = refreshable;
exports.repeat = repeat;
exports.resourceLoader = resourceLoader;
exports.scroller = scroller;
exports.slideItem = slideItem;
exports.slider = slider;

View File

@@ -4750,6 +4750,14 @@ function keyboard(context) {
};
}
function resourceLoader(context) {
return {
load: (resource) => {
return context.callNative('resourceLoader', 'load', resource.toModel());
},
};
}
class Observable {
constructor(provider, clz) {
this.observers = new Set;
@@ -5328,6 +5336,7 @@ exports.popover = popover;
exports.pullable = pullable;
exports.refreshable = refreshable;
exports.repeat = repeat;
exports.resourceLoader = resourceLoader;
exports.scroller = scroller;
exports.slideItem = slideItem;
exports.slider = slider;

9
doric-js/index.d.ts vendored
View File

@@ -112,6 +112,7 @@ declare module 'doric/lib/src/native/index.native' {
export * from 'doric/lib/src/native/coordinator';
export * from 'doric/lib/src/native/notch';
export * from 'doric/lib/src/native/keyboard';
export * from 'doric/lib/src/native/resourceLoader';
}
declare module 'doric/lib/src/util/index.util' {
@@ -1344,6 +1345,14 @@ declare module 'doric/lib/src/native/keyboard' {
};
}
declare module 'doric/lib/src/native/resourceLoader' {
import { Resource } from "doric/lib/src/util/resource";
import { BridgeContext } from "doric/lib/src/runtime/global";
export function resourceLoader(context: BridgeContext): {
load: (resource: Resource) => Promise<ArrayBuffer>;
};
}
declare module 'doric/lib/src/util/color' {
import { Modeling } from "doric/lib/src/util/types";
/**

View File

@@ -0,0 +1,6 @@
import { Resource } from "../util/resource";
import { BridgeContext } from "../runtime/global";
export declare function imageDecoder(context: BridgeContext): {
getBitmapInfo: (resource: Resource) => Promise<ArrayBuffer>;
decodeToPixels: (resource: Resource) => Promise<ArrayBuffer>;
};

View File

@@ -0,0 +1,25 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function imageDecoder(context) {
return {
getBitmapInfo: (resource) => {
return context.callNative('imageDecoder', 'getBitmapInfo', resource);
},
decodeToPixels: (resource) => {
return context.callNative('imageDecoder', 'decode', resource);
},
};
}

View File

@@ -10,3 +10,4 @@ export * from './statusbar';
export * from './coordinator';
export * from './notch';
export * from './keyboard';
export * from './resourceLoader';

View File

@@ -25,3 +25,4 @@ export * from './statusbar';
export * from './coordinator';
export * from './notch';
export * from './keyboard';
export * from './resourceLoader';

View File

@@ -0,0 +1,5 @@
import { Resource } from "../util/resource";
import { BridgeContext } from "../runtime/global";
export declare function resourceLoader(context: BridgeContext): {
load: (resource: Resource) => Promise<ArrayBuffer>;
};

View File

@@ -0,0 +1,7 @@
export function resourceLoader(context) {
return {
load: (resource) => {
return context.callNative('resourceLoader', 'load', resource.toModel());
},
};
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Resource } from "../util/resource"
import { BridgeContext } from "../runtime/global"
export function imageDecoder(context: BridgeContext) {
return {
getBitmapInfo: (resource: Resource) => {
return context.callNative('imageDecoder', 'getBitmapInfo', resource) as Promise<ArrayBuffer>
},
decodeToPixels: (resource: Resource) => {
return context.callNative('imageDecoder', 'decode', resource) as Promise<ArrayBuffer>
},
}
}

View File

@@ -24,4 +24,5 @@ export * from './notification'
export * from './statusbar'
export * from './coordinator'
export * from './notch'
export * from './keyboard'
export * from './keyboard'
export * from './resourceLoader'

View File

@@ -0,0 +1,25 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Resource } from "../util/resource"
import { BridgeContext } from "../runtime/global"
export function resourceLoader(context: BridgeContext) {
return {
load: (resource: Resource) => {
return context.callNative('resourceLoader', 'load', resource.toModel()) as Promise<ArrayBuffer>;
},
}
}