@viewfly/core 1.2.0 → 2.0.0-alpha.1
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/index.d.ts +2 -25
- package/bundles/index.esm.js +21 -63
- package/bundles/index.js +20 -63
- package/package.json +2 -2
package/bundles/index.d.ts
CHANGED
|
@@ -464,30 +464,7 @@ interface ComponentAnnotation {
|
|
|
464
464
|
scope?: Scope;
|
|
465
465
|
providers?: Provider[];
|
|
466
466
|
}
|
|
467
|
-
|
|
468
|
-
* 给组件添加注解
|
|
469
|
-
* @param annotation
|
|
470
|
-
* @param componentSetup
|
|
471
|
-
* @example
|
|
472
|
-
* ```ts
|
|
473
|
-
* export customScope = new Scope('scopeName')
|
|
474
|
-
* export const App = withAnnotation({
|
|
475
|
-
* scope: customScope,
|
|
476
|
-
* providers: [
|
|
477
|
-
* ExampleService
|
|
478
|
-
* ]
|
|
479
|
-
* }, function(props: Props) {
|
|
480
|
-
* return () => {
|
|
481
|
-
* return <div>...</div>
|
|
482
|
-
* }
|
|
483
|
-
* })
|
|
484
|
-
* ```
|
|
485
|
-
*/
|
|
486
|
-
declare function withAnnotation<T extends ComponentSetup>(annotation: ComponentAnnotation, componentSetup: T): T;
|
|
487
|
-
interface ContextProps extends Props {
|
|
488
|
-
providers: Provider[];
|
|
489
|
-
}
|
|
490
|
-
declare function Context(props: ContextProps): () => ViewFlyNode<string | ComponentSetup<any>>;
|
|
467
|
+
declare function withAnnotation<T extends ComponentSetup>(annotation: ComponentAnnotation, component: T): T;
|
|
491
468
|
|
|
492
469
|
declare function withMemo<T extends Props = Props>(canUseMemo: ComponentInstance<T>['$useMemo'], render: () => JSXNode): ComponentInstance<T>;
|
|
493
470
|
|
|
@@ -601,4 +578,4 @@ interface Module {
|
|
|
601
578
|
}
|
|
602
579
|
declare function viewfly<T extends NativeNode>(config: Config): Application<T>;
|
|
603
580
|
|
|
604
|
-
export { type AbstractInstanceType, type AbstractProvider, type AbstractType, type Application, type Atom, type ClassNames, type ClassProvider, Component, type ComponentAnnotation, type ComponentInstance, type ComponentSetup, type ComponentView, type Config, type ConstructorProvider,
|
|
581
|
+
export { type AbstractInstanceType, type AbstractProvider, type AbstractType, type Application, type Atom, type ClassNames, type ClassProvider, Component, type ComponentAnnotation, type ComponentInstance, type ComponentSetup, type ComponentView, type Config, type ConstructorProvider, DynamicRef, type ElementNamespace, ElementNamespaceMap, type ExistingProvider, type ExtractInstanceType, type ExtractValueType, type FactoryProvider, ForwardRef, Fragment, Inject, type InjectDecorator, InjectFlags, Injectable, type InjectableDecorator, type InjectableOptions, InjectionToken, Injector, JSX, type JSXNode, JSXNodeFactory, type Key, type LifeCycleCallback, type Module, type NativeNode, NativeRenderer, type NormalizedProvider, NullInjector, Optional, type OptionalDecorator, Prop, type PropDecorator, type Props, type PropsChangedCallback, type ProvideScope, type Provider, type RefListener, type ReflectiveDependency, ReflectiveInjector, RootComponent, Scope, Self, type SelfDecorator, type Signal, SkipSelf, type SkipSelfDecorator, type StaticProvider, StaticRef, THROW_IF_NOT_FOUND, Type, type TypeProvider, type ValueProvider, type ViewFlyNode, type WatchCallback, computed, createContext, createDerived, createDynamicRef, createRef, createRenderer, createSignal, forwardRef, getCurrentInstance, getSetupContext, inject, jsx, jsxs, makeError, normalizeProvider, onMounted, onPropsChanged, onUnmounted, onUpdated, viewfly, watch, withAnnotation, withMemo };
|
package/bundles/index.esm.js
CHANGED
|
@@ -1230,25 +1230,6 @@ function getCurrentInstance() {
|
|
|
1230
1230
|
return getSetupContext();
|
|
1231
1231
|
}
|
|
1232
1232
|
|
|
1233
|
-
function Fragment(props) {
|
|
1234
|
-
return () => {
|
|
1235
|
-
return props.children;
|
|
1236
|
-
};
|
|
1237
|
-
}
|
|
1238
|
-
function jsx(type, props, key) {
|
|
1239
|
-
return JSXNodeFactory.createNode(type, props, key);
|
|
1240
|
-
}
|
|
1241
|
-
const jsxs = jsx;
|
|
1242
|
-
const JSXNodeFactory = {
|
|
1243
|
-
createNode(type, props, key) {
|
|
1244
|
-
return {
|
|
1245
|
-
type,
|
|
1246
|
-
props,
|
|
1247
|
-
key
|
|
1248
|
-
};
|
|
1249
|
-
}
|
|
1250
|
-
};
|
|
1251
|
-
|
|
1252
1233
|
const injectMap = new WeakMap();
|
|
1253
1234
|
function getInjector(start) {
|
|
1254
1235
|
while (start) {
|
|
@@ -1278,60 +1259,37 @@ function inject(token, notFoundValue = THROW_IF_NOT_FOUND, flags) {
|
|
|
1278
1259
|
const injector = getInjector(component);
|
|
1279
1260
|
return injector.get(token, notFoundValue, flags);
|
|
1280
1261
|
}
|
|
1281
|
-
|
|
1282
|
-
* 给组件添加注解
|
|
1283
|
-
* @param annotation
|
|
1284
|
-
* @param componentSetup
|
|
1285
|
-
* @example
|
|
1286
|
-
* ```ts
|
|
1287
|
-
* export customScope = new Scope('scopeName')
|
|
1288
|
-
* export const App = withAnnotation({
|
|
1289
|
-
* scope: customScope,
|
|
1290
|
-
* providers: [
|
|
1291
|
-
* ExampleService
|
|
1292
|
-
* ]
|
|
1293
|
-
* }, function(props: Props) {
|
|
1294
|
-
* return () => {
|
|
1295
|
-
* return <div>...</div>
|
|
1296
|
-
* }
|
|
1297
|
-
* })
|
|
1298
|
-
* ```
|
|
1299
|
-
*/
|
|
1300
|
-
function withAnnotation(annotation, componentSetup) {
|
|
1262
|
+
function withAnnotation(annotation, component) {
|
|
1301
1263
|
return function (props) {
|
|
1302
1264
|
const instance = getCurrentInstance();
|
|
1303
1265
|
const parentInjector = injectMap.get(instance) || getInjector(instance.parentComponent);
|
|
1304
1266
|
const injector = new ReflectiveInjector(parentInjector, annotation.providers || [], annotation.scope);
|
|
1305
1267
|
injectMap.set(instance, injector);
|
|
1306
|
-
return
|
|
1268
|
+
return component(props);
|
|
1307
1269
|
};
|
|
1308
1270
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
return () => {
|
|
1315
|
-
return childProps.children;
|
|
1316
|
-
};
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
let contextComponent = createContextComponent(props.providers);
|
|
1320
|
-
onPropsChanged((newProps, oldProps) => {
|
|
1321
|
-
if (newProps.providers === oldProps.providers) {
|
|
1322
|
-
return;
|
|
1323
|
-
}
|
|
1324
|
-
contextComponent = createContextComponent(newProps.providers);
|
|
1325
|
-
});
|
|
1271
|
+
|
|
1272
|
+
class NativeRenderer {
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
function Fragment(props) {
|
|
1326
1276
|
return () => {
|
|
1327
|
-
return
|
|
1328
|
-
children: props.children
|
|
1329
|
-
});
|
|
1277
|
+
return props.children;
|
|
1330
1278
|
};
|
|
1331
1279
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1280
|
+
function jsx(type, props, key) {
|
|
1281
|
+
return JSXNodeFactory.createNode(type, props, key);
|
|
1334
1282
|
}
|
|
1283
|
+
const jsxs = jsx;
|
|
1284
|
+
const JSXNodeFactory = {
|
|
1285
|
+
createNode(type, props, key) {
|
|
1286
|
+
return {
|
|
1287
|
+
type,
|
|
1288
|
+
props,
|
|
1289
|
+
key
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1335
1293
|
|
|
1336
1294
|
function withMemo(canUseMemo, render) {
|
|
1337
1295
|
return {
|
|
@@ -2127,4 +2085,4 @@ function viewfly(config) {
|
|
|
2127
2085
|
return app;
|
|
2128
2086
|
}
|
|
2129
2087
|
|
|
2130
|
-
export { Component,
|
|
2088
|
+
export { Component, DynamicRef, ElementNamespaceMap, ForwardRef, Fragment, Inject, InjectFlags, Injectable, InjectionToken, Injector, JSXNodeFactory, NativeRenderer, NullInjector, Optional, Prop, ReflectiveInjector, RootComponent, Scope, Self, SkipSelf, StaticRef, THROW_IF_NOT_FOUND, Type, computed, createContext, createDerived, createDynamicRef, createRef, createRenderer, createSignal, forwardRef, getCurrentInstance, getSetupContext, inject, jsx, jsxs, makeError, normalizeProvider, onMounted, onPropsChanged, onUnmounted, onUpdated, viewfly, watch, withAnnotation, withMemo };
|
package/bundles/index.js
CHANGED
|
@@ -1232,25 +1232,6 @@ function getCurrentInstance() {
|
|
|
1232
1232
|
return getSetupContext();
|
|
1233
1233
|
}
|
|
1234
1234
|
|
|
1235
|
-
function Fragment(props) {
|
|
1236
|
-
return () => {
|
|
1237
|
-
return props.children;
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
function jsx(type, props, key) {
|
|
1241
|
-
return JSXNodeFactory.createNode(type, props, key);
|
|
1242
|
-
}
|
|
1243
|
-
const jsxs = jsx;
|
|
1244
|
-
const JSXNodeFactory = {
|
|
1245
|
-
createNode(type, props, key) {
|
|
1246
|
-
return {
|
|
1247
|
-
type,
|
|
1248
|
-
props,
|
|
1249
|
-
key
|
|
1250
|
-
};
|
|
1251
|
-
}
|
|
1252
|
-
};
|
|
1253
|
-
|
|
1254
1235
|
const injectMap = new WeakMap();
|
|
1255
1236
|
function getInjector(start) {
|
|
1256
1237
|
while (start) {
|
|
@@ -1280,60 +1261,37 @@ function inject(token, notFoundValue = THROW_IF_NOT_FOUND, flags) {
|
|
|
1280
1261
|
const injector = getInjector(component);
|
|
1281
1262
|
return injector.get(token, notFoundValue, flags);
|
|
1282
1263
|
}
|
|
1283
|
-
|
|
1284
|
-
* 给组件添加注解
|
|
1285
|
-
* @param annotation
|
|
1286
|
-
* @param componentSetup
|
|
1287
|
-
* @example
|
|
1288
|
-
* ```ts
|
|
1289
|
-
* export customScope = new Scope('scopeName')
|
|
1290
|
-
* export const App = withAnnotation({
|
|
1291
|
-
* scope: customScope,
|
|
1292
|
-
* providers: [
|
|
1293
|
-
* ExampleService
|
|
1294
|
-
* ]
|
|
1295
|
-
* }, function(props: Props) {
|
|
1296
|
-
* return () => {
|
|
1297
|
-
* return <div>...</div>
|
|
1298
|
-
* }
|
|
1299
|
-
* })
|
|
1300
|
-
* ```
|
|
1301
|
-
*/
|
|
1302
|
-
function withAnnotation(annotation, componentSetup) {
|
|
1264
|
+
function withAnnotation(annotation, component) {
|
|
1303
1265
|
return function (props) {
|
|
1304
1266
|
const instance = getCurrentInstance();
|
|
1305
1267
|
const parentInjector = injectMap.get(instance) || getInjector(instance.parentComponent);
|
|
1306
1268
|
const injector = new ReflectiveInjector(parentInjector, annotation.providers || [], annotation.scope);
|
|
1307
1269
|
injectMap.set(instance, injector);
|
|
1308
|
-
return
|
|
1270
|
+
return component(props);
|
|
1309
1271
|
};
|
|
1310
1272
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
return () => {
|
|
1317
|
-
return childProps.children;
|
|
1318
|
-
};
|
|
1319
|
-
});
|
|
1320
|
-
}
|
|
1321
|
-
let contextComponent = createContextComponent(props.providers);
|
|
1322
|
-
onPropsChanged((newProps, oldProps) => {
|
|
1323
|
-
if (newProps.providers === oldProps.providers) {
|
|
1324
|
-
return;
|
|
1325
|
-
}
|
|
1326
|
-
contextComponent = createContextComponent(newProps.providers);
|
|
1327
|
-
});
|
|
1273
|
+
|
|
1274
|
+
class NativeRenderer {
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
function Fragment(props) {
|
|
1328
1278
|
return () => {
|
|
1329
|
-
return
|
|
1330
|
-
children: props.children
|
|
1331
|
-
});
|
|
1279
|
+
return props.children;
|
|
1332
1280
|
};
|
|
1333
1281
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1282
|
+
function jsx(type, props, key) {
|
|
1283
|
+
return JSXNodeFactory.createNode(type, props, key);
|
|
1336
1284
|
}
|
|
1285
|
+
const jsxs = jsx;
|
|
1286
|
+
const JSXNodeFactory = {
|
|
1287
|
+
createNode(type, props, key) {
|
|
1288
|
+
return {
|
|
1289
|
+
type,
|
|
1290
|
+
props,
|
|
1291
|
+
key
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1337
1295
|
|
|
1338
1296
|
function withMemo(canUseMemo, render) {
|
|
1339
1297
|
return {
|
|
@@ -2130,7 +2088,6 @@ function viewfly(config) {
|
|
|
2130
2088
|
}
|
|
2131
2089
|
|
|
2132
2090
|
exports.Component = Component;
|
|
2133
|
-
exports.Context = Context;
|
|
2134
2091
|
exports.DynamicRef = DynamicRef;
|
|
2135
2092
|
exports.ElementNamespaceMap = ElementNamespaceMap;
|
|
2136
2093
|
exports.ForwardRef = ForwardRef;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "Viewfly is a simple and easy-to-use JavaScript framework with an intuitive development experience.",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"bugs": {
|
|
51
51
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "7a4f48b8c21d4450ff837485c191e3d9bf88f5fb",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"reflect-metadata": "^0.2.2"
|
|
56
56
|
}
|