@ibyar/core 1.1.0 → 1.2.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/annotation/decorators.js.map +1 -1
- package/annotation/options.d.ts +24 -0
- package/annotation/options.d.ts.map +1 -1
- package/annotation/options.js.map +1 -1
- package/binding/binding.expressions.js +2 -2
- package/binding/binding.expressions.js.map +1 -1
- package/component/component.d.ts +1 -0
- package/component/component.d.ts.map +1 -1
- package/component/component.js.map +1 -1
- package/component/custom-element.d.ts +2 -1
- package/component/custom-element.d.ts.map +1 -1
- package/component/custom-element.js.map +1 -1
- package/component/events.js.map +1 -1
- package/context/subscription.d.ts +1 -1
- package/context/subscription.d.ts.map +1 -1
- package/context/subscription.js +1 -1
- package/context/subscription.js.map +1 -1
- package/directive/parser.js.map +1 -1
- package/directive/providers.js.map +1 -1
- package/html/deserialize.js.map +1 -1
- package/html/expression.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/linker/template-ref.js.map +1 -1
- package/linker/view-container-ref.js.map +1 -1
- package/linker/view-ref.js.map +1 -1
- package/package.json +6 -6
- package/pipe/pipe.js.map +1 -1
- package/providers/provider.js.map +1 -1
- package/scope/scope.d.ts +29 -0
- package/scope/scope.d.ts.map +1 -0
- package/scope/scope.js +82 -0
- package/scope/scope.js.map +1 -0
- package/scope/signals.d.ts +15 -0
- package/scope/signals.d.ts.map +1 -0
- package/scope/signals.js +49 -0
- package/scope/signals.js.map +1 -0
- package/scope/stream.d.ts +1 -0
- package/scope/stream.d.ts.map +1 -0
- package/scope/stream.js +8 -0
- package/scope/stream.js.map +1 -0
- package/scope/variables.js.map +1 -1
- package/scope/web-scope.d.ts +4 -0
- package/scope/web-scope.d.ts.map +1 -0
- package/scope/web-scope.js +2 -0
- package/scope/web-scope.js.map +1 -0
- package/signals/signals.d.ts +14 -0
- package/signals/signals.d.ts.map +1 -0
- package/signals/signals.js +56 -0
- package/signals/signals.js.map +1 -0
- package/utils/elements-util.js.map +1 -1
- package/utils/path.js.map +1 -1
- package/view/base-view.d.ts.map +1 -1
- package/view/base-view.js +14 -1
- package/view/base-view.js.map +1 -1
- package/view/form-view.js.map +1 -1
- package/view/mutation.js.map +1 -1
- package/view/render.d.ts +1 -0
- package/view/render.d.ts.map +1 -1
- package/view/render.js +19 -8
- package/view/render.js.map +1 -1
- package/view/utils.js.map +1 -1
- package/view/view.js.map +1 -1
- package/zone/bootstrap.js.map +1 -1
- package/zone/proxy.js.map +1 -1
- package/zone/task.js.map +1 -1
- package/zone/zone.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,kBAAkB,EAAE,wBAAwB,EAC5C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAW7C,MAAM,UAAU,KAAK,CAAc,IAAa;IAC/C,OAAO,wBAAwB,CAC9B,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC5B,IAAI,CAAC,IAAI,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;YAC9C,MAAM,IAAI,SAAS,CAAC,QAAQ,OAAO,OAAO,CAAC,IAAI,QAAQ,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;SACpG;QACD,IAAI,OAAO,CAAC,OAAO,EAAE;YACpB,MAAM,IAAI,WAAW,CAAC,oBAAoB,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;SACxF;QACD,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,EAAE,OA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GAAG,CAAC,WAAW,CAAC;aACxB,IAAI,CAAC,YAAY,CAAC,EAAE;YACpB,IAAI,YAAY,EAAE;gBACjB,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;gBAC5B,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;aAClD;QACF,CAAC,CAAC;aACD,KAAK,CAAC,MAAM,CAAC,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,WAAW,sBAAsB,MAAM,CAAC,IAAI,eAAe,MAAM,GAAG,CAAC,CAAC;QACxG,CAAC,CAAC,CAAC;KACJ;SAAM;QACN,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;KAClD;AACF,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAC1C,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACvB,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE;YACvB,iBAAiB,CAAC,WAAkB,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;SACtD;KACD;SAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QACnC,iBAAiB,CAAC,WAAkB,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;KACrD;AACF,CAAC,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAC9C,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;IAC7B,UAAU,CAAC,UAAU,CAAC,WAAkB,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC,CACD,CAAC","sourcesContent":["import type { Class } from '../utils/typeof.js';\nimport {\n\tMetadataClass, MetadataContext,\n\tmakeClassDecorator, makeClassMemberDecorator\n} from '@ibyar/decorators';\nimport { Components } from '../component/component.js';\nimport { ReflectComponents } from '../component/reflect.js';\nimport { fetchHtml } from '../utils/path.js';\nimport {\n\tChildOptions, ComponentOptions, DirectiveOptions,\n\tOutputEventInit, OutputOptions, PipeOptions, ServiceOptions\n} from './options.js';\n\n\n\ntype PropertyValue<T> = T | ((value: T) => void) | undefined;\n\n\nexport function Input<This, Value>(name?: string) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (!name && typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addInput(metadata, context.name as string, name || context.name as string);\n\t\t}\n\t);\n}\n\nexport function FormValue<This, Value>() {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addInput(metadata, context.name, 'value');\n\t\t}\n\t);\n}\n\nexport function Output<This, Value>(options?: OutputOptions): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\nexport function Output<This, Value>(name?: string, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\nexport function Output<This, Value>(name?: string | OutputOptions, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void {\n\tconst eventType = typeof name === 'object' ? name.name : name;\n\tconst eventOpts = typeof name === 'object' ? name : options;\n\treturn makeClassMemberDecorator<undefined, ClassFieldDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addOutput(\n\t\t\t\tmetadata,\n\t\t\t\tcontext.name,\n\t\t\t\teventType || context.name,\n\t\t\t\t{\n\t\t\t\t\tbubbles: eventOpts?.bubbles ?? false,\n\t\t\t\t\tcomposed: eventOpts?.composed ?? false\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n}\n\nexport function View<This, Value>() {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.setComponentView(metadata, context.name);\n\t\t}\n\t);\n}\n\nexport function ViewChild<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor, childOptions?: ChildOptions) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addViewChild(metadata, context.name, selector, childOptions);\n\t\t}\n\t);\n}\n\nexport function ViewChildren<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addViewChildren(metadata, context.name, selector);\n\t\t}\n\t);\n}\n\n\nexport function HostListener<This, Value extends (this: This, ...args: any) => any>(eventName: string, args?: string | string[]) {\n\treturn makeClassMemberDecorator<Value, ClassMethodDecoratorContext>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\targs = typeof args === 'string' ? [args] : args;\n\t\t\tReflectComponents.addHostListener(\n\t\t\t\tmetadata,\n\t\t\t\tcontext.name,\n\t\t\t\teventName,\n\t\t\t\targs || []\n\t\t\t);\n\t\t}\n\t);\n}\n\n\ntype ValueGetter<T> = T | (() => T) | undefined;\n\nexport function HostBinding<This, Value>(hostPropertyName: string) {\n\treturn makeClassMemberDecorator<ValueGetter<Value>, ClassFieldDecoratorContext<This, Value> | ClassMethodDecoratorContext<This, any> | ClassGetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addHostBinding(metadata, context.name, hostPropertyName);\n\t\t}\n\t);\n}\n\nexport const Pipe = makeClassDecorator<PipeOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.definePipe(constructor as any, opt, metadata);\n\t}\n);\n\n\nexport const Directive = makeClassDecorator<DirectiveOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.defineDirective(constructor as any, opt, metadata);\n\t}\n);\n\n\nfunction generateComponent<T extends Class>(target: MetadataClass<T>, opt: ComponentOptions<T>, metadata: MetadataContext) {\n\tif (opt.templateUrl) {\n\t\tfetchHtml(opt.templateUrl)\n\t\t\t.then(htmlTemplate => {\n\t\t\t\tif (htmlTemplate) {\n\t\t\t\t\topt.template = htmlTemplate;\n\t\t\t\t\tComponents.defineComponent(target, opt, metadata);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(reason => {\n\t\t\t\tconsole.error(`Error @URL: ${opt.templateUrl}, for model Class: ${target.name},\\n Reason: ${reason}.`);\n\t\t\t});\n\t} else {\n\t\tComponents.defineComponent(target, opt, metadata);\n\t}\n}\n\nexport const Component = makeClassDecorator<ComponentOptions | ComponentOptions[]>(\n\t(opt, constructor, context, metadata) => {\n\t\tif (Array.isArray(opt)) {\n\t\t\tfor (const comp of opt) {\n\t\t\t\tgenerateComponent(constructor as any, comp, metadata);\n\t\t\t}\n\t\t} else if (typeof opt === 'object') {\n\t\t\tgenerateComponent(constructor as any, opt, metadata);\n\t\t}\n\t}\n);\n\nexport const customElement = makeClassDecorator<{ selector: string } & ElementDefinitionOptions, Class<HTMLElement>>(\n\t(opt, constructor, context) => {\n\t\tComponents.defineView(constructor as any, opt);\n\t}\n);\n"]}
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,kBAAkB,EAAE,wBAAwB,EAC5C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,k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C;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAC1C,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;YACxB,iBAAiB,CAAC,WAAkB,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACvD,CAAC;IACF,CAAC;SAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,iBAAiB,CAAC,WAAkB,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;AACF,CAAC,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAC9C,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;IAC7B,UAAU,CAAC,UAAU,CAAC,WAAkB,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC,CACD,CAAC","sourcesContent":["import type { Class } from '../utils/typeof.js';\nimport {\n\tMetadataClass, MetadataContext,\n\tmakeClassDecorator, makeClassMemberDecorator\n} from '@ibyar/decorators';\nimport { Components } from '../component/component.js';\nimport { ReflectComponents } from '../component/reflect.js';\nimport { fetchHtml } from '../utils/path.js';\nimport {\n\tChildOptions, ComponentOptions, DirectiveOptions,\n\tOutputEventInit, OutputOptions, PipeOptions, ServiceOptions\n} from './options.js';\n\n\n\ntype PropertyValue<T> = T | ((value: T) => void) | undefined;\n\n\nexport function Input<This, Value>(name?: string) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (!name && typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addInput(metadata, context.name as string, name || context.name as string);\n\t\t}\n\t);\n}\n\nexport function FormValue<This, Value>() {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addInput(metadata, context.name, 'value');\n\t\t}\n\t);\n}\n\nexport function Output<This, Value>(options?: OutputOptions): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\nexport function Output<This, Value>(name?: string, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\nexport function Output<This, Value>(name?: string | OutputOptions, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void {\n\tconst eventType = typeof name === 'object' ? name.name : name;\n\tconst eventOpts = typeof name === 'object' ? name : options;\n\treturn makeClassMemberDecorator<undefined, ClassFieldDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addOutput(\n\t\t\t\tmetadata,\n\t\t\t\tcontext.name,\n\t\t\t\teventType || context.name,\n\t\t\t\t{\n\t\t\t\t\tbubbles: eventOpts?.bubbles ?? false,\n\t\t\t\t\tcomposed: eventOpts?.composed ?? false\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n}\n\nexport function View<This, Value>() {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.setComponentView(metadata, context.name);\n\t\t}\n\t);\n}\n\nexport function ViewChild<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor, childOptions?: ChildOptions) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addViewChild(metadata, context.name, selector, childOptions);\n\t\t}\n\t);\n}\n\nexport function ViewChildren<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addViewChildren(metadata, context.name, selector);\n\t\t}\n\t);\n}\n\n\nexport function HostListener<This, Value extends (this: This, ...args: any) => any>(eventName: string, args?: string | string[]) {\n\treturn makeClassMemberDecorator<Value, ClassMethodDecoratorContext>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\targs = typeof args === 'string' ? [args] : args;\n\t\t\tReflectComponents.addHostListener(\n\t\t\t\tmetadata,\n\t\t\t\tcontext.name,\n\t\t\t\teventName,\n\t\t\t\targs || []\n\t\t\t);\n\t\t}\n\t);\n}\n\n\ntype ValueGetter<T> = T | (() => T) | undefined;\n\nexport function HostBinding<This, Value>(hostPropertyName: string) {\n\treturn makeClassMemberDecorator<ValueGetter<Value>, ClassFieldDecoratorContext<This, Value> | ClassMethodDecoratorContext<This, any> | ClassGetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addHostBinding(metadata, context.name, hostPropertyName);\n\t\t}\n\t);\n}\n\nexport const Pipe = makeClassDecorator<PipeOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.definePipe(constructor as any, opt, metadata);\n\t}\n);\n\n\nexport const Directive = makeClassDecorator<DirectiveOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.defineDirective(constructor as any, opt, metadata);\n\t}\n);\n\n\nfunction generateComponent<T extends Class>(target: MetadataClass<T>, opt: ComponentOptions<T>, metadata: MetadataContext) {\n\tif (opt.templateUrl) {\n\t\tfetchHtml(opt.templateUrl)\n\t\t\t.then(htmlTemplate => {\n\t\t\t\tif (htmlTemplate) {\n\t\t\t\t\topt.template = htmlTemplate;\n\t\t\t\t\tComponents.defineComponent(target, opt, metadata);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(reason => {\n\t\t\t\tconsole.error(`Error @URL: ${opt.templateUrl}, for model Class: ${target.name},\\n Reason: ${reason}.`);\n\t\t\t});\n\t} else {\n\t\tComponents.defineComponent(target, opt, metadata);\n\t}\n}\n\nexport const Component = makeClassDecorator<ComponentOptions | ComponentOptions[]>(\n\t(opt, constructor, context, metadata) => {\n\t\tif (Array.isArray(opt)) {\n\t\t\tfor (const comp of opt) {\n\t\t\t\tgenerateComponent(constructor as any, comp, metadata);\n\t\t\t}\n\t\t} else if (typeof opt === 'object') {\n\t\t\tgenerateComponent(constructor as any, opt, metadata);\n\t\t}\n\t}\n);\n\nexport const customElement = makeClassDecorator<{ selector: string } & ElementDefinitionOptions, Class<HTMLElement>>(\n\t(opt, constructor, context) => {\n\t\tComponents.defineView(constructor as any, opt);\n\t}\n);\n"]}
|
package/annotation/options.d.ts
CHANGED
|
@@ -11,6 +11,30 @@ export interface DirectiveOptions {
|
|
|
11
11
|
* and an attributes directive should not.
|
|
12
12
|
*/
|
|
13
13
|
selector: string;
|
|
14
|
+
/**
|
|
15
|
+
* export this directive to the HTML template scope,
|
|
16
|
+
*
|
|
17
|
+
* it can be accessed by the template reference name
|
|
18
|
+
* ex:
|
|
19
|
+
* ```ts
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
*
|
|
23
|
+
* Directive({
|
|
24
|
+
* selector: '*tooltip',
|
|
25
|
+
* exportAs: 'tooltip'
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* in your component
|
|
30
|
+
*
|
|
31
|
+
* ```html
|
|
32
|
+
* <a tooltip="I'm a tooltip!!" #tooltip="tooltip">I'm a link</a>
|
|
33
|
+
* <button (click)="tooltip.toggleTooltip()">Toggle tooltip</button>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
exportAs?: string;
|
|
14
38
|
/**
|
|
15
39
|
* - use `manual` for no zone.js patch effect applied,
|
|
16
40
|
* and used for manual change detection for heavily process components.
|
|
@@ -1 +1 @@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a,CAAC,EAAE,cAAc,CAAC;IAE/B;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmFG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAErD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,YAAY;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,GAAG,OAAO,WAAW,GAAG,wBAAwB,CAAC;IACjE,YAAY,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC5D,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"","sourcesContent":["import type { Class, TypeOf } from '../utils/typeof.js';\nimport { DomNode } from '@ibyar/elements';\nimport { TemplateUrl } from '../utils/path.js';\nimport { ZoneType } from '../zone/bootstrap.js';\nimport { ValueControl } from '../component/custom-element.js';\n\n\nexport interface DirectiveOptions {\n\n\t/**\n\t * the name of the directive which is used in the template\n\t * \n\t * a structural directive name should start with `*`,\n\t * and an attributes directive should not.\n\t */\n\tselector: string;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * if no value specified, the value will be initialized by the custom element `web component` zone,\n\t * - if the web component zone is `manual`, the directive zone also will be `manual`, expect weird behavior.\n\t * - if the web component zone is `proxy`, the directive zone also will be `proxy`.\n\t * - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.\n\t */\n\tzone?: ZoneType;\n}\n\nexport interface ServiceOptions {\n\tprovideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n}\n\nexport interface PipeOptions {\n\tname: string;\n\tasynchronous?: boolean;\n}\n\nexport interface ComponentOptions<T = Class> {\n\n\t/**\n\t * a tag name for the component,\n\t * if the tag name is valid custom element name, the view class will be a custom element,\n\t * otherwise an HTMLUnknownElement will be created\n\t */\n\tselector: string;\n\n\t/**\n\t * add html file url path to fetch,\n\t * templateUrl had propriety than template, and will override it.\n\t *\n\t * Can provide file name as \"person-view.html\" will resolved \n\t * as 'http://site-address.org/persin-view.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }\n\t * let (import.meta = '/person/person.js') will resolved \n\t * as 'http://site-address.org/person/person-edit.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta }\n\t * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.\n\t * \n\t * if url not found, component will not be defined,\n\t * \n\t * if you didn't use webpack or rollup.js or any bundler, \n\t * you should copy the html files to its folder by yourself. \n\t */\n\ttemplateUrl?: TemplateUrl | string;\n\n\t/**\n\t * template: typeof 'string' ==> html string,\n\t * \t\t\t TypeOf 'DomRootRenderNode<T>' ==> JSX, create factory\n\t * \tif template === null || undefined ==> it had nothing to render, \n\t * and may be inherit from an html element\n\t * \n\t * 2 possible way to write a template, as inline string, represent a a valid html, \n\t * or us aurora jsx factory \n\t * \t\t\t\t\n\t */\n\ttemplate?: string | DomNode;\n\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\n\t/**\n\t * what basic element should the new component inherit from,\n\t * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...\n\t * also, support extends a custom element tag name.\n\t */\n\textend?: keyof HTMLElementTagNameMap | `${string}-${string}`;\n\n\t/**\n\t * An encapsulation policy for the template and CSS styles. One of:\n\t * 'custom': Use global CSS without any encapsulation.\n\t * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.\n\t * \n\t * 'template': like 'custom', with load the template from the document ('index.html' file)\n\t * \t \t\t\tthat had the same id as the component \"selector\".\n\t * 'shadow-dom-template': like 'shadowDom', and load template by selector id.\n\t * \n\t * Both 'template' & 'shadow-dom-template' encapsulation type:\n\t * should had attributes name like lowercase,\n\t * \tthe browser itself, will convert all attributes to lowercase\n\t * \n\t * ```typescript\n\t *\t\t@Input('personage') personAge: number;\n\t *\t\t@Input('propname') propName: string;\n\t *\t\t@Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();\n\t *\t\t@View('personform') personForm: HTMLFormElement;\n\t * ```\n\t * \n\t * any app root element as \n\t * \n\t * ```html\n\t * <app-root></app-root>\n\t * ```\n\t * \n\t * the supported bind options is 'One way binding *(as passing data only)'\n\t * and 'template parsing' and 'event binding' syntax, HTML (angular) like.\n\t * it load its attributes from 'window object'\n\t * \n\t * so to pass date to A root element, \n\t * \n\t * ```html\n\t * <script>\n\t * \tconst appVersion = '0.1.504';\n\t * \tfunction onRootAppClick() {\n\t *\t\tconsole.log('root app clicked');\n\t * \t}\n\t * \tfunction onSave(data){\n\t *\t\tconsole.log('root app save', data);\n\t * \t}\n\t * </script>\n\t * <app-root [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" >\n\t * </app-root>\n\t * ```\n\t * \n\t * default is 'custom'\n\t * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}\n\t */\n\tencapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\n\t/**\n\t * default: 'open' when encapsulation used,\n\t * otherwise it is undefined and will not attach shadow root element.\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n\n\t/**\n\t * shadow root initialization options,\n\t * default mode: `open`, delegatesFocus: `false` and slotAssignment: `manual`\n\t */\n\tshadowRootInit?: Partial<ShadowRootInit>;\n\n\t/**\n\t * Create a custom form-associated element with HTMLElement.attachInternals\n\t * default: false\n\t * \n\t * if the value is `true` it is expected from the model class to implement `ValueControl<T>` interface\n\t * \n\t * otherwise you can register another class that implement `ValueControl<T>`,\n\t * in case if you want split the model and the value controller.\n\t * \n\t * #### Usage Notes:\n\t * \n\t * ```ts\n\t * \n\t * @Component({\n\t * \tselector: 'custom-message',\n\t * \ttemplate: `\n\t * \t\t<label for=\"message\">Message</label>\n\t * \t\t<textarea id=\"message\" [(value)]=\"message\" [disabled]=\"disabled\" (change)=\"onMessageChange($event.target.value)\"></textarea>\n\t * \t`,\n\t * \tformAssociated: true,\n\t * \t// formAssociated: CustomMessage,\n\t * })\n\t * export class CustomMessage implements ValueControl<string> {\n\t * \n\t * \tprivate message: string | null = '';\n\t * \tprivate disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<string>) {\n\t * \t\tthis.message = mode !== 'reset' ? value : '';\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis.disabled = isDisabled;\n\t * \t}\n\t * \n\t * \tonMessageChange(message: string) {\n\t * \t\tthis._onChange(message);\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * \n\t * export class CustomInputValueControl implements ValueControl<number> {\n\t * \n\t * \tprivate _value: number | null = null;\n\t * \tprivate _disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<number>) {\n\t * \t\tthis._value = mode !== 'reset' ? value : null;\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis._disabled = isDisabled;\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * @Component({\n\t * \tselector: 'custom-input',\n\t * \textend: 'input',\n\t * \tformAssociated: CustomInputValueControl,\n\t * })\n\t * export class CustomInputElement {\n\t * \t\n\t * @View()\n\t * \tview: HTMLInputElement;\n\t * \n\t * \tonInit() {\n\t * \t\tthis.view.type = 'number';\n\t * \t}\n\t * }\n\t * \n\t * ```\n\t */\n\tformAssociated?: boolean | TypeOf<ValueControl<any>>;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * the default value is the platform zone type which can be changed by:\n\t * \n\t * ```js\n\t * bootstrapZone('manual')\n\t * bootstrapZone('proxy')\n\t * bootstrapZone('aurora')\n\t * ```\n\t * \n\t * if `bootstrapZone` never been called, then the default zone is a `manual`.\n\t */\n\tzone?: ZoneType;\n\n\t/**\n\t * The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.\n\t */\n\timports?: (TypeOf<any> | ReadonlyArray<any>)[];\n}\n\nexport interface ChildOptions {\n\t[key: string]: any;\n}\n\nexport interface ViewChildOpt {\n\tselector: string | typeof HTMLElement | CustomElementConstructor;\n\tchildOptions?: ChildOptions;\n}\n\nexport type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n"]}
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"","sourcesContent":["import type { Class, TypeOf } from '../utils/typeof.js';\nimport { DomNode } from '@ibyar/elements';\nimport { TemplateUrl } from '../utils/path.js';\nimport { ZoneType } from '../zone/bootstrap.js';\nimport { ValueControl } from '../component/custom-element.js';\n\n\nexport interface DirectiveOptions {\n\n\t/**\n\t * the name of the directive which is used in the template\n\t * \n\t * a structural directive name should start with `*`,\n\t * and an attributes directive should not.\n\t */\n\tselector: string;\n\n\t/**\n\t * export this directive to the HTML template scope,\n\t * \n\t * it can be accessed by the template reference name \n\t * ex:\n\t * ```ts\n\t * \n\t * \n\t * \n\t * Directive({\n\t * \tselector: '*tooltip',\n\t * \texportAs: 'tooltip'\n\t * })\n\t * ```\n\t * \n\t * in your component\n\t * \n\t * ```html\n\t * <a tooltip=\"I'm a tooltip!!\" #tooltip=\"tooltip\">I'm a link</a>\n\t * <button (click)=\"tooltip.toggleTooltip()\">Toggle tooltip</button>\n\t * ```\n\t * \n\t */\n\n\texportAs?: string;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * if no value specified, the value will be initialized by the custom element `web component` zone,\n\t * - if the web component zone is `manual`, the directive zone also will be `manual`, expect weird behavior.\n\t * - if the web component zone is `proxy`, the directive zone also will be `proxy`.\n\t * - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.\n\t */\n\tzone?: ZoneType;\n}\n\nexport interface ServiceOptions {\n\tprovideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n}\n\nexport interface PipeOptions {\n\tname: string;\n\tasynchronous?: boolean;\n}\n\nexport interface ComponentOptions<T = Class> {\n\n\t/**\n\t * a tag name for the component,\n\t * if the tag name is valid custom element name, the view class will be a custom element,\n\t * otherwise an HTMLUnknownElement will be created\n\t */\n\tselector: string;\n\n\t/**\n\t * add html file url path to fetch,\n\t * templateUrl had propriety than template, and will override it.\n\t *\n\t * Can provide file name as \"person-view.html\" will resolved \n\t * as 'http://site-address.org/persin-view.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }\n\t * let (import.meta = '/person/person.js') will resolved \n\t * as 'http://site-address.org/person/person-edit.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta }\n\t * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.\n\t * \n\t * if url not found, component will not be defined,\n\t * \n\t * if you didn't use webpack or rollup.js or any bundler, \n\t * you should copy the html files to its folder by yourself. \n\t */\n\ttemplateUrl?: TemplateUrl | string;\n\n\t/**\n\t * template: typeof 'string' ==> html string,\n\t * \t\t\t TypeOf 'DomRootRenderNode<T>' ==> JSX, create factory\n\t * \tif template === null || undefined ==> it had nothing to render, \n\t * and may be inherit from an html element\n\t * \n\t * 2 possible way to write a template, as inline string, represent a a valid html, \n\t * or us aurora jsx factory \n\t * \t\t\t\t\n\t */\n\ttemplate?: string | DomNode;\n\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\n\t/**\n\t * what basic element should the new component inherit from,\n\t * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...\n\t * also, support extends a custom element tag name.\n\t */\n\textend?: keyof HTMLElementTagNameMap | `${string}-${string}`;\n\n\t/**\n\t * An encapsulation policy for the template and CSS styles. One of:\n\t * 'custom': Use global CSS without any encapsulation.\n\t * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.\n\t * \n\t * 'template': like 'custom', with load the template from the document ('index.html' file)\n\t * \t \t\t\tthat had the same id as the component \"selector\".\n\t * 'shadow-dom-template': like 'shadowDom', and load template by selector id.\n\t * \n\t * Both 'template' & 'shadow-dom-template' encapsulation type:\n\t * should had attributes name like lowercase,\n\t * \tthe browser itself, will convert all attributes to lowercase\n\t * \n\t * ```typescript\n\t *\t\t@Input('personage') personAge: number;\n\t *\t\t@Input('propname') propName: string;\n\t *\t\t@Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();\n\t *\t\t@View('personform') personForm: HTMLFormElement;\n\t * ```\n\t * \n\t * any app root element as \n\t * \n\t * ```html\n\t * <app-root></app-root>\n\t * ```\n\t * \n\t * the supported bind options is 'One way binding *(as passing data only)'\n\t * and 'template parsing' and 'event binding' syntax, HTML (angular) like.\n\t * it load its attributes from 'window object'\n\t * \n\t * so to pass date to A root element, \n\t * \n\t * ```html\n\t * <script>\n\t * \tconst appVersion = '0.1.504';\n\t * \tfunction onRootAppClick() {\n\t *\t\tconsole.log('root app clicked');\n\t * \t}\n\t * \tfunction onSave(data){\n\t *\t\tconsole.log('root app save', data);\n\t * \t}\n\t * </script>\n\t * <app-root [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" >\n\t * </app-root>\n\t * ```\n\t * \n\t * default is 'custom'\n\t * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}\n\t */\n\tencapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\n\t/**\n\t * default: 'open' when encapsulation used,\n\t * otherwise it is undefined and will not attach shadow root element.\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n\n\t/**\n\t * shadow root initialization options,\n\t * default mode: `open`, delegatesFocus: `false` and slotAssignment: `manual`\n\t */\n\tshadowRootInit?: Partial<ShadowRootInit>;\n\n\t/**\n\t * Create a custom form-associated element with HTMLElement.attachInternals\n\t * default: false\n\t * \n\t * if the value is `true` it is expected from the model class to implement `ValueControl<T>` interface\n\t * \n\t * otherwise you can register another class that implement `ValueControl<T>`,\n\t * in case if you want split the model and the value controller.\n\t * \n\t * #### Usage Notes:\n\t * \n\t * ```ts\n\t * \n\t * @Component({\n\t * \tselector: 'custom-message',\n\t * \ttemplate: `\n\t * \t\t<label for=\"message\">Message</label>\n\t * \t\t<textarea id=\"message\" [(value)]=\"message\" [disabled]=\"disabled\" (change)=\"onMessageChange($event.target.value)\"></textarea>\n\t * \t`,\n\t * \tformAssociated: true,\n\t * \t// formAssociated: CustomMessage,\n\t * })\n\t * export class CustomMessage implements ValueControl<string> {\n\t * \n\t * \tprivate message: string | null = '';\n\t * \tprivate disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<string>) {\n\t * \t\tthis.message = mode !== 'reset' ? value : '';\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis.disabled = isDisabled;\n\t * \t}\n\t * \n\t * \tonMessageChange(message: string) {\n\t * \t\tthis._onChange(message);\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * \n\t * export class CustomInputValueControl implements ValueControl<number> {\n\t * \n\t * \tprivate _value: number | null = null;\n\t * \tprivate _disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<number>) {\n\t * \t\tthis._value = mode !== 'reset' ? value : null;\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis._disabled = isDisabled;\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * @Component({\n\t * \tselector: 'custom-input',\n\t * \textend: 'input',\n\t * \tformAssociated: CustomInputValueControl,\n\t * })\n\t * export class CustomInputElement {\n\t * \t\n\t * @View()\n\t * \tview: HTMLInputElement;\n\t * \n\t * \tonInit() {\n\t * \t\tthis.view.type = 'number';\n\t * \t}\n\t * }\n\t * \n\t * ```\n\t */\n\tformAssociated?: boolean | TypeOf<ValueControl<any>>;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * the default value is the platform zone type which can be changed by:\n\t * \n\t * ```js\n\t * bootstrapZone('manual')\n\t * bootstrapZone('proxy')\n\t * bootstrapZone('aurora')\n\t * ```\n\t * \n\t * if `bootstrapZone` never been called, then the default zone is a `manual`.\n\t */\n\tzone?: ZoneType;\n\n\t/**\n\t * The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.\n\t */\n\timports?: (TypeOf<any> | ReadonlyArray<any>)[];\n}\n\nexport interface ChildOptions {\n\t[key: string]: any;\n}\n\nexport interface ViewChildOpt {\n\tselector: string | typeof HTMLElement | CustomElementConstructor;\n\tchildOptions?: ChildOptions;\n}\n\nexport type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
2
|
import { Deserializer, InfixExpressionNode, Scope, findReactiveScopeByEventMap } from '@ibyar/expressions';
|
|
3
3
|
import { isOnDestroy } from '../component/lifecycle.js';
|
|
4
|
-
import {
|
|
4
|
+
import { createDestroySubscription } from '../context/subscription.js';
|
|
5
5
|
import { AsyncPipeProvider, AsyncPipeScope, PipeProvider } from '../pipe/pipe.js';
|
|
6
6
|
let OneWayAssignmentExpression = (() => {
|
|
7
7
|
let _classDecorators = [Deserializer('OneWayAssignment')];
|
|
@@ -50,7 +50,7 @@ let OneWayAssignmentExpression = (() => {
|
|
|
50
50
|
hasAsync = true;
|
|
51
51
|
asyncPipeScope.set(pipelineName, pipe);
|
|
52
52
|
if (isOnDestroy(pipe.prototype)) {
|
|
53
|
-
subscriptions.push(
|
|
53
|
+
subscriptions.push(createDestroySubscription(() => asyncPipeScope.unsubscribe(pipelineName)));
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
else if (scope instanceof PipeProvider) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.expressions.js","sourceRoot":"","sources":["../../../src/core/binding/binding.expressions.ts"],"names":[],"mappings":";AAAA,OAAO,EACG,YAAY,EACT,mBAAmB,EACE,KAAK,EAEtC,2BAA2B,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;IAYrE,0BAA0B;4BADtC,YAAY,CAAC,kBAAkB,CAAC;;;;sBACe,mBAAmB;0CAA3B,SAAQ,WAAmC;;;;YAAnF,6KAwDC;;;YAxDY,uDAA0B;;QACtC,MAAM,CAAC,QAAQ,CAAC,IAAgC,EAAE,YAA8B;YAC/E,OAAO,IAAI,0BAA0B,CACpC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAqB,EAC3C,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CACxB,CAAC;QACH,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,IAAgC,EAAE,SAAwB;Y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AAgB,CAAC,CAAC;QAClD,CAAC;;;;SA5EW,0BAA0B","sourcesContent":["import {\n\tContext, Deserializer, ExpressionEventMap, ExpressionNode,\n\tIdentifier, InfixExpressionNode, MemberExpression,\n\tNodeDeserializer, ReactiveScope, Scope, ScopeSubscription,\n\tStack, ValueChangedCallback, VisitNodeType,\n\tfindReactiveScopeByEventMap\n} from '@ibyar/expressions';\nimport { isOnDestroy } from '../component/lifecycle.js';\nimport { createSubscriptionDestroyer } from '../context/subscription.js';\nimport { AsyncPipeProvider, AsyncPipeScope, PipeProvider } from '../pipe/pipe.js';\n\ntype OneWayOperator = '=:';\ntype TwoWayOperator = '=::';\ntype BindingOperators = OneWayOperator | TwoWayOperator;\n\nexport interface BindingAssignment extends InfixExpressionNode<BindingOperators> {\n\tsubscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<Context>[];\n}\n\n\n@Deserializer('OneWayAssignment')\nexport class OneWayAssignmentExpression extends InfixExpressionNode<OneWayOperator> implements BindingAssignment {\n\tstatic fromJSON(node: OneWayAssignmentExpression, deserializer: NodeDeserializer): OneWayAssignmentExpression {\n\t\treturn new OneWayAssignmentExpression(\n\t\t\tdeserializer(node.left) as MemberExpression,\n\t\t\tdeserializer(node.right)\n\t\t);\n\t}\n\tstatic visit(node: OneWayAssignmentExpression, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t}\n\n\tdeclare protected left: MemberExpression;\n\tprivate rightEvents = this.right.events();\n\tconstructor(left: MemberExpression, right: ExpressionNode) {\n\t\tsuper('=:', left, right);\n\t}\n\tset(stack: Stack, value: any) {\n\t\treturn this.left.set(stack, value);\n\t}\n\tget(stack: Stack): any {\n\t\tconst rv = this.right.get(stack);\n\t\tthis.set(stack, rv);\n\t\treturn rv;\n\t}\n\tsubscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tif (pipelineNames?.length) {\n\t\t\tconst syncPipeScope = Scope.blockScope();\n\t\t\tconst asyncPipeScope = AsyncPipeScope.blockScope();\n\t\t\tlet hasAsync = false, hasSync = false;\n\t\t\tpipelineNames.forEach(pipelineName => {\n\t\t\t\tconst scope = stack.findScope(pipelineName);\n\t\t\t\tconst pipe = scope.get(pipelineName)!;\n\t\t\t\tif (scope instanceof AsyncPipeProvider) {\n\t\t\t\t\thasAsync = true;\n\t\t\t\t\tasyncPipeScope.set(pipelineName, pipe);\n\t\t\t\t\tif (isOnDestroy(pipe.prototype)) {\n\t\t\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => asyncPipeScope.unsubscribe(pipelineName)));\n\t\t\t\t\t}\n\t\t\t\t} else if (scope instanceof PipeProvider) {\n\t\t\t\t\thasSync = true;\n\t\t\t\t\tsyncPipeScope.set(pipelineName, pipe);\n\t\t\t\t}\n\t\t\t});\n\t\t\thasSync && stack.pushScope(syncPipeScope);\n\t\t\thasAsync && stack.pushScope(asyncPipeScope);\n\t\t}\n\t\tconst tuples = findReactiveScopeByEventMap(this.rightEvents, stack);\n\t\tconst callback: ValueChangedCallback = () => this.get(stack);\n\t\ttuples.forEach(tuple => {\n\t\t\tconst subscription = tuple[1].subscribe(tuple[0], callback);\n\t\t\tsubscriptions.push(subscription);\n\t\t});\n\t\treturn subscriptions;\n\t}\n}\n\n\n/**\n * the default behavior is assign the right hand side to the left hand side.\n * \n * \n */\n@Deserializer('TwoWayAssignment')\nexport class TwoWayAssignmentExpression extends InfixExpressionNode<TwoWayOperator> implements BindingAssignment {\n\tstatic fromJSON(node: TwoWayAssignmentExpression, deserializer: NodeDeserializer): TwoWayAssignmentExpression {\n\t\treturn new TwoWayAssignmentExpression(\n\t\t\tdeserializer(node.left) as MemberExpression,\n\t\t\tdeserializer(node.right) as MemberExpression | Identifier\n\t\t);\n\t}\n\tstatic visit(node: TwoWayAssignmentExpression, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t}\n\n\tdeclare protected left: MemberExpression;\n\tdeclare protected right: MemberExpression | Identifier;\n\n\tprivate rightEvents: ExpressionEventMap;\n\tprivate leftEvents: ExpressionEventMap;\n\tconstructor(left: MemberExpression, right: MemberExpression | Identifier) {\n\t\tsuper('=::', left, right);\n\t\tthis.rightEvents = this.right.events();\n\t\tthis.leftEvents = this.left.events();\n\t}\n\n\tset(stack: Stack, value: any) {\n\t\treturn this.setRTL(stack, value);\n\t}\n\tget(stack: Stack): any {\n\t\treturn this.getRTL(stack);\n\t}\n\n\tprivate setRTL(stack: Stack, value: any) {\n\t\treturn this.left.set(stack, value);\n\t}\n\tprivate getRTL(stack: Stack): any {\n\t\tconst rv = this.right.get(stack);\n\t\tthis.setRTL(stack, rv);\n\t\treturn rv;\n\t}\n\tprivate actionRTL(stack: Stack): ValueChangedCallback {\n\t\treturn () => this.getRTL(stack);\n\t}\n\n\tprivate setLTR(stack: Stack, value: any) {\n\t\treturn this.right.set(stack, value);\n\t}\n\tprivate getLTR(stack: Stack): any {\n\t\tconst lv = this.left.get(stack);\n\t\tthis.setLTR(stack, lv);\n\t\treturn lv;\n\t}\n\tprivate actionLTR(stack: Stack): ValueChangedCallback {\n\t\treturn () => this.getLTR(stack);\n\t}\n\n\tprivate subscribeToEvents(stack: Stack, tuples: [string, ReactiveScope<Context>][], actionCallback: ValueChangedCallback) {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\ttuples.forEach(tuple => {\n\t\t\tconst subscription = tuple[1].subscribe(tuple[0], actionCallback);\n\t\t\tsubscriptions.push(subscription);\n\t\t});\n\t\treturn subscriptions;\n\t}\n\n\tsubscribe(stack: Stack): ScopeSubscription<Context>[] {\n\n\t\t// right to left\n\t\tconst rightTuples = findReactiveScopeByEventMap(this.rightEvents, stack);\n\t\tconst rtlAction = this.actionRTL(stack);\n\t\tconst rtlSubscriptions = this.subscribeToEvents(stack, rightTuples, rtlAction);\n\n\t\t// left to right \n\t\tconst leftTuples = findReactiveScopeByEventMap(this.leftEvents, stack);\n\t\tconst ltrAction = this.actionLTR(stack);\n\t\tconst ltrSubscriptions = this.subscribeToEvents(stack, leftTuples, ltrAction);\n\n\t\treturn rtlSubscriptions.concat(ltrSubscriptions);\n\t}\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"binding.expressions.js","sourceRoot":"","sources":["../../../src/core/binding/binding.expressions.ts"],"names":[],"mappings":";AAAA,OAAO,EACG,YAAY,EACT,mBAAmB,EACE,KAAK,EAEtC,2BAA2B,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;IAYrE,0BAA0B;4BADtC,YAAY,CAAC,kBAAkB,CAAC;;;;sBACe,mBAAmB;0CAA3B,SAAQ,WAAmC;;;;YAAnF,6KAwDC;;;YAxDY,uDAA0B;;QACtC,MAAM,CAAC,QAAQ,CAAC,IAAgC,EAAE,YAA8B;YAC/E,OAAO,IAAI,0BAA0B,CACpC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAqB,EAC3C,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CACxB,CAAC;QACH,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,IAAgC,EAAE,SAAwB;YACtE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAGO,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1C,YAAY,IAAsB,EAAE,KAAqB;YACxD,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC;QACD,GAAG,CAAC,KAAY,EAAE,KAAU;YAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,G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iBAAiB,CAAC,KAAY,EAAE,MAA0C,EAAE,cAAoC;YACvH,MAAM,aAAa,GAAiC,EAAE,CAAC;YACvD,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACtB,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;gBAClE,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAClC,CAAC,CAAC,CAAC;YACH,OAAO,aAAa,CAAC;QACtB,CAAC;QAED,SAAS,CAAC,KAAY;YAErB,gBAAgB;YAChB,MAAM,WAAW,GAAG,2BAA2B,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;YACzE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACxC,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;YAE/E,iBAAiB;YACjB,MAAM,UAAU,GAAG,2BAA2B,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YACvE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACxC,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;YAE9E,OAAO,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAClD,CAAC;;;;SA5EW,0BAA0B","sourcesContent":["import {\n\tContext, Deserializer, ExpressionEventMap, ExpressionNode,\n\tIdentifier, InfixExpressionNode, MemberExpression,\n\tNodeDeserializer, ReactiveScope, Scope, ScopeSubscription,\n\tStack, ValueChangedCallback, VisitNodeType,\n\tfindReactiveScopeByEventMap\n} from '@ibyar/expressions';\nimport { isOnDestroy } from '../component/lifecycle.js';\nimport { createDestroySubscription } from '../context/subscription.js';\nimport { AsyncPipeProvider, AsyncPipeScope, PipeProvider } from '../pipe/pipe.js';\n\ntype OneWayOperator = '=:';\ntype TwoWayOperator = '=::';\ntype BindingOperators = OneWayOperator | TwoWayOperator;\n\nexport interface BindingAssignment extends InfixExpressionNode<BindingOperators> {\n\tsubscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<Context>[];\n}\n\n\n@Deserializer('OneWayAssignment')\nexport class OneWayAssignmentExpression extends InfixExpressionNode<OneWayOperator> implements BindingAssignment {\n\tstatic fromJSON(node: OneWayAssignmentExpression, deserializer: NodeDeserializer): OneWayAssignmentExpression {\n\t\treturn new OneWayAssignmentExpression(\n\t\t\tdeserializer(node.left) as MemberExpression,\n\t\t\tdeserializer(node.right)\n\t\t);\n\t}\n\tstatic visit(node: OneWayAssignmentExpression, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t}\n\n\tdeclare protected left: MemberExpression;\n\tprivate rightEvents = this.right.events();\n\tconstructor(left: MemberExpression, right: ExpressionNode) {\n\t\tsuper('=:', left, right);\n\t}\n\tset(stack: Stack, value: any) {\n\t\treturn this.left.set(stack, value);\n\t}\n\tget(stack: Stack): any {\n\t\tconst rv = this.right.get(stack);\n\t\tthis.set(stack, rv);\n\t\treturn rv;\n\t}\n\tsubscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tif (pipelineNames?.length) {\n\t\t\tconst syncPipeScope = Scope.blockScope();\n\t\t\tconst asyncPipeScope = AsyncPipeScope.blockScope();\n\t\t\tlet hasAsync = false, hasSync = false;\n\t\t\tpipelineNames.forEach(pipelineName => {\n\t\t\t\tconst scope = stack.findScope(pipelineName);\n\t\t\t\tconst pipe = scope.get(pipelineName)!;\n\t\t\t\tif (scope instanceof AsyncPipeProvider) {\n\t\t\t\t\thasAsync = true;\n\t\t\t\t\tasyncPipeScope.set(pipelineName, pipe);\n\t\t\t\t\tif (isOnDestroy(pipe.prototype)) {\n\t\t\t\t\t\tsubscriptions.push(createDestroySubscription(() => asyncPipeScope.unsubscribe(pipelineName)));\n\t\t\t\t\t}\n\t\t\t\t} else if (scope instanceof PipeProvider) {\n\t\t\t\t\thasSync = true;\n\t\t\t\t\tsyncPipeScope.set(pipelineName, pipe);\n\t\t\t\t}\n\t\t\t});\n\t\t\thasSync && stack.pushScope(syncPipeScope);\n\t\t\thasAsync && stack.pushScope(asyncPipeScope);\n\t\t}\n\t\tconst tuples = findReactiveScopeByEventMap(this.rightEvents, stack);\n\t\tconst callback: ValueChangedCallback = () => this.get(stack);\n\t\ttuples.forEach(tuple => {\n\t\t\tconst subscription = tuple[1].subscribe(tuple[0], callback);\n\t\t\tsubscriptions.push(subscription);\n\t\t});\n\t\treturn subscriptions;\n\t}\n}\n\n\n/**\n * the default behavior is assign the right hand side to the left hand side.\n * \n * \n */\n@Deserializer('TwoWayAssignment')\nexport class TwoWayAssignmentExpression extends InfixExpressionNode<TwoWayOperator> implements BindingAssignment {\n\tstatic fromJSON(node: TwoWayAssignmentExpression, deserializer: NodeDeserializer): TwoWayAssignmentExpression {\n\t\treturn new TwoWayAssignmentExpression(\n\t\t\tdeserializer(node.left) as MemberExpression,\n\t\t\tdeserializer(node.right) as MemberExpression | Identifier\n\t\t);\n\t}\n\tstatic visit(node: TwoWayAssignmentExpression, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t}\n\n\tdeclare protected left: MemberExpression;\n\tdeclare protected right: MemberExpression | Identifier;\n\n\tprivate rightEvents: ExpressionEventMap;\n\tprivate leftEvents: ExpressionEventMap;\n\tconstructor(left: MemberExpression, right: MemberExpression | Identifier) {\n\t\tsuper('=::', left, right);\n\t\tthis.rightEvents = this.right.events();\n\t\tthis.leftEvents = this.left.events();\n\t}\n\n\tset(stack: Stack, value: any) {\n\t\treturn this.setRTL(stack, value);\n\t}\n\tget(stack: Stack): any {\n\t\treturn this.getRTL(stack);\n\t}\n\n\tprivate setRTL(stack: Stack, value: any) {\n\t\treturn this.left.set(stack, value);\n\t}\n\tprivate getRTL(stack: Stack): any {\n\t\tconst rv = this.right.get(stack);\n\t\tthis.setRTL(stack, rv);\n\t\treturn rv;\n\t}\n\tprivate actionRTL(stack: Stack): ValueChangedCallback {\n\t\treturn () => this.getRTL(stack);\n\t}\n\n\tprivate setLTR(stack: Stack, value: any) {\n\t\treturn this.right.set(stack, value);\n\t}\n\tprivate getLTR(stack: Stack): any {\n\t\tconst lv = this.left.get(stack);\n\t\tthis.setLTR(stack, lv);\n\t\treturn lv;\n\t}\n\tprivate actionLTR(stack: Stack): ValueChangedCallback {\n\t\treturn () => this.getLTR(stack);\n\t}\n\n\tprivate subscribeToEvents(stack: Stack, tuples: [string, ReactiveScope<Context>][], actionCallback: ValueChangedCallback) {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\ttuples.forEach(tuple => {\n\t\t\tconst subscription = tuple[1].subscribe(tuple[0], actionCallback);\n\t\t\tsubscriptions.push(subscription);\n\t\t});\n\t\treturn subscriptions;\n\t}\n\n\tsubscribe(stack: Stack): ScopeSubscription<Context>[] {\n\n\t\t// right to left\n\t\tconst rightTuples = findReactiveScopeByEventMap(this.rightEvents, stack);\n\t\tconst rtlAction = this.actionRTL(stack);\n\t\tconst rtlSubscriptions = this.subscribeToEvents(stack, rightTuples, rtlAction);\n\n\t\t// left to right \n\t\tconst leftTuples = findReactiveScopeByEventMap(this.leftEvents, stack);\n\t\tconst ltrAction = this.actionLTR(stack);\n\t\tconst ltrSubscriptions = this.subscribeToEvents(stack, leftTuples, ltrAction);\n\n\t\treturn rtlSubscriptions.concat(ltrSubscriptions);\n\t}\n\n}\n"]}
|
package/component/component.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,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M,CAAC,IAAI,EAAE;YACzD,YAAY,CAAC,WAAW,GAAG,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACrE;QAED,YAAY,CAAC,UAAU,GAAG,UAAU,CAAC;QACrC,YAAY,CAAC,SAAS,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAEzE,qBAAqB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,qBAAqB,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAE3D,MAAM,OAAO,GAA6B,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;QAChD,IAAI,aAAa,EAAE;YAClB,IAAI,aAAa,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC/D,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;aAChC;SACD;QAGD,cAAc,CAAC,MAAM,CACpB,YAAY,CAAC,QAAkB,EAC/B,YAAY,CAAC,SAAqC,EAClD,OAAO,CACP,CAAC;IAEH,CAAC;IAED,MAAM,CAAC,UAAU,CAAwB,SAA2B,EAAE,GAAoD;QACzH,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,GAAG,CAAC;QACxC,cAAc,CAAC,MAAM,CACpB,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CAAC;IACH,CAAC","sourcesContent":["import type { MetadataClass, MetadataContext } from '@ibyar/decorators';\nimport type { Class, TypeOf } from '../utils/typeof.js';\nimport type { ZoneType } from '../zone/bootstrap.js';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDomNode, DomRenderNode, canAttachShadow,\n\tdirectiveRegistry, DomElementNode,\n\tDomFragmentNode, DomParentNode,\n\tisValidCustomElementName\n} from '@ibyar/elements';\n\nimport { HTMLComponent, ValueControl } from './custom-element.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective, StructuralDirective } from '../directive/directive.js';\nimport { initCustomElementView } from '../view/view.js';\nimport { buildExpressionNodes } from '../html/expression.js';\nimport {\n\tComponentOptions, PipeOptions,\n\tServiceOptions, DirectiveOptions\n} from '../annotation/options.js';\nimport {\n\tChildRef, HostBindingRef, InputPropertyRef,\n\tListenerRef, OutputPropertyRef, PropertyRef\n} from './reflect.js';\nimport { deserializeExpressionNodes } from '../html/deserialize.js';\n\n\nexport interface ServiceRef<T> {\n\tprovideIn: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n\tmodelClass: TypeOf<T>;\n\tname: string;\n}\n\nexport interface PipeRef<T> {\n\tname: string;\n\tasynchronous?: boolean;\n\tmodelClass: TypeOf<T>;\n}\nexport interface DirectiveRef<T> {\n\tselector: string;\n\tzone?: ZoneType;\n\n\tmodelClass: TypeOf<StructuralDirective> | TypeOf<AttributeDirective>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostListeners: ListenerRef[];\n\thostBindings: HostBindingRef[];\n\tviewBindings?: DomElementNode;\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\tcompiledTemplate?: DomNode;\n\t// attrTemplate: JsxAttrComponent;\n\tstyles: string;\n\textend: Tag;\n\textendCustomElement: boolean;\n\n\tviewClass: MetadataClass<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: InputPropertyRef[];\n\toutputs: OutputPropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\tviewBindings?: DomElementNode;\n\twindowBindings?: DomElementNode;\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template' | 'shadow-slot';\n\tisShadowDom: boolean;\n\tshadowRootInit: ShadowRootInit;\n\tformAssociated: boolean | TypeOf<ValueControl<any>>;\n\tzone?: ZoneType;\n}\n\ntype ViewBindingOption = {\n\tprototype: Record<PropertyKey, any>;\n\thostBindings?: HostBindingRef[];\n\thostListeners?: ListenerRef[];\n\tselector?: string;\n};\n\ntype HostNode = {\n\thost?: DomElementNode;\n\twindow?: DomElementNode;\n\ttemplate?: DomElementNode[];\n};\n\nconst DEFAULT_SHADOW_ROOT_INIT: ShadowRootInit = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };\n\nexport class Components {\n\n\tprivate static EMPTY_LIST = Object.freeze<any>([]);\n\tprivate static emptyList<T>(): T[] {\n\t\treturn Components.EMPTY_LIST as T[];\n\t}\n\n\tprivate static patchTemplate(child: DomNode, templates: DomElementNode[]): void {\n\t\tif (child instanceof DomElementNode && child.templateRefName?.name) {\n\t\t\tconst ref = templates.find(node => child.templateRefName?.name === node.templateRefName?.name);\n\t\t\tif (ref?.outputs) {\n\t\t\t\t(child.outputs ??= []).push(...ref.outputs);\n\t\t\t}\n\t\t}\n\t\tif (child instanceof DomParentNode) {\n\t\t\tchild.children?.forEach(node => Components.patchTemplate(node, templates));\n\t\t}\n\t}\n\n\tprivate static createOutputs(Listeners?: ListenerRef[]) {\n\t\treturn Listeners?.map(\n\t\t\tlistener => `(${listener.eventName})=\"${listener.modelCallbackName}(${listener.args.join(', ')})\"`\n\t\t).join(' ') ?? ''\n\t}\n\n\tprivate static parseHostNode(option: ViewBindingOption): HostNode {\n\t\tconst inputs = option.hostBindings?.map(binding => {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(option.prototype, binding.modelPropertyName);\n\t\t\tif (typeof descriptor?.value === 'function') {\n\t\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}()\"`\n\t\t\t}\n\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}\"`;\n\t\t}).join(' ') ?? '';\n\n\t\tconst hostListeners: ListenerRef[] = [];\n\t\tconst windowListeners: ListenerRef[] = [];\n\t\tconst templateListeners: Record<string, ListenerRef[]> = {};\n\n\t\toption.hostListeners?.forEach(listener => {\n\t\t\tconst [host, event] = listener.eventName.split(':', 2);\n\t\t\tif (event === undefined) {\n\t\t\t\thostListeners.push(listener);\n\t\t\t} else if ('window' === host.toLowerCase()) {\n\t\t\t\twindowListeners.push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t} else {\n\t\t\t\t(templateListeners[host] ??= []).push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t}\n\t\t});\n\n\t\tconst result: HostNode = {};\n\n\t\tif (hostListeners.length) {\n\t\t\tconst hostOutputs = Components.createOutputs(hostListeners);\n\t\t\tconst selector = option.selector ?? 'div';\n\t\t\tconst hostTemplate = `<${selector} ${inputs} ${hostOutputs}></${selector}>`;\n\t\t\tresult.host = htmlParser.toDomRootNode(hostTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.host);\n\t\t}\n\n\t\tif (windowListeners.length) {\n\t\t\tconst windowOutputs = Components.createOutputs(windowListeners);\n\t\t\tconst windowTemplate = `<window ${windowOutputs}></window>`;\n\t\t\tresult.window = htmlParser.toDomRootNode(windowTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.window);\n\t\t}\n\n\t\tconst templateHosts = Object.keys(templateListeners);\n\t\tif (templateHosts.length) {\n\t\t\tconst template = templateHosts.map(host => {\n\t\t\t\tconst hostOutputs = Components.createOutputs(templateListeners[host]);\n\t\t\t\treturn `<template #${host} ${hostOutputs}></template>`;\n\t\t\t}).join('');\n\t\t\tconst templateNodes = htmlParser.toDomRootNode(template) as DomElementNode | DomFragmentNode;\n\t\t\tbuildExpressionNodes(templateNodes);\n\t\t\tresult.template = templateNodes instanceof DomFragmentNode\n\t\t\t\t? templateNodes.children?.filter(child => child instanceof DomElementNode) as DomElementNode[] ?? []\n\t\t\t\t: [templateNodes];\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tif (metadata.hostListeners?.length || metadata.hostBindings?.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\thostBindings: metadata.hostBindings,\n\t\t\t\thostListeners: metadata.hostListeners,\n\t\t\t});\n\t\t\tmetadata.viewBindings = hostNode.host;\n\t\t}\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (metadata.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (metadata.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t});\n\t}\n\n\tstatic definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineService<T extends Class>(modelClass: MetadataClass<T>, opts: ServiceOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tmetadata.name = modelClass.name;\n\t\tClassRegistryProvider.registerService(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Class>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext) {\n\t\tconst componentRef = Object.assign(metadata, opts) as any as ComponentRef<T>;\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\t\tcomponentRef.extendCustomElement = !!opts.extend && isValidCustomElementName(opts.extend);\n\n\t\tif (typeof componentRef.template === 'string') {\n\t\t\tif (componentRef.styles) {\n\t\t\t\tconst template = `<style>${componentRef.styles}</style>${componentRef.template}`;\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(template);\n\t\t\t} else {\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(componentRef.template);\n\t\t\t}\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.template === 'object') {\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.compiledTemplate === 'object') {\n\t\t\thtmlParser.deserializeNode(componentRef.compiledTemplate);\n\t\t\tdeserializeExpressionNodes(componentRef.compiledTemplate);\n\t\t\tcomponentRef.template = componentRef.compiledTemplate;\n\t\t\tcomponentRef.compiledTemplate = undefined;\n\t\t}\n\n\t\tif (!componentRef.template && /template/g.test(componentRef.encapsulation)) {\n\t\t\tconst template = document.querySelector('#' + componentRef.selector);\n\t\t\tif (template && template instanceof HTMLTemplateElement) {\n\t\t\t\tcomponentRef.template = templateParser.parse(template);\n\t\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t\t} else {\n\t\t\t\t// didn't find this template in 'index.html' document\n\t\t\t}\n\t\t}\n\n\t\tcomponentRef.inputs ||= Components.emptyList();\n\t\tcomponentRef.outputs ||= Components.emptyList();\n\t\tcomponentRef.viewChild ||= Components.emptyList();\n\t\tcomponentRef.ViewChildren ||= Components.emptyList();\n\t\tcomponentRef.hostBindings ||= Components.emptyList();\n\t\tcomponentRef.hostListeners ||= Components.emptyList();\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow/g.test(componentRef.encapsulation);\n\t\tif (componentRef.isShadowDom) {\n\t\t\tcomponentRef.shadowRootInit = Object.assign({}, DEFAULT_SHADOW_ROOT_INIT, (componentRef.shadowRootInit ?? {}));\n\t\t}\n\n\t\tif (componentRef.hostListeners.length || componentRef.hostBindings.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\tselector: componentRef.selector,\n\t\t\t\thostBindings: componentRef.hostBindings,\n\t\t\t\thostListeners: componentRef.hostListeners,\n\t\t\t});\n\t\t\tcomponentRef.viewBindings = hostNode.host;\n\t\t\tcomponentRef.windowBindings = hostNode.window;\n\n\t\t\tif (typeof componentRef.template === 'function') {\n\t\t\t\tconst creator = componentRef.template;\n\t\t\t\tcomponentRef.template = (model: T) => {\n\t\t\t\t\tconst template = creator(model);\n\t\t\t\t\tif (hostNode.template) {\n\t\t\t\t\t\tComponents.patchTemplate(template, hostNode.template);\n\t\t\t\t\t}\n\t\t\t\t\treturn template;\n\t\t\t\t};\n\t\t\t} else if (hostNode.template) {\n\t\t\t\tComponents.patchTemplate(componentRef.template, hostNode.template);\n\t\t\t}\n\n\t\t}\n\n\t\tif (!(componentRef.formAssociated === true || typeof componentRef.formAssociated === 'function')) {\n\t\t\tcomponentRef.formAssociated = false;\n\t\t}\n\n\t\tif (componentRef.isShadowDom && componentRef.extend.name) {\n\t\t\tcomponentRef.isShadowDom = canAttachShadow(componentRef.extend.name);\n\t\t}\n\n\t\tcomponentRef.modelClass = modelClass;\n\t\tcomponentRef.viewClass = initCustomElementView(modelClass, componentRef);\n\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(componentRef.viewClass);\n\n\t\tconst options: ElementDefinitionOptions = {};\n\t\tconst parentTagName = componentRef.extend?.name;\n\t\tif (parentTagName) {\n\t\t\tif (parentTagName !== '!' && parentTagName.indexOf('-') === -1) {\n\t\t\t\toptions.extends = parentTagName;\n\t\t\t}\n\t\t}\n\n\n\t\tcustomElements.define(\n\t\t\tcomponentRef.selector as string,\n\t\t\tcomponentRef.viewClass as CustomElementConstructor,\n\t\t\toptions\n\t\t);\n\n\t}\n\n\tstatic defineView<T extends HTMLElement>(viewClass: MetadataClass<T>, opt: { selector: string } & ElementDefinitionOptions) {\n\t\tClassRegistryProvider.registerView(viewClass);\n\t\tconst { selector, ...definition } = opt;\n\t\tcustomElements.define(\n\t\t\tselector,\n\t\t\tviewClass,\n\t\t\tdefinition,\n\t\t);\n\t}\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"component.js","source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AAI,CAAC;QAChD,IAAI,aAAa,EAAE,CAAC;YACnB,IAAI,aAAa,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAChE,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;YACjC,CAAC;QACF,CAAC;QAGD,cAAc,CAAC,MAAM,CACpB,YAAY,CAAC,QAAkB,EAC/B,YAAY,CAAC,SAAqC,EAClD,OAAO,CACP,CAAC;IAEH,CAAC;IAED,MAAM,CAAC,UAAU,CAAwB,SAA2B,EAAE,GAAoD;QACzH,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,GAAG,CAAC;QACxC,cAAc,CAAC,MAAM,CACpB,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CAAC;IACH,CAAC","sourcesContent":["import type { MetadataClass, MetadataContext } from '@ibyar/decorators';\nimport type { Class, TypeOf } from '../utils/typeof.js';\nimport type { ZoneType } from '../zone/bootstrap.js';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDomNode, DomRenderNode, canAttachShadow,\n\tdirectiveRegistry, DomElementNode,\n\tDomFragmentNode, DomParentNode,\n\tisValidCustomElementName\n} from '@ibyar/elements';\n\nimport { HTMLComponent, ValueControl } from './custom-element.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective, StructuralDirective } from '../directive/directive.js';\nimport { initCustomElementView } from '../view/view.js';\nimport { buildExpressionNodes } from '../html/expression.js';\nimport {\n\tComponentOptions, PipeOptions,\n\tServiceOptions, DirectiveOptions\n} from '../annotation/options.js';\nimport {\n\tChildRef, HostBindingRef, InputPropertyRef,\n\tListenerRef, OutputPropertyRef, PropertyRef\n} from './reflect.js';\nimport { deserializeExpressionNodes } from '../html/deserialize.js';\n\n\nexport interface ServiceRef<T> {\n\tprovideIn: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n\tmodelClass: TypeOf<T>;\n\tname: string;\n}\n\nexport interface PipeRef<T> {\n\tname: string;\n\tasynchronous?: boolean;\n\tmodelClass: TypeOf<T>;\n}\nexport interface DirectiveRef<T> {\n\tselector: string;\n\texportAs?: string;\n\tzone?: ZoneType;\n\n\tmodelClass: TypeOf<StructuralDirective> | TypeOf<AttributeDirective>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostListeners: ListenerRef[];\n\thostBindings: HostBindingRef[];\n\tviewBindings?: DomElementNode;\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\tcompiledTemplate?: DomNode;\n\t// attrTemplate: JsxAttrComponent;\n\tstyles: string;\n\textend: Tag;\n\textendCustomElement: boolean;\n\n\tviewClass: MetadataClass<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: InputPropertyRef[];\n\toutputs: OutputPropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\tviewBindings?: DomElementNode;\n\twindowBindings?: DomElementNode;\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template' | 'shadow-slot';\n\tisShadowDom: boolean;\n\tshadowRootInit: ShadowRootInit;\n\tformAssociated: boolean | TypeOf<ValueControl<any>>;\n\tzone?: ZoneType;\n}\n\ntype ViewBindingOption = {\n\tprototype: Record<PropertyKey, any>;\n\thostBindings?: HostBindingRef[];\n\thostListeners?: ListenerRef[];\n\tselector?: string;\n};\n\ntype HostNode = {\n\thost?: DomElementNode;\n\twindow?: DomElementNode;\n\ttemplate?: DomElementNode[];\n};\n\nconst DEFAULT_SHADOW_ROOT_INIT: ShadowRootInit = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };\n\nexport class Components {\n\n\tprivate static EMPTY_LIST = Object.freeze<any>([]);\n\tprivate static emptyList<T>(): T[] {\n\t\treturn Components.EMPTY_LIST as T[];\n\t}\n\n\tprivate static patchTemplate(child: DomNode, templates: DomElementNode[]): void {\n\t\tif (child instanceof DomElementNode && child.templateRefName?.name) {\n\t\t\tconst ref = templates.find(node => child.templateRefName?.name === node.templateRefName?.name);\n\t\t\tif (ref?.outputs) {\n\t\t\t\t(child.outputs ??= []).push(...ref.outputs);\n\t\t\t}\n\t\t}\n\t\tif (child instanceof DomParentNode) {\n\t\t\tchild.children?.forEach(node => Components.patchTemplate(node, templates));\n\t\t}\n\t}\n\n\tprivate static createOutputs(Listeners?: ListenerRef[]) {\n\t\treturn Listeners?.map(\n\t\t\tlistener => `(${listener.eventName})=\"${listener.modelCallbackName}(${listener.args.join(', ')})\"`\n\t\t).join(' ') ?? ''\n\t}\n\n\tprivate static parseHostNode(option: ViewBindingOption): HostNode {\n\t\tconst inputs = option.hostBindings?.map(binding => {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(option.prototype, binding.modelPropertyName);\n\t\t\tif (typeof descriptor?.value === 'function') {\n\t\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}()\"`\n\t\t\t}\n\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}\"`;\n\t\t}).join(' ') ?? '';\n\n\t\tconst hostListeners: ListenerRef[] = [];\n\t\tconst windowListeners: ListenerRef[] = [];\n\t\tconst templateListeners: Record<string, ListenerRef[]> = {};\n\n\t\toption.hostListeners?.forEach(listener => {\n\t\t\tconst [host, event] = listener.eventName.split(':', 2);\n\t\t\tif (event === undefined) {\n\t\t\t\thostListeners.push(listener);\n\t\t\t} else if ('window' === host.toLowerCase()) {\n\t\t\t\twindowListeners.push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t} else {\n\t\t\t\t(templateListeners[host] ??= []).push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t}\n\t\t});\n\n\t\tconst result: HostNode = {};\n\n\t\tif (hostListeners.length) {\n\t\t\tconst hostOutputs = Components.createOutputs(hostListeners);\n\t\t\tconst selector = option.selector ?? 'div';\n\t\t\tconst hostTemplate = `<${selector} ${inputs} ${hostOutputs}></${selector}>`;\n\t\t\tresult.host = htmlParser.toDomRootNode(hostTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.host);\n\t\t}\n\n\t\tif (windowListeners.length) {\n\t\t\tconst windowOutputs = Components.createOutputs(windowListeners);\n\t\t\tconst windowTemplate = `<window ${windowOutputs}></window>`;\n\t\t\tresult.window = htmlParser.toDomRootNode(windowTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.window);\n\t\t}\n\n\t\tconst templateHosts = Object.keys(templateListeners);\n\t\tif (templateHosts.length) {\n\t\t\tconst template = templateHosts.map(host => {\n\t\t\t\tconst hostOutputs = Components.createOutputs(templateListeners[host]);\n\t\t\t\treturn `<template #${host} ${hostOutputs}></template>`;\n\t\t\t}).join('');\n\t\t\tconst templateNodes = htmlParser.toDomRootNode(template) as DomElementNode | DomFragmentNode;\n\t\t\tbuildExpressionNodes(templateNodes);\n\t\t\tresult.template = templateNodes instanceof DomFragmentNode\n\t\t\t\t? templateNodes.children?.filter(child => child instanceof DomElementNode) as DomElementNode[] ?? []\n\t\t\t\t: [templateNodes];\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tif (metadata.hostListeners?.length || metadata.hostBindings?.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\thostBindings: metadata.hostBindings,\n\t\t\t\thostListeners: metadata.hostListeners,\n\t\t\t});\n\t\t\tmetadata.viewBindings = hostNode.host;\n\t\t}\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (metadata.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (metadata.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t});\n\t}\n\n\tstatic definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineService<T extends Class>(modelClass: MetadataClass<T>, opts: ServiceOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tmetadata.name = modelClass.name;\n\t\tClassRegistryProvider.registerService(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Class>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext) {\n\t\tconst componentRef = Object.assign(metadata, opts) as any as ComponentRef<T>;\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\t\tcomponentRef.extendCustomElement = !!opts.extend && isValidCustomElementName(opts.extend);\n\n\t\tif (typeof componentRef.template === 'string') {\n\t\t\tif (componentRef.styles) {\n\t\t\t\tconst template = `<style>${componentRef.styles}</style>${componentRef.template}`;\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(template);\n\t\t\t} else {\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(componentRef.template);\n\t\t\t}\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.template === 'object') {\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.compiledTemplate === 'object') {\n\t\t\thtmlParser.deserializeNode(componentRef.compiledTemplate);\n\t\t\tdeserializeExpressionNodes(componentRef.compiledTemplate);\n\t\t\tcomponentRef.template = componentRef.compiledTemplate;\n\t\t\tcomponentRef.compiledTemplate = undefined;\n\t\t}\n\n\t\tif (!componentRef.template && /template/g.test(componentRef.encapsulation)) {\n\t\t\tconst template = document.querySelector('#' + componentRef.selector);\n\t\t\tif (template && template instanceof HTMLTemplateElement) {\n\t\t\t\tcomponentRef.template = templateParser.parse(template);\n\t\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t\t} else {\n\t\t\t\t// didn't find this template in 'index.html' document\n\t\t\t}\n\t\t}\n\n\t\tcomponentRef.inputs ||= Components.emptyList();\n\t\tcomponentRef.outputs ||= Components.emptyList();\n\t\tcomponentRef.viewChild ||= Components.emptyList();\n\t\tcomponentRef.ViewChildren ||= Components.emptyList();\n\t\tcomponentRef.hostBindings ||= Components.emptyList();\n\t\tcomponentRef.hostListeners ||= Components.emptyList();\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow/g.test(componentRef.encapsulation);\n\t\tif (componentRef.isShadowDom) {\n\t\t\tcomponentRef.shadowRootInit = Object.assign({}, DEFAULT_SHADOW_ROOT_INIT, (componentRef.shadowRootInit ?? {}));\n\t\t}\n\n\t\tif (componentRef.hostListeners.length || componentRef.hostBindings.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\tselector: componentRef.selector,\n\t\t\t\thostBindings: componentRef.hostBindings,\n\t\t\t\thostListeners: componentRef.hostListeners,\n\t\t\t});\n\t\t\tcomponentRef.viewBindings = hostNode.host;\n\t\t\tcomponentRef.windowBindings = hostNode.window;\n\n\t\t\tif (typeof componentRef.template === 'function') {\n\t\t\t\tconst creator = componentRef.template;\n\t\t\t\tcomponentRef.template = (model: T) => {\n\t\t\t\t\tconst template = creator(model);\n\t\t\t\t\tif (hostNode.template) {\n\t\t\t\t\t\tComponents.patchTemplate(template, hostNode.template);\n\t\t\t\t\t}\n\t\t\t\t\treturn template;\n\t\t\t\t};\n\t\t\t} else if (hostNode.template) {\n\t\t\t\tComponents.patchTemplate(componentRef.template, hostNode.template);\n\t\t\t}\n\n\t\t}\n\n\t\tif (!(componentRef.formAssociated === true || typeof componentRef.formAssociated === 'function')) {\n\t\t\tcomponentRef.formAssociated = false;\n\t\t}\n\n\t\tif (componentRef.isShadowDom && componentRef.extend.name) {\n\t\t\tcomponentRef.isShadowDom = canAttachShadow(componentRef.extend.name);\n\t\t}\n\n\t\tcomponentRef.modelClass = modelClass;\n\t\tcomponentRef.viewClass = initCustomElementView(modelClass, componentRef);\n\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(componentRef.viewClass);\n\n\t\tconst options: ElementDefinitionOptions = {};\n\t\tconst parentTagName = componentRef.extend?.name;\n\t\tif (parentTagName) {\n\t\t\tif (parentTagName !== '!' && parentTagName.indexOf('-') === -1) {\n\t\t\t\toptions.extends = parentTagName;\n\t\t\t}\n\t\t}\n\n\n\t\tcustomElements.define(\n\t\t\tcomponentRef.selector as string,\n\t\t\tcomponentRef.viewClass as CustomElementConstructor,\n\t\t\toptions\n\t\t);\n\n\t}\n\n\tstatic defineView<T extends HTMLElement>(viewClass: MetadataClass<T>, opt: { selector: string } & ElementDefinitionOptions) {\n\t\tClassRegistryProvider.registerView(viewClass);\n\t\tconst { selector, ...definition } = opt;\n\t\tcustomElements.define(\n\t\t\tselector,\n\t\t\tviewClass,\n\t\t\tdefinition,\n\t\t);\n\t}\n\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactiveScope, ReactiveScopeControl, Context } from '@ibyar/expressions';
|
|
1
|
+
import type { ReactiveScope, ReactiveScopeControl, Context, SignalScope } from '@ibyar/expressions';
|
|
2
2
|
import type { TypeOf } from '../utils/typeof.js';
|
|
3
3
|
import { EventEmitter } from './events.js';
|
|
4
4
|
import { ComponentRef } from './component.js';
|
|
@@ -17,6 +17,7 @@ export type NodeContextType<T> = {
|
|
|
17
17
|
export interface BaseComponent<T> extends CustomElement {
|
|
18
18
|
_model: ModelType<T>;
|
|
19
19
|
_modelScope: ReactiveScopeControl<T & Context>;
|
|
20
|
+
_signalScope: SignalScope;
|
|
20
21
|
_viewScope: ReactiveScope<{
|
|
21
22
|
'this': BaseComponent<T>;
|
|
22
23
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-element.d.ts","sourceRoot":"","sources":["../../../src/core/component/custom-element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"custom-element.d.ts","sourceRoot":"","sources":["../../../src/core/component/custom-element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,aAAa;IAC7B,eAAe,IAAI,IAAI,CAAC;IACxB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI,CAAC;IAC3E,iBAAiB,IAAI,IAAI,CAAC;IAC1B,oBAAoB,IAAI,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;AAEvC,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,aAAa,CAAC,CAAC,CAAE,SAAQ,aAAa;IAEtD,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,WAAW,E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,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAGzJ,MAAM,WAAW,iBAAiB,CAAC,CAAC;IACnC,QAAO,CAAC,CAAC;IACT,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;CACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-element.js","sourceRoot":"","sources":["../../../src/core/component/custom-element.ts"],"names":[],"mappings":"AAoDA,MAAM,UAAU,eAAe,CAAC,MAAW;IAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;WAChC,MAAM,YAAY,WAAW,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAmB,MAAW,EAAE,SAAoB;IACxF,OAAO,eAAe,CAAC,MAAM,CAAC;WAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,SAAS,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAoB;IACjD,OAAO,OAAO,IAAI,OAAO,YAAY,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACxD,OAAO,OAAO,IAAI,OAAO,YAAY,kBAAkB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC5F,CAAC;AAqHD,MAAM,UAAU,cAAc,CAAC,GAAQ;IACtC,OAAO,GAAG;WACN,OAAO,GAAG,KAAK,QAAQ;WACvB,OAAO,GAAG,CAAC,UAAU,KAAK,UAAU;WACpC,OAAO,GAAG,CAAC,gBAAgB,KAAK,UAAU,CAAC;AAChD,CAAC","sourcesContent":["import type { ReactiveScope, ReactiveScopeControl, Context } from '@ibyar/expressions';\nimport type { TypeOf } from '../utils/typeof.js';\nimport { EventEmitter } from './events.js';\nimport { ComponentRef } from './component.js';\nimport { AuroraZone } from '../zone/zone.js';\nimport { PropertyRef } from './reflect.js';\n\nexport interface CustomElement {\n\tadoptedCallback(): void;\n\tattributeChangedCallback(name: string, oldValue: any, newValue: any): void;\n\tconnectedCallback(): void;\n\tdisconnectedCallback(): void;\n}\n\nexport type ModelType<T> = T & Context;\n\nexport type NodeContextType<T> = { 'this': BaseComponent<T> };\n\nexport interface BaseComponent<T> extends CustomElement {\n\n\t_model: ModelType<T>;\n\t_modelScope: ReactiveScopeControl<T & Context>;\n\n\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\n\t_zone: AuroraZone;\n\n\tgetComponentRef(): ComponentRef<T>;\n\n\thasInputStartWith(viewProp: string): boolean;\n\tgetInputStartWith(viewProp: string): PropertyRef | undefined;\n\tgetInput(viewProp: string): PropertyRef | undefined;\n\tgetInputValue(viewProp: string): any;\n\tsetInputValue(viewProp: string, value: any): void;\n\n\thasInput(viewProp: string): boolean;\n\thasProp(propName: string): boolean;\n\thasOutput(viewProp: string): boolean;\n\n\tgetOutput(viewProp: string): PropertyRef | undefined;\n\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined;\n\n\ttriggerOutput(eventName: string, value?: any): void;\n\tonDestroy(callback: () => void): void;\n\n\t/**\n\t * apply change detection\n\t */\n\tdetectChanges(): void;\n}\n\nexport interface HTMLComponent<T> extends BaseComponent<T>, HTMLElement { }\n\nexport function isHTMLComponent(object: any): object is HTMLComponent<any> {\n\treturn Reflect.has(object, '_model')\n\t\t&& object instanceof HTMLElement;\n}\n\nexport function isHTMLComponentOfType<T extends object>(object: any, typeClass: TypeOf<T>): object is HTMLComponent<T> {\n\treturn isHTMLComponent(object)\n\t\t&& Reflect.get(object, '_model') instanceof typeClass;\n}\n\nexport function isHTMLElement(element: HTMLElement): element is HTMLElement {\n\treturn element && element instanceof HTMLElement && !element.tagName?.includes('-');\n}\n\nexport function isHTMLUnknownElement(element: HTMLElement): element is HTMLElement {\n\treturn element && element instanceof HTMLUnknownElement && !element.tagName?.includes('-');\n}\n\n/**\n * Lifecycle callbacks\n * A map, whose keys are the strings \"connectedCallback\", \"disconnectedCallback\", \"adoptedCallback\", \"attributeChangedCallback\", \n * \"formAssociatedCallback\", \"formDisabledCallback\", \"formResetCallback\", and \"formStateRestoreCallback\" \n * https://html.spec.whatwg.org/multipage/custom-elements.html#concept-custom-element-definition-lifecycle-callbacks\n * \n * A form-associated custom element API includes a set of extra lifecycle callbacks to tie in to the form lifecycle.\n * The callbacks are optional: only implement a callback if your element needs to do something at that point in the lifecycle.\n * https://html.spec.whatwg.org/multipage/custom-elements.html#the-elementinternals-interface \n * https://docs.google.com/document/d/1JO8puctCSpW-ZYGU8lF-h4FWRIDQNDVexzHoOQ2iQmY/edit\n */\nexport interface FormAssociatedCustomElement extends CustomElement {\n\n\t/**\n\t * Called when the browser associates the element with a form element,\n\t * or disassociates the element from a form element.\n\t * @param form \n\t */\n\tformAssociatedCallback(form: HTMLFormElement | null): void;\n\n\t/**\n\t * Called after the disabled state of the element changes,\n\t * either because the disabled attribute of this element was added or removed;\n\t * or because the disabled state changed on a <fieldset> that's an ancestor of this element.\n\t * The disabled parameter represents the new disabled state of the element.\n\t * The element may, for example, disable elements in its shadow DOM when it is disabled.\n\t * @param disabled \n\t */\n\tformDisabledCallback(disabled: boolean): void;\n\n\t/**\n\t * Called after the form is reset.\n\t * The element should reset itself to some kind of default state.\n\t * For <input> elements, this usually involves setting the value property to\n\t * match the value attribute set in markup (or in the case of a checkbox,\n\t * setting the checked property to match the checked attribute.\n\t */\n\tformResetCallback(): void;\n\n\t/**\n\t * Called in one of two circumstances:\n\t * When the browser restores the state of the element (for example, after a navigation, or when the browser restarts).\n\t * The mode argument is \"restore\" in this case.\n\t * \n\t * When the browser's input-assist features such as form auto filling sets a value.\n\t * The mode argument is \"autocomplete\" in this case.\n\t * \n\t * The type of the first argument depends on how the setFormValue() method was called.\n\t * For more details, see Restoring form state.\n\t */\n\tformStateRestoreCallback(value: any, mode: 'restore' | 'autocomplete'): void;\n}\n\nexport type WriteValueMode = 'restore' | 'autocomplete' | 'reset';\n\nexport type WriteValueOptions<T> = { value: T | null, mode?: 'restore' | 'autocomplete' } | { value?: undefined, mode: 'reset' };\n\n\nexport interface ValueControl<T = any> {\n\t/**\n\t * reset the value of the\n\t * @param value \n\t * @param mode \n\t */\n\twriteValue(opt: { value?: undefined, mode: 'reset' }): void;\n\n\t/**\n\t * \n\t * When the browser restores the state of the element (for example, after a navigation, or when the browser restarts).\n\t * The mode argument is \"restore\" in this case.\n\t * \n\t * When the browser's input-assist features such as form auto filling sets a value.\n\t * The mode argument is \"autocomplete\" in this case.\n\t * \n\t * @param opt: options contain the `value` to be written and `mode` represented by `restore` or `autocomplete` or `undefined`\n\t */\n\n\twriteValue(opt: { value: T | null, mode?: 'restore' | 'autocomplete' }): void;\n\n\twriteValue(opt: { value?: T | null, mode?: WriteValueMode }): void;\n\n\twriteValue(opt: WriteValueOptions<T>): void;\n\n\t/**\n\t * This method is called when new `ValueControl` assigned to the form associated element.\n\t * \n\t * When implementing the registerOnChange method in your own value accessor, save the given function so your class calls it at the appropriate time.\n\t * \n\t * ```ts\n\t * registerOnChange(fn: (_: any) => void): void {\n\t * \tthis._onChange = fn;\n\t * }\n\t * ```\n\t * \n\t * When the value changes in the UI, call the registered function to allow the forms API to update itself:\n\t * \n\t * ```ts\n\t * \n\t * onChange(event: Event){\n\t * \t\n\t * }\n\t * \n\t * ```\n\t * @param fn the function to be called when a control want to change the value of a form associated element.\n\t */\n\n\tregisterOnChange(fn: (value?: T | null) => void): void;\n\n\t/**\n\t * called when `disabled` attribute change.\n\t * @param isDisabled \n\t */\n\tsetDisabledState?(isDisabled: boolean): void;\n}\n\nexport function isValueControl(obj: any): obj is ValueControl {\n\treturn obj\n\t\t&& typeof obj === 'object'\n\t\t&& typeof obj.writeValue === 'function'\n\t\t&& typeof obj.registerOnChange === 'function';\n}\n\nexport interface BaseFormAssociatedComponent<T extends Object> extends BaseComponent<T>, FormAssociatedCustomElement {\n\treadonly internals: ElementInternals;\n\treadonly form: HTMLFormElement | null;\n\treadonly valueControl?: ValueControl<T>;\n\n\tregisterValueControl(valueControl: ValueControl): void;\n}\n\nexport interface FormAssociatedComponent<T extends Object, V = any> extends BaseFormAssociatedComponent<T>, HTMLComponent<T> {\n\n\tvalue: V | null;\n}\n\nexport type HTMLFormElement = HTMLButtonElement | HTMLDataListElement | HTMLFieldSetElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\n\nexport interface ConstructorOfView<T> {\n\tnew(): T;\n\treadonly prototype: T;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"custom-element.js","sourceRoot":"","sources":["../../../src/core/component/custom-element.ts"],"names":[],"mappings":"AAoDA,MAAM,UAAU,eAAe,CAAC,MAAW;IAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;WAChC,MAAM,YAAY,WAAW,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAmB,MAAW,EAAE,SAAoB;IACxF,OAAO,eAAe,CAAC,MAAM,CAAC;WAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,SAAS,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAoB;IACjD,OAAO,OAAO,IAAI,OAAO,YAAY,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACxD,OAAO,OAAO,IAAI,OAAO,YAAY,kBAAkB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC5F,CAAC;AAqHD,MAAM,UAAU,cAAc,CAAC,GAAQ;IACtC,OAAO,GAAG;WACN,OAAO,GAAG,KAAK,QAAQ;WACvB,OAAO,GAAG,CAAC,UAAU,KAAK,UAAU;WACpC,OAAO,GAAG,CAAC,gBAAgB,KAAK,UAAU,CAAC;AAChD,CAAC","sourcesContent":["import type { ReactiveScope, ReactiveScopeControl, Context, SignalScope } from '@ibyar/expressions';\nimport type { TypeOf } from '../utils/typeof.js';\nimport { EventEmitter } from './events.js';\nimport { ComponentRef } from './component.js';\nimport { AuroraZone } from '../zone/zone.js';\nimport { PropertyRef } from './reflect.js';\n\nexport interface CustomElement {\n\tadoptedCallback(): void;\n\tattributeChangedCallback(name: string, oldValue: any, newValue: any): void;\n\tconnectedCallback(): void;\n\tdisconnectedCallback(): void;\n}\n\nexport type ModelType<T> = T & Context;\n\nexport type NodeContextType<T> = { 'this': BaseComponent<T> };\n\nexport interface BaseComponent<T> extends CustomElement {\n\n\t_model: ModelType<T>;\n\t_modelScope: ReactiveScopeControl<T & Context>;\n\t_signalScope: SignalScope;\n\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\n\t_zone: AuroraZone;\n\n\tgetComponentRef(): ComponentRef<T>;\n\n\thasInputStartWith(viewProp: string): boolean;\n\tgetInputStartWith(viewProp: string): PropertyRef | undefined;\n\tgetInput(viewProp: string): PropertyRef | undefined;\n\tgetInputValue(viewProp: string): any;\n\tsetInputValue(viewProp: string, value: any): void;\n\n\thasInput(viewProp: string): boolean;\n\thasProp(propName: string): boolean;\n\thasOutput(viewProp: string): boolean;\n\n\tgetOutput(viewProp: string): PropertyRef | undefined;\n\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined;\n\n\ttriggerOutput(eventName: string, value?: any): void;\n\tonDestroy(callback: () => void): void;\n\n\t/**\n\t * apply change detection\n\t */\n\tdetectChanges(): void;\n}\n\nexport interface HTMLComponent<T> extends BaseComponent<T>, HTMLElement { }\n\nexport function isHTMLComponent(object: any): object is HTMLComponent<any> {\n\treturn Reflect.has(object, '_model')\n\t\t&& object instanceof HTMLElement;\n}\n\nexport function isHTMLComponentOfType<T extends object>(object: any, typeClass: TypeOf<T>): object is HTMLComponent<T> {\n\treturn isHTMLComponent(object)\n\t\t&& Reflect.get(object, '_model') instanceof typeClass;\n}\n\nexport function isHTMLElement(element: HTMLElement): element is HTMLElement {\n\treturn element && element instanceof HTMLElement && !element.tagName?.includes('-');\n}\n\nexport function isHTMLUnknownElement(element: HTMLElement): element is HTMLElement {\n\treturn element && element instanceof HTMLUnknownElement && !element.tagName?.includes('-');\n}\n\n/**\n * Lifecycle callbacks\n * A map, whose keys are the strings \"connectedCallback\", \"disconnectedCallback\", \"adoptedCallback\", \"attributeChangedCallback\", \n * \"formAssociatedCallback\", \"formDisabledCallback\", \"formResetCallback\", and \"formStateRestoreCallback\" \n * https://html.spec.whatwg.org/multipage/custom-elements.html#concept-custom-element-definition-lifecycle-callbacks\n * \n * A form-associated custom element API includes a set of extra lifecycle callbacks to tie in to the form lifecycle.\n * The callbacks are optional: only implement a callback if your element needs to do something at that point in the lifecycle.\n * https://html.spec.whatwg.org/multipage/custom-elements.html#the-elementinternals-interface \n * https://docs.google.com/document/d/1JO8puctCSpW-ZYGU8lF-h4FWRIDQNDVexzHoOQ2iQmY/edit\n */\nexport interface FormAssociatedCustomElement extends CustomElement {\n\n\t/**\n\t * Called when the browser associates the element with a form element,\n\t * or disassociates the element from a form element.\n\t * @param form \n\t */\n\tformAssociatedCallback(form: HTMLFormElement | null): void;\n\n\t/**\n\t * Called after the disabled state of the element changes,\n\t * either because the disabled attribute of this element was added or removed;\n\t * or because the disabled state changed on a <fieldset> that's an ancestor of this element.\n\t * The disabled parameter represents the new disabled state of the element.\n\t * The element may, for example, disable elements in its shadow DOM when it is disabled.\n\t * @param disabled \n\t */\n\tformDisabledCallback(disabled: boolean): void;\n\n\t/**\n\t * Called after the form is reset.\n\t * The element should reset itself to some kind of default state.\n\t * For <input> elements, this usually involves setting the value property to\n\t * match the value attribute set in markup (or in the case of a checkbox,\n\t * setting the checked property to match the checked attribute.\n\t */\n\tformResetCallback(): void;\n\n\t/**\n\t * Called in one of two circumstances:\n\t * When the browser restores the state of the element (for example, after a navigation, or when the browser restarts).\n\t * The mode argument is \"restore\" in this case.\n\t * \n\t * When the browser's input-assist features such as form auto filling sets a value.\n\t * The mode argument is \"autocomplete\" in this case.\n\t * \n\t * The type of the first argument depends on how the setFormValue() method was called.\n\t * For more details, see Restoring form state.\n\t */\n\tformStateRestoreCallback(value: any, mode: 'restore' | 'autocomplete'): void;\n}\n\nexport type WriteValueMode = 'restore' | 'autocomplete' | 'reset';\n\nexport type WriteValueOptions<T> = { value: T | null, mode?: 'restore' | 'autocomplete' } | { value?: undefined, mode: 'reset' };\n\n\nexport interface ValueControl<T = any> {\n\t/**\n\t * reset the value of the\n\t * @param value \n\t * @param mode \n\t */\n\twriteValue(opt: { value?: undefined, mode: 'reset' }): void;\n\n\t/**\n\t * \n\t * When the browser restores the state of the element (for example, after a navigation, or when the browser restarts).\n\t * The mode argument is \"restore\" in this case.\n\t * \n\t * When the browser's input-assist features such as form auto filling sets a value.\n\t * The mode argument is \"autocomplete\" in this case.\n\t * \n\t * @param opt: options contain the `value` to be written and `mode` represented by `restore` or `autocomplete` or `undefined`\n\t */\n\n\twriteValue(opt: { value: T | null, mode?: 'restore' | 'autocomplete' }): void;\n\n\twriteValue(opt: { value?: T | null, mode?: WriteValueMode }): void;\n\n\twriteValue(opt: WriteValueOptions<T>): void;\n\n\t/**\n\t * This method is called when new `ValueControl` assigned to the form associated element.\n\t * \n\t * When implementing the registerOnChange method in your own value accessor, save the given function so your class calls it at the appropriate time.\n\t * \n\t * ```ts\n\t * registerOnChange(fn: (_: any) => void): void {\n\t * \tthis._onChange = fn;\n\t * }\n\t * ```\n\t * \n\t * When the value changes in the UI, call the registered function to allow the forms API to update itself:\n\t * \n\t * ```ts\n\t * \n\t * onChange(event: Event){\n\t * \t\n\t * }\n\t * \n\t * ```\n\t * @param fn the function to be called when a control want to change the value of a form associated element.\n\t */\n\n\tregisterOnChange(fn: (value?: T | null) => void): void;\n\n\t/**\n\t * called when `disabled` attribute change.\n\t * @param isDisabled \n\t */\n\tsetDisabledState?(isDisabled: boolean): void;\n}\n\nexport function isValueControl(obj: any): obj is ValueControl {\n\treturn obj\n\t\t&& typeof obj === 'object'\n\t\t&& typeof obj.writeValue === 'function'\n\t\t&& typeof obj.registerOnChange === 'function';\n}\n\nexport interface BaseFormAssociatedComponent<T extends Object> extends BaseComponent<T>, FormAssociatedCustomElement {\n\treadonly internals: ElementInternals;\n\treadonly form: HTMLFormElement | null;\n\treadonly valueControl?: ValueControl<T>;\n\n\tregisterValueControl(valueControl: ValueControl): void;\n}\n\nexport interface FormAssociatedComponent<T extends Object, V = any> extends BaseFormAssociatedComponent<T>, HTMLComponent<T> {\n\n\tvalue: V | null;\n}\n\nexport type HTMLFormElement = HTMLButtonElement | HTMLDataListElement | HTMLFieldSetElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\n\nexport interface ConstructorOfView<T> {\n\tnew(): T;\n\treadonly prototype: T;\n}\n"]}
|
package/component/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/core/component/events.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAEJ;IADZ,kBAAkB,CAAsB;IAChD,YAAoB,YAA6B;QAA7B,iBAAY,GAAZ,YAAY,CAAiB;IAAI,CAAC;IACtD,GAAG,CAAC,YAA+B;QAClC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/core/component/events.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAEJ;IADZ,kBAAkB,CAAsB;IAChD,YAAoB,YAA6B;QAA7B,iBAAY,GAAZ,YAAY,CAAiB;IAAI,CAAC;IACtD,GAAG,CAAC,YAA+B;QAClC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC9B,IAAI,CAAC,kBAAkB,GAAG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IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,YAA6B;QACnC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;CACD","sourcesContent":["export class Subscription<T> {\n\tprivate othersSubscription: Subscription<any>[];\n\tconstructor(private eventEmitter: EventEmitter<T>) { }\n\tadd(subscription: Subscription<any>) {\n\t\tif (!this.othersSubscription) {\n\t\t\tthis.othersSubscription = [];\n\t\t}\n\t\tthis.othersSubscription.push(subscription);\n\t}\n\tunsubscribe(): void {\n\t\tthis.eventEmitter.remove(this);\n\t\tif (this.othersSubscription) {\n\t\t\tthis.othersSubscription.forEach((subscription) => {\n\t\t\t\tsubscription.unsubscribe();\n\t\t\t});\n\t\t}\n\t}\n}\n\ninterface Subscribe {\n\tnext?: any;\n\terror?: any;\n\tcomplete?: any;\n}\n\nexport class EventEmitter<T> {\n\tprivate subscribers: Map<Subscription<T>, Subscribe> = new Map();\n\tconstructor() { }\n\temit(value?: T): void {\n\t\tthis.subscribers.forEach((subscribe) => {\n\t\t\ttry {\n\t\t\t\tsubscribe.next(value);\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tsubscribe.error?.(error);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handling event', error);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tsubscribe.complete?.();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handling event', error);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\tsubscribe(next?: any, error?: any, complete?: any): Subscription<T> {\n\t\tconst subscription: Subscription<T> = new Subscription(this);\n\t\tthis.subscribers.set(subscription, { next, error, complete });\n\t\treturn subscription;\n\t}\n\n\tremove(subscription: Subscription<T>) {\n\t\tthis.subscribers.delete(subscription);\n\t}\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ScopeSubscription } from '@ibyar/expressions';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function createDestroySubscription(unsubscribe: () => void, pause?: () => void, resume?: () => void): ScopeSubscription<void>;
|
|
3
3
|
//# sourceMappingURL=subscription.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/core/context/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wBAAgB,
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/core/context/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAYnI"}
|
package/context/subscription.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../src/core/context/subscription.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../src/core/context/subscription.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,yBAAyB,CAAC,WAAuB,EAAE,KAAkB,EAAE,MAAmB;IACzG,OAAO;QACN,KAAK;YACJ,KAAK,EAAE,EAAE,CAAC;QACX,CAAC;QACD,MAAM;YACL,MAAM,EAAE,EAAE,CAAC;QACZ,CAAC;QACD,WAAW;YACV,WAAW,EAAE,CAAC;QACf,CAAC;KAC0B,CAAC;AAC9B,CAAC","sourcesContent":["import { ScopeSubscription } from '@ibyar/expressions';\n\nexport function createDestroySubscription(unsubscribe: () => void, pause?: () => void, resume?: () => void): ScopeSubscription<void> {\n\treturn {\n\t\tpause(): void {\n\t\t\tpause?.();\n\t\t},\n\t\tresume(): void {\n\t\t\tresume?.();\n\t\t},\n\t\tunsubscribe(): void {\n\t\t\tunsubscribe();\n\t\t},\n\t} as ScopeSubscription<void>;\n}\n"]}
|
package/directive/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/directive/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOrF,MAAM,aAAa;IAClB,MAAM,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,CAAC,KAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/F,MAAM,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;;AAGvD,MAAM,OAAO,yBAAyB;IAiBf;IAAiC;IAdhD,MAAM,CAAC,KAAK,CAAC,aAAqB,EAAE,UAAkB;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I,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEhF,CAAC;IAEO,gBAAgB,CAAC,KAAsB;QAC9C,IAAI,KAAK,CAAC,KAAK,EAAE;YAChB,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;SAC9B;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import { Identifier, Token, TokenExpression, TokenStream } from '@ibyar/expressions';\n\nexport type DirectiveExpressionType = {\n\ttemplateExpressions: Array<TokenExpression[]>;\n\tdirectiveInputs: Map<string, string>;\n};\n\nclass TokenConstant {\n\tstatic LET = new TokenExpression(Token.LET, [-1, -1]);\n\tstatic COMMA = new TokenExpression(Token.COMMA, [-1, -1]);\n\tstatic ASSIGN = new TokenExpression(Token.ASSIGN, [-1, -1]);\n\tstatic IMPLICIT = new TokenExpression(Token.IDENTIFIER, [-1, -1], new Identifier('$implicit'));\n\tstatic EOS = new TokenExpression(Token.EOS, [-1, -1]);\n}\n\nexport class DirectiveExpressionParser {\n\n\n\tpublic static parse(directiveName: string, expression: string): DirectiveExpressionType {\n\t\tconst stream = TokenStream.getTokenStream(expression);\n\t\tconst parser = new DirectiveExpressionParser(directiveName, stream);\n\t\ttry {\n\t\t\tparser.scan();\n\t\t} catch (error) {\n\t\t\tconsole.error('error parsing template expression', expression, parser, error);\n\t\t}\n\t\treturn parser.getDirectiveExpressionType();\n\t}\n\n\tprotected templateExpressions = new Array<TokenExpression[]>();\n\tprotected directiveInputs = new Map<string, string>();\n\n\tconstructor(protected directiveName: string, protected stream: TokenStream) { }\n\n\tgetDirectiveExpressionType(): DirectiveExpressionType {\n\t\treturn {\n\t\t\ttemplateExpressions: this.templateExpressions,\n\t\t\tdirectiveInputs: this.directiveInputs\n\t\t};\n\t}\n\tscan(): void {\n\t\t// parse 'let/const/var' if found, or switch to expression mode.\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tthis.parseTemplateInput();\n\t\t} else {\n\t\t\t// parse expression, possible ends is semicolon, comma, let and 'EOS'\n\t\t\tthis.parseExpression(this.directiveName);\n\t\t}\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.consumeSemicolonOrComma();\n\n\t\t// parse let and parseDirectiveAndTemplateInputs\n\t\twhile (this.stream.peek().isNotType(Token.EOS)) {\n\t\t\tthis.parseTemplateInput() || this.parseDirectiveAndTemplateInputs();\n\t\t\tthis.consumeSemicolonOrComma();\n\t\t}\n\t}\n\tprotected consume(token: Token) {\n\t\tif (this.stream.next().isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t}\n\tprotected check(token: Token): boolean {\n\t\tconst peek = this.stream.peek();\n\t\tif (peek.isType(token)) {\n\t\t\tthis.stream.next();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tprotected consumeToList(token: Token, list: TokenExpression[]) {\n\t\tconst next = this.stream.next();\n\t\tif (next.isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t\tlist.push(next);\n\t}\n\n\tprotected consumeIfToken(token: Token, list: TokenExpression[]): boolean {\n\t\tconst next = this.stream.peek();\n\t\tif (next.isNotType(token)) {\n\t\t\treturn false;\n\t\t}\n\t\tlist.push(next);\n\t\tthis.stream.next();\n\t\treturn true;\n\t}\n\n\tprotected isDeclareKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.LET) || peek.isType(Token.CONST) || peek.isType(Token.VAR);\n\t}\n\n\tprotected isIdentifier(): boolean {\n\t\treturn this.stream.peek().isType(Token.IDENTIFIER);\n\t}\n\n\tprotected isAsKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.IDENTIFIER) && (peek.getValue<Identifier>().getName() == 'as');\n\t}\n\n\tprotected consumeAsKeyword() {\n\t\tthis.consume(Token.IDENTIFIER);\n\t}\n\tprotected isSemicolon() {\n\t\treturn this.stream.peek().isType(Token.SEMICOLON);\n\t}\n\tprotected isComma() {\n\t\treturn this.stream.peek().isType(Token.COMMA);\n\t}\n\tprotected consumeSemicolonOrComma() {\n\t\tlet peek = this.stream.peek();\n\t\tif (peek.isType(Token.SEMICOLON) || peek.isType(Token.COMMA)) {\n\t\t\tthis.stream.next();\n\t\t\treturn;\n\t\t}\n\t}\n\tprotected parseTemplateInput() {\n\t\t// let = \"let\" :local \"=\" :export \";\"?\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tlet peek = this.stream.peek();\n\t\t\tconst list: TokenExpression[] = [peek];\n\t\t\tthis.consume(peek.token);\n\t\t\tpeek = this.stream.peek();\n\t\t\tif (Token.isOpenPair(peek.token) && peek.isNotType(Token.LPAREN)) {\n\t\t\t\t// object and array pattern, destructing\n\t\t\t\tthis.stream.readTill(Token.closeOf(peek.token), list);\n\t\t\t} else if (peek.isType(Token.IDENTIFIER)) {\n\t\t\t\tthis.consumeToList(Token.IDENTIFIER, list);\n\t\t\t} else {\n\t\t\t\tthrow new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));\n\t\t\t}\n\t\t\tif (this.consumeIfToken(Token.ASSIGN, list)) {\n\t\t\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\t\t\t} else {\n\t\t\t\tlist.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);\n\t\t\t}\n\t\t\tthis.templateExpressions.push(list);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected parseExpression(inputName: string) {\n\t\tconst list: TokenExpression[] = [];\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\t}\n\n\t/**\n\t * check if the first is\n\t * @returns `boolean`\n\t */\n\tprotected parseDirectiveAndTemplateInputs() {\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tlet inputToken: TokenExpression;\n\t\tif (this.isIdentifier()) {\n\t\t\tinputToken = this.stream.next();\n\t\t} else {\n\t\t\tinputToken = this.stream.next();\n\t\t\tconst identifierName = inputToken.token.getName();\n\t\t\tinputToken = new TokenExpression(Token.IDENTIFIER, [-1, -1], new Identifier(identifierName));\n\t\t}\n\n\t\t// only template input\n\t\t// mapping from directive scope(context) to template scope\n\t\tif (this.isAsKeyword()) {\n\t\t\t// as = :export \"as\" :local \";\"?\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input as alias`\n\t\t\t// ==> in template -> alias = input\n\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.check(Token.ASSIGN) || this.check(Token.COLON);\n\n\t\tconst list: TokenExpression[] = [];\n\t\t// keyExp = :key \":\"? :expression (\"as\" :local)? \";\"?\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\n\t\t// mix for directive input and template input\n\t\tif (this.isAsKeyword()) {\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input {x: 7, y: 9} as alias` \n\t\t\t// ==> in directive ->`input = {x: 7, y: 9}`\n\t\t\t// ==> or in template -> let alias = input\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(TokenConstant.LET, aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t}\n\t\tconst inputName = inputToken.getValue<Identifier>().getName() as string;\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\n\t}\n\n\tprivate mapTokenToString(token: TokenExpression): String {\n\t\tif (token.value) {\n\t\t\treturn token.value.toString();\n\t\t}\n\t\treturn token.token.getName();\n\t}\n\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/directive/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOrF,MAAM,aAAa;IAClB,MAAM,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,CAAC,KAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/F,MAAM,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;;AAGvD,MAAM,OAAO,yBAAyB;IAiBf;IAAiC;IAdhD,MAAM,CAAC,KAAK,CAAC,aAAqB,EAAE,UAAkB;QAC5D,MAAM,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACtD,MAAM,MA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,SAAS,CAAC,CAAC;QAC1C,CAAC;QACD,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,EAAc,CAAC,OAAO,EAAY,CAAC;QACxE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEhF,CAAC;IAEO,gBAAgB,CAAC,KAAsB;QAC9C,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import { Identifier, Token, TokenExpression, TokenStream } from '@ibyar/expressions';\n\nexport type DirectiveExpressionType = {\n\ttemplateExpressions: Array<TokenExpression[]>;\n\tdirectiveInputs: Map<string, string>;\n};\n\nclass TokenConstant {\n\tstatic LET = new TokenExpression(Token.LET, [-1, -1]);\n\tstatic COMMA = new TokenExpression(Token.COMMA, [-1, -1]);\n\tstatic ASSIGN = new TokenExpression(Token.ASSIGN, [-1, -1]);\n\tstatic IMPLICIT = new TokenExpression(Token.IDENTIFIER, [-1, -1], new Identifier('$implicit'));\n\tstatic EOS = new TokenExpression(Token.EOS, [-1, -1]);\n}\n\nexport class DirectiveExpressionParser {\n\n\n\tpublic static parse(directiveName: string, expression: string): DirectiveExpressionType {\n\t\tconst stream = TokenStream.getTokenStream(expression);\n\t\tconst parser = new DirectiveExpressionParser(directiveName, stream);\n\t\ttry {\n\t\t\tparser.scan();\n\t\t} catch (error) {\n\t\t\tconsole.error('error parsing template expression', expression, parser, error);\n\t\t}\n\t\treturn parser.getDirectiveExpressionType();\n\t}\n\n\tprotected templateExpressions = new Array<TokenExpression[]>();\n\tprotected directiveInputs = new Map<string, string>();\n\n\tconstructor(protected directiveName: string, protected stream: TokenStream) { }\n\n\tgetDirectiveExpressionType(): DirectiveExpressionType {\n\t\treturn {\n\t\t\ttemplateExpressions: this.templateExpressions,\n\t\t\tdirectiveInputs: this.directiveInputs\n\t\t};\n\t}\n\tscan(): void {\n\t\t// parse 'let/const/var' if found, or switch to expression mode.\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tthis.parseTemplateInput();\n\t\t} else {\n\t\t\t// parse expression, possible ends is semicolon, comma, let and 'EOS'\n\t\t\tthis.parseExpression(this.directiveName);\n\t\t}\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.consumeSemicolonOrComma();\n\n\t\t// parse let and parseDirectiveAndTemplateInputs\n\t\twhile (this.stream.peek().isNotType(Token.EOS)) {\n\t\t\tthis.parseTemplateInput() || this.parseDirectiveAndTemplateInputs();\n\t\t\tthis.consumeSemicolonOrComma();\n\t\t}\n\t}\n\tprotected consume(token: Token) {\n\t\tif (this.stream.next().isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t}\n\tprotected check(token: Token): boolean {\n\t\tconst peek = this.stream.peek();\n\t\tif (peek.isType(token)) {\n\t\t\tthis.stream.next();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tprotected consumeToList(token: Token, list: TokenExpression[]) {\n\t\tconst next = this.stream.next();\n\t\tif (next.isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t\tlist.push(next);\n\t}\n\n\tprotected consumeIfToken(token: Token, list: TokenExpression[]): boolean {\n\t\tconst next = this.stream.peek();\n\t\tif (next.isNotType(token)) {\n\t\t\treturn false;\n\t\t}\n\t\tlist.push(next);\n\t\tthis.stream.next();\n\t\treturn true;\n\t}\n\n\tprotected isDeclareKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.LET) || peek.isType(Token.CONST) || peek.isType(Token.VAR);\n\t}\n\n\tprotected isIdentifier(): boolean {\n\t\treturn this.stream.peek().isType(Token.IDENTIFIER);\n\t}\n\n\tprotected isAsKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.IDENTIFIER) && (peek.getValue<Identifier>().getName() == 'as');\n\t}\n\n\tprotected consumeAsKeyword() {\n\t\tthis.consume(Token.IDENTIFIER);\n\t}\n\tprotected isSemicolon() {\n\t\treturn this.stream.peek().isType(Token.SEMICOLON);\n\t}\n\tprotected isComma() {\n\t\treturn this.stream.peek().isType(Token.COMMA);\n\t}\n\tprotected consumeSemicolonOrComma() {\n\t\tlet peek = this.stream.peek();\n\t\tif (peek.isType(Token.SEMICOLON) || peek.isType(Token.COMMA)) {\n\t\t\tthis.stream.next();\n\t\t\treturn;\n\t\t}\n\t}\n\tprotected parseTemplateInput() {\n\t\t// let = \"let\" :local \"=\" :export \";\"?\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tlet peek = this.stream.peek();\n\t\t\tconst list: TokenExpression[] = [peek];\n\t\t\tthis.consume(peek.token);\n\t\t\tpeek = this.stream.peek();\n\t\t\tif (Token.isOpenPair(peek.token) && peek.isNotType(Token.LPAREN)) {\n\t\t\t\t// object and array pattern, destructing\n\t\t\t\tthis.stream.readTill(Token.closeOf(peek.token), list);\n\t\t\t} else if (peek.isType(Token.IDENTIFIER)) {\n\t\t\t\tthis.consumeToList(Token.IDENTIFIER, list);\n\t\t\t} else {\n\t\t\t\tthrow new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));\n\t\t\t}\n\t\t\tif (this.consumeIfToken(Token.ASSIGN, list)) {\n\t\t\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\t\t\t} else {\n\t\t\t\tlist.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);\n\t\t\t}\n\t\t\tthis.templateExpressions.push(list);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected parseExpression(inputName: string) {\n\t\tconst list: TokenExpression[] = [];\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\t}\n\n\t/**\n\t * check if the first is\n\t * @returns `boolean`\n\t */\n\tprotected parseDirectiveAndTemplateInputs() {\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tlet inputToken: TokenExpression;\n\t\tif (this.isIdentifier()) {\n\t\t\tinputToken = this.stream.next();\n\t\t} else {\n\t\t\tinputToken = this.stream.next();\n\t\t\tconst identifierName = inputToken.token.getName();\n\t\t\tinputToken = new TokenExpression(Token.IDENTIFIER, [-1, -1], new Identifier(identifierName));\n\t\t}\n\n\t\t// only template input\n\t\t// mapping from directive scope(context) to template scope\n\t\tif (this.isAsKeyword()) {\n\t\t\t// as = :export \"as\" :local \";\"?\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input as alias`\n\t\t\t// ==> in template -> alias = input\n\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.check(Token.ASSIGN) || this.check(Token.COLON);\n\n\t\tconst list: TokenExpression[] = [];\n\t\t// keyExp = :key \":\"? :expression (\"as\" :local)? \";\"?\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\n\t\t// mix for directive input and template input\n\t\tif (this.isAsKeyword()) {\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input {x: 7, y: 9} as alias` \n\t\t\t// ==> in directive ->`input = {x: 7, y: 9}`\n\t\t\t// ==> or in template -> let alias = input\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(TokenConstant.LET, aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t}\n\t\tconst inputName = inputToken.getValue<Identifier>().getName() as string;\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\n\t}\n\n\tprivate mapTokenToString(token: TokenExpression): String {\n\t\tif (token.value) {\n\t\t\treturn token.value.toString();\n\t\t}\n\t\treturn token.token.getName();\n\t}\n\n}\n\n"]}
|