@nstudio/nativescript-compiler 9.2.0-alpha.10 → 9.2.0-alpha.12
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/dist/api/ir.js +7 -1
- package/dist/cli/runtime.cjs +7 -1
- package/dist/css/css.js +30 -6
- package/dist/driver/cli.js +2 -0
- package/dist/driver/compile.js +23 -10
- package/dist/driver/paths.js +7 -0
- package/dist/driver/unimplemented.js +15 -0
- package/dist/kotlin/access.js +23 -5
- package/dist/kotlin/arguments.js +5 -0
- package/dist/kotlin/builtins.js +0 -4
- package/dist/kotlin/calls.js +6 -2
- package/dist/kotlin/class-methods.js +9 -3
- package/dist/kotlin/components.js +13 -8
- package/dist/kotlin/conversion.js +17 -5
- package/dist/kotlin/core-api.js +2 -13
- package/dist/kotlin/declarations.js +2 -0
- package/dist/kotlin/expression-statements.js +5 -4
- package/dist/kotlin/expressions.js +8 -3
- package/dist/kotlin/functions.js +13 -4
- package/dist/kotlin/global-calls.js +11 -0
- package/dist/kotlin/literals.js +58 -14
- package/dist/kotlin/names.js +2 -2
- package/dist/kotlin/native/api.js +9 -1
- package/dist/kotlin/native/calls.js +84 -3
- package/dist/kotlin/native/subclasses.js +4 -3
- package/dist/kotlin/native/types.js +8 -5
- package/dist/kotlin/operators.js +4 -1
- package/dist/kotlin/overrides.js +7 -5
- package/dist/kotlin/placement.js +3 -1
- package/dist/kotlin/prototype-calls.js +5 -0
- package/dist/kotlin/render.js +62 -0
- package/dist/kotlin/statements.js +9 -0
- package/dist/kotlin/static-calls.js +10 -7
- package/dist/kotlin/translator.js +31 -11
- package/dist/kotlin/type-facts.js +10 -2
- package/dist/kotlin/types.js +6 -6
- package/dist/plugins/native-android.js +37 -5
- package/dist/plugins/native-ios.js +2 -0
- package/dist/plugins/source.js +73 -23
- package/dist/program/app-modules.js +91 -16
- package/dist/program/app-paths.js +80 -12
- package/dist/program/class-mixins.js +463 -0
- package/dist/program/core-facts.js +7 -0
- package/dist/program/glob.js +274 -0
- package/dist/program/platform.js +32 -4
- package/dist/program/program.js +239 -38
- package/dist/program/source-lines.js +4 -1
- package/dist/program/vite-plugins.js +144 -0
- package/dist/semantics/apis/globals.js +2 -2
- package/dist/semantics/apis/object.js +1 -0
- package/dist/semantics/apis/statics.js +6 -0
- package/dist/semantics/ast.js +20 -2
- package/dist/semantics/classes.js +36 -1
- package/dist/semantics/facts.js +28 -1
- package/dist/semantics/globals.js +3 -0
- package/dist/semantics/lang.js +13 -1
- package/dist/semantics/nullish.js +29 -11
- package/dist/semantics/refuse-receivers.js +3 -3
- package/dist/semantics/refuse-scope.js +2 -7
- package/dist/semantics/runtime.js +1 -0
- package/dist/semantics/shapes.js +21 -1
- package/dist/semantics/states/value-states.js +1 -1
- package/dist/semantics/throws.js +1 -0
- package/dist/semantics/translator-methods.js +1 -1
- package/dist/semantics/types.js +21 -1
- package/dist/swift/access.js +25 -10
- package/dist/swift/arguments.js +10 -2
- package/dist/swift/assignment.js +12 -1
- package/dist/swift/builtins.js +0 -4
- package/dist/swift/calls.js +6 -2
- package/dist/swift/class-methods.js +3 -3
- package/dist/swift/components.js +28 -8
- package/dist/swift/construction.js +4 -0
- package/dist/swift/conversion.js +1 -1
- package/dist/swift/core-api.js +9 -12
- package/dist/swift/from-any.js +2 -2
- package/dist/swift/functions.js +13 -2
- package/dist/swift/generics.js +5 -1
- package/dist/swift/global-calls.js +2 -0
- package/dist/swift/literals.js +57 -10
- package/dist/swift/modules.js +1 -1
- package/dist/swift/names.js +1 -1
- package/dist/swift/native/sdk-tables.js +52 -4
- package/dist/swift/native/sdk.js +9 -1
- package/dist/swift/operators.js +4 -1
- package/dist/swift/parameters.js +5 -2
- package/dist/swift/placement.js +44 -4
- package/dist/swift/prototype-calls.js +17 -2
- package/dist/swift/render.js +64 -0
- package/dist/swift/results.js +1 -1
- package/dist/swift/statements.js +9 -0
- package/dist/swift/static-calls.js +13 -6
- package/dist/swift/types.js +9 -9
- package/dist/targets/android/build.js +18 -12
- package/dist/targets/ios/build.js +11 -10
- package/dist/targets/ios/dependencies.js +12 -0
- package/dist/targets/resources.js +15 -1
- package/dist/template/plan.js +105 -8
- package/dist/types/adapter-api.d.ts +13 -0
- package/dist/types/ir.d.ts +47 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/__Objects.kt +102 -7485
- package/kit-android/generated/kotlin/org/nativescript/kit/application_application.kt +4 -4
- package/kit-android/generated/kotlin/org/nativescript/kit/image_source_index.kt +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_animation_animation_common.kt +7 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_animation_index.kt +3 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_base_index.kt +2 -4
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_index.kt +5 -6
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_view_common.kt +1 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_dialogs_index.kt +11 -6
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_frame_fragment_transitions.kt +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_frame_frame_common.kt +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_frame_frame_helper_for_android.kt +7 -5
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_frame_index.kt +6 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_gestures_touch_manager.kt +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_layouts_flexbox_layout_index.kt +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_search_bar_index.kt +4 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_segmented_bar_index.kt +2 -2
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_text_base_formatted_string.kt +1 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_text_base_index.kt +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_transition_fade_transition.kt +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_transition_flip_transition.kt +8 -8
- package/kit-android/generated/kotlin/org/nativescript/kit/utils_index.kt +1 -1
- package/kit-android/generated/source-lines.json +1 -1
- package/kit-android/gradlew.bat +94 -0
- package/kit-android/src/fromcore/kotlin/org/nativescript/kit/CoreBridge.kt +67 -1
- package/kit-android/src/main/kotlin/org/nativescript/kit/Signals.kt +15 -2
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Prototypes.kt +26 -0
- package/kit-apple/Overlays/xml-free/Core/ui.core.bindable.index.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity1.swift +26 -161
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity2.swift +9 -284
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity3Plus.swift +11 -7
- package/kit-apple/Sources/NativeScriptKit/Core/Object_callback_thisArg_once.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_index_section_view_ios_android.swift +7 -5
- package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_oldIndex_newIndex.swift +4 -2
- package/kit-apple/Sources/NativeScriptKit/Core/{Object_iterator_prototype_for_keyFor_hasInstance_isConcatSpreadable_and_19_more_91b5f3.swift → Object_iterator_prototype_for_keyFor_hasInstance_isConcatSpreadable_and_19_more_fa18e1.swift} +28 -103
- package/kit-apple/Sources/NativeScriptKit/Core/__Namespace.Utils.swift +17 -15
- package/kit-apple/Sources/NativeScriptKit/Core/application-settings.index.ios.swift +8 -8
- package/kit-apple/Sources/NativeScriptKit/Core/application.application-common.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/color.color-common.swift +7 -7
- package/kit-apple/Sources/NativeScriptKit/Core/data.observable.index.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.index.ios.swift +2 -1
- package/kit-apple/Sources/NativeScriptKit/Core/image-source.index.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/kit-index.json +40 -246
- package/kit-apple/Sources/NativeScriptKit/Core/manifest.json +1 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.action-bar.index.ios.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.button.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.content-view.index.swift +8 -8
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.bindable.index.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.index.ios.swift +8 -8
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-common.swift +1 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-helper.view-helper-common.swift +7 -7
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.weak-event-listener.index.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.gestures.index.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.html-view.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.image.image-common.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.image.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.label.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.absolute-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.dock-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.flexbox-layout.index.ios.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.grid-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.stack-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.wrap-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.list-view.index.ios.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.page.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.repeater.index.swift +10 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.scroll-view.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.split-view.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.background.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.tab-view.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.formatted-string.swift +2 -1
- package/kit-apple/Sources/NativeScriptKit/Core/utils.common.swift +9 -9
- package/kit-apple/Sources/NativeScriptKit/Core/utils.layout-helper.index.ios.swift +10 -10
- package/kit-apple/Sources/NativeScriptKit/CoreBridge.swift +67 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Lowering.swift +4 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Prototypes.swift +25 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/RegExp.swift +6 -0
- package/kit-apple/Sources/NativeScriptKit/Signals.swift +20 -2
- package/package.json +2 -1
- package/kit-apple/Sources/NativeScriptKit/Core/Object_toString_charAt_charCodeAt_concat_indexOf_lastIndexOf_and_44_more_fc25df.swift +0 -481
package/dist/template/plan.js
CHANGED
|
@@ -61,6 +61,8 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
61
61
|
const viewMark = (nodes) => behaviour.effectScope === 'view' && hasRegion(nodes);
|
|
62
62
|
// The steps being written, innermost last, and the template scopes whose deferred steps follow their own.
|
|
63
63
|
const out = [];
|
|
64
|
+
/** Enclosing child component instance variables while emitting projected slot bodies (for `contentHost` queries). */
|
|
65
|
+
const slotTargets = [];
|
|
64
66
|
const say = (step) => out.at(-1).push(step);
|
|
65
67
|
const templates = [];
|
|
66
68
|
/** A node's change, init and check hooks, which run once the next node bound is reached: a `let` before it precedes them. */
|
|
@@ -143,6 +145,7 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
143
145
|
for (const u of uses ?? []) {
|
|
144
146
|
const d = `d${n++}`;
|
|
145
147
|
say({ kind: 'directive', name: d, view, make: call(u.make, loops) });
|
|
148
|
+
queried(u.queries, loops, view, d);
|
|
146
149
|
const inner = [...loops, { item: u.name, itemExpr: d }];
|
|
147
150
|
if (u.destroy)
|
|
148
151
|
say({ kind: 'cleanup', call: call(u.destroy, inner) });
|
|
@@ -189,9 +192,10 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
189
192
|
const queried = (hooks, loops, view, instance) => {
|
|
190
193
|
for (const q of hooks ?? []) {
|
|
191
194
|
const made = q.on === 'view' ? view : instance;
|
|
192
|
-
|
|
195
|
+
const args = q.contentHost && slotTargets.length ? [slotTargets.at(-1), made] : [made];
|
|
196
|
+
say({ kind: 'run', call: call(q.set, loops, args) });
|
|
193
197
|
if (q.unset)
|
|
194
|
-
say({ kind: 'cleanup', call: call(q.unset, loops,
|
|
198
|
+
say({ kind: 'cleanup', call: call(q.unset, loops, args) });
|
|
195
199
|
}
|
|
196
200
|
};
|
|
197
201
|
const component = (node, loops, view, parent, region) => {
|
|
@@ -220,6 +224,21 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
220
224
|
});
|
|
221
225
|
const passed = info.passed ? node.props.map((a) => a.name).concat(node.events.map((e) => 'on' + e.name[0].toUpperCase() + e.name.slice(1))) : null;
|
|
222
226
|
say({ kind: 'component', name: cv, type: node.name, args, passed, initThrows: !!info.initThrows });
|
|
227
|
+
if (node.slots && info.slots?.length) {
|
|
228
|
+
slotTargets.push(cv);
|
|
229
|
+
try {
|
|
230
|
+
for (const [slotName, slotNodes] of Object.entries(node.slots)) {
|
|
231
|
+
if (!slotNodes.length || !info.slots.includes(slotName))
|
|
232
|
+
continue;
|
|
233
|
+
const f = `f${n++}`;
|
|
234
|
+
const b = template(block([], f, viewMark(slotNodes)), () => emit(slotNodes, loops, f, null), false);
|
|
235
|
+
say({ kind: 'setSlot', component: cv, name: slotName, scope: scoped('region'), viewMark: b.viewMark, body: b });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
slotTargets.pop();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
223
242
|
const write = (p) => {
|
|
224
243
|
const a = given(p);
|
|
225
244
|
return { component: cv, prop: p, setter: setter(p), throwingSetter: !!info.throwingSetters?.includes(p), convert: a ? conversion(p, a) : null, changes: !!info.changes, inputChanged: onPush && !!info.onPush };
|
|
@@ -281,8 +300,10 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
281
300
|
else {
|
|
282
301
|
say({ kind: 'createView', view, component: cv, member: members(node.name).create, update: u });
|
|
283
302
|
queried(node.queries, loops, view, cv);
|
|
303
|
+
const { end: endDir } = directed(node.directives, loops, view);
|
|
284
304
|
events();
|
|
285
305
|
attach(view, parent, region, 'created');
|
|
306
|
+
endDir();
|
|
286
307
|
}
|
|
287
308
|
props();
|
|
288
309
|
if (!info.fragment)
|
|
@@ -407,10 +428,76 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
407
428
|
}
|
|
408
429
|
if (node.kind === 'template')
|
|
409
430
|
throw new Error(`${c.name}: an item template outside a ListView or Pager`);
|
|
431
|
+
if (node.kind === 'slot') {
|
|
432
|
+
if (!parent)
|
|
433
|
+
throw new Error(`${c.name}: a slot at the root of a non-fragment template`);
|
|
434
|
+
const r = `r${n++}`;
|
|
435
|
+
say({ kind: 'region', name: r, parent, detached: false });
|
|
436
|
+
let fallback = null;
|
|
437
|
+
if (node.fallback?.length) {
|
|
438
|
+
const f = `f${n++}`;
|
|
439
|
+
fallback = template(block([], f, viewMark(node.fallback)), () => emit(node.fallback, loops, f, null), false);
|
|
440
|
+
}
|
|
441
|
+
say({ kind: 'slot', name: node.name, host: { region: r }, fallback });
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (node.kind === 'componentOutlet') {
|
|
445
|
+
if (!parent)
|
|
446
|
+
throw new Error(`${c.name}: a component outlet at the root of a non-fragment template`);
|
|
447
|
+
const r = `r${n++}`;
|
|
448
|
+
say({ kind: 'region', name: r, parent, detached: false });
|
|
449
|
+
(passes ? binding : say)({
|
|
450
|
+
kind: 'componentOutlet',
|
|
451
|
+
host: { region: r },
|
|
452
|
+
call: kit('componentOutlet'),
|
|
453
|
+
component: call(node.component, loops),
|
|
454
|
+
injector: node.injector ? call(node.injector, loops) : null,
|
|
455
|
+
inputs: node.inputs ? call(node.inputs, loops) : null,
|
|
456
|
+
});
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (node.kind === 'templateOutlet') {
|
|
460
|
+
if (!parent)
|
|
461
|
+
throw new Error(`${c.name}: a template outlet at the root of a non-fragment template`);
|
|
462
|
+
const r = `r${n++}`;
|
|
463
|
+
say({ kind: 'region', name: r, parent, detached: false });
|
|
464
|
+
(passes ? binding : say)({
|
|
465
|
+
kind: 'templateOutlet',
|
|
466
|
+
host: { region: r },
|
|
467
|
+
call: kit('templateOutlet'),
|
|
468
|
+
template: call(node.template, loops),
|
|
469
|
+
context: node.context ? call(node.context, loops) : null,
|
|
470
|
+
});
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (node.kind === 'bindTemplate') {
|
|
474
|
+
const f = `f${n++}`;
|
|
475
|
+
const innerLoops = [...loops, { item: node.ctxParam, itemExpr: node.ctxParam }];
|
|
476
|
+
const b = template(block([], f, viewMark(node.body)), () => emit(node.body, innerLoops, f, null), false);
|
|
477
|
+
say({ kind: 'bindTemplate', field: node.field, scope: scoped('region'), viewMark: b.viewMark, ctxParam: node.ctxParam, body: b });
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
if (node.kind === 'structural') {
|
|
481
|
+
if (!parent)
|
|
482
|
+
throw new Error(`${c.name}: a structural directive at the root of a non-fragment template`);
|
|
483
|
+
const r = `r${n++}`;
|
|
484
|
+
const tplName = `tpl${n++}`;
|
|
485
|
+
const f = `f${n++}`;
|
|
486
|
+
say({ kind: 'region', name: r, parent, detached: false });
|
|
487
|
+
const innerLoops = [...loops, { item: node.ctxParam, itemExpr: node.ctxParam }];
|
|
488
|
+
const tplBody = template(block([], f, viewMark(node.body)), () => emit(node.body, innerLoops, f, null), false);
|
|
489
|
+
const dirSteps = [];
|
|
490
|
+
out.push(dirSteps);
|
|
491
|
+
const { end: endDir } = directed([node.directive], loops, parent);
|
|
492
|
+
out.pop();
|
|
493
|
+
endDir();
|
|
494
|
+
say({ kind: 'structural', region: r, call: kit('structuralScope'), tplName, scope: scoped('region'), viewMark: tplBody.viewMark, ctxParam: node.ctxParam, body: tplBody, steps: dirSteps });
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
410
497
|
if (!parent)
|
|
411
498
|
throw new Error(`${c.name}: an if/for at the root of a template`);
|
|
412
499
|
// A component whose views join its parent (no single root) is a region of the body it is in.
|
|
413
|
-
const nested = (body) => withoutLocals(body).some((x) => x.kind === 'if' || x.kind === 'for' || (x.kind === 'component' && !!components.get(x.name)?.fragment));
|
|
500
|
+
const nested = (body) => withoutLocals(body).some((x) => x.kind === 'if' || x.kind === 'for' || x.kind === 'slot' || x.kind === 'componentOutlet' || x.kind === 'templateOutlet' || x.kind === 'structural' || (x.kind === 'component' && !!components.get(x.name)?.fragment));
|
|
414
501
|
const nestedBody = node.kind === 'if' ? node.branches.some((b) => nested(b.body)) : nested(node.body);
|
|
415
502
|
// A framework that inserts top-down puts a branch's views in place as it builds them; a body with regions of its own attaches as a fragment.
|
|
416
503
|
const live = insertion !== 'built' && !nestedBody ? `r${n++}` : null;
|
|
@@ -529,6 +616,7 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
529
616
|
};
|
|
530
617
|
const plan = {
|
|
531
618
|
fragment,
|
|
619
|
+
hasSlots: !!c.slots?.length,
|
|
532
620
|
scope: scoped('template'),
|
|
533
621
|
viewMark: viewMark(c.template),
|
|
534
622
|
derived: (c.derived ?? []).map((x) => ({ name: x.name, call: member(x.method) })),
|
|
@@ -544,6 +632,14 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
544
632
|
members: members(c.name),
|
|
545
633
|
...(passes ? { passes: rootHooks() } : {}),
|
|
546
634
|
};
|
|
635
|
+
const emitTemplates = () => {
|
|
636
|
+
for (const t of c.templates ?? []) {
|
|
637
|
+
const f = `f${n++}`;
|
|
638
|
+
const innerLoops = [{ item: t.ctxParam, itemExpr: t.ctxParam }];
|
|
639
|
+
const b = template(block([], f, viewMark(t.body)), () => emit(t.body, innerLoops, f, null), false);
|
|
640
|
+
say({ kind: 'bindTemplate', field: t.field, scope: scoped('region'), viewMark: b.viewMark, ctxParam: t.ctxParam, body: b });
|
|
641
|
+
}
|
|
642
|
+
};
|
|
547
643
|
if (c.page) {
|
|
548
644
|
// A routed component's template is its page's content: the action bar and the view.
|
|
549
645
|
const content = ledger.pageContentLayout ? behaviour.pageContentAttrs : undefined;
|
|
@@ -551,6 +647,7 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
551
647
|
if (content) {
|
|
552
648
|
const isBar = (x) => x.kind === 'element' && x.tag === 'ActionBar';
|
|
553
649
|
template(body, () => {
|
|
650
|
+
emitTemplates();
|
|
554
651
|
emit(c.template.filter(isBar), [], 'page', null);
|
|
555
652
|
say({ kind: 'create', view: 'content', tag: 'FlexboxLayout' });
|
|
556
653
|
for (const [name, value] of Object.entries(content))
|
|
@@ -559,18 +656,18 @@ export function renderPlan(c, components, behaviour = DEFAULT_BEHAVIOUR, ledger)
|
|
|
559
656
|
}, true);
|
|
560
657
|
}
|
|
561
658
|
else
|
|
562
|
-
template(body, () => emit(c.template, [], 'page', null), true);
|
|
659
|
+
template(body, () => { emitTemplates(); emit(c.template, [], 'page', null); }, true);
|
|
563
660
|
return { ...plan, root: { kind: 'page', host: c.host ?? null, body, content: content ? 'content' : null } };
|
|
564
661
|
}
|
|
565
662
|
if (fragment)
|
|
566
|
-
return { ...plan, root: { kind: 'fragment', body: template(block(), () => emit(c.template, [], 'root', null), true) } };
|
|
663
|
+
return { ...plan, root: { kind: 'fragment', body: template(block(), () => { emitTemplates(); emit(c.template, [], 'root', null); }, true) } };
|
|
567
664
|
const roots = [];
|
|
568
|
-
const body = template(block(roots), () => emit(c.template, [], null, roots), true);
|
|
665
|
+
const body = template(block(roots), () => { emitTemplates(); emit(c.template, [], null, roots); }, true);
|
|
569
666
|
if (roots.length !== 1)
|
|
570
667
|
throw new Error(`${c.name}: a template needs exactly one root element`);
|
|
571
668
|
return { ...plan, root: { kind: 'view', body, view: roots[0] } };
|
|
572
669
|
}
|
|
573
|
-
/** Whether a template holds an `if` or
|
|
670
|
+
/** Whether a template holds an `if`, `for`, or projected slot content of its own (not inside an item template). */
|
|
574
671
|
function hasRegion(nodes) {
|
|
575
|
-
return withoutLocals(nodes).some((n) => n.kind === 'if' || n.kind === 'for' || (n.kind === 'element' && !TEMPLATE_HOSTS.has(n.tag) && hasRegion(n.children)));
|
|
672
|
+
return withoutLocals(nodes).some((n) => n.kind === 'if' || n.kind === 'for' || n.kind === 'componentOutlet' || n.kind === 'templateOutlet' || n.kind === 'structural' || (n.kind === 'component' && !!n.slots && Object.keys(n.slots).length > 0) || (n.kind === 'slot' && !!n.fallback && hasRegion(n.fallback)) || (n.kind === 'element' && !TEMPLATE_HOSTS.has(n.tag) && hasRegion(n.children)));
|
|
576
673
|
}
|
|
@@ -138,6 +138,9 @@ export interface EntryContext {
|
|
|
138
138
|
readonly components: ReadonlyMap<string, {
|
|
139
139
|
members: ComponentMembers;
|
|
140
140
|
initThrows?: boolean;
|
|
141
|
+
fragment?: boolean;
|
|
142
|
+
props?: string[];
|
|
143
|
+
optional?: string[];
|
|
141
144
|
}>;
|
|
142
145
|
/** The code making a component's root view (`make`), wrapped as the translator wraps root views (`TranslatorHooks.wrapsRootViews`). */
|
|
143
146
|
rootView(component: string, make: string): string;
|
|
@@ -253,6 +256,12 @@ export interface TemplateKit {
|
|
|
253
256
|
call: string;
|
|
254
257
|
primary: string;
|
|
255
258
|
};
|
|
259
|
+
/** Mounts a dynamic component into a region (`[ngComponentOutlet]` / `*ngComponentOutlet`). */
|
|
260
|
+
componentOutlet?: string;
|
|
261
|
+
/** Mounts a dynamic or recursive template into a region (`[ngTemplateOutlet]` / `*ngTemplateOutlet`). */
|
|
262
|
+
templateOutlet?: string;
|
|
263
|
+
/** Runs a custom structural directive with its `TemplateRef` and `ViewContainerRef` bound to its region. */
|
|
264
|
+
structuralScope?: string;
|
|
256
265
|
/** An attribute's bound value as the view takes it, under `slots`. */
|
|
257
266
|
attributeValue?: string;
|
|
258
267
|
/** A bound class name as the view takes it, under `slots`. */
|
|
@@ -461,6 +470,8 @@ export interface FrameworkModel {
|
|
|
461
470
|
calledByFramework?(cls: ts.ClassLikeDeclaration, m: ts.MethodDeclaration | ts.SetAccessorDeclaration, checker: ts.TypeChecker): boolean;
|
|
462
471
|
/** Whether a declared member may hold undefined at run time though its declared type leaves it out (e.g. `linkedSignal`'s `previous.source`). */
|
|
463
472
|
unsetMembers?(d: ts.PropertySignature | ts.PropertyDeclaration, checker: ts.TypeChecker): boolean;
|
|
473
|
+
/** Whether a generic class managed by the framework's DI / template factory erases its type parameters on reified backends (Swift). */
|
|
474
|
+
erasesGenericClass?(cls: ts.ClassDeclaration): boolean;
|
|
464
475
|
}
|
|
465
476
|
/** A component's field the framework's call makes a prop of (`input(0)`): its value's type and the default a parent may leave it at. */
|
|
466
477
|
export interface PropField {
|
|
@@ -494,6 +505,8 @@ export interface TranslatorHooks<V extends TranslatorView = TranslatorView> exte
|
|
|
494
505
|
serviceClass?(t: V, cls: ts.ClassDeclaration, name: string): string;
|
|
495
506
|
/** What a class's translation adds for the framework; `code` is the class's so far. */
|
|
496
507
|
classExtras?(t: V, cls: ts.ClassDeclaration, name: string, code: string): ClassExtras | undefined;
|
|
508
|
+
/** A dynamic `import(specifier)` the framework handles itself (e.g. rejecting JIT-only compiler imports); undefined for any other. */
|
|
509
|
+
dynamicImport?(specifier: string): string | undefined;
|
|
497
510
|
/** Code following a class's translation (`code`), as a Swift extension of it. */
|
|
498
511
|
afterClass?(t: V, cls: ts.ClassDeclaration, code: string): string | undefined;
|
|
499
512
|
}
|
package/dist/types/ir.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export interface QueryHook {
|
|
|
28
28
|
set: string;
|
|
29
29
|
unset?: string;
|
|
30
30
|
on: 'view' | 'instance';
|
|
31
|
+
/** A content query targeting the enclosing projected component instance (`$host` passed as first argument). */
|
|
32
|
+
contentHost?: boolean;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* A directive on an element, one per view of it. Its methods take the names in scope, then the directive
|
|
@@ -80,6 +82,8 @@ export interface DirectiveUse {
|
|
|
80
82
|
* directives made after it on the element, the element's bindings and events, its children and the nodes after it.
|
|
81
83
|
*/
|
|
82
84
|
exposed?: boolean;
|
|
85
|
+
/** Queries matched against this directive instance (e.g. `contentChild(SomeDirective)`). */
|
|
86
|
+
queries?: QueryHook[];
|
|
83
87
|
}
|
|
84
88
|
export type TNode = {
|
|
85
89
|
kind: 'element';
|
|
@@ -101,6 +105,41 @@ export type TNode = {
|
|
|
101
105
|
props: Attr[];
|
|
102
106
|
events: Event[];
|
|
103
107
|
queries?: QueryHook[];
|
|
108
|
+
slots?: Record<string, TNode[]>;
|
|
109
|
+
directives?: DirectiveUse[];
|
|
110
|
+
}
|
|
111
|
+
/** A content projection slot (`<ng-content>`): `name` is `'default'` or the `select` selector; `fallback` renders when the parent gives no content. */
|
|
112
|
+
| {
|
|
113
|
+
kind: 'slot';
|
|
114
|
+
name: string;
|
|
115
|
+
fallback?: TNode[];
|
|
116
|
+
}
|
|
117
|
+
/** A dynamic component outlet (`*ngComponentOutlet` / `[ngComponentOutlet]`): mounts the component type returned by `component`. */
|
|
118
|
+
| {
|
|
119
|
+
kind: 'componentOutlet';
|
|
120
|
+
component: string;
|
|
121
|
+
injector?: string;
|
|
122
|
+
inputs?: string;
|
|
123
|
+
}
|
|
124
|
+
/** A dynamic or recursive template outlet (`*ngTemplateOutlet` / `[ngTemplateOutlet]`): renders a `TemplateRef` with optional context. */
|
|
125
|
+
| {
|
|
126
|
+
kind: 'templateOutlet';
|
|
127
|
+
template: string;
|
|
128
|
+
context?: string;
|
|
129
|
+
}
|
|
130
|
+
/** Binds a `<ng-template #ref>` body to a component `TemplateRef` field in its enclosing scope (e.g. inside `@let`). */
|
|
131
|
+
| {
|
|
132
|
+
kind: 'bindTemplate';
|
|
133
|
+
field: string;
|
|
134
|
+
ctxParam: string;
|
|
135
|
+
body: TNode[];
|
|
136
|
+
}
|
|
137
|
+
/** A custom structural directive (`*myDir="expr"`): constructs `directive` with `TemplateRef` and `ViewContainerRef` scoped to its region. */
|
|
138
|
+
| {
|
|
139
|
+
kind: 'structural';
|
|
140
|
+
directive: DirectiveUse;
|
|
141
|
+
ctxParam: string;
|
|
142
|
+
body: TNode[];
|
|
104
143
|
} | {
|
|
105
144
|
kind: 'if';
|
|
106
145
|
branches: {
|
|
@@ -169,6 +208,12 @@ export interface ComponentIR {
|
|
|
169
208
|
/** A routed component whose template is a page's content (an ActionBar plus a view). */
|
|
170
209
|
page?: boolean;
|
|
171
210
|
template: TNode[];
|
|
211
|
+
/** Named `<ng-template #ref>` bodies bound to `TemplateRef` fields on the component for dynamic/recursive `*ngTemplateOutlet`. */
|
|
212
|
+
templates?: {
|
|
213
|
+
field: string;
|
|
214
|
+
ctxParam: string;
|
|
215
|
+
body: TNode[];
|
|
216
|
+
}[];
|
|
172
217
|
/** Props a parent may leave out. */
|
|
173
218
|
optional?: string[];
|
|
174
219
|
/** Props set through the component's `$set_<prop>` method (an input's setter) when the binding changes, not passed to its constructor. */
|
|
@@ -220,6 +265,8 @@ export interface ComponentIR {
|
|
|
220
265
|
onPush?: boolean;
|
|
221
266
|
/** The component's own stylesheets, scoped by its framework, which the app's build adds after app.css. */
|
|
222
267
|
styles?: ComponentStyle[];
|
|
268
|
+
/** Content projection slot names declared in this component's template (`'default'` or `select` selectors). */
|
|
269
|
+
slots?: string[];
|
|
223
270
|
/** Lines of the virtual file (0-based) its template's bindings were made from, with their line (1-based) in `file`, the template's own. */
|
|
224
271
|
templateLines?: {
|
|
225
272
|
file: string;
|