nativescript-vue 3.0.0-dev.4 → 3.0.0-rc.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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -1
  3. package/devtools.js +33 -0
  4. package/dist/compiler-sfc/index.d.ts +1 -0
  5. package/dist/compiler-sfc/index.js +2 -0
  6. package/dist/compiler-sfc/index.js.map +1 -0
  7. package/dist/compiler.d.ts +4 -0
  8. package/dist/compiler.js +32 -0
  9. package/dist/compiler.js.map +1 -0
  10. package/dist/components/ActionBar.d.ts +3 -0
  11. package/dist/components/ActionBar.js +70 -0
  12. package/dist/components/ActionBar.js.map +1 -0
  13. package/dist/components/ListView.d.ts +20 -0
  14. package/dist/components/ListView.js +110 -0
  15. package/dist/components/ListView.js.map +1 -0
  16. package/dist/components/index.d.ts +22 -0
  17. package/dist/components/index.js +8 -0
  18. package/dist/components/index.js.map +1 -0
  19. package/dist/directives/vModel.d.ts +8 -0
  20. package/dist/directives/vModel.js +38 -0
  21. package/dist/directives/vModel.js.map +1 -0
  22. package/dist/directives/vShow.d.ts +7 -0
  23. package/dist/directives/vShow.js +45 -0
  24. package/dist/directives/vShow.js.map +1 -0
  25. package/dist/dom/index.d.ts +66 -0
  26. package/dist/dom/index.js +303 -0
  27. package/dist/dom/index.js.map +1 -0
  28. package/dist/index.d.ts +27 -0
  29. package/dist/index.js +101 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/nativescript/elements.d.ts +1 -0
  32. package/dist/nativescript/elements.js +164 -0
  33. package/dist/nativescript/elements.js.map +1 -0
  34. package/dist/nativescript/index.d.ts +6 -0
  35. package/dist/nativescript/index.js +26 -0
  36. package/dist/nativescript/index.js.map +1 -0
  37. package/dist/plugins/modals.d.ts +26 -0
  38. package/dist/plugins/modals.js +79 -0
  39. package/dist/plugins/modals.js.map +1 -0
  40. package/dist/plugins/navigation.d.ts +32 -0
  41. package/dist/plugins/navigation.js +110 -0
  42. package/dist/plugins/navigation.js.map +1 -0
  43. package/dist/plugins/templates.d.ts +10 -0
  44. package/dist/plugins/templates.js +12 -0
  45. package/dist/plugins/templates.js.map +1 -0
  46. package/dist/registry/index.d.ts +26 -0
  47. package/dist/registry/index.js +55 -0
  48. package/dist/registry/index.js.map +1 -0
  49. package/dist/renderer/index.d.ts +1 -0
  50. package/dist/renderer/index.js +8 -0
  51. package/dist/renderer/index.js.map +1 -0
  52. package/dist/renderer/modules/attrs.d.ts +2 -0
  53. package/dist/renderer/modules/attrs.js +31 -0
  54. package/dist/renderer/modules/attrs.js.map +1 -0
  55. package/dist/renderer/modules/class.d.ts +2 -0
  56. package/dist/renderer/modules/class.js +9 -0
  57. package/dist/renderer/modules/class.js.map +1 -0
  58. package/dist/renderer/modules/events.d.ts +12 -0
  59. package/dist/renderer/modules/events.js +59 -0
  60. package/dist/renderer/modules/events.js.map +1 -0
  61. package/dist/renderer/modules/style.d.ts +5 -0
  62. package/dist/renderer/modules/style.js +80 -0
  63. package/dist/renderer/modules/style.js.map +1 -0
  64. package/dist/renderer/nodeOps.d.ts +17 -0
  65. package/dist/renderer/nodeOps.js +70 -0
  66. package/dist/renderer/nodeOps.js.map +1 -0
  67. package/dist/renderer/patchProp.d.ts +2 -0
  68. package/dist/renderer/patchProp.js +47 -0
  69. package/dist/renderer/patchProp.js.map +1 -0
  70. package/dist/runtimeHelpers.d.ts +31 -0
  71. package/dist/runtimeHelpers.js +51 -0
  72. package/dist/runtimeHelpers.js.map +1 -0
  73. package/dist/types.d.ts +15 -0
  74. package/dist/types.js +2 -0
  75. package/dist/types.js.map +1 -0
  76. package/dist/withCompiler.d.ts +3 -0
  77. package/dist/withCompiler.js +6 -0
  78. package/dist/withCompiler.js.map +1 -0
  79. package/nativescript.webpack.js +162 -0
  80. package/package.json +43 -22
  81. package/dist/nativescript-vue.cjs.js +0 -56
  82. package/dist/nativescript-vue.cjs.prod.js +0 -55
  83. package/dist/nativescript-vue.esm-bundler.js +0 -36
  84. package/index.js +0 -7
