Platform-Node.st 797 B

123456789101112131415161718192021222324252627282930
  1. Smalltalk createPackage: 'Platform-Node'!
  2. (Smalltalk packageAt: 'Platform-Node' ifAbsent: [ self error: 'Package not created: Platform-Node' ]) imports: {'amber_core/Platform-Services'}!
  3. Object subclass: #NodePlatform
  4. instanceVariableNames: ''
  5. package: 'Platform-Node'!
  6. !NodePlatform commentStamp!
  7. I am `Platform` service implementation for node-like environment.!
  8. !NodePlatform methodsFor: 'accessing'!
  9. globals
  10. ^ global
  11. !
  12. newXhr
  13. XMLHttpRequest
  14. ifNotNil: [ ^ XMLHttpRequest new ]
  15. ifNil: [ self error: 'XMLHttpRequest not available.' ]
  16. ! !
  17. !NodePlatform class methodsFor: 'testing'!
  18. initialize
  19. self isFeasible ifTrue: [ Platform registerIfNone: self new ]
  20. !
  21. isFeasible
  22. <inlineJS: 'return typeof process !!== "undefined" && process && process.versions && process.versions.node'>
  23. ! !