@viewfly/platform-browser 0.0.30 → 0.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/bundles/create-app.d.ts +3 -2
- package/bundles/fork.d.ts +3 -2
- package/bundles/index.esm.js +20 -29
- package/bundles/index.js +19 -28
- package/package.json +3 -3
package/bundles/create-app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSXNode } from '@viewfly/core';
|
|
1
|
+
import { JSXNode, Application, Config } from '@viewfly/core';
|
|
2
2
|
/**
|
|
3
3
|
* 创建一个 Viewfly 实例
|
|
4
4
|
* @param root 应用根节点
|
|
@@ -13,4 +13,5 @@ import { JSXNode } from '@viewfly/core';
|
|
|
13
13
|
* app.render() // 手动更新视图
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export declare function createApp(root: JSXNode, autoUpdate?: boolean):
|
|
16
|
+
export declare function createApp(root: JSXNode, autoUpdate?: boolean): Application;
|
|
17
|
+
export declare function createApp(root: JSXNode, config?: Omit<Config, 'nativeRenderer' | 'root'>): Application;
|
package/bundles/fork.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function fork(root:
|
|
1
|
+
import { JSXNode, Application, Config } from '@viewfly/core';
|
|
2
|
+
export declare function fork(root: JSXNode, autoUpdate?: boolean): Application;
|
|
3
|
+
export declare function fork(root: JSXNode, config?: Omit<Config, 'nativeRenderer' | 'root'>): Application;
|
package/bundles/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NativeRenderer, viewfly, makeError, inject, Injector, THROW_IF_NOT_FOUND, InjectFlags,
|
|
1
|
+
import { NativeRenderer, viewfly, makeError, inject, Injector, THROW_IF_NOT_FOUND, InjectFlags, onUnmounted } from '@viewfly/core';
|
|
2
2
|
|
|
3
3
|
class DomRenderer extends NativeRenderer {
|
|
4
4
|
constructor() {
|
|
@@ -197,30 +197,26 @@ class DomRenderer extends NativeRenderer {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
* // do something...
|
|
210
|
-
*
|
|
211
|
-
* app.render() // 手动更新视图
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
function createApp(root, autoUpdate = true) {
|
|
215
|
-
return viewfly({
|
|
216
|
-
root,
|
|
217
|
-
autoUpdate,
|
|
218
|
-
nativeRenderer: new DomRenderer()
|
|
219
|
-
});
|
|
200
|
+
function createApp(root, config = true) {
|
|
201
|
+
const c = { autoUpdate: true };
|
|
202
|
+
if (typeof config === 'boolean') {
|
|
203
|
+
c.autoUpdate = config;
|
|
204
|
+
}
|
|
205
|
+
else if (typeof config === 'object') {
|
|
206
|
+
Object.assign(c, config);
|
|
207
|
+
}
|
|
208
|
+
return viewfly(Object.assign({ root, nativeRenderer: new DomRenderer() }, c));
|
|
220
209
|
}
|
|
221
210
|
|
|
222
211
|
const forkErrorFn = makeError('fork');
|
|
223
|
-
function fork(root,
|
|
212
|
+
function fork(root, config = true) {
|
|
213
|
+
const c = { autoUpdate: true };
|
|
214
|
+
if (typeof config === 'boolean') {
|
|
215
|
+
c.autoUpdate = config;
|
|
216
|
+
}
|
|
217
|
+
else if (typeof config === 'object') {
|
|
218
|
+
Object.assign(c, config);
|
|
219
|
+
}
|
|
224
220
|
let injector;
|
|
225
221
|
try {
|
|
226
222
|
injector = inject(Injector, THROW_IF_NOT_FOUND, InjectFlags.Default);
|
|
@@ -228,13 +224,8 @@ function fork(root, autoUpdate = true) {
|
|
|
228
224
|
catch (_a) {
|
|
229
225
|
throw forkErrorFn('The fork function can only be called synchronously within a component.');
|
|
230
226
|
}
|
|
231
|
-
const app = viewfly({
|
|
232
|
-
|
|
233
|
-
context: injector,
|
|
234
|
-
autoUpdate,
|
|
235
|
-
nativeRenderer: new DomRenderer()
|
|
236
|
-
});
|
|
237
|
-
onDestroy(() => {
|
|
227
|
+
const app = viewfly(Object.assign({ root, context: injector, nativeRenderer: new DomRenderer() }, c));
|
|
228
|
+
onUnmounted(() => {
|
|
238
229
|
app.destroy();
|
|
239
230
|
});
|
|
240
231
|
return app;
|
package/bundles/index.js
CHANGED
|
@@ -199,30 +199,26 @@ class DomRenderer extends core.NativeRenderer {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
* // do something...
|
|
212
|
-
*
|
|
213
|
-
* app.render() // 手动更新视图
|
|
214
|
-
* ```
|
|
215
|
-
*/
|
|
216
|
-
function createApp(root, autoUpdate = true) {
|
|
217
|
-
return core.viewfly({
|
|
218
|
-
root,
|
|
219
|
-
autoUpdate,
|
|
220
|
-
nativeRenderer: new DomRenderer()
|
|
221
|
-
});
|
|
202
|
+
function createApp(root, config = true) {
|
|
203
|
+
const c = { autoUpdate: true };
|
|
204
|
+
if (typeof config === 'boolean') {
|
|
205
|
+
c.autoUpdate = config;
|
|
206
|
+
}
|
|
207
|
+
else if (typeof config === 'object') {
|
|
208
|
+
Object.assign(c, config);
|
|
209
|
+
}
|
|
210
|
+
return core.viewfly(Object.assign({ root, nativeRenderer: new DomRenderer() }, c));
|
|
222
211
|
}
|
|
223
212
|
|
|
224
213
|
const forkErrorFn = core.makeError('fork');
|
|
225
|
-
function fork(root,
|
|
214
|
+
function fork(root, config = true) {
|
|
215
|
+
const c = { autoUpdate: true };
|
|
216
|
+
if (typeof config === 'boolean') {
|
|
217
|
+
c.autoUpdate = config;
|
|
218
|
+
}
|
|
219
|
+
else if (typeof config === 'object') {
|
|
220
|
+
Object.assign(c, config);
|
|
221
|
+
}
|
|
226
222
|
let injector;
|
|
227
223
|
try {
|
|
228
224
|
injector = core.inject(core.Injector, core.THROW_IF_NOT_FOUND, core.InjectFlags.Default);
|
|
@@ -230,13 +226,8 @@ function fork(root, autoUpdate = true) {
|
|
|
230
226
|
catch (_a) {
|
|
231
227
|
throw forkErrorFn('The fork function can only be called synchronously within a component.');
|
|
232
228
|
}
|
|
233
|
-
const app = core.viewfly({
|
|
234
|
-
|
|
235
|
-
context: injector,
|
|
236
|
-
autoUpdate,
|
|
237
|
-
nativeRenderer: new DomRenderer()
|
|
238
|
-
});
|
|
239
|
-
core.onDestroy(() => {
|
|
229
|
+
const app = core.viewfly(Object.assign({ root, context: injector, nativeRenderer: new DomRenderer() }, c));
|
|
230
|
+
core.onUnmounted(() => {
|
|
240
231
|
app.destroy();
|
|
241
232
|
});
|
|
242
233
|
return app;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/platform-browser",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "This project is used to enable the Viewfly framework to run in a browser.",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"keywords": [],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@viewfly/core": "^0.0
|
|
15
|
+
"@viewfly/core": "^0.1.0",
|
|
16
16
|
"csstype": "^3.1.2"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"bugs": {
|
|
34
34
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "790bb591abb02c500f54c579c7783da66a999b87"
|
|
37
37
|
}
|