Speech-Rule-Engine / speech-rule-engine

Generating speech descriptions for XML structures
https://zorkow.github.io/speech-rule-engine/
Apache License 2.0
75 stars 39 forks source link

importing package in angular app #256

Open ojas-p opened 6 years ago

ojas-p commented 6 years ago

screen shot 2018-08-27 at 9 20 41 pm

I'm getting this issue, while importing the package in my Angular4 app. I'm importing the package as, import * as sre from 'speech-rule-engine';

I guess there's a issue with webpack.

zorkow commented 6 years ago

speech-rule-engine is ES5 and does not contain any export statements, so I can't see it working as a module. Have you tried importing it simply as a JS module, i.e., something along the line of import '{PATH}/speech-rule-engine/lib/sre.js'

Could you send a large code snippet how you want to SRE?

ojas-p commented 6 years ago

@zorkow I have imported the lib in ".angular-cli.json" as,

"scripts": [
    "../node_modules/speech-rule-engine/lib/sre.js",
 ];

It gives following error, I guess something related to lazy loading and webpack. screen shot 2018-08-30 at 4 20 26 pm

But eventually it loads.

Then declare as, declare var sre:any; in typings.d.ts file.

When I console it, I get following methods in the "sre" variable. AbstractAudioRenderer: ƒ () AbstractEnrichCase: ƒ (a) AbstractHighlighter: ƒ () AbstractSpeechGenerator: ƒ () AbstractTrieNode: ƒ (a,b) AbstractWalker: ƒ (a,b,c,d) AbstractionRules: ƒ () AbstractionSpanish: ƒ () AcssRenderer: ƒ () AdhocSpeechGenerator: ƒ () Api: {} AudioRenderer: ƒ () AudioUtil: {} AuditoryDescription: ƒ (a) AuralRendering: ƒ () BaseRuleStore: ƒ () BaseUtil: {} BooleanTrieNode: ƒ (a,b) BrowserUtil: {} CaseBinomial: ƒ (a) CaseDoubleScript: ƒ (a) CaseEmbellished: ƒ (a) CaseLine: ƒ (a) CaseMultiindex: ƒ (a) CaseMultiscripts: ƒ (a) CaseTable: ƒ (a) CaseTensor: ƒ (a) CaseText: ƒ (a) ClearspeakPreferences: ƒ (a,b) ClearspeakRules: ƒ () ClearspeakUtil: {} ColorPicker: ƒ (a,b) CssHighlighter: ƒ () Debugger: ƒ () DirectSpeechGenerator: ƒ () DomUtil: {} DummySpeechGenerator: ƒ () DummyWalker: ƒ (a,b,c,d) DynamicCstr: ƒ (a,b) DynamicProperties: ƒ (a,b) DynamicTrieNode: ƒ (a) EmacspeakRules: ƒ () Engine: ƒ () Enrich: {} EnrichCase: ƒ () EnrichCaseFactory: ƒ () EnrichCases: ƒ () EnrichMathml: {}, EventType: {}, Event: ƒ} Focus: ƒ (a,b) Grammar: ƒ () Highlighter: ƒ () HighlighterFactory: {} HtmlHighlighter: ƒ () L10n: {} Levels: ƒ () Locale: {} MarkupRenderer: ƒ () MathCompoundStore: ƒ () MathMap: ƒ () MathSimpleStore: ƒ () MathStore: ƒ () MathUtil: {} MathmlStore: ƒ () MathmlStoreRules: ƒ () MathmlStoreUtil: {} MathspeakRules: ƒ () MathspeakSpanish: ƒ () MathspeakSpanishUtil: {europeanNumber: ƒ, onesOrdinals: A MmlCssHighlighter: ƒ () MmlHighlighter: ƒ () NodeSpeechGenerator: ƒ () PrefixRules: ƒ () PrefixSpanish: ƒ () PunctuationRenderer: ƒ () QueryTrieNode: ƒ (a,b) RebuildStree: ƒ (a) RootTrieNode: ƒ () SableRenderer: ƒ () Semantic: {Font: {…}, Role: {…}, Type: {…}, xmlTree: ƒ, getTree: ƒ, …} SemanticAbstractParser: ƒ (a) SemanticAnnotations: ƒ () SemanticAnnotator: ƒ (a,b) SemanticAttr: ƒ ()SemanticMathml: ƒ () SemanticNode: ƒ (a)SemanticNodeFactory: ƒ () SemanticParser: ƒ () SemanticPred: {} SemanticProcessor: ƒ () SemanticSkeleton: ƒ (a)SemanticTree: ƒ (a)SemanticTreeRules: ƒ () SemanticUtil: ƒ () SemanticWalker: ƒ (a,b,c,d)Span: ƒ (a,b) SpeechGenerator: ƒ () SpeechGeneratorFactory: {} SpeechGeneratorUtil: {} SpeechRule: ƒ (a,b,c,d) SpeechRuleEngine: ƒ () SpeechRuleEvaluator: ƒ () SpeechRuleFunctions: ƒ () SpeechRuleStore: ƒ () SpeechRuleStores: {} SsmlRenderer: ƒ () SsmlStepRenderer: ƒ () StaticTrieNode: ƒ (a,b) StoreUtil: {nodeCounter: ƒ, pauseSeparator: ƒ} StringRenderer: ƒ () SummarySpeechGenerator: ƒ () SvgHighlighter: ƒ () SyntaxWalker: ƒ (a,b,c,d)System: ƒ () SystemExternal: ƒ () TableWalker: ƒ (a,b,c,d) TreeSpeechGenerator: ƒ () TrieNodeFactory: {} Variables: ƒ () Walker: ƒ () WalkerFactory: {} XmlRenderer: ƒ () XpathUtil: {}