@@ -0,0 +1,26 @@
1
+ import { Application } from '@nativescript/core';
2
+ import { registerCoreElements } from './elements';
3
+ export function init() {
4
+ registerCoreElements();
5
+ global.__onLiveSyncCore = () => {
6
+ Application.getRootView()?._onCssStateChange();
7
+ };
8
+ }
9
+ export function startApp(rootComponent) {
10
+ Application.run({
11
+ create() {
12
+ return rootComponent.$el.nativeView;
13
+ },
14
+ });
15
+ }
16
+ export function resetRoot(view) {
17
+ Application.resetRootView({
18
+ create() {
19
+ return view;
20
+ },
21
+ });
22
+ }
23
+ export { isAndroid, isIOS } from '@nativescript/core';
24
+ // export const isAndroid = false;
25
+ // export const isIOS = false;
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nativescript/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAQ,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMlD,MAAM,UAAU,IAAI;IAClB,oBAAoB,EAAE,CAAC;IAEvB,MAAM,CAAC,gBAAgB,GAAG,GAAG,EAAE;QAC7B,WAAW,CAAC,WAAW,EAAE,EAAE,iBAAiB,EAAE,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,aAAsC;IAC7D,WAAW,CAAC,GAAG,CAAC;QACd,MAAM;YACJ,OAAO,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC;QACtC,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAU;IAClC,WAAW,CAAC,aAAa,CAAC;QACxB,MAAM;YACJ,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEtD,kCAAkC;AAClC,8BAA8B"}
@@ -0,0 +1,26 @@
1
+ import { ShowModalOptions, View } from '@nativescript/core';
2
+ import { App, Component, ComponentPublicInstance } from '@vue/runtime-core';
3
+ import { NSVElement } from '../dom';
4
+ declare module '@vue/runtime-core' {
5
+ interface ComponentCustomProperties {
6
+ /**
7
+ * todo: update docblock
8
+ */
9
+ $showModal: <T = any>(component: Component, options?: ModalOptions) => Promise<T | false | undefined>;
10
+ $closeModal: (arg: any) => void;
11
+ $modal: {
12
+ close: (arg: any) => void;
13
+ };
14
+ }
15
+ }
16
+ type ResolvableModalTarget = ComponentPublicInstance | NSVElement | View;
17
+ export interface ModalOptions extends Partial<ShowModalOptions> {
18
+ props?: Record<string, any>;
19
+ target?: ResolvableModalTarget;
20
+ }
21
+ /**
22
+ * @internal
23
+ */
24
+ export declare function install(app: App): void;
25
+ export declare function $showModal<T = any>(component: Component, options?: ModalOptions): Promise<T | false | undefined>;
26
+ export {};
@@ -0,0 +1,79 @@
1
+ import { Application, View } from '@nativescript/core';
2
+ import { unref, warn, } from '@vue/runtime-core';
3
+ import { NSVElement, NSVRoot } from '../dom';
4
+ import { createNativeView } from '../runtimeHelpers';
5
+ import { isObject } from '@vue/shared';
6
+ /**
7
+ * @internal
8
+ */
9
+ export function install(app) {
10
+ app.config.globalProperties.$showModal = $showModal;
11
+ }
12
+ function resolveModalTarget(target) {
13
+ const ob = unref(target);
14
+ if (ob instanceof NSVElement) {
15
+ return ob.nativeView;
16
+ }
17
+ else if (ob instanceof View) {
18
+ return ob;
19
+ }
20
+ else if (isObject(ob) && isObject(ob.$el)) {
21
+ return ob.$el.nativeView;
22
+ }
23
+ return false;
24
+ }
25
+ export async function $showModal(component, options = {}) {
26
+ const modalTarget = resolveModalTarget(options.target ?? Application.getRootView());
27
+ if (!modalTarget) {
28
+ if (__DEV__) {
29
+ warn(`could not open modal because the target does not exist`);
30
+ }
31
+ return;
32
+ }
33
+ return new Promise((resolve) => {
34
+ let isResolved = false;
35
+ let isReloading = false;
36
+ let root = new NSVRoot();
37
+ const reloadModal = () => {
38
+ isReloading = true;
39
+ closeModal();
40
+ // reopening is done in `closeCallback`
41
+ };
42
+ let view = createNativeView(component, options.props, {
43
+ reload: reloadModal,
44
+ });
45
+ const closeCallback = (data) => {
46
+ if (isResolved)
47
+ return;
48
+ if (isReloading) {
49
+ view.unmount();
50
+ view.mount(root);
51
+ openModal({
52
+ // todo: for this to work nicely, we'd need to add `animated: false` to `closeModal` as well
53
+ // but not currently possible without a core change.
54
+ // animated: false,
55
+ });
56
+ isReloading = false;
57
+ return;
58
+ }
59
+ isResolved = true;
60
+ view.unmount();
61
+ view = null;
62
+ resolve(data);
63
+ };
64
+ const openModal = (additionalOptions) => {
65
+ modalTarget.showModal(view.nativeView, {
66
+ ...options,
67
+ context: null,
68
+ closeCallback,
69
+ ...additionalOptions,
70
+ });
71
+ };
72
+ const closeModal = (...args) => view.nativeView?.closeModal(...args);
73
+ view.context.config.globalProperties.$closeModal = closeModal;
74
+ view.context.config.globalProperties.$modal = { close: closeModal };
75
+ view.mount(root);
76
+ openModal();
77
+ });
78
+ }
79
+ //# sourceMappingURL=modals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modals.js","sourceRoot":"","sources":["../../src/plugins/modals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAKL,KAAK,EACL,IAAI,GACL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAyBvC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,GAAQ;IAC9B,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,UAAU,CAAC;AACtD,CAAC;AAED,SAAS,kBAAkB,CACzB,MAA0D;IAE1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W,EAAE,CAAC;gBAChB,IAAI,CAAC,OAAO,EAAE,CAAC;gBACf,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACjB,SAAS,CAAC;gBACR,4FAA4F;gBAC5F,oDAAoD;gBACpD,mBAAmB;iBACpB,CAAC,CAAC;gBACH,WAAW,GAAG,KAAK,CAAC;gBAEpB,OAAO;YACT,CAAC;YAED,UAAU,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,GAAG,IAAI,CAAC;YAEZ,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;QAEF,MAAM,SAAS,GAAG,CAAC,iBAA6C,EAAE,EAAE;YAClE,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE;gBACrC,GAAG,OAAO;gBACV,OAAO,EAAE,IAAI;gBACb,aAAa;gBACb,GAAG,iBAAiB;aACrB,CAAC,CAAC;QACL,CAAC,CAAC;QACF,MAAM,UAAU,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;QAE5E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9D,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;QAEpE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,SAAS,EAAE,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { Frame, NavigationEntry, Page } from '@nativescript/core';
2
+ import { App, Component, Ref } from '@vue/runtime-core';
3
+ import { NSVElement } from '../dom';
4
+ declare module '@vue/runtime-core' {
5
+ interface ComponentCustomProperties {
6
+ /**
7
+ * todo: update docblock
8
+ * Navigate to {target} component.
9
+ *
10
+ * The frame to navigate defaults to the topmost frame
11
+ * @param target
12
+ * @param options
13
+ */
14
+ $navigateTo: (target: Component, options?: NavigationOptions) => Page;
15
+ $navigateBack: (options?: NavigationOptions) => void;
16
+ }
17
+ }
18
+ type ResolvableFrame = string | Ref | NSVElement | Frame | undefined;
19
+ export interface NavigationOptions extends NavigationEntry {
20
+ props?: Record<string, any>;
21
+ frame?: ResolvableFrame;
22
+ }
23
+ export interface BackNavigationOptions {
24
+ frame?: ResolvableFrame;
25
+ }
26
+ /**
27
+ * @internal
28
+ */
29
+ export declare function install(app: App): void;
30
+ export declare function $navigateTo(target: Component, options?: NavigationOptions): Page;
31
+ export declare function $navigateBack(options?: BackNavigationOptions): Promise<void>;
32
+ export {};
@@ -0,0 +1,110 @@
1
+ import { Frame } from '@nativescript/core';
2
+ import { nextTick, unref } from '@vue/runtime-core';
3
+ import { NSVElement, NSVRoot } from '../dom';
4
+ import { createNativeView } from '../runtimeHelpers';
5
+ /**
6
+ * @internal
7
+ */
8
+ export function install(app) {
9
+ app.config.globalProperties.$navigateTo = $navigateTo;
10
+ app.config.globalProperties.$navigateBack = $navigateBack;
11
+ }
12
+ function resolveFrame(frame) {
13
+ if (!frame) {
14
+ return Frame.topmost();
15
+ }
16
+ const ob = unref(frame);
17
+ if (ob instanceof Frame) {
18
+ return ob;
19
+ }
20
+ if (ob instanceof NSVElement) {
21
+ return ob.nativeView;
22
+ }
23
+ // todo: either change core Frame to add frames to the stack when they are created
24
+ // or do as we did in 2.x - handle a Map of frames.
25
+ // right now, empty frames can't be navigated as they are not recognized by `getFrameById`
26
+ return Frame.getFrameById(ob);
27
+ }
28
+ export function $navigateTo(target, options) {
29
+ try {
30
+ const frame = resolveFrame(options?.frame);
31
+ if (!frame) {
32
+ throw new Error('Failed to resolve frame. Make sure your frame exists.');
33
+ }
34
+ const root = new NSVRoot();
35
+ let isReloading = false;
36
+ const attachDisposeCallback = (page) => {
37
+ const dispose = page.disposeNativeView;
38
+ page.disposeNativeView = () => {
39
+ dispose.call(page);
40
+ // if we are reloading, don't unmount the view, as the reload will unmount/remount it.
41
+ if (!isReloading) {
42
+ view.unmount();
43
+ view = null;
44
+ }
45
+ };
46
+ };
47
+ const reloadPage = () => {
48
+ if (isReloading) {
49
+ return;
50
+ }
51
+ // if the page we are reloading is not the current page, wait for it to be navigated to
52
+ if (frame.currentPage !== view.nativeView) {
53
+ view.nativeView.once('navigatedTo', () => {
54
+ nextTick(() => {
55
+ reloadPage();
56
+ });
57
+ });
58
+ return;
59
+ }
60
+ isReloading = true;
61
+ view.unmount();
62
+ view.mount(root);
63
+ attachDisposeCallback(view.nativeView);
64
+ const originalTransition = frame.currentEntry.transition;
65
+ // replace current page
66
+ frame.replacePage({
67
+ ...options,
68
+ transition: {
69
+ name: 'fade',
70
+ duration: 10,
71
+ },
72
+ create: () => view.nativeView,
73
+ });
74
+ // reset the transition to the original one
75
+ frame.once('navigatedTo', () => {
76
+ frame.currentEntry.transition = originalTransition;
77
+ isReloading = false;
78
+ });
79
+ };
80
+ let view = createNativeView(target, options?.props, {
81
+ /**
82
+ * Called by @vue/runtime-core when the component is reloaded during HMR.
83
+ */
84
+ reload: reloadPage,
85
+ });
86
+ view.mount(root);
87
+ attachDisposeCallback(view.nativeView);
88
+ frame.navigate({
89
+ ...options,
90
+ create: () => view.nativeView,
91
+ });
92
+ return view.nativeView;
93
+ }
94
+ catch (e) {
95
+ console.error('[$navigateTo] Failed to navigate:\n\n');
96
+ console.error(e, e.stack);
97
+ throw e;
98
+ }
99
+ }
100
+ export async function $navigateBack(options) {
101
+ const frame = resolveFrame(options?.frame);
102
+ if (!frame) {
103
+ throw new Error('Failed to resolve frame. Make sure your frame exists.');
104
+ }
105
+ if (!frame.canGoBack()) {
106
+ return;
107
+ }
108
+ frame.goBack();
109
+ }
110
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/plugins/navigation.ts"],"names":[],"mappings":"AA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AY,CAAC,UAAU,GAAG,kBAAkB,CAAC;gBACnD,WAAW,GAAG,KAAK,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,IAAI,GAAG,gBAAgB,CAAO,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE;YACxD;;eAEG;YACH,MAAM,EAAE,UAAU;SACnB,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,qBAAqB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEvC,KAAK,CAAC,QAAQ,CAAC;YACb,GAAG,OAAO;YACV,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU;SAC9B,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACvD,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA+B;IACjE,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAE3C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IAED,KAAK,CAAC,MAAM,EAAE,CAAC;AACjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { App } from '@vue/runtime-core';
2
+ declare module '@vue/runtime-core' {
3
+ interface ComponentCustomProperties {
4
+ $templates: any;
5
+ }
6
+ }
7
+ /**
8
+ * @internal
9
+ */
10
+ export declare function install(app: App): void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export function install(app) {
5
+ app.config.globalProperties.$templates = {
6
+ getKeyedTemplates() { },
7
+ selectorFn() { },
8
+ patchTemplate(name, context, oldVnode) { },
9
+ registerTemplate() { }
10
+ };
11
+ }
12
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/plugins/templates.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,GAAQ;IAC9B,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG;QACvC,iBAAiB,KAAI,CAAC;QACtB,UAAU,KAAI,CAAC;QACf,aAAa,CAAC,IAAY,EAAE,OAAY,EAAE,QAAe,IAAG,CAAC;QAC7D,gBAAgB,KAAI,CAAC;KACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { NSVElement, NSVViewFlags } from '../dom';
2
+ export type NSVElementResolver = () => any;
3
+ export type NSVModelDescriptor = {
4
+ prop: string;
5
+ event: string;
6
+ };
7
+ export interface NSVViewMeta {
8
+ viewFlags: NSVViewFlags;
9
+ nodeOps?: {
10
+ insert(child: NSVElement, parent: NSVElement, atIndex?: number): void;
11
+ remove(child: NSVElement, parent: NSVElement): void;
12
+ };
13
+ model?: NSVModelDescriptor;
14
+ overwriteExisting?: boolean;
15
+ }
16
+ export interface NSVElementDescriptor {
17
+ meta: NSVViewMeta;
18
+ resolver?: NSVElementResolver;
19
+ }
20
+ export declare let defaultViewMeta: NSVViewMeta;
21
+ export declare function getViewMeta(elementName: string): NSVViewMeta;
22
+ export declare function registerUnknownViewResolver(resolver: (name: string) => any): void;
23
+ export declare function getViewClass(elementName: string): any;
24
+ export declare function normalizeElementName(elementName: string): string;
25
+ export declare function registerElement(elementName: string, resolver?: NSVElementResolver, meta?: Partial<NSVViewMeta>): void;
26
+ export declare function isKnownView(elementName: string): boolean;
@@ -0,0 +1,55 @@
1
+ export let defaultViewMeta = {
2
+ viewFlags: 0, // NSVViewFlags.NONE - circular dependency, using constant value instead
3
+ };
4
+ let elementMap = {};
5
+ export function getViewMeta(elementName) {
6
+ // console.log(`->getViewMeta(${elementName})`)
7
+ const normalizedName = normalizeElementName(elementName);
8
+ const entry = elementMap[normalizedName];
9
+ if (!entry) {
10
+ throw new Error(`No known component for element ${elementName}.`);
11
+ }
12
+ return entry.meta;
13
+ }
14
+ let unknownViewResolver;
15
+ export function registerUnknownViewResolver(resolver) {
16
+ unknownViewResolver = resolver;
17
+ }
18
+ export function getViewClass(elementName) {
19
+ // console.log(`->getViewClass(${elementName})`)
20
+ const normalizedName = normalizeElementName(elementName);
21
+ const entry = elementMap[normalizedName];
22
+ if (!entry) {
23
+ const resolved = unknownViewResolver?.(elementName);
24
+ if (resolved) {
25
+ return resolved;
26
+ }
27
+ throw new Error(`No known component for element ${elementName}.`);
28
+ }
29
+ try {
30
+ return entry.resolver();
31
+ }
32
+ catch (e) {
33
+ throw new Error(`Could not load view for: ${elementName}. ${e}`);
34
+ }
35
+ }
36
+ export function normalizeElementName(elementName) {
37
+ return elementName.replace(/-/g, '').toLowerCase();
38
+ }
39
+ export function registerElement(elementName, resolver, meta) {
40
+ const normalizedName = normalizeElementName(elementName);
41
+ const mergedMeta = Object.assign({}, defaultViewMeta, meta);
42
+ if (elementMap[normalizedName] && !mergedMeta.overwriteExisting) {
43
+ throw new Error(`Element for ${elementName} already registered.\n` +
44
+ `If this is intentional set 'overwriteExisting: true' in 'meta'`);
45
+ }
46
+ elementMap[normalizedName] = {
47
+ meta: mergedMeta,
48
+ resolver,
49
+ };
50
+ // console.log(`->registerElement(${elementName})`)
51
+ }
52
+ export function isKnownView(elementName) {
53
+ return elementMap.hasOwnProperty(normalizeElementName(elementName));
54
+ }
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC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EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,WAAmB,EACnB,QAA6B,EAC7B,IAA2B;IAE3B,MAAM,cAAc,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IACzD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;IAE5D,IAAI,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,eAAe,WAAW,wBAAwB;YAChD,gEAAgE,CACnE,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,cAAc,CAAC,GAAG;QAC3B,IAAI,EAAE,UAAU;QAChB,QAAQ;KACT,CAAC;IACF,mDAAmD;AACrD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC7C,OAAO,UAAU,CAAC,cAAc,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC;AACtE,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const renderer: import("@vue/runtime-core").Renderer<import("@vue/runtime-core").RendererElement>;
@@ -0,0 +1,8 @@
1
+ import { createRenderer } from '@vue/runtime-core';
2
+ import { patchProp } from './patchProp';
3
+ import { nodeOps } from './nodeOps';
4
+ export const renderer = createRenderer({
5
+ patchProp,
6
+ ...nodeOps,
7
+ });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/renderer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC;IACrC,SAAS;IACT,GAAG,OAAO;CACX,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { NSVElement } from '../../dom';
2
+ export declare function patchAttr(el: NSVElement, key: string, prevValue: any, nextValue: any): void;
@@ -0,0 +1,31 @@
1
+ import { isBoolean, isAndroidKey, isIOSKey } from '../../runtimeHelpers';
2
+ import { isAndroid, isIOS } from '../../nativescript';
3
+ export function patchAttr(el, key, prevValue, nextValue) {
4
+ if (isAndroidKey(key)) {
5
+ if (!isAndroid) {
6
+ // if we encounter an android key, and we are not on android we can safely ignore it
7
+ return;
8
+ }
9
+ key = key.substring(8);
10
+ }
11
+ else if (isIOSKey(key)) {
12
+ if (!isIOS) {
13
+ // if we encounter an ios key, and we are not on ios we can safely ignore it
14
+ return;
15
+ }
16
+ key = key.substring(4);
17
+ }
18
+ // detect expandable attrs for boolean values
19
+ // see https://vuejs.org/v2/guide/components-props.html#Passing-a-Boolean
20
+ if (isBoolean(el.getAttribute(key)) && nextValue === '') {
21
+ nextValue = true;
22
+ }
23
+ if (nextValue === null) {
24
+ // if the nextValue is null, we are removing the attribute
25
+ el.removeAttribute(key);
26
+ }
27
+ else {
28
+ el.setAttribute(key, nextValue);
29
+ }
30
+ }
31
+ //# sourceMappingURL=attrs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attrs.js","sourceRoot":"","sources":["../../../src/renderer/modules/attrs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,UAAU,SAAS,CACvB,EAAc,EACd,GAAW,EACX,SAAc,EACd,SAAc;IAEd,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,oFAAoF;YACpF,OAAO;QACT,CAAC;QACD,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;SAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,4EAA4E;YAC5E,OAAO;QACT,CAAC;QACD,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,6CAA6C;IAC7C,yEAAyE;IACzE,IAAI,SAAS,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC;QACxD,SAAS,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,0DAA0D;QAC1D,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACN,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { NSVElement } from '../../dom';
2
+ export declare function patchClass(el: NSVElement, value: string | null): void;
@@ -0,0 +1,9 @@
1
+ // compiler should normalize class + :class bindings on the same element
2
+ // into a single binding ['staticClass', dynamic]
3
+ export function patchClass(el, value) {
4
+ if (value == null) {
5
+ value = '';
6
+ }
7
+ el.setAttribute('class', value);
8
+ }
9
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../../src/renderer/modules/class.ts"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,iDAAiD;AACjD,MAAM,UAAU,UAAU,CAAC,EAAc,EAAE,KAAoB;IAC7D,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,KAAK,GAAG,EAAE,CAAC;IACb,CAAC;IACD,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { NSVElement } from '../../dom';
2
+ import { ComponentInternalInstance } from '@vue/runtime-core';
3
+ interface Invoker extends EventListener {
4
+ value: EventValue;
5
+ }
6
+ type EventValue = Function | Function[];
7
+ export declare function addEventListener(el: NSVElement, event: string, handler: EventListener, options?: EventListenerOptions): void;
8
+ export declare function removeEventListener(el: NSVElement, event: string, handler: EventListener, options?: EventListenerOptions): void;
9
+ export declare function patchEvent(el: NSVElement & {
10
+ _vei?: Record<string, Invoker | undefined>;
11
+ }, rawName: string, prevValue: EventValue | null, nextValue: EventValue | null, instance?: ComponentInternalInstance | null): void;
12
+ export {};
@@ -0,0 +1,59 @@
1
+ import { callWithAsyncErrorHandling, } from '@vue/runtime-core';
2
+ export function addEventListener(el, event, handler, options = {}) {
3
+ el.addEventListener(event, handler, options);
4
+ }
5
+ export function removeEventListener(el, event, handler, options = {}) {
6
+ el.removeEventListener(event, handler);
7
+ }
8
+ export function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
9
+ // vei = vue event invokers
10
+ const invokers = el._vei || (el._vei = {});
11
+ const existingInvoker = invokers[rawName];
12
+ if (nextValue && existingInvoker) {
13
+ // patch
14
+ existingInvoker.value = nextValue;
15
+ }
16
+ else {
17
+ const [name, options] = parseName(rawName);
18
+ if (nextValue) {
19
+ // add
20
+ const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
21
+ addEventListener(el, name, invoker, options);
22
+ }
23
+ else if (existingInvoker) {
24
+ // remove
25
+ removeEventListener(el, name, existingInvoker, options);
26
+ invokers[rawName] = undefined;
27
+ }
28
+ }
29
+ }
30
+ const optionsModifierRE = /(?:Once|Capture)$/;
31
+ function parseName(name) {
32
+ let options;
33
+ if (optionsModifierRE.test(name)) {
34
+ options = {};
35
+ let m;
36
+ while ((m = name.match(optionsModifierRE))) {
37
+ name = name.slice(0, name.length - m[0].length);
38
+ options[m[0].toLowerCase()] = true;
39
+ options;
40
+ }
41
+ }
42
+ // todo: optimise if necessary
43
+ // this isn't technically perfect,
44
+ // since if the event name was UPPER then we'll convert it to uPPER
45
+ // but for the majority of cases, this should be the right thing to do.
46
+ name = name.slice(name.startsWith('on:') ? 3 : 2);
47
+ name = name.charAt(0).toLowerCase() + name.slice(1);
48
+ // return event name by removing on prefix. eg. onitemTap -> itemTap
49
+ return [name, options];
50
+ // return [hyphenate(name.slice(2)), options]
51
+ }
52
+ function createInvoker(initialValue, instance) {
53
+ const invoker = (e) => {
54
+ callWithAsyncErrorHandling(invoker.value, instance, 5, [e]);
55
+ };
56
+ invoker.value = initialValue;
57
+ return invoker;
58
+ }
59
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/renderer/modules/events.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,GAE3B,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,UAAU,gBAAgB,CAC9B,EAAc,EACd,KAAa,EACb,OAAsB,EACtB,UAAgC,EAAE;IAElC,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,EAAc,EACd,KAAa,EACb,OAAsB,EACtB,UAAgC,EAAE;IAElC,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,EAA+D,EAC/D,OAAe,EACf,SAA4B,EAC5B,SAA4B,EAC5B,WAA6C,IAAI;IAEjD,2BAA2B;IAC3B,MAAM,QAAQ,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IAC3C,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,SAAS,IAAI,eAAe,EAAE,CAAC;QACjC,QAAQ;QACR,eAAe,CAAC,KAAK,GAAG,SAAS,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,EAA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,CAAC;IAClD,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEpD,oEAAoE;IACpE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvB,6CAA6C;AAC/C,CAAC;AAED,SAAS,aAAa,CACpB,YAAwB,EACxB,QAA0C;IAE1C,MAAM,OAAO,GAAY,CAAC,CAAQ,EAAE,EAAE;QACpC,0BAA0B,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC;IACF,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC;IAC7B,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { NSVElement } from '../../dom';
2
+ type Style = string | Record<string, string | number> | null;
3
+ export declare const STYLE_ORIGINAL_VALUE: unique symbol;
4
+ export declare function patchStyle(el: NSVElement, prev: Style, next: Style): void;
5
+ export {};
@@ -0,0 +1,80 @@
1
+ import { parseStringStyle, isArray, isString, isObject, } from '@vue/shared';
2
+ function normalizeStyle(style) {
3
+ if (!style) {
4
+ return null;
5
+ }
6
+ if (isString(style)) {
7
+ if (style.trim().charAt(0) === '{') {
8
+ return JSON.parse(style);
9
+ }
10
+ return parseStringStyle(style);
11
+ }
12
+ if (isArray(style)) {
13
+ return style.reduce((normalizedStyle, currentStyle) => {
14
+ return Object.assign(normalizedStyle, normalizeStyle(currentStyle));
15
+ }, {});
16
+ }
17
+ if (isObject(style)) {
18
+ return style;
19
+ }
20
+ return {};
21
+ }
22
+ function normalizeProperty(property) {
23
+ if (property.endsWith('Align')) {
24
+ // NativeScript uses Alignment instead of Align, this ensures that text-align works
25
+ property += 'ment';
26
+ }
27
+ return property;
28
+ }
29
+ export const STYLE_ORIGINAL_VALUE = Symbol('style_original_value');
30
+ function addStyleProperty(el, property, value) {
31
+ const _sov = el[STYLE_ORIGINAL_VALUE] ?? (el[STYLE_ORIGINAL_VALUE] = new Map());
32
+ property = normalizeProperty(property);
33
+ if (!_sov.has(property)) {
34
+ _sov.set(property, el.style[property]);
35
+ }
36
+ el.style[property] = value;
37
+ }
38
+ function removeStyleProperty(el, property) {
39
+ const _sov = el[STYLE_ORIGINAL_VALUE] ?? (el[STYLE_ORIGINAL_VALUE] = new Map());
40
+ property = normalizeProperty(property);
41
+ // only delete styles we added
42
+ if (_sov.has(property)) {
43
+ const originalValue = _sov.get(property);
44
+ _sov.delete(property);
45
+ // edge case: if a style property also exists as an attribute (ie backgroundColor)
46
+ // changing the attribute will not update our originalValue, so when removing
47
+ // the previous color will be applied. Fixing this would involve listening to
48
+ // individual attribute changes, and it's not worth the overhead.
49
+ try {
50
+ el.style[property] = originalValue;
51
+ }
52
+ catch (err) {
53
+ // hack: if the original value is invalid, we can't set it back to it's original value
54
+ // instead we set it to null, which will remove the style, however this may
55
+ // still lead to incorrect styling in some cases.
56
+ el.style[property] = null;
57
+ }
58
+ }
59
+ }
60
+ // todo: perhaps mimic dom version with prefixing stripped out: https://github.com/vuejs/core/blob/main/packages/runtime-dom/src/modules/style.ts
61
+ export function patchStyle(el, prev, next) {
62
+ if (prev) {
63
+ const style = normalizeStyle(prev);
64
+ // undo old styles
65
+ Object.keys(style).forEach((property) => {
66
+ removeStyleProperty(el, property);
67
+ });
68
+ }
69
+ if (!next) {
70
+ el.removeAttribute('style');
71
+ }
72
+ else {
73
+ // set new styles
74
+ const style = normalizeStyle(next);
75
+ Object.keys(style).forEach((property) => {
76
+ addStyleProperty(el, property, style[property]);
77
+ });
78
+ }
79
+ }
80
+ //# sourceMappingURL=style.js.map